import * as React from 'react'; export declare interface BaseSlots { root: React.ElementType; } /** * Generic set of module to class name map. */ export declare type ClassDictionary = Record; /** * Generic class resolver function type. */ export declare type ClassFunction = (state: GenericDictionary, slots: GenericDictionary) => ClassDictionary; export declare interface ComponentProps { as?: React.ElementType; className?: string; } export declare type ComponentWithAs = ((props: Omit, 'as' | keyof TProps> & { as?: TExtendedElementType; } & TProps) => JSX.Element) & { propTypes?: React.WeakValidationMap & { as: React.Requireable any) | (new (props: any, context?: any) => any)>; }; contextTypes?: React.ValidationMap; defaultProps?: Partial; displayName?: string; /** * A hack to simplify the resolution for ComponentWithAs. * @see https://github.com/microsoft/fluentui/pull/13841 */ readonly __PRIVATE_PROPS?: Omit, 'as' | keyof TProps> & { as?: TElementType; } & TProps; }; export declare function compose(input: Input, inputOptions?: ComposeOptions): ComponentWithAs; export declare type ComposedComponent = React.FunctionComponent & { fluentComposeConfig: Required; }; export declare type ComposeOptions = { className?: string; classes?: ClassDictionary | ClassFunction | (ClassDictionary | ClassFunction)[]; displayName?: string; mapPropsToStylesProps?: (props: TParentStylesProps & TInputProps) => TInputStylesProps; handledProps?: (keyof TInputProps | 'as')[]; overrideStyles?: boolean; slots?: Record; slotProps?: (props: TParentProps & TInputProps) => Record; shorthandConfig?: ShorthandConfig; state?: (props: TState, ref: React.Ref, options: ComposePreparedOptions) => any; }; /** * Merged ComposeOptions. */ export declare type ComposePreparedOptions = { className: string; classes: (undefined | ClassDictionary | ClassFunction)[]; displayName: string; displayNames: string[]; mapPropsToStylesPropsChain: ((props: object) => object)[]; render: ComposeRenderFunction; handledProps: (keyof TProps | 'as')[]; overrideStyles: boolean; slots: Record & { __self: React.ElementType; }; slotProps: ((props: TProps) => Record)[]; state: (props: TParentState, ref: React.Ref, options: ComposePreparedOptions) => TInputState; resolveSlotProps: (props: TResolvedProps) => Record; shorthandConfig: ShorthandConfig; }; export declare type ComposeRenderFunction = (props: TProps, ref: React.Ref, options: ComposePreparedOptions & { state: any; }) => React.ReactElement | null; /** * `createClassResolver` is a factory function which creates a state to classmap resolver for * slot specific class names. It can be used in conjunction with the `compose` option `classes` to * inject css modules without writing cx(...) logic manually distributing classnames. * * Class names which map to slots are automatically distributed to correct slot props. * * Class names with an underscore are interpretted as enum matchable classes. For example, * the class "size_large" would be applied to the `root` slot when the component's state contains * a prop `size` with a value `large`. * * Remaining class names would be interpretted as modifiers, applied to the `root` slot when * the component `state` contains a truthy matching prop name. */ export declare const createClassResolver: (classes: Record) => (state: Record) => Record; /** * Generic name to any dictionary. */ export declare type GenericDictionary = Record; export declare type Input = InputComposeComponent | ComposeRenderFunction; export declare type InputComposeComponent = React.FunctionComponent & { fluentComposeConfig?: Required; }; /** * Merge props takes in state and compose options, and resolves slots and slotProps. * It's expected that the component will call mergeProps(state, options) from within * render; after resolving state and before rendering slots and slotProps. */ export declare function mergeProps(state: TState, options: ComposePreparedOptions): MergePropsResult; export declare type MergePropsResult = { state: TState; slots: TSlots; slotProps: TSlotProps; }; /** * Merge props for a slot to a slot prop. * @param slotProp - Slot prop. * @param slotProps - Props for the slot. * @param mappedProp - Optional mapped prop name for the slotProp after merging. */ export declare function mergeSlotProp(slotProp: SlotProp, slotProps: TProps, mappedProp?: string): SlotProp; export declare type ObjectSlotProp = TProps & { children?: TProps['children'] | SlotPropRenderFunction; }; export declare type PropsOfElement | ComponentWithAs> = E extends { __PRIVATE_PROPS: any; } ? E['__PRIVATE_PROPS'] : JSX.LibraryManagedAttributes>; export declare interface ShorthandConfig { mappedProp?: keyof TProps; mappedArrayProp?: keyof TProps; allowsJSX?: boolean; } export declare type SlotProp = React.ReactChild | React.ReactNodeArray | React.ReactPortal | boolean | null | undefined | ObjectSlotProp; export declare type SlotPropRenderFunction = (Component: React.ElementType, props: TProps) => React.ReactNode; export declare type SlotProps> = { [key in keyof Omit]: key extends keyof TProps ? TProps[key] : any; } & { root: TRootProps; }; export { }