UNPKG

@hitachivantara/uikit-react-utils

Version:
52 lines (41 loc) 2.01 kB
import { CSSInterpolation } from '@emotion/serialize'; import { HvTheme } from '@hitachivantara/uikit-react-shared'; import { HvThemeContextValue } from '@hitachivantara/uikit-react-shared'; export declare const clamp: (value: number, max?: number, min?: number) => number; /** Utility function to create classes for a component. */ export declare function createClasses<Name extends string, Styles extends Record<string, CSSInterpolation>>( /** Component name in PascalCase (ie. `HvTableCell`). */ name: Name, stylesObject: Styles): { readonly useClasses: (classesProp?: Partial<Record<keyof Styles, string>>, addStatic?: boolean) => { readonly classes: { [J in keyof Styles]: string; }; readonly css: any; readonly cx: (...args: any) => string; }; readonly staticClasses: { [J in keyof Styles]: string; }; }; export declare type ExtractNames<T extends (...args: any) => { classes: Record<string, any>; cx: any; }> = Partial<ReturnType<T>["classes"]>; export { HvTheme } /** * Utility that merges the `style` prop (`styleProp`) with an external `style` object. * * The external object accepts CSS vars (`--var`) and removes empty style entries. */ export declare const mergeStyles: (styleProp: React.CSSProperties | undefined, styles: Record<string, any>) => React.CSSProperties; declare interface ThemeContextValue extends HvThemeContextValue { /** Colors of the currently active theme and mode */ colors?: HvTheme["colors"]["modes"]["mode"]; } export declare function useCss(): { readonly css: any; readonly cx: (...args: any) => string; }; /** Injects into `props` the props defined in the theme `componentName`. */ export declare function useDefaultProps<T extends Record<string, any>>( /** Name of the theme component key to inject defaultProps */ componentName: string, // keyof HvThemeComponents, props: T): T; export declare const useTheme: () => ThemeContextValue; export { }