UNPKG

@furystack/shades

Version:

A lightweight UI framework for FuryStack with JSX support

51 lines 2.26 kB
import type { CSSObject } from './models/css-object.js'; /** * Owns a shared `<style data-shades-styles>` element in `document.head` * and dedupes component-style registration. Internal — consumers use * the {@link StyleManager} singleton. */ declare class StyleManagerClass { private styleElement; private registeredComponents; private getStyleElement; /** * Registers CSS styles for a component. * Styles are only injected once per component (based on the custom element name). * * @param customElementName - The custom element tag name (used as CSS selector) * @param cssObject - The CSSObject containing styles and nested selectors * @param elementBaseName - Optional base element name for customized built-in elements (e.g., 'a', 'button'). * When provided, generates selector like `a[is="component-name"]` instead of `component-name` * @returns True if styles were injected, false if already registered * * @example * ```typescript * // Regular custom element * StyleManager.registerComponentStyles('my-button', { * padding: '12px', * '&:hover': { backgroundColor: 'blue' } * }) * * // Customized built-in element (extends anchor) * StyleManager.registerComponentStyles('my-link', { * color: 'blue', * '&:hover': { textDecoration: 'underline' } * }, 'a') * // Generates: a[is="my-link"] { color: blue; } * ``` */ registerComponentStyles(customElementName: string, cssObject: CSSObject, elementBaseName?: string): boolean; isRegistered(customElementName: string): boolean; /** Snapshot of registered component names. Intended for diagnostics + tests. */ getRegisteredComponents(): ReadonlySet<string>; /** Removes the shared style element and clears the registration set. Test-only. */ clear(): void; } /** * Process-wide CSS injection registry for Shade components. The {@link Shade} * factory calls `registerComponentStyles` automatically; direct use is rare * (e.g. injecting a third-party stylesheet keyed off a component name). */ export declare const StyleManager: StyleManagerClass; export {}; //# sourceMappingURL=style-manager.d.ts.map