import type { Properties } from 'csstype'; /** A CSS property value. */ export type CSSValue = string | number | null | undefined; /** * CSS properties with full value autocomplete. Uses csstype's original value * unions (which include `string & {}` for arbitrary strings) plus `null` * (filtered at runtime). Numbers accepted for length properties. */ export type CSSProperties = { [K in keyof Properties<(string & {}) | number, string & {}>]?: Properties<(string & {}) | number, string & {}>[K] | null; }; /** * A style rule object. Keys can be CSS properties (camelCase) or selectors * for nesting (`&:hover`), at-rules (`@media ...`), global styles (`@global`), * and class references (`$className`). */ export interface StyleRule extends CSSProperties { [selector: string]: StyleRule | CSSValue; } /** Top-level styles object mapping class names and selectors to style rules. */ export type Styles = Record; /** A renderer function: receives the current value and returns the next, called with the StyleSheet as `this`. */ export type RendererFn = (this: StyleSheet, styles: any) => any; /** A value provided directly or as a function returning it (called with the StyleSheet as `this`). */ export type Resolvable = T | ((this: StyleSheet) => T); /** * Characters that can't appear in a top-level class key. At runtime only keys * matching `/^\w+$/` produce a class name; keys containing any selector * syntax (dashes, spaces, combinators, at-rules, references, etc.) don't. */ type InvalidClassChar = | '-' | ' ' | '.' | ',' | ':' | '&' | '>' | '+' | '~' | '*' | '[' | ']' | '(' | ')' | '#' | '@' | '$' | '%' | '"' | "'" | '=' | '|' | '^'; /** Options for the StyleSheet constructor. Accepts custom keys for subclasses and custom renderers. */ export interface StyleSheetOptions { /** * Prefix for generating unique identifiers and data attributes. Default: `'fun'`. * May be a function returning the prefix, evaluated when the instance is created. */ prefix?: Resolvable; /** Custom function to generate the unique identifier. */ generateUid?: (this: StyleSheet) => string; /** Custom function to generate unique class names. */ generateClassName?: (this: StyleSheet, className: string, index: number) => string; /** Custom function to determine whether the StyleSheet should be added to the DOM. */ shouldAttachToDOM?: (this: StyleSheet) => boolean; /** * Attributes to be added to the `