import { a as TreeItem, n as TreeExclusivity, o as TreeNode, r as TreeFilterPredicate, s as TreeSelectionFilter, t as LoadChildrenCallback } from "./types-6hpXRKt7.js"; import { l as ViewStateful } from "./types-16GC5k1z.js"; interface ListDragEntry { readonly key: string; readonly index: number; readonly item: T | Element; /** * Available rendered presentation for the entry, for use only during the * synchronous drag-preview operation. * * - Element-backed lists: the consumer/source element. * - Data-backed virtual lists: the currently rendered row or cell that * presents the item. * - `undefined` when no presentation is currently rendered (e.g. a * virtualized-off-screen selection). * * Do not retain the element afterwards: virtualization may recycle or * disconnect it. */ readonly element?: Element; } type ListDragSource = `grid-list` | `detail-list` | `vertical-list` | `data-grid` | `tree-list`; interface ListDragPreviewContext { readonly source: ListDragSource; readonly origin: ListDragEntry; readonly selected: ReadonlyArray>; readonly metrics: { readonly itemSize?: number; readonly captionStyle?: string; readonly captionHeight?: number; readonly rowHeight?: number; }; readonly hostStyle: CSSStyleDeclaration; readonly resolveDragPreviewSource?: ListDragPreviewSourceResolver; } interface ListDragPreview { readonly element: HTMLElement; readonly hotspot?: Readonly<{ x: number; y: number; }>; readonly canvas?: HTMLCanvasElement; readonly dispose?: () => void; } /** * Writes an application payload onto the drag's `DataTransfer` at `dragstart`. * Every list component exposes this as a public `writeDataTransfer` property; * `ListNativeDragController` invokes it after any built-in payload writer. */ type ListDragDataTransferWriter = (dataTransfer: DataTransfer, detail: ListNativeDragStartDetail) => void; type ListDragPreviewRenderer = (context: ListDragPreviewContext) => ListDragPreview; type ListDragPreviewSourceResolver = (entry: ListDragEntry) => CanvasImageSource | undefined; interface ListNativeDragStartDetail { readonly key: string; readonly index: number; readonly item: T | Element; readonly selectedKeys: readonly string[]; readonly selected: ReadonlyArray>; readonly preview?: ListDragPreview; } type ListNativeDragStartEvent = CustomEvent>; type InvalidateEvent = { type: `invalidate`; key: string; }; type RootEvent = { type: `root`; root: TreeNode; }; type ModelEvent = InvalidateEvent | RootEvent; type ModelSubscriber = (event: ModelEvent) => void; type TreeDataModelOptions = { /** The initial root node. Required. */ root: TreeNode; /** * Optional callback for lazily loading children. * If omitted, nodes with `children === undefined` are treated as empty branches. */ loadChildren?: LoadChildrenCallback; }; /** * Manages tree data for tree-like components. * * Handles two concerns: * 1. **Lazy loading** — caches children fetched via `loadChildren` and can invalidate * specific branches so they are re-fetched on next expand. * 2. **Structural mutations** — convenience methods to add, remove, update, or move * nodes. Each mutation produces a new immutable root and notifies connected components. * * Assign an instance to a component's `model` property instead of setting `root`/`loadChildren` * directly. The same model instance can be shared across multiple components. * * @example * ```typescript * const model = new TreeDataModel({ * root: { item: { key: 'root', label: 'Root' }, children: [] }, * loadChildren: async (node, depth, signal) => fetchChildren(node.item.key), * }); * myTreeList.model = model; * myMillerList.model = model; * * // Later — invalidate a branch to force a re-fetch on next expand: * model.invalidate('some-key'); * ``` */ declare class TreeDataModel { #private; constructor(options: TreeDataModelOptions); /** The current immutable root snapshot. */ get root(): TreeNode; /** * Replace the entire root with a new immutable snapshot. * All cached children are cleared. Connected components re-render. */ setRoot(root: TreeNode): void; /** * Returns children for the given node. * If children are cached, they are returned immediately (as a resolved Promise). * Otherwise the `loadChildren` callback is invoked and the result is cached. * If no `loadChildren` is set and no cache entry exists, returns `[]`. * * Called by components internally — not typically called by application code. */ getChildren(node: TreeNode, depth: number, signal: AbortSignal): Promise; /** * Clears the cached children for the node with the given key. * Connected components will collapse that node (if currently expanded), so that * the next expand triggers a fresh `loadChildren` call. */ invalidate(key: string): void; /** * Adds `node` as a child of the node identified by `parentKey`. * Returns the new root (connected components are notified automatically). */ addNode(parentKey: string, node: TreeNode): TreeNode; /** * Removes the node with the given key and all its descendants. * Returns the new root (connected components are notified automatically). */ removeNode(key: string): TreeNode; /** * Applies a partial update to the `item` of the node with the given key. * Returns the new root (connected components are notified automatically). */ updateItem(key: string, patch: Partial): TreeNode; /** * Moves the node with the given key to become a child of `newParentKey`. * When `index` is provided, inserts at that position; otherwise appends. * Returns the new root (connected components are notified automatically). */ moveNode(key: string, newParentKey: string, index?: number): TreeNode; /** * Moves the node with the given key to become a sibling of `referenceKey`, * positioned `before` or `after` it. A no-op (returns the unchanged root) when * `key` is `referenceKey`, an ancestor of it, or either is missing. * Returns the new root (connected components are notified automatically). */ moveNodeRelative(key: string, referenceKey: string, position: `before` | `after`): TreeNode; /** * Applies a resolved drop (from `ixfx-tree-list`'s `tree-drop` event or a * hand-built context) to the current root. No-op when the drop is invalid. * Returns the new root (connected components are notified automatically). */ applyDrop(ctx: TreeDropApplyContext): TreeNode; /** * Inserts `node` as a child of `parentKey` (or at the root level when `parentKey` is undefined). * When `index` is provided, inserts at that position; otherwise appends. * Returns the new root (connected components are notified automatically). */ insertNode(parentKey: string | undefined, node: TreeNode, index?: number): TreeNode; /** * Subscribe to model events. Returns an unsubscribe function. * Components call this when the `model` property is set, and unsubscribe when it is unset. * * @internal */ _subscribe(callback: ModelSubscriber): () => void; } type TreeDndMode = `none` | `internal` | `external` | `both`; type TreeDropPosition = `before` | `after` | `inside`; interface TreeDropTarget { readonly parentKey: string | undefined; readonly index: number; readonly referenceKey: string; readonly position: TreeDropPosition; readonly depth: number; } interface TreeDragContext { readonly nodes: readonly TreeNode[]; readonly keys: readonly string[]; } /** * The structural subset of {@link TreeDropContext} needed to apply a drop to a * tree root. Passed to `applyTreeDrop()` / `TreeDataModel.applyDrop()`. */ interface TreeDropApplyContext { readonly source: `internal` | `external`; /** * For `internal` drops this is advisory — the nodes are re-resolved from the * live root by `draggedKeys`. For `external` drops it is the payload to insert. */ readonly dragged?: readonly TreeNode[]; readonly draggedKeys: readonly string[]; readonly target: TreeDropTarget; } interface TreeDropContext extends TreeDropApplyContext { readonly dataTransfer: DataTransfer | null; } interface TreeDropDetail extends TreeDropContext { readonly external?: readonly TreeNode[]; } type TreeDragStartEvent = CustomEvent; type TreeDragOverEvent = CustomEvent; type TreeDropEvent = CustomEvent; type TreeDragEndEvent = CustomEvent<{ dropped: boolean; }>; /** How `navigateTo` scrolls its target: edge-align it, or centre it when it is off screen. */ type TreeRevealMode = `edge` | `center-if-hidden`; type TreeNavigateOptions = { /** Scroll behaviour for the target (default `edge`). */ reveal?: TreeRevealMode; /** Suppress the `select` event this navigation would otherwise fire. */ silent?: boolean; /** * Whether to animate row enter/leave for this operation. * When omitted, uses the `animation` property value (`'auto'` by default). */ animate?: boolean; }; /** * Fired when the selection set changes by any means (click, keyboard, programmatic). * Event name: `select` */ type TreeSelectDetail = { /** The new selection set. */ readonly selected: ReadonlySet; /** The previous selection set (empty set if there was no prior selection). */ readonly previous: ReadonlySet; /** * What caused the change: `programmatic` for `navigateTo` and friends, `user` * otherwise. Absent on components that do not distinguish the two. */ readonly origin?: `user` | `programmatic`; }; /** * Fired when an item enters cursor focus — either the pointer hovers over it, or * the keyboard navigation cursor moves to it. * Event name: `tickle` */ type TreeTickleDetail = { readonly node: TreeNode; readonly depth: number; }; /** * Fired when the user explicitly activates an item (Enter key or double-click). * Event name: `activate` */ type TreeActivateDetail = { readonly node: TreeNode; readonly depth: number; }; /** * Fired when the user clicks an item (raw pointer event, before any selection change). * Event name: `item-click` */ type TreeItemClickDetail = { readonly node: TreeNode; readonly depth: number; }; /** * Fired when the user double-clicks an item. The second click of the pair is * swallowed, so a branch is never toggled open/closed by a double-click. * Event name: `item-dblclick` */ type TreeItemDblClickDetail = { readonly node: TreeNode; readonly depth: number; }; /** * Fired when a node or column is expanded. * Event name: `expand` */ type TreeExpandDetail = { readonly node: TreeNode; readonly depth: number; }; /** * Fired when a node or column is collapsed. * Event name: `collapse` */ type TreeCollapseDetail = { readonly node: TreeNode; readonly depth: number; }; type TreeSelectEvent = CustomEvent; type TreeTickleEvent = CustomEvent; type TreeActivateEvent = CustomEvent; type TreeItemClickEvent = CustomEvent; type TreeItemDblClickEvent = CustomEvent; type TreeExpandEvent = CustomEvent; type TreeCollapseEvent = CustomEvent; interface TreeComponentEventMap { 'select': TreeSelectEvent; 'tickle': TreeTickleEvent; 'activate': TreeActivateEvent; 'item-click': TreeItemClickEvent; 'expand': TreeExpandEvent; 'collapse': TreeCollapseEvent; 'list-native-drag-start': CustomEvent>; 'tree-drag-start': TreeDragStartEvent; 'tree-drag-over': TreeDragOverEvent; 'tree-drop': TreeDropEvent; 'tree-drag-end': TreeDragEndEvent; } /** Options for `selectAll()` / `deselectAll()`. */ type TreeSelectAllOptions = { /** Only act on rows that are showing (e.g. Ctrl+A), not those in collapsed branches. */ readonly visibleOnly?: boolean; }; /** * The common interface all tree-like components must implement. * * Use this interface when writing controllers or utilities that should work * across different tree component implementations. * * @example Writing a controller that works with any tree component: * ```typescript * function attachMyController(component: TreeComponent) { * component.addEventListener('select', e => console.log(e.detail.selected)); * } * ``` */ /** * Every tree component supports view-state snapshot / restore * (`getViewState` / `setViewState` / `clearPendingViewState`, see * `docs/infra-view-state.md`). Each narrows the state type with its own fields. */ interface TreeComponent extends EventTarget, ViewStateful { /** * Root node of the tree. * Set this directly for static/fully-known trees. * Use `model` for lazy-loaded or programmatically mutated trees. */ root: TreeNode | undefined; /** * Optional data model providing lazy loading, caching, and mutation helpers. * When set, the component uses `model.getChildren()` instead of `loadChildren`, * and re-renders when the model notifies of root or invalidation changes. * `model` takes precedence over `loadChildren` when both are set. */ model: TreeDataModel | undefined; /** * Callback for lazily loading children of a node. * Superseded by `model` when both are set. * Kept for backwards compatibility and simple use-cases. */ loadChildren: LoadChildrenCallback | undefined; /** * The primary/most-recently selected node, or `undefined` if nothing is selected. * In multi-selection modes (e.g. `interactionMode='standard'` with Ctrl+click) this is the most recently added node. */ selectedNode: TreeNode | undefined; /** * The full selection set. Always in sync with `selectedNode`. * Empty set when nothing is selected. */ readonly selectedNodes: ReadonlySet; /** * Restricts which kinds of nodes may be selected. Applied as a guard in all interaction modes. * Reflected as the `selection-filter` attribute. * @default 'leaf' */ selectionFilter: TreeSelectionFilter; /** * Predicate used by search/filter controllers. * When set, nodes for which the predicate returns `false` (and which have no * matching descendants) are hidden from the rendered output. */ filterPredicate: TreeFilterPredicate | undefined; /** * Controls how expanding one node affects other expanded nodes. * Reflected as the `exclusivity` attribute. * @default 'none' */ exclusivity: TreeExclusivity; /** Select `node`, replacing any current selection. Respects `selectionFilter` — no-op if the node is not selectable. */ select: (node: TreeNode) => void; /** Remove `node` from the selection. */ deselect: (node: TreeNode) => void; /** Clear the entire selection. */ clearSelection: () => void; /** * Select every selectable item — in tree components, including those inside * collapsed branches (only filter matches while a filter is active). Pass * `{ visibleOnly: true }` to limit it to the items showing. */ selectAll: (options?: TreeSelectAllOptions) => void; /** Mirror of `selectAll`: deselect the items it would select. */ deselectAll: (options?: TreeSelectAllOptions) => void; /** * Expand ancestors and select the node reached by following `keys` from the root's children. * Returns `true` if the path was found and applied. */ navigateTo: (keys: readonly string[], options?: TreeNavigateOptions) => boolean; /** * Expand ancestors and select the first node for which `predicate` returns `true`. * Returns `true` if a matching node was found. * @param predicate - Function to find the target node * @param animate - Whether to animate row enter/leave. When omitted, uses the `animation` property value. */ navigateToNode: (predicate: (node: TreeNode) => boolean, animate?: boolean) => boolean; /** * Expand ancestors of the node with `key` and move the keyboard cursor to it, * scrolling it into view — **without** changing the selection. Returns `true` * if the node was found. Used by incremental-search "navigate" mode. * @param key - Key of the node to reveal * @param animate - Whether to animate row enter/leave. When omitted, uses the `animation` property value. */ revealKey: (key: string, animate?: boolean) => boolean; /** Replace the selection with `nodes` (subject to `selectionFilter`). Used by incremental-search "select" mode. */ selectMany: (nodes: Iterable) => void; /** * Returns all nodes currently visible in the rendered output, in render order, * with their depth (0-based, root's children are depth 0). */ getNodes: () => ReadonlyArray<{ node: TreeNode; depth: number; }>; } /** * Extended interface used by search/filter controllers. * Both TreeBaseElement and MillerBaseElement implement this. * * Replaces the previous separate `TreeSearchHost` / `MillerSearchHost` types * in `searchable.ts`. The unified `filterPredicate` signature (with `depth`) * allows a single search controller implementation to work with all tree components. */ interface TreeSearchHost extends TreeComponent { readonly shadowRoot: ShadowRoot | null; readonly updateComplete: Promise; } export { TreeTickleDetail as A, ListDragSource as B, TreeItemDblClickEvent as C, TreeSelectAllOptions as D, TreeSearchHost as E, ListDragEntry as F, ListNativeDragStartEvent as H, ListDragPreview as I, ListDragPreviewContext as L, TreeDataModel as M, TreeDataModelOptions as N, TreeSelectDetail as O, ListDragDataTransferWriter as P, ListDragPreviewRenderer as R, TreeItemDblClickDetail as S, TreeRevealMode as T, ListNativeDragStartDetail as V, TreeDropTarget as _, TreeComponent as a, TreeItemClickDetail as b, TreeDragContext as c, TreeDragStartEvent as d, TreeDropApplyContext as f, TreeDropPosition as g, TreeDropEvent as h, TreeCollapseEvent as i, TreeTickleEvent as j, TreeSelectEvent as k, TreeDragEndEvent as l, TreeDropDetail as m, TreeActivateEvent as n, TreeComponentEventMap as o, TreeDropContext as p, TreeCollapseDetail as r, TreeDndMode as s, TreeActivateDetail as t, TreeDragOverEvent as u, TreeExpandDetail as v, TreeNavigateOptions as w, TreeItemClickEvent as x, TreeExpandEvent as y, ListDragPreviewSourceResolver as z };