UNPKG

2.86 kBTypeScriptView Raw
1import * as React from 'react';
2import { IStyleSet, IStyleFunctionOrObject } from '@uifabric/merge-styles';
3export interface IPropsWithStyles<TStyleProps, TStyleSet extends IStyleSet<TStyleSet>> {
4 styles?: IStyleFunctionOrObject<TStyleProps, TStyleSet>;
5}
6export interface ICustomizableProps {
7 /**
8 * Name of scope, which can be targeted using the Customizer.
9 */
10 scope: string;
11 /**
12 * List of fields which can be customized.
13 * @defaultvalue [ 'theme', 'styles' ]
14 */
15 fields?: string[];
16}
17export declare type StyleFunction<TStyleProps, TStyleSet> = IStyleFunctionOrObject<TStyleProps, TStyleSet> & {
18 /** Cache for all style functions. */
19 __cachedInputs__: (IStyleFunctionOrObject<TStyleProps, TStyleSet> | undefined)[];
20 /** True if no styles prop or styles from Customizer is passed to wrapped component. */
21 __noStyleOverride__: boolean;
22};
23/**
24 * The styled HOC wrapper allows you to create a functional wrapper around a given component which will resolve
25 * getStyles functional props, and mix customized props passed in using concatStyleSets.
26 *
27 * @example
28 * ```tsx
29 * export const Toggle = styled(
30 * ToggleBase,
31 * props => ({ root: { background: 'red' }})
32 * );
33 * ```
34 * @param Component - The unstyled base component to render, which receives styles.
35 * @param baseStyles - The styles which should be curried with the component.
36 * @param getProps - A helper which provides default props.
37 * @param customizable - An object which defines which props can be customized using the Customizer.
38 * @param pure - A boolean indicating if the component should avoid re-rendering when props haven't changed.
39 * Note that pure should not be used on components which allow children, or take in complex objects or
40 * arrays as props which could mutate on every render.
41 */
42export declare function styled<TComponentProps extends IPropsWithStyles<TStyleProps, TStyleSet>, TStyleProps, TStyleSet extends IStyleSet<TStyleSet>>(Component: React.ComponentClass<TComponentProps> | React.FunctionComponent<TComponentProps>, baseStyles: IStyleFunctionOrObject<TStyleProps, TStyleSet>, getProps?: (props: TComponentProps) => Partial<TComponentProps>, customizable?: ICustomizableProps, pure?: boolean): React.FunctionComponent<TComponentProps>;
43export declare function styled<TComponentProps extends IPropsWithStyles<TStyleProps, TStyleSet> & React.RefAttributes<TRef>, TStyleProps, TStyleSet extends IStyleSet<TStyleSet>, TRef = unknown>(Component: React.ComponentClass<TComponentProps> | React.FunctionComponent<TComponentProps>, baseStyles: IStyleFunctionOrObject<TStyleProps, TStyleSet>, getProps?: (props: TComponentProps) => Partial<TComponentProps>, customizable?: ICustomizableProps, pure?: boolean): React.ForwardRefExoticComponent<React.PropsWithoutRef<TComponentProps> & React.RefAttributes<TRef>>;