import CSS from "csstype"; import React, { DependencyList } from "react"; import { Destructor } from "./destructors"; type BaseCSSProperties = CSS.Properties; type CustomProperties = { [name: `--${string}`]: string | number | undefined; }; type Declarations = BaseCSSProperties & CustomProperties; type NestedRuleKey = `&${CSS.SimplePseudos}` | `${CSS.AtRules}${string}` | `.${string}` | `&${string}`; /** * Value under a pattern key (`--*` custom property or nested rule). Both share * one value type because TypeScript widens computed keys such as * `` [`&[data-selected] ${part}`] `` to `string`, and a `string` key must fit * every pattern signature at once. */ type PatternValue = Declarations | string | number | undefined; export type CSSProperties = { [Key in keyof BaseCSSProperties]?: BaseCSSProperties[Key]; } & { [Key in `--${string}` | NestedRuleKey]?: PatternValue; }; export type StyleApi = { addStyleElement: (styleElement: StyleElement) => Destructor; addGlobalStyle: (styleRule: string) => Destructor; }; declare const __style__: unique symbol; type StyleRule = string; export type StyleElement = { __style__: typeof __style__; composed: StyleElement[]; /** This style's own class. Present even when it only composes other styles. */ owned: { styleRules: StyleRule[]; className: string; }; className: string; /** * The own class as a selector, so a style interpolates into nested rules: * `` [`&[data-selected] ${part}`]: { … } ``. */ toString(): string; }; export type InMemoryStyleApi = { styleRulesRef: { current: string[]; }; addStyleElement: StyleApi["addStyleElement"]; addGlobalStyle: StyleApi["addGlobalStyle"]; detachVariableGroups: Destructor; }; export declare function createInMemoryStyleApi(): InMemoryStyleApi; export declare function PurseProvider(props: { children?: React.ReactNode; }): React.JSX.Element; /** Compile a style object against a selector (same nesting rules as `style()`). */ export declare function compileGlobalStyleRules(selector: string, cssProperties: CSSProperties): StyleRule[]; export type StyleArgument = CSSProperties | StyleElement | false | null | undefined; export declare function style(...styleElementsOrCSS: StyleArgument[]): StyleElement; export declare function useInjectGlobalStyles(selector: string, cssProperties: CSSProperties, deps: DependencyList): void; export declare function useStyles(...styleElementsOrCSS: StyleArgument[]): string; export {};