import { type PropertyValues, type TemplateResult } from "lit"; import { OrElement } from "@openremote/or-element"; import type { OrTreeNode } from "./or-tree-node"; import type { OrTreeGroup } from "./or-tree-group"; import { TreeMenuSelection, TreeMenuSorting, type TreeNode } from "./model"; import "@openremote/or-translate"; import "./or-tree-group"; import "./or-tree-node"; export * from "./or-tree-group"; export * from "./or-tree-node"; export * from "./model"; /** * A component for displaying a hierarchical, tree-like structure of elements. * Common use cases are visualizing parent-child relationships, or for grouping elements together. * * @event {OrTreeSelectEvent} or-tree-select - Triggers upon selecting a node, and dispatches a list of the nodes selected. * @event {OrTreeDragEvent} or-tree-drag - Triggers upon dragging a node to a new group, and dispatches a list of dragged nodes, the group node, and the updated list of all nodes. */ export declare class OrTreeMenu extends OrElement { /** * List of node items in the menu. * Uses the TreeNode format for rendering the OrTreeNode elements. */ nodes: TreeNode[]; /** * Changes the allowed selection method within the tree. * Common options are `LEAF`, `SINGLE` and `MULTI`. */ selection: TreeMenuSelection; /** * Disables and enables dragging of nodes into groups. */ draggable: boolean; /** * Removes the header from the tree menu. */ noHeader: boolean; /** * Adjusts the title in the menu header. */ menuTitle: string; /** * List of options available to sort the object with */ sortOptions?: TreeMenuSorting[]; /** * Represents the selected sorting option */ sortBy: TreeMenuSorting; /** * Automatically prioritizes the groups, and positions these on top. */ groupFirst: boolean; protected _uiNodes?: NodeListOf; protected _uiGroups?: NodeListOf; protected _treeNodeCache: Map; protected _lastSelectedNode?: OrTreeNode; static get styles(): import("lit").CSSResult[]; protected willUpdate(changedProps: PropertyValues): void; render(): TemplateResult; /** * Function that moves an array of {@link TreeNode} into another {@link TreeNode}, by adding them to their children. * The function takes care of removing the nodes from the former group, and makes sure no duplicates end up in the list. * * @param nodesToMove - The array of nodes that are moved into a group. * @param groupNode - The group node to insert nodesToMove in. */ moveNodesToGroup(nodesToMove: TreeNode[], groupNode?: TreeNode): void; /** * Returns a HTML template that displays the tree menu. * @param nodes - List of nodes to be rendered */ protected _getTreeTemplate(nodes: TreeNode[]): TemplateResult; /** * Returns an HTML template for displaying a single node within a tree menu. This can both be a group or a solo node. * @param node - Node to be rendered * @param parent - Optional parent (group node) if the node is placed inside a group */ protected _getNodeTemplate(node: TreeNode, parent?: TreeNode): TemplateResult; /** * Returns an HTML template for displaying a single node * @param node - Node to be rendered * @param parent - Optional parent (group node) if the node is placed inside a group */ protected _getSingleNodeTemplate(node: TreeNode, parent?: TreeNode): TemplateResult; /** * Returns an HTML template for the slot element inside . * It allows customization such as a prefix icon, adjusting the label, etc. * @param node - Node to be rendered */ protected _getSingleNodeSlotTemplate(node: TreeNode): TemplateResult; /** * Returns a HTML template for rendering a group node (aka a node with children) * @param node - Node to be rendered * @param _parent - Optional parent (group node) if the node is placed inside a group */ protected _getGroupNodeTemplate(node: TreeNode, _parent?: TreeNode): TemplateResult; /** * Returns an HTML template for the parent slot element inside . * It allows customization such as a prefix icon, adjusting the label, etc. * @param node - Node to be rendered */ protected _getGroupNodeSlotTemplate(node: TreeNode): TemplateResult; /** * Returns a HTML template for the header */ protected _getHeaderTemplate(): TemplateResult; /** * Returns a HTML template for the sorting options menu. * @param value - The selected sorting option * @param options - The available sorting options */ protected _getSortActionTemplate(value?: string, options?: TreeMenuSorting[]): TemplateResult; /** * Returns a HTML template for displaying errors */ protected _getErrorTemplate(): TemplateResult; /** * HTML callback event for selecting a sort option in the dropdown menu,. * @param value - The new selected sort option */ protected _onSortClick(value: string): void; /** * HTML callback event for clicking on a group node. (aka a node with children) * Based on the configured TreeMenuSelection, it single- or multi selects the nodes. */ protected _onTreeGroupClick(ev: PointerEvent): void; /** HTML callback event for when a child node of the tree gets clicked on. */ protected _onTreeNodeClick(ev: PointerEvent): void; /** HTML callback event for 'dragstart' (the moment when a drag gesture is started) */ protected _onDragStart(ev: DragEvent, node: TreeNode): void; /** HTML callback event for 'dragover' on the list element */ protected _onDragOverList(ev: DragEvent): void; /** HTML callback event for 'dragover', so while a node is dragged over a single node */ protected _onDragOverSingleNode(ev: DragEvent, node: TreeNode, parent?: TreeNode): void; /** HTML callback event for 'dragover', so while a node is dragged over a group node */ protected _onDragOverGroup(ev: DragEvent, groupNode: TreeNode): void; /** HTML callback event for 'dragover', so while a node is dragged over a single node */ protected _onDragLeaveSingleNode(ev: DragEvent, node: TreeNode, parent?: TreeNode): void; /** HTML callback event for 'dragleave', so after a node has been dragged over a group node */ protected _onDragLeaveGroup(ev: DragEvent, groupNode: TreeNode): void; /** HTML callback event for when a node is dropped on the list level. */ protected _onDragDropList(ev: DragEvent): void; /** HTML callback event for when a node is dropped onto a single node, after dragging it over. */ protected _onDragDropSingleNode(ev: DragEvent, groupNode?: TreeNode, parent?: TreeNode): void; /** HTML callback event for when a node is dropped onto a group node, after dragging it over. */ protected _onDragDropGroup(ev: DragEvent, groupNode?: TreeNode): void; /** * Dispatches a cancelable tree drag event. */ protected _dispatchCancellableDragEvent(nodes: TreeNode[], groupNode?: TreeNode, allNodes?: TreeNode[]): Promise; /** * Selects the node using the HTML attribute 'selected' of OrTreeNode * @param node - Node to be selected * @param notify - Boolean whether to notify the HTML parents of an or-tree-select. */ protected _selectNode(node?: OrTreeNode, notify?: boolean): void; /** * Multi-selects the nodes between two indexes in a list of OrTreeNode. * @param nodes - List of nodes in the tree menu * @param index1 - Start index of the nodes to select * @param index2 - End index of the nodes to select * @param notify - Boolean whether to notify the HTML parents of an or-tree-select. */ protected _selectNodesBetween(nodes: OrTreeNode[], index1: number, index2: number, notify?: boolean): void; /** * Function that notifies parent HTMLElements that a tree node got selected. * It dispatches the OrTreeSelectEvent, which includes a list of the selected nodes. * @returns a 'success' boolean whether the event was canceled or not */ protected _notifyNodesSelect(selectedNodes?: TreeNode[]): Promise; /** * Utility function to detect the selected tree nodes. * @param uiNodes - List of UI elements * @param cache - Optionally, supply the cache for retrieving a {@link TreeNode} object from a element. */ protected _findSelectedTreeNodes(uiNodes?: OrTreeNode[], cache?: Map): TreeNode[]; /** * Utility function that gets a {@link TreeNode} based on an {@link OrTreeNode} HTML element in the menu. * @param uiNode - The tree node HTML element * @param cache - Optional cache to get the TreeNode from */ protected _getTreeNodeFromTree(uiNode: OrTreeNode, cache?: Map): TreeNode | undefined; /** * Utility function that gets an {@link OrTreeNode} HTML element based on the {@link TreeNode} input object. * @param treeNode - The tree node object * @param cache - Optional cache to get the HTML element from */ protected _getUiNodeFromTree(treeNode: TreeNode, cache?: Map): OrTreeNode | undefined; /** * Utility function for sending a "select" event, so consumers of this component are aware a new node has been selected. * @param selectedNodes - List of selected nodes to include in the event payload. * @returns a 'success' boolean whether the event was canceled or not. */ protected _dispatchSelectEvent(selectedNodes?: TreeNode[]): boolean; /** * Public function that deselects all tree nodes. */ deselectAllNodes(): void; /** * Utility function that sorts the list of {@link nodes} based on the given {@link sortBy} method. * @param nodes - List of nodes to be sorted * @param sortBy - Sorting option * @param groupFirst - Whether to prioritize group nodes, and place them on the top of the list. */ protected _sortNodes(nodes: TreeNode[], sortBy?: TreeMenuSorting, groupFirst?: boolean): TreeNode[]; /** * Function that caches a random ID into a key-value storage, linking the TreeNode with a generated ID. * This generated ID can be used somewhere else, for example in an HTMLElement ID as a unique identifier. * @param node - The TreeNode object to cache * @param randomId - Optionally you can supply an ID to use for caching */ protected _setTreeNodeId(node: TreeNode, randomId?: string): string; /** * Function for retrieving the sorting for TreeNodes based on a sortBy parameter. * The sortBy parameter represents a key in the TreeNode object like 'label'. * @param sortBy - Sorting option to use, such as "a_to_z" */ protected _getSortFunction(sortBy?: TreeMenuSorting): (a: TreeNode, b: TreeNode) => number; /** * Programmatically finds a group by its ID and sets it to be expanded. * This is called by the parent component after a new node is added to a tree group. * @param {string} groupId The ID of the group to expand. */ expandGroup(groupId: string): void; } //# sourceMappingURL=index.d.ts.map