@itwin/components-react 3.5.0-dev.8 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -1
- package/lib/cjs/components-react/UiComponents.d.ts +1 -1
- package/lib/cjs/components-react/UiComponents.js +2 -2
- package/lib/cjs/components-react/UiComponents.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts +2 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js +2 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js +2 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +1 -0
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -2
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/cjs/components-react/table/SimpleTableDataProvider.d.ts +1 -0
- package/lib/cjs/components-react/table/SimpleTableDataProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/table/SimpleTableDataProvider.js +2 -0
- package/lib/cjs/components-react/table/SimpleTableDataProvider.js.map +1 -1
- package/lib/cjs/components-react/table/TableDataProvider.d.ts +8 -0
- package/lib/cjs/components-react/table/TableDataProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/table/TableDataProvider.js +3 -0
- package/lib/cjs/components-react/table/TableDataProvider.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.d.ts +16 -0
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.js +7 -0
- package/lib/cjs/components-react/table/columnfiltering/ColumnFiltering.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/ColumnFilteringUtilities.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/ColumnFilteringUtilities.js +1 -0
- package/lib/cjs/components-react/table/columnfiltering/ColumnFilteringUtilities.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/FilterableColumnBase.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/FilterableColumnBase.js +1 -0
- package/lib/cjs/components-react/table/columnfiltering/FilterableColumnBase.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableColumnFilterDescriptor.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableColumnFilterDescriptor.js +1 -0
- package/lib/cjs/components-react/table/columnfiltering/TableColumnFilterDescriptor.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptor.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptor.js +1 -0
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptor.js.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptorCollection.d.ts.map +1 -1
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptorCollection.js +1 -0
- package/lib/cjs/components-react/table/columnfiltering/TableFilterDescriptorCollection.js.map +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.d.ts +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.js +1 -1
- package/lib/cjs/components-react/table/component/ColumnDragLayer.js.map +1 -1
- package/lib/cjs/components-react/table/component/Table.d.ts +16 -8
- package/lib/cjs/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/cjs/components-react/table/component/Table.js +4 -2
- package/lib/cjs/components-react/table/component/Table.js.map +1 -1
- package/lib/cjs/components-react/table/component/TableCell.d.ts +10 -4
- package/lib/cjs/components-react/table/component/TableCell.d.ts.map +1 -1
- package/lib/cjs/components-react/table/component/TableCell.js +5 -2
- package/lib/cjs/components-react/table/component/TableCell.js.map +1 -1
- package/lib/cjs/components-react/table/component/TableColumn.d.ts +2 -1
- package/lib/cjs/components-react/table/component/TableColumn.d.ts.map +1 -1
- package/lib/cjs/components-react/table/component/TableColumn.js.map +1 -1
- package/lib/cjs/components-react/toolbar/Items.d.ts.map +1 -1
- package/lib/cjs/components-react/toolbar/Items.js +1 -1
- package/lib/cjs/components-react/toolbar/Items.js.map +1 -1
- package/lib/cjs/components-react/tree/TreeDataProvider.d.ts +1 -0
- package/lib/cjs/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/TreeDataProvider.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js +17 -16
- package/lib/cjs/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeModel.d.ts +2 -0
- package/lib/cjs/components-react/tree/controlled/TreeModel.d.ts.map +1 -1
- package/lib/cjs/components-react/tree/controlled/TreeModel.js +1 -0
- package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/lib/esm/components-react/UiComponents.d.ts +1 -1
- package/lib/esm/components-react/UiComponents.js +2 -2
- package/lib/esm/components-react/UiComponents.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts +2 -0
- package/lib/esm/components-react/filter-builder/FilterBuilder.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilder.js +2 -2
- package/lib/esm/components-react/filter-builder/FilterBuilder.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js +2 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRule.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts +1 -0
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -2
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
- package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
- package/lib/esm/components-react/table/SimpleTableDataProvider.d.ts +1 -0
- package/lib/esm/components-react/table/SimpleTableDataProvider.d.ts.map +1 -1
- package/lib/esm/components-react/table/SimpleTableDataProvider.js +2 -0
- package/lib/esm/components-react/table/SimpleTableDataProvider.js.map +1 -1
- package/lib/esm/components-react/table/TableDataProvider.d.ts +8 -0
- package/lib/esm/components-react/table/TableDataProvider.d.ts.map +1 -1
- package/lib/esm/components-react/table/TableDataProvider.js +3 -0
- package/lib/esm/components-react/table/TableDataProvider.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.d.ts +16 -0
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.js +7 -0
- package/lib/esm/components-react/table/columnfiltering/ColumnFiltering.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/ColumnFilteringUtilities.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/ColumnFilteringUtilities.js +1 -0
- package/lib/esm/components-react/table/columnfiltering/ColumnFilteringUtilities.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/FilterableColumnBase.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/FilterableColumnBase.js +1 -0
- package/lib/esm/components-react/table/columnfiltering/FilterableColumnBase.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableColumnFilterDescriptor.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableColumnFilterDescriptor.js +1 -0
- package/lib/esm/components-react/table/columnfiltering/TableColumnFilterDescriptor.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptor.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptor.js +1 -0
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptor.js.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptorCollection.d.ts.map +1 -1
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptorCollection.js +1 -0
- package/lib/esm/components-react/table/columnfiltering/TableFilterDescriptorCollection.js.map +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.d.ts +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.js +1 -1
- package/lib/esm/components-react/table/component/ColumnDragLayer.js.map +1 -1
- package/lib/esm/components-react/table/component/Table.d.ts +16 -8
- package/lib/esm/components-react/table/component/Table.d.ts.map +1 -1
- package/lib/esm/components-react/table/component/Table.js +4 -2
- package/lib/esm/components-react/table/component/Table.js.map +1 -1
- package/lib/esm/components-react/table/component/TableCell.d.ts +10 -4
- package/lib/esm/components-react/table/component/TableCell.d.ts.map +1 -1
- package/lib/esm/components-react/table/component/TableCell.js +5 -2
- package/lib/esm/components-react/table/component/TableCell.js.map +1 -1
- package/lib/esm/components-react/table/component/TableColumn.d.ts +2 -1
- package/lib/esm/components-react/table/component/TableColumn.d.ts.map +1 -1
- package/lib/esm/components-react/table/component/TableColumn.js.map +1 -1
- package/lib/esm/components-react/toolbar/Items.d.ts.map +1 -1
- package/lib/esm/components-react/toolbar/Items.js +2 -2
- package/lib/esm/components-react/toolbar/Items.js.map +1 -1
- package/lib/esm/components-react/tree/TreeDataProvider.d.ts +1 -0
- package/lib/esm/components-react/tree/TreeDataProvider.d.ts.map +1 -1
- package/lib/esm/components-react/tree/TreeDataProvider.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js +17 -16
- package/lib/esm/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeModel.d.ts +2 -0
- package/lib/esm/components-react/tree/controlled/TreeModel.d.ts.map +1 -1
- package/lib/esm/components-react/tree/controlled/TreeModel.js +1 -0
- package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeModel.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAe,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAuHhE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAkC;IAChE,OAAO,GAAG,KAAK,SAAS,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAkC;IAC3E,OAAO,GAAG,KAAK,SAAS,IAAI,YAAY,IAAI,GAAG,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAkC;IACpE,OAAO,GAAG,KAAK,SAAS,IAAK,GAAyB,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC;AACpG,CAAC;AAqCD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAM3B,YAAmB,IAAgB;QAL5B,QAAW,GAAG,IAAI,CAAC;QAElB,UAAK,GAAG,IAAI,UAAU,EA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------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tree\r\n */\r\n\r\nimport { immerable } from \"immer\";\r\nimport _ from \"lodash\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { CheckBoxState } from \"@itwin/core-react\";\r\nimport { DelayLoadedTreeNodeItem, ImmediatelyLoadedTreeNodeItem, TreeNodeItem } from \"../TreeDataProvider\";\r\nimport { SparseArray, SparseTree } from \"./internal/SparseTree\";\r\n\r\n/**\r\n * Immutable data structure that describes tree node.\r\n * @public\r\n */\r\nexport interface TreeModelNode {\r\n readonly id: string;\r\n readonly parentId: string | undefined;\r\n readonly depth: number;\r\n\r\n readonly isLoading?: boolean;\r\n readonly numChildren: number | undefined;\r\n\r\n readonly description: string | undefined;\r\n readonly isExpanded: boolean;\r\n readonly label: PropertyRecord;\r\n readonly isSelected: boolean;\r\n\r\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\r\n readonly editingInfo?: TreeModelNodeEditingInfo;\r\n\r\n readonly checkbox: CheckBoxInfo;\r\n\r\n readonly item: TreeNodeItem;\r\n}\r\n\r\n/**\r\n * Immutable data structure that describes checkbox info.\r\n * @public\r\n */\r\nexport interface CheckBoxInfo {\r\n readonly state: CheckBoxState;\r\n readonly tooltip?: string;\r\n readonly isDisabled: boolean;\r\n readonly isVisible: boolean;\r\n}\r\n\r\n/**\r\n * Mutable data structure that describes tree node.\r\n * @public\r\n */\r\nexport interface MutableTreeModelNode extends TreeModelNode {\r\n isLoading: boolean;\r\n\r\n description: string;\r\n isExpanded: boolean;\r\n label: PropertyRecord;\r\n isSelected: boolean;\r\n\r\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\r\n editingInfo?: TreeModelNodeEditingInfo;\r\n\r\n checkbox: MutableCheckBoxInfo;\r\n\r\n item: TreeNodeItem;\r\n}\r\n\r\n/**\r\n * Data structure that holds callbacks used for tree node editing.\r\n * @public\r\n */\r\nexport interface TreeModelNodeEditingInfo {\r\n onCommit: (node: TreeModelNode, newValue: string) => void;\r\n onCancel: () => void;\r\n}\r\n\r\n/**\r\n * Mutable data structure that describes checkbox info.\r\n * @public\r\n */\r\nexport interface MutableCheckBoxInfo extends CheckBoxInfo {\r\n state: CheckBoxState;\r\n tooltip?: string;\r\n isDisabled: boolean;\r\n isVisible: boolean;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree node placeholder.\r\n * @public\r\n */\r\nexport interface TreeModelNodePlaceholder {\r\n readonly childIndex: number;\r\n readonly depth: number;\r\n readonly parentId?: string;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree root node.\r\n * @public\r\n */\r\nexport interface TreeModelRootNode {\r\n readonly depth: -1;\r\n readonly id: undefined;\r\n readonly numChildren: number | undefined;\r\n}\r\n\r\n/**\r\n * Data structure that describes input used to create tree node.\r\n * @public\r\n */\r\nexport interface TreeModelNodeInput {\r\n readonly description?: string;\r\n readonly isExpanded: boolean;\r\n readonly id: string;\r\n readonly item: TreeNodeItem;\r\n readonly label: PropertyRecord;\r\n readonly isLoading: boolean;\r\n readonly numChildren?: number;\r\n readonly isSelected: boolean;\r\n}\r\n\r\n/**\r\n * Type definition of all tree model nodes.\r\n * @public\r\n */\r\nexport type TreeModelNodeType = TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode;\r\n\r\n/**\r\n * Checks if object is [[TreeModelNode]]\r\n * @public\r\n */\r\nexport function isTreeModelNode(obj: TreeModelNodeType | undefined): obj is TreeModelNode {\r\n return obj !== undefined && !isTreeModelNodePlaceholder(obj) && !isTreeModelRootNode(obj);\r\n}\r\n\r\n/**\r\n * Checks if object is [[TreeModelNodePlaceholder]]\r\n * @public\r\n */\r\nexport function isTreeModelNodePlaceholder(obj: TreeModelNodeType | undefined): obj is TreeModelNodePlaceholder {\r\n return obj !== undefined && \"childIndex\" in obj;\r\n}\r\n\r\n/**\r\n * Checks if object is [[TreeModelRootNode]]\r\n * @public\r\n */\r\nexport function isTreeModelRootNode(obj: TreeModelNodeType | undefined): obj is TreeModelRootNode {\r\n return obj !== undefined && (obj as TreeModelRootNode).id === undefined && !(\"childIndex\" in obj);\r\n}\r\n\r\n/**\r\n * Type definition of tree node item data.\r\n * @public\r\n */\r\nexport type TreeNodeItemData = ImmediatelyLoadedTreeNodeItem & DelayLoadedTreeNodeItem;\r\n\r\n/**\r\n * Data structure that describes set of visible tree nodes as a flat list.\r\n * @public\r\n */\r\nexport interface VisibleTreeNodes extends Iterable<TreeModelNode | TreeModelNodePlaceholder> {\r\n getNumNodes(): number;\r\n getAtIndex(index: number): TreeModelNode | TreeModelNodePlaceholder | undefined;\r\n getModel(): TreeModel;\r\n getNumRootNodes(): number | undefined;\r\n getIndexOfNode(nodeId: string): number;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree model.\r\n * @public\r\n */\r\nexport interface TreeModel {\r\n getRootNode(): TreeModelRootNode;\r\n\r\n getNode(id: string): TreeModelNode | undefined;\r\n getNode(parentId: string | undefined, childIndex: number): TreeModelNode | TreeModelNodePlaceholder | undefined;\r\n getNode(nodeId: string | undefined, childIndex?: number): TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode | undefined;\r\n\r\n getChildren(parentId: string | undefined): SparseArray<string> | undefined;\r\n getChildOffset(parentId: string | undefined, childId: string): number | undefined;\r\n\r\n iterateTreeModelNodes(parentId?: string): IterableIterator<TreeModelNode>;\r\n}\r\n\r\n/**\r\n * Mutable tree model which holds nodes and allows adding or removing them.\r\n * @public\r\n */\r\nexport class MutableTreeModel implements TreeModel {\r\n public [immerable] = true;\r\n\r\n private _tree = new SparseTree<MutableTreeModelNode>();\r\n private _rootNode: TreeModelRootNode = { depth: -1, id: undefined, numChildren: undefined };\r\n\r\n public constructor(seed?: TreeModel) {\r\n if (!seed) {\r\n return;\r\n }\r\n\r\n cloneSubree(seed, this, undefined);\r\n }\r\n\r\n /** Returns root node of a tree. This node is not visible and is there to allow having multiple visible root nodes. */\r\n public getRootNode(): TreeModelRootNode {\r\n return this._rootNode;\r\n }\r\n\r\n /** Returns tree node or placeholder for node that is not loaded yet.\r\n * @returns node, node placeholder or undefined if node is not found in model.\r\n */\r\n public getNode(id: string): MutableTreeModelNode | undefined;\r\n public getNode(parentId: string | undefined, childIndex: number): MutableTreeModelNode | TreeModelNodePlaceholder | undefined;\r\n public getNode(nodeId: string | undefined, childIndex?: number): MutableTreeModelNode | TreeModelNodePlaceholder | undefined {\r\n if (childIndex === undefined) {\r\n return this._tree.getNode(nodeId!);\r\n }\r\n\r\n const children = this._tree.getChildren(nodeId);\r\n const childId = children !== undefined ? children.get(childIndex) : undefined;\r\n if (childId !== undefined) {\r\n return this._tree.getNode(childId);\r\n }\r\n\r\n const parentNode = nodeId === undefined ? this._rootNode : this._tree.getNode(nodeId);\r\n if (parentNode !== undefined) {\r\n return {\r\n childIndex,\r\n depth: parentNode.depth + 1,\r\n parentId: nodeId,\r\n };\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Returns children for specific parent.\r\n * @param parentId id of parent node.\r\n * @returns children of parent node or root nodes if undefined is passed as parent id.\r\n */\r\n public getChildren(parentId: string | undefined): SparseArray<string> | undefined {\r\n return this._tree.getChildren(parentId);\r\n }\r\n\r\n /** Returns children offset in children array for specific parent. */\r\n public getChildOffset(parentId: string | undefined, childId: string): number | undefined {\r\n return this._tree.getChildOffset(parentId, childId);\r\n }\r\n\r\n /**\r\n * Sets children for parent node starting from the specific offset.\r\n * If offset overlaps with already added nodes, the overlapping nodes are overwritten.\r\n */\r\n public setChildren(parentId: string | undefined, nodeInputs: TreeModelNodeInput[], offset: number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined)\r\n return;\r\n\r\n const children: MutableTreeModelNode[] = [];\r\n for (const input of nodeInputs) {\r\n const child = MutableTreeModel.createTreeModelNode(parentNode, input);\r\n children.push(child);\r\n }\r\n\r\n this._tree.setChildren(parentNode.id, children, offset);\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /**\r\n * Inserts child in the specified position.\r\n * If offset is higher then current length of children array, the length is increased.\r\n */\r\n public insertChild(parentId: string | undefined, childNodeInput: TreeModelNodeInput, offset: number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined)\r\n return;\r\n\r\n const child = MutableTreeModel.createTreeModelNode(parentNode, childNodeInput);\r\n\r\n this._tree.insertChild(parentNode.id, child, offset);\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /**\r\n * Changes the id of target node.\r\n * @returns `true` on success, `false` otherwise.\r\n */\r\n public changeNodeId(currentId: string, newId: string): boolean {\r\n const node = this.getNode(currentId);\r\n if (node === undefined) {\r\n return false;\r\n }\r\n\r\n if (currentId === newId) {\r\n return true;\r\n }\r\n\r\n const index = this.getChildOffset(node.parentId, currentId);\r\n assert(index !== undefined);\r\n\r\n if (!this._tree.setNodeId(node.parentId, index, newId)) {\r\n return false;\r\n }\r\n\r\n (node.id as string) = newId; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion\r\n for (const [childId] of this.getChildren(newId)?.iterateValues() ?? []) {\r\n const child = this.getNode(childId);\r\n assert(child !== undefined);\r\n (child.parentId as string) = newId;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Transfers node along with its children to a new location. Fails if destination has undefined child count.\r\n * @param sourceNodeId Node that is being moved.\r\n * @param targetParentId Node that will receive a new child.\r\n * @param targetIndex Insertion location among target's *current* children.\r\n * @returns `true` on success, `false` otherwise.\r\n */\r\n public moveNode(sourceNodeId: string, targetParentId: string | undefined, targetIndex: number): boolean {\r\n const sourceNode = this.getNode(sourceNodeId);\r\n if (sourceNode === undefined) {\r\n return false;\r\n }\r\n\r\n const targetParent = targetParentId === undefined ? this._rootNode : this.getNode(targetParentId);\r\n if (targetParent === undefined || targetParent.numChildren === undefined) {\r\n return false;\r\n }\r\n\r\n if (targetParentId !== undefined && this.areNodesRelated(sourceNodeId, targetParentId)) {\r\n return false;\r\n }\r\n\r\n this._tree.moveNode(sourceNode.parentId, sourceNodeId, targetParentId, targetIndex);\r\n\r\n const sourceParent = sourceNode.parentId === undefined ? this._rootNode : this.getNode(sourceNode.parentId);\r\n assert(sourceParent !== undefined);\r\n MutableTreeModel.setNumChildrenForNode(sourceParent, this._tree.getChildren(sourceNode.parentId));\r\n MutableTreeModel.setNumChildrenForNode(targetParent, this._tree.getChildren(targetParentId));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (sourceNode.parentId as string | undefined) = targetParentId;\r\n\r\n const updateDepths = (parentId: string, depth: number) => {\r\n const node = this.getNode(parentId);\r\n assert(node !== undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (node.depth as number) = depth;\r\n for (const [nodeId] of this.getChildren(parentId)?.iterateValues() ?? []) {\r\n updateDepths(nodeId, depth + 1);\r\n }\r\n };\r\n\r\n updateDepths(sourceNodeId, targetParent.depth + 1);\r\n return true;\r\n }\r\n\r\n private areNodesRelated(ancestorNodeId: string, descendantNodeId: string): boolean {\r\n const node = this.getNode(descendantNodeId);\r\n if (node === undefined || node.parentId === undefined) {\r\n return false;\r\n }\r\n\r\n return node.parentId === ancestorNodeId ? true : this.areNodesRelated(ancestorNodeId, node.parentId);\r\n }\r\n\r\n /**\r\n * Sets the number of child nodes a parent is expected to contain. All child nodes of this parent will be subsequently\r\n * removed.\r\n */\r\n public setNumChildren(parentId: string | undefined, numChildren: number | undefined): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined) {\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (parentNode.numChildren as number | undefined) = numChildren;\r\n this._tree.setNumChildren(parentId, numChildren ?? 0);\r\n }\r\n\r\n /** Removes children specified by id.\r\n * @param parentId id of the parent node.\r\n * @param child child node id or index that should be removed.\r\n */\r\n public removeChild(parentId: string | undefined, child: string | number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n this._tree.removeChild(parentId, child);\r\n\r\n // istanbul ignore else\r\n if (parentNode)\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /** Removes all children for parent specified by id.\r\n * @param parentId id of parent node or undefined to remove root nodes.\r\n */\r\n public clearChildren(parentId: string | undefined) {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode !== undefined) {\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (parentNode.numChildren as number | undefined) = undefined;\r\n }\r\n this._tree.deleteSubtree(parentId, false);\r\n }\r\n\r\n /** Iterates over all nodes present in the tree model. */\r\n public * iterateTreeModelNodes(parentId?: string): IterableIterator<MutableTreeModelNode> {\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const _this = this;\r\n function* iterateDescendants(subParentId: string | undefined): IterableIterator<MutableTreeModelNode> {\r\n const children = _this.getChildren(subParentId);\r\n if (children === undefined) {\r\n return;\r\n }\r\n\r\n for (const [nodeId] of children.iterateValues()) {\r\n const node = _this.getNode(nodeId);\r\n if (node !== undefined) {\r\n yield node;\r\n yield* iterateDescendants(nodeId);\r\n }\r\n }\r\n }\r\n\r\n yield* iterateDescendants(parentId);\r\n }\r\n\r\n private static setNumChildrenForNode(node: TreeModelRootNode | MutableTreeModelNode, children: SparseArray<string> | undefined) {\r\n const numChildren = children ? children.getLength() : undefined;\r\n if (node.numChildren === numChildren)\r\n return;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (node.numChildren as number | undefined) = numChildren;\r\n }\r\n\r\n private static createTreeModelNode(parentNode: TreeModelNode | TreeModelRootNode, input: TreeModelNodeInput): MutableTreeModelNode {\r\n return {\r\n id: input.id,\r\n parentId: parentNode.id,\r\n depth: parentNode.depth + 1,\r\n\r\n isLoading: input.isLoading,\r\n numChildren: input.numChildren,\r\n\r\n description: input.description || \"\",\r\n isExpanded: input.isExpanded,\r\n label: input.label,\r\n isSelected: input.isSelected,\r\n\r\n checkbox: {\r\n state: input.item.checkBoxState || CheckBoxState.Off,\r\n isDisabled: !!input.item.isCheckboxDisabled,\r\n isVisible: !!input.item.isCheckboxVisible,\r\n },\r\n\r\n item: _.cloneDeep(input.item),\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Generates flat list of visible nodes in the tree model.\r\n * @public\r\n */\r\nexport function computeVisibleNodes(model: TreeModel): VisibleTreeNodes {\r\n const result = getVisibleDescendants(model, model.getRootNode());\r\n return {\r\n getNumNodes: () => result.length,\r\n getAtIndex: (index: number): TreeModelNode | TreeModelNodePlaceholder | undefined => {\r\n return result[index];\r\n },\r\n getModel: () => model,\r\n getNumRootNodes: () => model.getRootNode().numChildren,\r\n [Symbol.iterator]: () => result[Symbol.iterator](),\r\n getIndexOfNode: (nodeId: string): number => {\r\n return result.findIndex((visibleNode) => (visibleNode as TreeModelNode).id === nodeId);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Traverses the tree and collects visible descendants.\r\n * @internal\r\n */\r\nexport function getVisibleDescendants(\r\n model: TreeModel,\r\n parentNode: TreeModelNode | TreeModelRootNode,\r\n result: Array<TreeModelNode | TreeModelNodePlaceholder> = [],\r\n): Array<TreeModelNode | TreeModelNodePlaceholder> {\r\n const children = model.getChildren(parentNode.id);\r\n if (!children) {\r\n return result;\r\n }\r\n\r\n let index = 0;\r\n for (const childId of children) {\r\n if (childId === undefined) {\r\n result.push({ parentId: parentNode.id, depth: parentNode.depth + 1, childIndex: index });\r\n } else {\r\n const childNode = model.getNode(childId);\r\n if (childNode === undefined) {\r\n // node was disposed\r\n result.push({ parentId: parentNode.id, depth: parentNode.depth + 1, childIndex: index });\r\n } else {\r\n result.push(childNode);\r\n if (childNode.isExpanded && childNode.numChildren !== undefined) {\r\n getVisibleDescendants(model, childNode, result);\r\n }\r\n }\r\n }\r\n ++index;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction cloneSubree(source: TreeModel, target: MutableTreeModel, parentId: string | undefined): void {\r\n target.setNumChildren(\r\n parentId,\r\n (parentId === undefined ? source.getRootNode() : source.getNode(parentId)!).numChildren,\r\n );\r\n for (const [childId, index] of source.getChildren(parentId)?.iterateValues() ?? []) {\r\n const node = source.getNode(childId)!;\r\n target.setChildren(parentId, [{ ...node, isLoading: !!node.isLoading }], index);\r\n cloneSubree(source, target, childId);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeModel.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAe,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAyHhE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAkC;IAChE,OAAO,GAAG,KAAK,SAAS,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAkC;IAC3E,OAAO,GAAG,KAAK,SAAS,IAAI,YAAY,IAAI,GAAG,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAkC;IACpE,OAAO,GAAG,KAAK,S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AAC,OAAO,CAAC,OAAO,CAAE,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAChF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tree\r\n */\r\n\r\nimport { immerable } from \"immer\";\r\nimport _ from \"lodash\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { CheckBoxState } from \"@itwin/core-react\";\r\nimport { DelayLoadedTreeNodeItem, ImmediatelyLoadedTreeNodeItem, TreeNodeItem } from \"../TreeDataProvider\";\r\nimport { SparseArray, SparseTree } from \"./internal/SparseTree\";\r\n\r\n/**\r\n * Immutable data structure that describes tree node.\r\n * @public\r\n */\r\nexport interface TreeModelNode {\r\n readonly id: string;\r\n readonly parentId: string | undefined;\r\n readonly depth: number;\r\n\r\n readonly isLoading?: boolean;\r\n readonly numChildren: number | undefined;\r\n\r\n readonly description: string | undefined;\r\n readonly isExpanded: boolean;\r\n readonly label: PropertyRecord;\r\n readonly isSelected: boolean;\r\n readonly isSelectionDisabled?: boolean;\r\n\r\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\r\n readonly editingInfo?: TreeModelNodeEditingInfo;\r\n\r\n readonly checkbox: CheckBoxInfo;\r\n\r\n readonly item: TreeNodeItem;\r\n}\r\n\r\n/**\r\n * Immutable data structure that describes checkbox info.\r\n * @public\r\n */\r\nexport interface CheckBoxInfo {\r\n readonly state: CheckBoxState;\r\n readonly tooltip?: string;\r\n readonly isDisabled: boolean;\r\n readonly isVisible: boolean;\r\n}\r\n\r\n/**\r\n * Mutable data structure that describes tree node.\r\n * @public\r\n */\r\nexport interface MutableTreeModelNode extends TreeModelNode {\r\n isLoading: boolean;\r\n\r\n description: string;\r\n isExpanded: boolean;\r\n label: PropertyRecord;\r\n isSelected: boolean;\r\n isSelectionDisabled?: boolean;\r\n\r\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\r\n editingInfo?: TreeModelNodeEditingInfo;\r\n\r\n checkbox: MutableCheckBoxInfo;\r\n\r\n item: TreeNodeItem;\r\n}\r\n\r\n/**\r\n * Data structure that holds callbacks used for tree node editing.\r\n * @public\r\n */\r\nexport interface TreeModelNodeEditingInfo {\r\n onCommit: (node: TreeModelNode, newValue: string) => void;\r\n onCancel: () => void;\r\n}\r\n\r\n/**\r\n * Mutable data structure that describes checkbox info.\r\n * @public\r\n */\r\nexport interface MutableCheckBoxInfo extends CheckBoxInfo {\r\n state: CheckBoxState;\r\n tooltip?: string;\r\n isDisabled: boolean;\r\n isVisible: boolean;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree node placeholder.\r\n * @public\r\n */\r\nexport interface TreeModelNodePlaceholder {\r\n readonly childIndex: number;\r\n readonly depth: number;\r\n readonly parentId?: string;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree root node.\r\n * @public\r\n */\r\nexport interface TreeModelRootNode {\r\n readonly depth: -1;\r\n readonly id: undefined;\r\n readonly numChildren: number | undefined;\r\n}\r\n\r\n/**\r\n * Data structure that describes input used to create tree node.\r\n * @public\r\n */\r\nexport interface TreeModelNodeInput {\r\n readonly description?: string;\r\n readonly isExpanded: boolean;\r\n readonly id: string;\r\n readonly item: TreeNodeItem;\r\n readonly label: PropertyRecord;\r\n readonly isLoading: boolean;\r\n readonly numChildren?: number;\r\n readonly isSelected: boolean;\r\n}\r\n\r\n/**\r\n * Type definition of all tree model nodes.\r\n * @public\r\n */\r\nexport type TreeModelNodeType = TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode;\r\n\r\n/**\r\n * Checks if object is [[TreeModelNode]]\r\n * @public\r\n */\r\nexport function isTreeModelNode(obj: TreeModelNodeType | undefined): obj is TreeModelNode {\r\n return obj !== undefined && !isTreeModelNodePlaceholder(obj) && !isTreeModelRootNode(obj);\r\n}\r\n\r\n/**\r\n * Checks if object is [[TreeModelNodePlaceholder]]\r\n * @public\r\n */\r\nexport function isTreeModelNodePlaceholder(obj: TreeModelNodeType | undefined): obj is TreeModelNodePlaceholder {\r\n return obj !== undefined && \"childIndex\" in obj;\r\n}\r\n\r\n/**\r\n * Checks if object is [[TreeModelRootNode]]\r\n * @public\r\n */\r\nexport function isTreeModelRootNode(obj: TreeModelNodeType | undefined): obj is TreeModelRootNode {\r\n return obj !== undefined && (obj as TreeModelRootNode).id === undefined && !(\"childIndex\" in obj);\r\n}\r\n\r\n/**\r\n * Type definition of tree node item data.\r\n * @public\r\n */\r\nexport type TreeNodeItemData = ImmediatelyLoadedTreeNodeItem & DelayLoadedTreeNodeItem;\r\n\r\n/**\r\n * Data structure that describes set of visible tree nodes as a flat list.\r\n * @public\r\n */\r\nexport interface VisibleTreeNodes extends Iterable<TreeModelNode | TreeModelNodePlaceholder> {\r\n getNumNodes(): number;\r\n getAtIndex(index: number): TreeModelNode | TreeModelNodePlaceholder | undefined;\r\n getModel(): TreeModel;\r\n getNumRootNodes(): number | undefined;\r\n getIndexOfNode(nodeId: string): number;\r\n}\r\n\r\n/**\r\n * Data structure that describes tree model.\r\n * @public\r\n */\r\nexport interface TreeModel {\r\n getRootNode(): TreeModelRootNode;\r\n\r\n getNode(id: string): TreeModelNode | undefined;\r\n getNode(parentId: string | undefined, childIndex: number): TreeModelNode | TreeModelNodePlaceholder | undefined;\r\n getNode(nodeId: string | undefined, childIndex?: number): TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode | undefined;\r\n\r\n getChildren(parentId: string | undefined): SparseArray<string> | undefined;\r\n getChildOffset(parentId: string | undefined, childId: string): number | undefined;\r\n\r\n iterateTreeModelNodes(parentId?: string): IterableIterator<TreeModelNode>;\r\n}\r\n\r\n/**\r\n * Mutable tree model which holds nodes and allows adding or removing them.\r\n * @public\r\n */\r\nexport class MutableTreeModel implements TreeModel {\r\n public [immerable] = true;\r\n\r\n private _tree = new SparseTree<MutableTreeModelNode>();\r\n private _rootNode: TreeModelRootNode = { depth: -1, id: undefined, numChildren: undefined };\r\n\r\n public constructor(seed?: TreeModel) {\r\n if (!seed) {\r\n return;\r\n }\r\n\r\n cloneSubree(seed, this, undefined);\r\n }\r\n\r\n /** Returns root node of a tree. This node is not visible and is there to allow having multiple visible root nodes. */\r\n public getRootNode(): TreeModelRootNode {\r\n return this._rootNode;\r\n }\r\n\r\n /** Returns tree node or placeholder for node that is not loaded yet.\r\n * @returns node, node placeholder or undefined if node is not found in model.\r\n */\r\n public getNode(id: string): MutableTreeModelNode | undefined;\r\n public getNode(parentId: string | undefined, childIndex: number): MutableTreeModelNode | TreeModelNodePlaceholder | undefined;\r\n public getNode(nodeId: string | undefined, childIndex?: number): MutableTreeModelNode | TreeModelNodePlaceholder | undefined {\r\n if (childIndex === undefined) {\r\n return this._tree.getNode(nodeId!);\r\n }\r\n\r\n const children = this._tree.getChildren(nodeId);\r\n const childId = children !== undefined ? children.get(childIndex) : undefined;\r\n if (childId !== undefined) {\r\n return this._tree.getNode(childId);\r\n }\r\n\r\n const parentNode = nodeId === undefined ? this._rootNode : this._tree.getNode(nodeId);\r\n if (parentNode !== undefined) {\r\n return {\r\n childIndex,\r\n depth: parentNode.depth + 1,\r\n parentId: nodeId,\r\n };\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Returns children for specific parent.\r\n * @param parentId id of parent node.\r\n * @returns children of parent node or root nodes if undefined is passed as parent id.\r\n */\r\n public getChildren(parentId: string | undefined): SparseArray<string> | undefined {\r\n return this._tree.getChildren(parentId);\r\n }\r\n\r\n /** Returns children offset in children array for specific parent. */\r\n public getChildOffset(parentId: string | undefined, childId: string): number | undefined {\r\n return this._tree.getChildOffset(parentId, childId);\r\n }\r\n\r\n /**\r\n * Sets children for parent node starting from the specific offset.\r\n * If offset overlaps with already added nodes, the overlapping nodes are overwritten.\r\n */\r\n public setChildren(parentId: string | undefined, nodeInputs: TreeModelNodeInput[], offset: number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined)\r\n return;\r\n\r\n const children: MutableTreeModelNode[] = [];\r\n for (const input of nodeInputs) {\r\n const child = MutableTreeModel.createTreeModelNode(parentNode, input);\r\n children.push(child);\r\n }\r\n\r\n this._tree.setChildren(parentNode.id, children, offset);\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /**\r\n * Inserts child in the specified position.\r\n * If offset is higher then current length of children array, the length is increased.\r\n */\r\n public insertChild(parentId: string | undefined, childNodeInput: TreeModelNodeInput, offset: number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined)\r\n return;\r\n\r\n const child = MutableTreeModel.createTreeModelNode(parentNode, childNodeInput);\r\n\r\n this._tree.insertChild(parentNode.id, child, offset);\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /**\r\n * Changes the id of target node.\r\n * @returns `true` on success, `false` otherwise.\r\n */\r\n public changeNodeId(currentId: string, newId: string): boolean {\r\n const node = this.getNode(currentId);\r\n if (node === undefined) {\r\n return false;\r\n }\r\n\r\n if (currentId === newId) {\r\n return true;\r\n }\r\n\r\n const index = this.getChildOffset(node.parentId, currentId);\r\n assert(index !== undefined);\r\n\r\n if (!this._tree.setNodeId(node.parentId, index, newId)) {\r\n return false;\r\n }\r\n\r\n (node.id as string) = newId; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion\r\n for (const [childId] of this.getChildren(newId)?.iterateValues() ?? []) {\r\n const child = this.getNode(childId);\r\n assert(child !== undefined);\r\n (child.parentId as string) = newId;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Transfers node along with its children to a new location. Fails if destination has undefined child count.\r\n * @param sourceNodeId Node that is being moved.\r\n * @param targetParentId Node that will receive a new child.\r\n * @param targetIndex Insertion location among target's *current* children.\r\n * @returns `true` on success, `false` otherwise.\r\n */\r\n public moveNode(sourceNodeId: string, targetParentId: string | undefined, targetIndex: number): boolean {\r\n const sourceNode = this.getNode(sourceNodeId);\r\n if (sourceNode === undefined) {\r\n return false;\r\n }\r\n\r\n const targetParent = targetParentId === undefined ? this._rootNode : this.getNode(targetParentId);\r\n if (targetParent === undefined || targetParent.numChildren === undefined) {\r\n return false;\r\n }\r\n\r\n if (targetParentId !== undefined && this.areNodesRelated(sourceNodeId, targetParentId)) {\r\n return false;\r\n }\r\n\r\n this._tree.moveNode(sourceNode.parentId, sourceNodeId, targetParentId, targetIndex);\r\n\r\n const sourceParent = sourceNode.parentId === undefined ? this._rootNode : this.getNode(sourceNode.parentId);\r\n assert(sourceParent !== undefined);\r\n MutableTreeModel.setNumChildrenForNode(sourceParent, this._tree.getChildren(sourceNode.parentId));\r\n MutableTreeModel.setNumChildrenForNode(targetParent, this._tree.getChildren(targetParentId));\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (sourceNode.parentId as string | undefined) = targetParentId;\r\n\r\n const updateDepths = (parentId: string, depth: number) => {\r\n const node = this.getNode(parentId);\r\n assert(node !== undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (node.depth as number) = depth;\r\n for (const [nodeId] of this.getChildren(parentId)?.iterateValues() ?? []) {\r\n updateDepths(nodeId, depth + 1);\r\n }\r\n };\r\n\r\n updateDepths(sourceNodeId, targetParent.depth + 1);\r\n return true;\r\n }\r\n\r\n private areNodesRelated(ancestorNodeId: string, descendantNodeId: string): boolean {\r\n const node = this.getNode(descendantNodeId);\r\n if (node === undefined || node.parentId === undefined) {\r\n return false;\r\n }\r\n\r\n return node.parentId === ancestorNodeId ? true : this.areNodesRelated(ancestorNodeId, node.parentId);\r\n }\r\n\r\n /**\r\n * Sets the number of child nodes a parent is expected to contain. All child nodes of this parent will be subsequently\r\n * removed.\r\n */\r\n public setNumChildren(parentId: string | undefined, numChildren: number | undefined): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode === undefined) {\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (parentNode.numChildren as number | undefined) = numChildren;\r\n this._tree.setNumChildren(parentId, numChildren ?? 0);\r\n }\r\n\r\n /** Removes children specified by id.\r\n * @param parentId id of the parent node.\r\n * @param child child node id or index that should be removed.\r\n */\r\n public removeChild(parentId: string | undefined, child: string | number): void {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n this._tree.removeChild(parentId, child);\r\n\r\n // istanbul ignore else\r\n if (parentNode)\r\n MutableTreeModel.setNumChildrenForNode(parentNode, this._tree.getChildren(parentNode.id));\r\n }\r\n\r\n /** Removes all children for parent specified by id.\r\n * @param parentId id of parent node or undefined to remove root nodes.\r\n */\r\n public clearChildren(parentId: string | undefined) {\r\n const parentNode = parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\r\n if (parentNode !== undefined) {\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (parentNode.numChildren as number | undefined) = undefined;\r\n }\r\n this._tree.deleteSubtree(parentId, false);\r\n }\r\n\r\n /** Iterates over all nodes present in the tree model. */\r\n public * iterateTreeModelNodes(parentId?: string): IterableIterator<MutableTreeModelNode> {\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const _this = this;\r\n function* iterateDescendants(subParentId: string | undefined): IterableIterator<MutableTreeModelNode> {\r\n const children = _this.getChildren(subParentId);\r\n if (children === undefined) {\r\n return;\r\n }\r\n\r\n for (const [nodeId] of children.iterateValues()) {\r\n const node = _this.getNode(nodeId);\r\n if (node !== undefined) {\r\n yield node;\r\n yield* iterateDescendants(nodeId);\r\n }\r\n }\r\n }\r\n\r\n yield* iterateDescendants(parentId);\r\n }\r\n\r\n private static setNumChildrenForNode(node: TreeModelRootNode | MutableTreeModelNode, children: SparseArray<string> | undefined) {\r\n const numChildren = children ? children.getLength() : undefined;\r\n if (node.numChildren === numChildren)\r\n return;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n (node.numChildren as number | undefined) = numChildren;\r\n }\r\n\r\n private static createTreeModelNode(parentNode: TreeModelNode | TreeModelRootNode, input: TreeModelNodeInput): MutableTreeModelNode {\r\n return {\r\n id: input.id,\r\n parentId: parentNode.id,\r\n depth: parentNode.depth + 1,\r\n\r\n isLoading: input.isLoading,\r\n numChildren: input.numChildren,\r\n\r\n description: input.description || \"\",\r\n isExpanded: input.isExpanded,\r\n label: input.label,\r\n isSelected: input.isSelected,\r\n isSelectionDisabled: input.item.isSelectionDisabled,\r\n\r\n checkbox: {\r\n state: input.item.checkBoxState || CheckBoxState.Off,\r\n isDisabled: !!input.item.isCheckboxDisabled,\r\n isVisible: !!input.item.isCheckboxVisible,\r\n },\r\n\r\n item: _.cloneDeep(input.item),\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Generates flat list of visible nodes in the tree model.\r\n * @public\r\n */\r\nexport function computeVisibleNodes(model: TreeModel): VisibleTreeNodes {\r\n const result = getVisibleDescendants(model, model.getRootNode());\r\n return {\r\n getNumNodes: () => result.length,\r\n getAtIndex: (index: number): TreeModelNode | TreeModelNodePlaceholder | undefined => {\r\n return result[index];\r\n },\r\n getModel: () => model,\r\n getNumRootNodes: () => model.getRootNode().numChildren,\r\n [Symbol.iterator]: () => result[Symbol.iterator](),\r\n getIndexOfNode: (nodeId: string): number => {\r\n return result.findIndex((visibleNode) => (visibleNode as TreeModelNode).id === nodeId);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Traverses the tree and collects visible descendants.\r\n * @internal\r\n */\r\nexport function getVisibleDescendants(\r\n model: TreeModel,\r\n parentNode: TreeModelNode | TreeModelRootNode,\r\n result: Array<TreeModelNode | TreeModelNodePlaceholder> = [],\r\n): Array<TreeModelNode | TreeModelNodePlaceholder> {\r\n const children = model.getChildren(parentNode.id);\r\n if (!children) {\r\n return result;\r\n }\r\n\r\n let index = 0;\r\n for (const childId of children) {\r\n if (childId === undefined) {\r\n result.push({ parentId: parentNode.id, depth: parentNode.depth + 1, childIndex: index });\r\n } else {\r\n const childNode = model.getNode(childId);\r\n if (childNode === undefined) {\r\n // node was disposed\r\n result.push({ parentId: parentNode.id, depth: parentNode.depth + 1, childIndex: index });\r\n } else {\r\n result.push(childNode);\r\n if (childNode.isExpanded && childNode.numChildren !== undefined) {\r\n getVisibleDescendants(model, childNode, result);\r\n }\r\n }\r\n }\r\n ++index;\r\n }\r\n\r\n return result;\r\n}\r\n\r\nfunction cloneSubree(source: TreeModel, target: MutableTreeModel, parentId: string | undefined): void {\r\n target.setNumChildren(\r\n parentId,\r\n (parentId === undefined ? source.getRootNode() : source.getNode(parentId)!).numChildren,\r\n );\r\n for (const [childId, index] of source.getChildren(parentId)?.iterateValues() ?? []) {\r\n const node = source.getNode(childId)!;\r\n target.setChildren(parentId, [{ ...node, isLoading: !!node.isLoading }], index);\r\n cloneSubree(source, target, childId);\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "3.5.0
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "iTwin.js UI complex components",
|
|
5
5
|
"main": "lib/cjs/components-react.js",
|
|
6
6
|
"module": "lib/esm/components-react.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"url": "http://www.bentley.com"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@itwin/appui-abstract": "^3.5.0
|
|
24
|
-
"@itwin/core-bentley": "^3.5.0
|
|
25
|
-
"@itwin/core-react": "^3.5.0
|
|
23
|
+
"@itwin/appui-abstract": "^3.5.0",
|
|
24
|
+
"@itwin/core-bentley": "^3.5.0",
|
|
25
|
+
"@itwin/core-react": "^3.5.0",
|
|
26
26
|
"react": "^17.0.0",
|
|
27
27
|
"react-dom": "^17.0.0"
|
|
28
28
|
},
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@itwin/appui-abstract": "3.5.0
|
|
35
|
-
"@itwin/build-tools": "3.5.0
|
|
36
|
-
"@itwin/core-bentley": "3.5.0
|
|
37
|
-
"@itwin/core-common": "3.5.0
|
|
38
|
-
"@itwin/core-i18n": "3.5.0
|
|
39
|
-
"@itwin/core-react": "3.5.0
|
|
40
|
-
"@itwin/eslint-plugin": "3.5.0
|
|
34
|
+
"@itwin/appui-abstract": "3.5.0",
|
|
35
|
+
"@itwin/build-tools": "3.5.0",
|
|
36
|
+
"@itwin/core-bentley": "3.5.0",
|
|
37
|
+
"@itwin/core-common": "3.5.0",
|
|
38
|
+
"@itwin/core-i18n": "3.5.0",
|
|
39
|
+
"@itwin/core-react": "3.5.0",
|
|
40
|
+
"@itwin/eslint-plugin": "3.5.0",
|
|
41
41
|
"@testing-library/dom": "^8.11.2",
|
|
42
42
|
"@testing-library/react": "^12.0.0",
|
|
43
43
|
"@testing-library/react-hooks": "^7.0.2",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@types/linkify-it": "~2.1.0",
|
|
54
54
|
"@types/lodash": "^4.14.0",
|
|
55
55
|
"@types/mocha": "^8.2.2",
|
|
56
|
-
"@types/node": "
|
|
56
|
+
"@types/node": "18.11.5",
|
|
57
57
|
"@types/react": "^17.0.37",
|
|
58
58
|
"@types/react-data-grid": "4.0.2",
|
|
59
59
|
"@types/react-dom": "^17.0.0",
|