1 | import { ComponentType, FunctionComponent } from 'react';
|
2 | import { ISystem } from './system';
|
3 | import { IThemeSettings } from './theme';
|
4 | export interface IComponentOptions<TProps extends object, TStyle> extends IStylingOptions<TProps, TStyle> {
|
5 | passthrough?: boolean;
|
6 | }
|
7 | export interface IComponentFactoryOptions<TProps extends object, TStyle> extends IStylingOptions<TProps, TStyle> {
|
8 | style?: TStyle | StylingFn<TProps, TStyle>;
|
9 | }
|
10 | export interface IComponentStylesRegistry<TStyle> {
|
11 | [componentName: string]: Array<IStyler<any, TStyle>>;
|
12 | }
|
13 | export interface IDSComponent<TProps extends object> extends FunctionComponent<TProps> {
|
14 | $$nprdds: boolean;
|
15 | }
|
16 | export declare type IDSProps<TStylerProps> = {
|
17 | as?: string | ComponentType<any> | IDSComponent<any>;
|
18 | } & TStylerProps;
|
19 | export interface IStyleCache {
|
20 | get<T = any>(name: string): T | void;
|
21 | set<T = any>(name: string, value: T): T;
|
22 | }
|
23 | export interface IStylingOptions<TProps extends object, TStyle> {
|
24 | cacheProps?: string[];
|
25 | styles?: Array<IStyler<TProps, TStyle>>;
|
26 | stripProps?: string[];
|
27 | }
|
28 | export interface IStyler<TProps extends object, TStyle = {}> {
|
29 | apply: StylingFn<TProps, TStyle>;
|
30 | propNames: Array<keyof TProps>;
|
31 | stripProps: Array<keyof TProps>;
|
32 | }
|
33 | export declare type extractStylerProps<Type> = Type extends IStyler<infer x, any> ? x : object;
|
34 | export interface IInternalDSProps<TStyle> {
|
35 | compPath?: string[];
|
36 | stripProps?: string[];
|
37 | stylers?: Array<IStyler<any, TStyle>>;
|
38 | }
|
39 | export interface IStyleApplicator<TStyleProps extends object, TStyle> {
|
40 | apply<TProps extends object>(componentName: string, props: Partial<IInternalDSProps<TStyle> & TStyleProps> & TProps, system: ISystem, componentOptions: IComponentOptions<TProps, TStyle>): IInternalDSProps<TStyle> & TStyleProps & TProps;
|
41 | }
|
42 | export interface ITheme {
|
43 | color(valueOrName: string, defaultValueOrName?: string): string;
|
44 | get(attributeName: keyof IThemeSettings, defaultValue?: any): any;
|
45 | }
|
46 | export declare type ComponentFactory<TStyleProps extends object, TStyle = {}, TPropsDefault extends object = {}, TAsPropsDefault extends object = {}> = <TProps extends object = TPropsDefault, TAsProps extends object = TAsPropsDefault>(componentName: string, component: string | ComponentType<TAsProps> | IDSComponent<TAsProps>, options?: IComponentFactoryOptions<TProps, TStyle>) => IDSComponent<TProps & TAsProps & IDSProps<TStyleProps> & TStyleProps & {
|
47 | [key: string]: any;
|
48 | }>;
|
49 | export declare type StyleCacheKeyFn = (props: object, cacheProps: string[], viewport: number, compPath?: string[], componentName?: string) => string;
|
50 | export declare type StyleApplicatorFactory<TStyle, TProps extends object = {}> = (options: {
|
51 | cache: IStyleCache;
|
52 | cacheKeyFn?: StyleCacheKeyFn;
|
53 | componentStyles: IComponentStylesRegistry<TStyle>;
|
54 | globalStyles: Array<IStyler<any, TStyle>>;
|
55 | }) => IStyleApplicator<TProps, TStyle>;
|
56 | export declare type StylerCreatorFn<TProps extends object, TStyle> = (propNames: string[], style: TStyle | StylingFn<TProps, TStyle>, stripProps?: string[]) => IStyler<TProps, TStyle>;
|
57 | export declare type StylingFn<TProps extends object, TStyle> = (props: TProps, designSystem: ISystem) => TStyle;
|