import type { PinceauMediaQueries, PinceauUtils } from '@pinceau/outputs' import type { CSSProperties, PseudosProperties } from './properties' import type { ComputedStyleDefinition } from './computed-styles' import type { Variants } from './variants' export type PropertyType = (string & {}) | (number & {}) | undefined export type ExtractVariantsProps = { [K in keyof V]?: ResponsiveProp> } export type ResponsiveProp = { [key in PinceauMediaQueries]?: T } | T export type StyledFunctionArg< Props extends {} = {}, LocalTokens extends string | undefined = undefined, TemplateSource extends {} = {}, SupportVariants extends boolean = true, > = // Support for variants ( SupportVariants extends true ? { variants?: Variants } : { variants?: undefined } ) | RawCSS export type CSSFunctionArg< LocalTokens extends string | undefined = undefined, TemplateSource extends {} = {}, > = RawCSS export type RawCSS< LocalTokens extends string | undefined = undefined, TemplateSource = {}, Props = {}, HasRoot extends boolean = false, > = // Utils properties { [K in keyof PinceauUtils]?: // `utils: { mx: (value: string) => ... }`, grab the type of `value` and inject it. | Parameters[0] // Same but as Computed Style | ComputedStyleDefinition } | // Autocomplete from template source { [K in keyof TemplateSource]?: RawCSS } | // $media queries { [K in PinceauMediaQueries]?: RawCSS } | // If the CSS has a root, display all possible properties. ( HasRoot extends true ? // CSS Properties { [K in keyof CSSProperties]?: CSSProperties[K] | ComputedStyleDefinition } | // Pseudos properties { [K in keyof PseudosProperties]?: RawCSS } | // Local tokens overwriting ( LocalTokens extends string ? { [K in LocalTokens]?: PropertyType | ComputedStyleDefinition } : {} ) | // Support for custom properties { [K in `$${string}`]?: PropertyType | ComputedStyleDefinition } | { [K in `--${string}`]?: PropertyType | ComputedStyleDefinition } : {} ) | // Make this recursive, set root to true past first level { [key: string]: RawCSS } // interface TestTemplate { div: { button: {}; span: {}; '.test': {} }; '.class-test': { button: {}; span: { a: {} } } } // function css(declaration: CSSFunctionArg<'$test.token', TestTemplate>) { return declaration as Readonly } // function styled(declaration: StyledFunctionArg) { return declaration as Readonly }