import { Annotation, PropertyName } from '../types'; /** * [Hierarchy Vocabulary](https://github.com/SAP/odata-vocabularies/blob/master/vocabularies/Hierarchy.md) */ export interface RecursiveHierarchyType extends Annotation { parentNodeProperty: PropertyName; /** * TODO 意思应该是指被子节点`parentNodeProperty`引用的唯一键字段 */ externalKeyProperty?: PropertyName; valueProperty: PropertyName; labelProperty?: PropertyName; levelProperty?: PropertyName; /** * Property holding the number of descendants of a node * The descendant count of a node is the number of its descendants in the hierarchy structure of the result considering * only those nodes matching any specified $filter and $search. A property holding descendant counts has an integer data type. */ descendantCountProperty?: PropertyName; /** * Property holding the drill state of a node * The drill state is indicated by one of the following string values: collapsed, expanded, leaf. * For an expanded node, its children are included in the result collection. For a collapsed node, * the children are included in the entity set, but they are not part of the result collection. * Retrieving them requires a relaxed filter expression or a separate request filtering on the parent node ID with the ID of * the collapsed node. * A leaf does not have any child in the entity set. */ drillStateProperty?: PropertyName; /** * Property holding the sibling rank of a node * The sibling rank of a node is the index of the node in the sequence of all nodes with the same parent created by preorder traversal of * the hierarchy structure after evaluating the $filter expression in the request excluding any conditions on key properties. * The first sibling is at position 0. */ siblingRankProperty?: PropertyName; /** * Property holding the preorder rank of a node * The preorder rank of a node expresses its position in the sequence of nodes created from preorder traversal of * the hierarchy structure after evaluating the $filter expression in the request excluding any conditions on key properties. * The first node in preorder traversal has rank 0. */ preorderRankProperty?: PropertyName; memberTypeProperty?: PropertyName; } /** * RecursiveHierarchy 类型的数据与 RecursiveHierarchy Annotation 绑定一起的类型 */ export interface RecursiveHierarchyData { data: Array>; recursiveHierarchy: RecursiveHierarchyType; } export interface TreeNodeInterface { /** * The memebr key (id) for tree node */ key: string; /** * The member label for tree node */ caption: string; /** * @deprecated use `caption` * caption */ label?: string; /** * @deprecated use `caption` */ name?: string; /** * @deprecated use `caption` */ title?: string; raw: T; value?: number; level?: number; expand?: boolean; children?: TreeNodeInterface[]; parent?: TreeNodeInterface; isLeaf?: boolean; } /** * Flat node type for tree structure */ export interface FlatTreeNode { key: string; caption: string; /** * @deprecated use `caption` */ name?: string; /** * @deprecated use `caption` */ label?: string; value?: number; level: number; expandable?: boolean; childrenCardinality?: number; raw?: T; } export declare function hierarchize(items: Array, recursiveHierarchy: RecursiveHierarchyType, options?: { compositeKeys?: string[]; valueProperty?: string; startLevel?: number; onlyLeaves?: boolean; memberCaption?: string; }): Array>; /** * Filters a tree-structured array based on a given text query. * * ### Matching logic * - If the keyword contains `*`, wildcard mode is automatically enabled: * - `st*` → matches strings starting with "st" * - `*st` → matches strings ending with "st" * - `*st*` → matches strings containing "st" * - If there is **no `*`**, performs normal case-insensitive substring matching. * - Supports multiple space-separated keywords (logical OR). * - Trims extra spaces automatically. * * @template T The type of the node data. * @param array The tree-structured array. * @param text The filter text. Supports multiple keywords and optional * wildcard. * @param options Additional options: * - `considerKey`: Whether to also match against the node's `key`. * @returns A filtered tree array containing only nodes that match the query. */ export declare function filterTreeNodes(array: TreeNodeInterface[], text: string, options?: { considerKey?: boolean; }): TreeNodeInterface[]; export declare function findTreeNode(array: TreeNodeInterface[], key: string): TreeNodeInterface;