UNPKG

@furystack/shades

Version:

A lightweight UI framework for FuryStack with JSX support

47 lines 2.65 kB
import type { ChildrenList, ShadeComponent } from './models/index.js'; /** * When true, the JSX factory produces VNode descriptors instead of real DOM elements. * Set to true by `_performUpdate` before calling `render()`, then back to false after. */ export declare const setRenderMode: (mode: boolean) => void; /** * Appends `children` to `el`. Strings/numbers are wrapped in text nodes; * nested arrays are flattened recursively. Used outside render mode (real * DOM); inside render mode the JSX factory builds VNodes instead. */ export declare const appendChild: (el: Element | DocumentFragment, children: ChildrenList) => void; export declare const hasStyle: (props: unknown) => props is { style: Partial<CSSStyleDeclaration>; }; /** Copies `props.style` (when present) onto `el.style`. No-op for non-styled props. */ export declare const attachStyles: (el: HTMLElement, props: unknown) => void; export declare const attachDataAttributes: <TProps extends object>(el: HTMLElement, props: TProps) => void; /** * Assigns `props` onto `el` as element properties (not attributes). `style` * is forwarded to {@link attachStyles}; `data-*` / `aria-*` are forwarded to * {@link attachDataAttributes}. */ export declare const attachProps: <TProps extends object>(el: HTMLElement, props: TProps) => void; /** * SVG counterpart of {@link attachProps}. SVG attributes are XML-based and * must be set via `setAttribute` rather than property assignment. Event * handlers (`on*`) and `style` are still set as properties. */ export declare const attachSvgProps: <TProps extends object>(el: Element, props: TProps) => void; type CreateComponentArgs<TProps> = [ elementType: string | ShadeComponent<TProps>, props: TProps, ...children: ChildrenList ]; /** * JSX factory backing both intrinsic elements (`<div>`, `<svg>`, …) and * Shade components (`<MyShade>`). Configured as `jsxFactory` in tsconfig. * Outside render mode this returns real DOM nodes; the render-mode wrapper * {@link createComponent} swaps in VNode descriptors. */ export declare const createComponentInner: <TProps extends object>(...[elementType, props, ...children]: CreateComponentArgs<TProps>) => HTMLElement | SVGElement | undefined; type CreateFragmentArgs = [props: null, ...children: ChildrenList]; export declare const createFragmentInner: (...[_props, ...children]: CreateFragmentArgs) => DocumentFragment; export declare const createComponent: <TProps extends object>(...args: CreateComponentArgs<TProps> | CreateFragmentArgs) => HTMLElement | SVGElement | DocumentFragment | undefined; export {}; //# sourceMappingURL=shade-component.d.ts.map