UNPKG

@artifak/component-generator

Version:

Component generator utility for Artifak

33 lines (32 loc) 1.83 kB
import { AllHTMLAttributes } from 'react'; import * as CSS from 'csstype'; import { ThemedStyledFunction, ThemedStyledProps } from 'styled-components'; import { styleFn, Scale } from 'styled-system'; import { BackgroundProps, BorderProps, ColorProps, DisplayProps, LayoutProps, PositionProps, ShadowProps, SpaceProps, TypographyProps, ResponsiveValue } from 'styled-system'; export declare type BaseProps<ThemeType> = BaseComponentProps & Variant<ThemeType>; export declare type BaseComponentProps = BackgroundProps | BorderProps | ColorProps | DisplayProps | LayoutProps | PositionProps | ShadowProps | SpaceProps | TypographyProps; export declare type Variant<ThemeType = void> = { variant?: ResponsiveValue<string | number, ThemeType>; }; export declare type Attrs<Props, Attributes extends Partial<Props>, ThemeType> = ((props: ThemedStyledProps<Props, ThemeType>) => Attributes) | Attributes; export declare type BaseConfig<Props = void, Attributes = void, ThemeType = void> = { styles?: ScalableCSS; attrs?: Attributes; styleProps?: styleFn[]; element?: keyof JSX.IntrinsicElements; component?: ThemedStyledFunction<keyof JSX.IntrinsicElements, ThemeType | any, React.ComponentType<Props>, keyof any>; }; export declare type CSSObjectWithScale = CSS.Properties<string | number | Scale>; export declare type CSSPseudos = { [K in CSS.Pseudos]?: CSSObjectWithScale; }; export declare type ScalableCSS = CSSObjectWithScale & CSSPseudos; export declare type ComponentsRecord<Dict, Props, ThemeType> = { [key in keyof Dict | 'Base']: React.FC<Props & BaseProps<ThemeType>>; }; export declare type Settings<Element = HTMLDivElement> = { [key: string]: ScalableCSS & { as?: keyof JSX.IntrinsicElements; attrs?: AllHTMLAttributes<Element>; }; };