UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

23 lines (22 loc) 1.02 kB
export type DefaultsProps = Record<string, unknown>; export type Contexts = Array<Record<string, unknown>>; /** * Overrides default props with values from context. * * "undefined" is considered the default value of a prop * unless otherwise provided * * @param props object of component properties * @param defaults object of default values * @param contexts one or more contexts to merge * @returns merged properties */ export declare function extendPropsWithContext<Props>(props: Props, defaults?: DefaultsProps, ...contexts: Contexts): Props & {}; /** * Like extendPropsWithContext, but only merges context values * for props that already exist on the props object. * This prevents unknown context keys from leaking into * the component and potentially reaching DOM attributes. */ export declare function extendExistingPropsWithContext<Props>(props: Props, defaults?: DefaultsProps, ...contexts: Contexts): Props & {}; export declare function reduceContext(contexts: Contexts): Record<string, unknown>;