import type { Future, MaybeFuture } from './futures'; export type CSSProperty = Omit; // export type CSSValue = string | number | undefined; // export type CSSValue = unknown; //typeof CSSStyleDeclaration[T]; export type CSSValue = CSSStyleDeclaration[T]; export type CSSDeclaration = { [K in keyof CSSStyleDeclaration]?: NonNullable>; }; // export type CSSWritableDeclaration = { // [K in keyof CSSStyleDeclaration as CSSStyleDeclaration[K] extends string | number | null ? K : never]?: NonNullable>; // }; export type CSSWritableDeclaration = { [K in keyof CSSStyleDeclaration as IsWritable]?: NonNullable>; }; /* * Helper type to check if a CSS property is writable **/ export type IsWritable = { -readonly [P in K]: CSSStyleDeclaration[K] } extends { [P in K]: CSSStyleDeclaration[K] } ? K : never ; export type CSSWritableProperty = Omit; export type CSSClassName = string & { _CSSClassNameBrand: never }; // const isValidCSSClassName = (name: string): name is CSSClassName => /^[_a-zA-Z][_a-zA-Z0-9-]*$/.test(name); export type CSSFuture = { [P in keyof CSSStyleDeclaration]?: MaybeFuture }; /** * Just an easier-to-remember alias for CSSStyleDeclaration * * ## Example * * ```ts * const styles = { * font-family: 'system-ui', * color: Promise.resolve('red'), * 'text-decoration': Observable.of('underline'), * }; */ export type CSSObject = CSSDeclaration | CSSFuture; /** * Just a friendly alias for CSSStyleDeclaration */ export type StyleObject = CSSFuture;