import React, { ComponentType, FC, PropsWithChildren, ReactElement, ReactNode, Ref } from 'react'; /** * The options for Beyond */ export type BeyondOptions = { /** The id of the Beyond Feature */ id: string; /** The function to invoke the render function */ invokeRender?: (Cmp: FC, props: PropsWithChildren, ref?: Ref) => ReactElement; /** Function to map the component */ mapComponent?: (Cmp: FC) => FC; /** * Define directive props. This can be a string or array of string. * */ directiveProp?: string | string[]; /** * Function to map the elements * - If `directiveProp` is set, `mapElement` will only be called when any of * the directive props are set on the elements. `directiveValue` will hold * the props value, or prop values in case directiveProp is an array. */ mapElement?: (element: ReactElement, directiveValue?: any) => ReactElement; /** * Function to filter the nodes to which the HOC should be applied. Useful for * handling edge cases and create white or blacklists. */ filterNodes?: (node: unknown) => boolean; /** * Function to map the JSX nodes. This is similar to mapElements, * - If `directiveProp` is set, `mapElement` will only be called when any of * the directive props are set on the elements. `directiveValue` will hold * the props value, or prop values in case directiveProp is an array. */ mapNode?: (node: unknown) => ReactElement; /** Function to map the children of elements */ mapChildren?: (elements: ReactNode | ReactNode[]) => ReactElement[]; /** * Strategy to avoid the "Each child in a list should have a unique "key" * prop." issues. This is an under-the-hood option, and all of them work fine. * Set it for experimental purposes. The base problem is that React children * are array-ified by the time Beyond maps the elements. * @default 'flatAndSpread' * - 'reactChildrenMap': Uses the React.Children.map API to map the children. * This is probably the "reference" solution, generating automatic keys, but * it pollutes the devtools inspector. * - 'flatAndSpread': Flatten the children array and spread it into * createElement. Spreading is enough most of the time, but when components * render {props.children} next to an element, that's an array in an array, * so we need to flatten it as well. (React knows that those cases are okay * by marking the children earlier with _store: { validated: true } - see * "validatedFlag"). This is a user land solution, and it seems to work * well. It doesn't prevent warnings in case of legitimate key issues. * - validatedFlag: Add a _store: { validated: true } marker to the elements. * This is the simplest and probably the closest way to how React handles * it, but it is an internal API, so it's not really future-proof. */ experimentalKeyStrategy?: 'reactChildrenMap' | 'flatAndSpread' | 'validatedFlag'; }; export declare const $$beyondInfo: unique symbol; /** * A deep higher-order component (HOC) utility function that applies itself * recursively to all children, even penetrating through renders. * @param {ComponentType} wrappedComponent - The component to wrap * @param {BeyondOptions} opts - The options for the HOC * @returns {ComponentType} The wrapped component */ export declare function beyond(wrappedComponent: FC, opts: BeyondOptions): FC; /** * Use it like this: * * * */ export declare function Beyond(props: { children: ReactNode; features: Function[]; }): React.FunctionComponentElement;