/** * Wrapper around zag's spreadProps that converts boolean ARIA attributes to strings * ("true" or "false") for accessibility compliance. All other attributes are passed * through unchanged. * * The vanilla spreadProps removes boolean false attributes, but ARIA attributes * should always be present as strings when provided by the API. * * Exception: `aria-readonly` is omitted when false as it's invalid on certain roles * (e.g., role="button"). */ export declare function spreadProps(node: Element, attrs: Record): () => void; type PropertyType = "string" | "boolean" | "number" | "string[]"; type PropMap = Record; /** * Renders a specific part of the UI based on the component's props. * If `propsToSend` is a PropMap, attributes are read from the DOM. * If `propsToSend` is a plain object, it is passed directly to the API. * * NOTE: This version treats the passed `root` element itself as a candidate * part (so you can call renderPart(li, 'item', api, { item }) for a single li). */ export declare const renderPart: (root: HTMLElement, name: string, api: any, propsToSend?: PropMap | Record any)>) => void; /** * Renders a list of items inside the root element. Each item is identified by the `name`, and the * properties for each item are retrieved from the API based on its `data-value`, `data-disabled`, and `data-index` attributes. * @param root - The root HTML element containing the items. * @param name - The name of the item part to render. * @param api - The API object used to retrieve the properties for each item. * ``` */ export declare function renderList(root: HTMLElement, name: string, api: any, items: T[]): void; interface Node { id: string; name: string; children?: Node[]; } /** * Recursively searches for a node in a hierarchical structure based on its `id`. * @param tree - The tree structure to search through. * @param id - The ID of the node to find. * @returns The node if found, or `null` if no node with the specified ID exists. * ``` */ export declare function findNodeById(tree: Node, id: string): Node | null; /** * Tree View Component: Renders a node from the provided hierarchical tree view into the specified part in the UI. * The part is identified by the `name`, and the node is retrieved from the tree using its `id` attribute. * @param root - The root HTML element in which the node resides. * @param name - The name of the node part to render. * @param api - The API object used to retrieve the properties for the node. * @param tree - The hierarchical tree structure containing the nodes. * * Example: * ```ts * const root = document.getElementById('root'); * const tree = { id: '1', name: 'root', children: [{ id: '2', name: 'child' }] }; * renderNode(root, 'node', api, tree); // Renders the node with properties from the tree * ``` */ export declare const renderNode: (root: HTMLElement, name: string, api: any, tree: Node) => void; /** * Extract a string data attribute with validation for specific type * @param element - The HTML element to extract from * @param attrName - The data attribute name (without 'data-' prefix) * @param validValues - Optional array of allowed values * @returns Validated string value or undefined */ export declare const getString: (element: HTMLElement, attrName: string, validValues?: readonly T[]) => T | undefined; /** * Extract a list of string values from a data attribute * @param element - The HTML element to extract from * @param attrName - The data attribute name (without 'data-' prefix) * @returns Array of strings or undefined */ export declare const getStringList: (element: HTMLElement, attrName: string) => string[] | undefined; /** * Extract a number data attribute with optional validation * @param element - The HTML element to extract from * @param attrName - The data attribute name (without 'data-' prefix) * @param validValues - Optional array of allowed numeric values * @returns Parsed number value or undefined */ export declare const getNumber: (element: HTMLElement, attrName: string, validValues?: readonly number[]) => number | undefined; /** * Extract a boolean data attribute * @param element - The HTML element to extract from * @param attrName - The data attribute name (without 'data-' prefix) * @returns Boolean value or undefined */ export declare const getBoolean: (element: HTMLElement, attrName: string) => boolean | undefined; /** * Generate a random ID if none is provided * @param element - Optional HTML element to get an existing id * @param fallbackId - Optional fallback base string (e.g. "checkbox") * @returns ID string (existing or generated) */ export declare const generateId: (element?: HTMLElement, fallbackId?: string) => string; export declare function valuesEqual(a: T, b: T): boolean; export declare function arraysEqualUnordered(a?: string[], b?: string[]): boolean; /** * Parse element IDs from child parts with data-part and data-id attributes * @param root - The root element containing the parts * @param partNames - Array of part names to look for (e.g., ['root', 'control', 'label']) * @returns Object with parsed IDs or undefined if no IDs found * * Example: * ```html *
*
*
*
* ``` * ```ts * const ids = getPartIds(element, ['root', 'control', 'label']); * // Returns: { root: 'my-root', control: 'my-control' } * ``` */ export declare const getPartIds: (root: HTMLElement, partNames: readonly string[]) => Record | undefined; export {};