@fluentui/react-northstar
Version:
A themable React component library.
70 lines (69 loc) • 3.88 kB
TypeScript
import { ComponentWithAs, ComposePreparedOptions, ShorthandConfig } from '@fluentui/react-bindings';
import * as React from 'react';
import { ShorthandValue, Props, PropsOf, ShorthandRenderFunction } from '../types';
interface CreateShorthandOptions<P> {
/** Default props object */
defaultProps?: () => Partial<Props<P>>;
/** Override props object or function (called with regular props) */
overrideProps?: Partial<Props<P>> | ((props: P) => Partial<Props<P>>);
/** Whether or not automatic key generation is allowed */
generateKey?: boolean;
/** Override the default render implementation. */
render?: ShorthandRenderFunction<P>;
}
export declare type ShorthandFactory<P> = (value: ShorthandValue<P>, options?: CreateShorthandOptions<P>) => React.ReactElement | null | undefined;
/**
* @param config - Options passed to factory
* @returns A shorthand factory function waiting for `val` and `defaultProps`.
*/
export declare function createShorthandFactory<TStringElement extends keyof JSX.IntrinsicElements, P>(config: {
/** A ReactClass or string */
Component: TStringElement;
/** A function that maps a primitive value to the Component props */
mappedProp?: keyof PropsOf<TStringElement>;
/** A function that maps an array value to the Component props */
mappedArrayProp?: keyof PropsOf<TStringElement>;
/** Indicates if factory supports React Elements */
allowsJSX?: boolean;
}): ShorthandFactory<P>;
export declare function createShorthandFactory<TFunctionComponent extends React.FunctionComponent, P>(config: {
Component: TFunctionComponent;
mappedProp?: keyof PropsOf<TFunctionComponent>;
mappedArrayProp?: keyof PropsOf<TFunctionComponent>;
allowsJSX?: boolean;
}): ShorthandFactory<P>;
export declare function createShorthandFactory<TInstance extends React.Component, P>(config: {
Component: {
new (...args: any[]): TInstance;
};
mappedProp?: keyof PropsOf<TInstance>;
mappedArrayProp?: keyof PropsOf<TInstance>;
allowsJSX?: boolean;
}): ShorthandFactory<P>;
export declare function createShorthandInternal<P>({ Component, mappedProp, mappedArrayProp, value, options, allowsJSX, }: {
Component: React.ElementType<P>;
mappedProp?: string;
mappedArrayProp?: string;
allowsJSX?: boolean;
value?: ShorthandValue<P>;
options?: CreateShorthandOptions<P>;
}): any;
export declare function createShorthand<TFunctionComponent extends React.FunctionComponent>(Component: TFunctionComponent & {
shorthandConfig?: ShorthandConfig<PropsOf<TFunctionComponent>>;
fluentComposeConfig?: ComposePreparedOptions<PropsOf<TFunctionComponent>>;
}, value?: ShorthandValue<PropsOf<TFunctionComponent>>, options?: CreateShorthandOptions<PropsOf<TFunctionComponent>>): React.ReactElement;
export declare function createShorthand<TInstance extends React.Component>(Component: {
new (...args: any[]): TInstance;
} & {
shorthandConfig?: ShorthandConfig<PropsOf<TInstance>>;
fluentComposeConfig?: ComposePreparedOptions<PropsOf<TInstance>>;
}, value?: ShorthandValue<PropsOf<TInstance>>, options?: CreateShorthandOptions<PropsOf<TInstance>>): React.ReactElement;
export declare function createShorthand<E extends keyof JSX.IntrinsicElements, P>(Component: ComponentWithAs<E, P> & {
shorthandConfig?: ShorthandConfig<P>;
fluentComposeConfig?: ComposePreparedOptions<P>;
}, value?: ShorthandValue<P>, options?: CreateShorthandOptions<P>): React.ReactElement;
export declare function createShorthand<TElementType extends React.ElementType>(Component: TElementType & {
shorthandConfig?: ShorthandConfig<PropsOf<TElementType>>;
fluentComposeConfig?: ComposePreparedOptions<PropsOf<TElementType>>;
}, value?: ShorthandValue<PropsOf<TElementType>>, options?: CreateShorthandOptions<PropsOf<TElementType>>): React.ReactElement;
export {};