ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
33 lines (32 loc) • 1.92 kB
TypeScript
import type { Ref } from './builder/core';
/**
* Honour the user's "reduce motion" OS setting in every component. Adopted into
* each shadow root (last, so it overrides the component's own transitions), and
* scoped to the shadow tree by `*`. Only active when the user has the preference set.
*/
export declare const REDUCED_MOTION_CSS: string;
export declare const ensureShadowRoot: (host: HTMLElement, cssText?: string, options?: ShadowRootInit) => ShadowRoot;
/**
* The element the builder captured for this component, or a loud failure.
*
* Components build their shadow tree once, in the constructor, so `.ref()` on the builder
* is the element — there is nothing to search for. Reading it back out with a selector
* re-derives what the caller already had, and a renamed class then silently yields `null`
* that surfaces much later as a property read on nothing. `verify-design-rules` rejects
* that pattern; this is the replacement.
*
* @param ref - Holder passed to `.ref()` on the builder for this element.
* @param name - Field name for the failure message.
* @returns The element.
* @throws Error - When the builder never captured it, which means the `.ref()` call is
* missing or the tree was built somewhere the ref could not reach.
*/
export declare const shadowPart: <T extends HTMLElement>(ref: Ref<T>, name: string) => T;
export declare const getStringAttribute: (element: HTMLElement, name: string, fallback?: string) => string;
export declare const setStringAttribute: (element: HTMLElement, name: string, value: string | null | undefined, options?: {
removeEmpty?: boolean;
}) => void;
export declare const setBooleanAttribute: (element: HTMLElement, name: string, value: boolean, options?: {
aria?: string;
}) => void;
export declare const syncSheetAttribute: (host: HTMLElement, root: ShadowRoot, name: string, oldValue: string | null, newValue: string | null) => void;