export type DefaultTraverseChildren = TraverseChildren /** * Converts specified groups into camelCase props. Use in combination with your component * props like: * ``` * const Header: React.FC = ({ children }) => { * return
{children}
; * }; * * const childGroups = { * Header, * Footer: null, * } as const; * * const MyComponentInternal: React.FC> = ({ * header, * footer, * ... * }) => ... * ``` */ export type GroupedChildrenProps> = { [key in Uncapitalize]: Array } export type ToArray = (children: React.ReactNode | React.ReactNode[]) => Array> export type ChildrenSpec = Record | null> export type SwapNullWithComponent = { [K in keyof S]: S[K] extends NonNullable ? S[K] : React.ComponentType & GeneratedGroupingComponent } export type WithGroupedChildrenComponent = React.FC< React.PropsWithChildren > & SwapNullWithComponent export type OmitGroupedChildren

= Omit> export type ArrayElement = T extends readonly (infer ElementType)[] ? ElementType : never export type TrueReactChild = ArrayElement> type ReactChildOrNull = TrueReactChild | null export type OptimizedReactChild = ReturnType export type TraverseChildren = (component: ReactChildOrNull) => R export type ChildMatcher = (component: TrueReactChild, key: PropertyKey, type: string | React.ComponentType) => boolean export type ComponentFactory = (key: string) => React.ComponentType export interface ExtractionConfig { /** * A custom method to convert React component initial children to array on preprocessing stage. * Use when you want to flatten children. * The function must always return a cloned array of children as it will be mutated. * If not defined standard React.Children.toArray is used. */ childrenToArray?: ToArray /** * A custom component matcher * @param component Child Component */ componentMatcher?: ChildMatcher /** * Function to transform children of generated groups (those defined by `null` in the provided spec) */ traverseChildren?: TraverseChildren } export interface Config> extends ExtractionConfig { childrenSpec: S /** * A custom HOC name generation factory. * @returns Custom component name which will be displayed in React Dev Tools. */ getComponentName?: () => string /** * A factory which returns a custom implementation of Proxy component * @param key Current key of specification object * @returns A React component */ proxyComponentFactory?: ComponentFactory } export type GeneratedGroupingComponent = { _groupGenerated?: true }