stoop
Version:
CSS-in-JS library with type inference, theme creation, and variants support.
42 lines (41 loc) • 2.18 kB
TypeScript
/**
* Styled component API.
* Creates polymorphic styled components with variant support, theme awareness,
* and CSS prop merging. Supports component targeting via selector references.
*/
import { forwardRef, type Context } from "react";
import type { CSS, StyledComponentProps, StyledComponentRef, StylableElement, Theme, ThemeContextValue, ThemeScale, UtilityFunction, Variants } from "../types";
/**
* Creates a styled component reference for selector targeting.
*
* @param className - Class name to reference
* @returns StyledComponentRef for use in CSS selectors
*/
export declare function createStyledComponentRef(className: string): StyledComponentRef;
type CSSWithVariants = {
[K in keyof CSS]: CSS[K];
} & {
variants: Variants;
compoundVariants?: unknown[];
};
/**
* Creates a styled component factory function.
* Supports polymorphic components, variants, theme awareness, and CSS prop merging.
*
* @param defaultTheme - Default theme for token resolution
* @param prefix - Optional prefix for generated class names
* @param media - Optional media query breakpoints
* @param utils - Optional utility functions
* @param themeMap - Optional theme scale mappings
* @param themeContext - React context for theme values (instance-specific)
* @returns Styled component factory function
*/
export declare function createStyledFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>, themeContext?: Context<ThemeContextValue | null>): {
<DefaultElement extends StylableElement, BaseStyles extends CSSWithVariants>(defaultElement: DefaultElement, baseStyles: BaseStyles): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, BaseStyles["variants"]>>> & {
selector: StyledComponentRef;
};
<DefaultElement extends StylableElement, VariantsConfig extends Variants = {}>(defaultElement: DefaultElement, baseStyles?: CSS, variants?: VariantsConfig): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, VariantsConfig>>> & {
selector: StyledComponentRef;
};
};
export {};