declare type BaseParts = Record; declare type VariantName = string; declare type VariantValue = any; declare type VariantsMap = Record; declare type Styles = Record; /** * A type that represent an object containing: * * - the styles applied when no particular state is on, via the "normal" key (default styles) * - the "state" styles via a key each * (ie. styles that are applied in certain states, like "hover", "focus", …) * * example: * ``` * { * normal: { borderColor: 'blue', color: 'blue', }, * hover: { backgroundColor: 'blue', color: 'white' } * disabled: { opacity: 0.5; pointerEvents: 'none' } * } * ``` */ export declare type PartStyles = { normal?: Styles; } & { [stateName in StateNames]?: Styles; }; /** * This type represents the styles for each part of the primitive. * It is essentially a map of part names to `Styles` objects. * * example: * ``` * { * base: { * button: { * normal: { borderColor: 'blue', color: 'blue', } * }, * icon: { * normal: { marginRight: 10 }, * } * } * } * ``` */ export declare type PartsStyles = { [partName in keyof Parts]?: PartStyles; }; /** * The primary type representing the supported structure * to style a primitive. It separates: * * - what we call "base" styles which are the styles the component parts * gets by default as well as their states (ie. hover, focus, …) * * - what we call "variants" styles which are the styles related to variants * added to the component (ie. type: 'primary' | 'secondary', size: 'small' | 'big', …) * keyed by variant names. * * example: * ``` * { * base: { … } * variants: { * mode: { * light: { … }, * dark: { … }, * }, * size: { * small: { … }, * large: { … }, * }, * } * } * ``` */ export declare type StyleConfig = { base: PartsStyles; variants?: Record>>; }; /** * Extract the variant names from a style config object. * * example: * ``` * const styleConfig = { base: { … }, variants: { mode: { … }, size: { … } }}; * getVariantNamesFromStyleConfig(styleConfig) => ['mode', 'size'] * ``` */ export declare function getVariantNamesFromStyleConfig(styleConfig?: StyleConfig): VariantName[]; /** * Utility to infer variants based on props and variant names. * Given all the props, and an array of variant names, computes * a map of variant names to variant values. * * ie. * ``` * const props = { value: 'hello', onChange: () => {}, mode: 'dark' }; * const variantNames = ['mode', 'size']; * makeVariantsMap(props, variantNames) => { mode: 'dark', size: 'big' } * ``` */ export declare function makeVariantsMap>(props: Props, variantNames?: VariantName[]): Partial; /** * Primary utility to compute the final styles of a part based on: * - its states * - the global variants. * * Given a style config and the values for each variants, * merges and flattens all the necessary styles. */ export declare function getPartStyles['base']>(partName: PartName, styleConfig?: StyleConfig, variantsMap?: VariantsMap): PartStyles; /** * Returns the `styleConfig` as a React ref because it will not change once exported * from Modulz. Without this, anything depending on `styleConfig` would re-render/re-execute * unnecessarily, for example, as a useEffect dependency or Context provider value. */ export declare function useStyleConfig>(parts: (keyof Parts)[], props: Props, styleConfig?: StyleConfig): PartsStyles; export {};