import { UiElement } from '../shared/element.js'; import type { TreeNodeToggleDetail, TreeLazyLoadDetail } from './tree-view-shared.js'; /** * One node of a `` (Carbon `TreeNode`). Nest ``s as children to make * a branch (expand with the caret, Enter, or Right; collapse with Left); `href` turns the label into * a link. Selection, focus and `active` are managed by the tree. * * Children loaded on demand (Carbon has no pattern; this is Shoelace's `lazy`): a `lazy` node is a * branch before it has children. Expanding it the first time sets `loading` (a spinner replaces the * caret, `aria-busy`, "Loading" for screen readers) and fires `ui-lazy-load`; append the child * ``s and `lazy` / `loading` clear themselves. No children to add: set `lazy = false` * (it becomes a leaf). A failed load: set `loading = false` — the node collapses and can be retried. * * @slot - Child nodes * @slot icon - 16px icon before the label * @slot label - Rich label (Carbon React's `label` node): replaces the `label` text, which stays the plain-text fallback * @slot end - Beyond Carbon: content at the end of the row (an amount, a count, a badge), kept whole while the label truncates; it then describes the node, which the label alone names * @fires ui-toggle - detail: { expanded, value } when the branch opens / closes * @fires ui-lazy-load - detail: { value } when a `lazy` node is expanded and its children should be fetched * @csspart label - The row * @csspart toggle - The caret button (branches) * @csspart children - The `role=group` container * @csspart end - The end content's wrapper (beyond Carbon) * @fires ui-navigate - detail: { href } (cancelable) on a plain click of the link; cancel it to route client-side (README: SPA router) * @cssprop --ui-tree-background / --ui-tree-row-radius - Row fill and corners (default the layer, 0; Kanok: transparent, 6px) * @cssprop --ui-tree-selected / --ui-tree-selected-hover - The selected row's fill and its hover (default layer-selected, layer-selected-hover; Kanok: the highlight tint) * @cssprop --ui-tree-mark / --ui-tree-mark-width / --ui-tree-mark-inset / --ui-tree-mark-radius - The selected row's start mark (default interactive, 4px, full height, square; Kanok: none, the tint alone — forced colours still show it) * @cssprop --ui-tree-pointer-outline - The ring of a node focused by a click, not the keyboard (default the focus ring, as Carbon; Kanok: none) */ export declare class UiTreeNode extends UiElement { static readonly styles: import("lit").CSSResult[]; label: string; /** Identifies the node in `selected` / `active`; defaults to `label`. */ value: string; expanded: boolean; disabled: boolean; href: string; /** A branch whose children aren't loaded yet: it shows a caret and fires `ui-lazy-load` when first expanded. */ lazy: boolean; /** The children are being fetched; set by the node when a `lazy` branch opens, cleared when children arrive. */ loading: boolean; /** Set by the tree. */ depth: number; private hasChildren; private readonly ids; private readonly slots; private readonly localize; /** The node set its own aria-label / aria-labelledby / aria-describedby (end content in use). */ private namedByParts; /** Has child nodes, or is `lazy` and will have them. */ get isBranch(): boolean; /** What identifies the node in the tree's `selected` / `active`: `value`, else `label`, else the label slot's text. (Was `nodeValue`, which shadowed DOM `Node.nodeValue`.) */ get treeValue(): string; /** The label as text, which type-ahead matches: the `label` slot's text when it is used, else `label`. */ get labelText(): string; /** Light-DOM children assigned to slot `name` (none under Lit SSR, where children aren't visible). */ private slotted; /** Direct child nodes. */ get childTreeNodes(): UiTreeNode[]; /** The enclosing node, or null at the top level. */ get parentTreeNode(): UiTreeNode | null; connectedCallback(): void; protected willUpdate(changed: Map): void; private get branch(); protected updated(changed: Map): void; /** * With end content the label alone names the treeitem and the end content describes it (else the name * would end with the amount); without, the row's content names it, as before. An author's own name wins. */ private syncName; /** The ids of slotted elements (given one when they have none), for aria-labelledby / aria-describedby. */ private idsOf; /** Expand / collapse (branches only, including `lazy` ones). */ toggle(expanded?: boolean): void; /** Children added or removed (e.g. a lazy load): re-render, and let the tree set their depth, size and tab stops. */ private onChildrenChange; private onToggleClick; render(): import("lit-html").TemplateResult<1>; } export interface UiTreeNodeEventMap extends HTMLElementEventMap { 'ui-toggle': CustomEvent; 'ui-lazy-load': CustomEvent; } /** Typed listeners for UiTreeNode's events (declaration merging with the class). */ export interface UiTreeNode { addEventListener(type: K, listener: (this: UiTreeNode, event: UiTreeNodeEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: UiTreeNode, event: UiTreeNodeEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare global { interface HTMLElementTagNameMap { 'ui-tree-node': UiTreeNode; } }