@itwin/components-react 5.27.0 → 5.28.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/lib/cjs/components-react/common/HighlightedText.scss +8 -0
  3. package/lib/components-react/abstract-types.d.ts +8 -0
  4. package/lib/components-react/abstract-types.d.ts.map +1 -0
  5. package/lib/components-react/abstract-types.js +6 -0
  6. package/lib/components-react/abstract-types.js.map +1 -0
  7. package/lib/components-react/common/HighlightedText.d.ts +6 -0
  8. package/lib/components-react/common/HighlightedText.d.ts.map +1 -1
  9. package/lib/components-react/common/HighlightedText.js +7 -4
  10. package/lib/components-react/common/HighlightedText.js.map +1 -1
  11. package/lib/components-react/common/HighlightedText.scss +8 -0
  12. package/lib/components-react/common/selection/SelectionHandler.d.ts +3 -0
  13. package/lib/components-react/common/selection/SelectionHandler.d.ts.map +1 -1
  14. package/lib/components-react/common/selection/SelectionHandler.js.map +1 -1
  15. package/lib/components-react/common/selection/SelectionModes.d.ts +3 -0
  16. package/lib/components-react/common/selection/SelectionModes.d.ts.map +1 -1
  17. package/lib/components-react/common/selection/SelectionModes.js +4 -0
  18. package/lib/components-react/common/selection/SelectionModes.js.map +1 -1
  19. package/lib/components-react/editors/CustomNumberEditor.d.ts +1 -0
  20. package/lib/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  21. package/lib/components-react/editors/CustomNumberEditor.js +9 -2
  22. package/lib/components-react/editors/CustomNumberEditor.js.map +1 -1
  23. package/lib/components-react/editors/NumericInputEditor.d.ts +1 -0
  24. package/lib/components-react/editors/NumericInputEditor.d.ts.map +1 -1
  25. package/lib/components-react/editors/NumericInputEditor.js +7 -0
  26. package/lib/components-react/editors/NumericInputEditor.js.map +1 -1
  27. package/lib/components-react/editors/TextEditor.d.ts +1 -0
  28. package/lib/components-react/editors/TextEditor.d.ts.map +1 -1
  29. package/lib/components-react/editors/TextEditor.js +9 -2
  30. package/lib/components-react/editors/TextEditor.js.map +1 -1
  31. package/lib/components-react/editors/TextareaEditor.d.ts +1 -0
  32. package/lib/components-react/editors/TextareaEditor.d.ts.map +1 -1
  33. package/lib/components-react/editors/TextareaEditor.js +7 -0
  34. package/lib/components-react/editors/TextareaEditor.js.map +1 -1
  35. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.d.ts.map +1 -1
  36. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js +3 -0
  37. package/lib/components-react/new-editors/interop/old-editors/CustomNumber.js.map +1 -1
  38. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js +3 -0
  39. package/lib/components-react/new-editors/interop/old-editors/NumericInput.js.map +1 -1
  40. package/lib/components-react/tree/HighlightingEngine.d.ts +5 -0
  41. package/lib/components-react/tree/HighlightingEngine.d.ts.map +1 -1
  42. package/lib/components-react/tree/HighlightingEngine.js +3 -0
  43. package/lib/components-react/tree/HighlightingEngine.js.map +1 -1
  44. package/lib/components-react/tree/ImageLoader.d.ts +2 -0
  45. package/lib/components-react/tree/ImageLoader.d.ts.map +1 -1
  46. package/lib/components-react/tree/ImageLoader.js +1 -0
  47. package/lib/components-react/tree/ImageLoader.js.map +1 -1
  48. package/lib/components-react/tree/SimpleTreeDataProvider.d.ts +2 -0
  49. package/lib/components-react/tree/SimpleTreeDataProvider.d.ts.map +1 -1
  50. package/lib/components-react/tree/SimpleTreeDataProvider.js +1 -0
  51. package/lib/components-react/tree/SimpleTreeDataProvider.js.map +1 -1
  52. package/lib/components-react/tree/TreeDataProvider.d.ts +14 -0
  53. package/lib/components-react/tree/TreeDataProvider.d.ts.map +1 -1
  54. package/lib/components-react/tree/TreeDataProvider.js +5 -0
  55. package/lib/components-react/tree/TreeDataProvider.js.map +1 -1
  56. package/lib/components-react/tree/controlled/Observable.d.ts +9 -0
  57. package/lib/components-react/tree/controlled/Observable.d.ts.map +1 -1
  58. package/lib/components-react/tree/controlled/Observable.js +2 -0
  59. package/lib/components-react/tree/controlled/Observable.js.map +1 -1
  60. package/lib/components-react/tree/controlled/TreeActions.d.ts +1 -0
  61. package/lib/components-react/tree/controlled/TreeActions.d.ts.map +1 -1
  62. package/lib/components-react/tree/controlled/TreeActions.js.map +1 -1
  63. package/lib/components-react/tree/controlled/TreeEventDispatcher.d.ts.map +1 -1
  64. package/lib/components-react/tree/controlled/TreeEventDispatcher.js.map +1 -1
  65. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts +3 -0
  66. package/lib/components-react/tree/controlled/TreeEventHandler.d.ts.map +1 -1
  67. package/lib/components-react/tree/controlled/TreeEventHandler.js +2 -0
  68. package/lib/components-react/tree/controlled/TreeEventHandler.js.map +1 -1
  69. package/lib/components-react/tree/controlled/TreeEvents.d.ts +7 -0
  70. package/lib/components-react/tree/controlled/TreeEvents.d.ts.map +1 -1
  71. package/lib/components-react/tree/controlled/TreeEvents.js.map +1 -1
  72. package/lib/components-react/tree/controlled/TreeHooks.d.ts +5 -0
  73. package/lib/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  74. package/lib/components-react/tree/controlled/TreeHooks.js +6 -2
  75. package/lib/components-react/tree/controlled/TreeHooks.js.map +1 -1
  76. package/lib/components-react/tree/controlled/TreeModel.d.ts +18 -0
  77. package/lib/components-react/tree/controlled/TreeModel.d.ts.map +1 -1
  78. package/lib/components-react/tree/controlled/TreeModel.js +7 -0
  79. package/lib/components-react/tree/controlled/TreeModel.js.map +1 -1
  80. package/lib/components-react/tree/controlled/TreeModelSource.d.ts +2 -0
  81. package/lib/components-react/tree/controlled/TreeModelSource.d.ts.map +1 -1
  82. package/lib/components-react/tree/controlled/TreeModelSource.js +1 -0
  83. package/lib/components-react/tree/controlled/TreeModelSource.js.map +1 -1
  84. package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts +9 -0
  85. package/lib/components-react/tree/controlled/TreeNodeLoader.d.ts.map +1 -1
  86. package/lib/components-react/tree/controlled/TreeNodeLoader.js +4 -1
  87. package/lib/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  88. package/lib/components-react/tree/controlled/component/ControlledTree.d.ts +3 -0
  89. package/lib/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  90. package/lib/components-react/tree/controlled/component/ControlledTree.js +4 -3
  91. package/lib/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  92. package/lib/components-react/tree/controlled/component/NodeContent.d.ts +2 -1
  93. package/lib/components-react/tree/controlled/component/NodeContent.d.ts.map +1 -1
  94. package/lib/components-react/tree/controlled/component/NodeContent.js +3 -4
  95. package/lib/components-react/tree/controlled/component/NodeContent.js.map +1 -1
  96. package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts +3 -0
  97. package/lib/components-react/tree/controlled/component/TreeNodeEditor.d.ts.map +1 -1
  98. package/lib/components-react/tree/controlled/component/TreeNodeEditor.js +2 -0
  99. package/lib/components-react/tree/controlled/component/TreeNodeEditor.js.map +1 -1
  100. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts +3 -0
  101. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.d.ts.map +1 -1
  102. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js +5 -7
  103. package/lib/components-react/tree/controlled/component/TreeNodeRenderer.js.map +1 -1
  104. package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts +4 -0
  105. package/lib/components-react/tree/controlled/component/TreeRenderer.d.ts.map +1 -1
  106. package/lib/components-react/tree/controlled/component/TreeRenderer.js +3 -6
  107. package/lib/components-react/tree/controlled/component/TreeRenderer.js.map +1 -1
  108. package/lib/components-react/tree/controlled/internal/SparseTree.d.ts +1 -0
  109. package/lib/components-react/tree/controlled/internal/SparseTree.d.ts.map +1 -1
  110. package/lib/components-react/tree/controlled/internal/SparseTree.js +2 -0
  111. package/lib/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  112. package/lib/components-react/tree/controlled/internal/TreeModelMutator.d.ts.map +1 -1
  113. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js +1 -0
  114. package/lib/components-react/tree/controlled/internal/TreeModelMutator.js.map +1 -1
  115. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.d.ts.map +1 -1
  116. package/lib/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  117. package/lib/components-react.d.ts +2 -0
  118. package/lib/components-react.d.ts.map +1 -1
  119. package/lib/components-react.js +1 -0
  120. package/lib/components-react.js.map +1 -1
  121. package/lib/esm/components-react/common/HighlightedText.scss +8 -0
  122. package/package.json +41 -38
@@ -17,6 +17,7 @@ type CheckboxRendererProps = Omit<CheckboxProps, "onChange" | "onClick"> & {
17
17
  /**
18
18
  * Properties for [[TreeNodeRenderer]].
19
19
  * @public
20
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
20
21
  */
21
22
  export interface TreeNodeRendererProps extends CommonProps {
22
23
  /** Tree node to render. */
@@ -46,6 +47,7 @@ export interface TreeNodeRendererProps extends CommonProps {
46
47
  /**
47
48
  * Default component for rendering tree node.
48
49
  * @public
50
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
49
51
  */
50
52
  export declare const TreeNodeRenderer: React.NamedExoticComponent<TreeNodeRendererProps>;
51
53
  /**
@@ -62,6 +64,7 @@ export interface TreeNodeIconProps {
62
64
  /**
63
65
  * React component that renders icon for [[TreeNode]].
64
66
  * @public
67
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
65
68
  */
66
69
  export declare function TreeNodeIcon(props: TreeNodeIconProps): React.JSX.Element | null;
67
70
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,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IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAEnE,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,mDAmE3B,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,gDAAgD;IAChD,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;GAGG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,4BAQpD"}
1
+ {"version":3,"file":"TreeNodeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAExE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,KAAK,aAAa,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,QAAQ,CAAC,CAAC;AAErE,KAAK,qBAAqB,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,SAAS,CAAC,GAAG;IACzE,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,qBAAsB,SAAQ,WAAW;IACxD,2BAA2B;IAC3B,IAAI,EAAE,aAAa,CAAC;IAEpB,sBAAsB;IACtB,WAAW,EAAE,WAAW,CAAC;IAEzB,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,0BAA0B,CAAC;IAEhD,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,mCAAmC;IACnC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAC;IAErE,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,sBAAsB,CAAC;IAE5C;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAEhD,mEAAmE;IACnE,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;IAEnE,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mDAiE3B,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,IAAI,EAAE,aAAa,CAAC;IACpB,gDAAgD;IAChD,WAAW,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,4BAQpD"}
@@ -5,6 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module Tree
7
7
  */
8
+ /* eslint-disable @typescript-eslint/no-deprecated */
8
9
  import * as React from "react";
9
10
  import { TreeNode } from "@itwin/core-react";
10
11
  import { ImageRenderer } from "../../../common/ImageRenderer.js";
@@ -13,6 +14,7 @@ import { TreeNodeContent } from "./NodeContent.js";
13
14
  /**
14
15
  * Default component for rendering tree node.
15
16
  * @public
17
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
16
18
  */
17
19
  export const TreeNodeRenderer = React.memo(function TreeNodeRenderer(props) {
18
20
  const label = (React.createElement(TreeNodeContent, { key: props.node.id, node: props.node, showDescription: props.descriptionEnabled, highlightProps: props.nodeHighlightProps, onLabelRendered: props.onLabelRendered, nodeEditorRenderer: props.nodeEditorRenderer }));
@@ -26,25 +28,21 @@ export const TreeNodeRenderer = React.memo(function TreeNodeRenderer(props) {
26
28
  e.preventDefault();
27
29
  props.onContextMenu && props.onContextMenu(e, props.node);
28
30
  }
29
- const createCheckboxProps = (checkboxInfo
30
- // eslint-disable-next-line @typescript-eslint/no-deprecated
31
- ) => ({
31
+ const createCheckboxProps = (checkboxInfo) => ({
32
32
  state: checkboxInfo.state,
33
33
  tooltip: checkboxInfo.tooltip,
34
34
  isDisabled: checkboxInfo.isDisabled,
35
35
  onClick: (newState) => props.treeActions.onNodeCheckboxClicked(props.node.id, newState),
36
36
  });
37
- return (
38
- // eslint-disable-next-line @typescript-eslint/no-deprecated
39
- React.createElement(TreeNode, { "data-testid": TreeComponentTestId.Node, className: props.className, checkboxProps: props.node.checkbox.isVisible
37
+ return (React.createElement(TreeNode, { "data-testid": TreeComponentTestId.Node, className: props.className, checkboxProps: props.node.checkbox.isVisible
40
38
  ? createCheckboxProps(props.node.checkbox)
41
39
  : undefined, style: props.style, isExpanded: props.node.isExpanded, isSelected: props.node.isSelected, isLoading: props.node.isLoading, isLeaf: props.node.numChildren === 0, icon: props.imageLoader ? (React.createElement(TreeNodeIcon, { node: props.node, imageLoader: props.imageLoader })) : undefined, label: label, level: props.node.depth, onClick: (event) => props.treeActions.onNodeClicked(props.node.id, event), onMouseDown: () => props.treeActions.onNodeMouseDown(props.node.id), onMouseMove: () => props.treeActions.onNodeMouseMove(props.node.id), onClickExpansionToggle: onExpansionToggle, onContextMenu: onContextMenu, renderOverrides: { renderCheckbox: props.checkboxRenderer } }, props.children));
42
40
  });
43
41
  /**
44
42
  * React component that renders icon for [[TreeNode]].
45
43
  * @public
44
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
46
45
  */
47
- // eslint-disable-next-line @typescript-eslint/no-deprecated
48
46
  export function TreeNodeIcon(props) {
49
47
  const { imageLoader, node } = props;
50
48
  const image = imageLoader.load(node.item);
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkDnD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAClE,KAA4B;IAE5B,MAAM,KAAK,GAAG,CACZ,oBAAC,eAAe,IACd,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,eAAe,EAAE,KAAK,CAAC,kBAAkB,EACzC,cAAc,EAAE,KAAK,CAAC,kBAAkB,EACxC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAC5C,CACH,CAAC;IAEF,SAAS,iBAAiB;QACxB,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;YACvE,KAAK,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,EAAE,KAAK,CAAC,WAAW,GAAI,CACnE,CAAC,CAAC,CAAC,SAAS,EAEf,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EACvB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,EACzE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,sBAAsB,EAAE,iBAAiB,EACzC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,EAAE,cAAc,EAAE,KAAK,CAAC,gBAAgB,EAAE,IAE1D,KAAK,CAAC,QAAQ,CACN,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAcH;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,OAAO,0CAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAI,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport * as React from \"react\";\nimport type { CommonProps, NodeCheckboxProps } from \"@itwin/core-react\";\nimport { TreeNode } from \"@itwin/core-react\";\nimport type { Checkbox } from \"@itwin/itwinui-react\";\nimport { ImageRenderer } from \"../../../common/ImageRenderer.js\";\nimport type { HighlightableTreeNodeProps } from \"../../HighlightingEngine.js\";\nimport type { ITreeImageLoader } from \"../../ImageLoader.js\";\nimport { TreeComponentTestId } from \"../../TreeComponentTestId.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type { CheckBoxInfo, TreeModelNode } from \"../TreeModel.js\";\nimport { TreeNodeContent } from \"./NodeContent.js\";\nimport type { TreeNodeEditorRenderer } from \"./TreeNodeEditor.js\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\ntype CheckboxRendererProps = Omit<CheckboxProps, \"onChange\" | \"onClick\"> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/**\n * Properties for [[TreeNodeRenderer]].\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport interface TreeNodeRendererProps extends CommonProps {\n /** Tree node to render. */\n node: TreeModelNode;\n\n /** Action handler. */\n treeActions: TreeActions;\n\n /** Properties used to highlight matches when tree is filtered. */\n nodeHighlightProps?: HighlightableTreeNodeProps;\n\n /** Specifies whether to show descriptions or not. */\n descriptionEnabled?: boolean;\n\n /** Image loader for node icons. */\n imageLoader?: ITreeImageLoader;\n\n /** Callback to render custom checkbox. */\n checkboxRenderer?: (props: CheckboxRendererProps) => React.ReactNode;\n\n /** Callback to render custom node editor when node is in editing mode. */\n nodeEditorRenderer?: TreeNodeEditorRenderer;\n\n /**\n * Callback used to detect when label is rendered. It is used by TreeRenderer for scrolling to active match.\n * @internal\n */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback that is invoked when context menu should be opened. */\n onContextMenu?: (e: React.MouseEvent, node: TreeModelNode) => void;\n\n /** Child components to render inside the node.*/\n children?: React.ReactNode;\n}\n\n/**\n * Default component for rendering tree node.\n * @public\n */\nexport const TreeNodeRenderer = React.memo(function TreeNodeRenderer(\n props: TreeNodeRendererProps\n) {\n const label = (\n <TreeNodeContent\n key={props.node.id}\n node={props.node}\n showDescription={props.descriptionEnabled}\n highlightProps={props.nodeHighlightProps}\n onLabelRendered={props.onLabelRendered}\n nodeEditorRenderer={props.nodeEditorRenderer}\n />\n );\n\n function onExpansionToggle() {\n if (props.node.isExpanded) props.treeActions.onNodeCollapsed(props.node.id);\n else props.treeActions.onNodeExpanded(props.node.id);\n }\n\n function onContextMenu(e: React.MouseEvent) {\n e.preventDefault();\n props.onContextMenu && props.onContextMenu(e, props.node);\n }\n\n const createCheckboxProps = (\n checkboxInfo: CheckBoxInfo\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ): NodeCheckboxProps => ({\n state: checkboxInfo.state,\n tooltip: checkboxInfo.tooltip,\n isDisabled: checkboxInfo.isDisabled,\n onClick: (newState) =>\n props.treeActions.onNodeCheckboxClicked(props.node.id, newState),\n });\n\n return (\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n <TreeNode\n data-testid={TreeComponentTestId.Node}\n className={props.className}\n checkboxProps={\n props.node.checkbox.isVisible\n ? createCheckboxProps(props.node.checkbox)\n : undefined\n }\n style={props.style}\n isExpanded={props.node.isExpanded}\n isSelected={props.node.isSelected}\n isLoading={props.node.isLoading}\n isLeaf={props.node.numChildren === 0}\n icon={\n props.imageLoader ? (\n <TreeNodeIcon node={props.node} imageLoader={props.imageLoader} />\n ) : undefined\n }\n label={label}\n level={props.node.depth}\n onClick={(event) => props.treeActions.onNodeClicked(props.node.id, event)}\n onMouseDown={() => props.treeActions.onNodeMouseDown(props.node.id)}\n onMouseMove={() => props.treeActions.onNodeMouseMove(props.node.id)}\n onClickExpansionToggle={onExpansionToggle}\n onContextMenu={onContextMenu}\n renderOverrides={{ renderCheckbox: props.checkboxRenderer }}\n >\n {props.children}\n </TreeNode>\n );\n});\n\n/**\n * Props for [[TreeNodeIcon]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof TreeNodeIcon>`\n */\nexport interface TreeNodeIconProps {\n /** Tree node to render icon for. */\n node: TreeModelNode;\n /** Image loader used to load tree node icon. */\n imageLoader: ITreeImageLoader;\n}\n\n/**\n * React component that renders icon for [[TreeNode]].\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport function TreeNodeIcon(props: TreeNodeIconProps) {\n const { imageLoader, node } = props;\n const image = imageLoader.load(node.item);\n\n if (!image) return null;\n\n const renderer = new ImageRenderer();\n return <>{renderer.render(image)}</>;\n}\n"]}
1
+ {"version":3,"file":"TreeNodeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeNodeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAkDnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,gBAAgB,CAClE,KAA4B;IAE5B,MAAM,KAAK,GAAG,CACZ,oBAAC,eAAe,IACd,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAClB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,eAAe,EAAE,KAAK,CAAC,kBAAkB,EACzC,cAAc,EAAE,KAAK,CAAC,kBAAkB,EACxC,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,GAC5C,CACH,CAAC;IAEF,SAAS,iBAAiB;QACxB,IAAI,KAAK,CAAC,IAAI,CAA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,CAAC,CAClB,oBAAC,YAAY,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,GAAI,CACnE,CAAC,CAAC,CAAC,SAAS,EAEf,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,EACvB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,EACzE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EACnE,sBAAsB,EAAE,iBAAiB,EACzC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,EAAE,cAAc,EAAE,KAAK,CAAC,gBAAgB,EAAE,IAE1D,KAAK,CAAC,QAAQ,CACN,CACZ,CAAC;AACJ,CAAC,CAAC,CAAC;AAcH;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IAExB,MAAM,QAAQ,GAAG,IAAI,aAAa,EAAE,CAAC;IACrC,OAAO,0CAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAI,CAAC;AACvC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport * as React from \"react\";\nimport type { CommonProps, NodeCheckboxProps } from \"@itwin/core-react\";\nimport { TreeNode } from \"@itwin/core-react\";\nimport type { Checkbox } from \"@itwin/itwinui-react\";\nimport { ImageRenderer } from \"../../../common/ImageRenderer.js\";\nimport type { HighlightableTreeNodeProps } from \"../../HighlightingEngine.js\";\nimport type { ITreeImageLoader } from \"../../ImageLoader.js\";\nimport { TreeComponentTestId } from \"../../TreeComponentTestId.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type { CheckBoxInfo, TreeModelNode } from \"../TreeModel.js\";\nimport { TreeNodeContent } from \"./NodeContent.js\";\nimport type { TreeNodeEditorRenderer } from \"./TreeNodeEditor.js\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\ntype CheckboxRendererProps = Omit<CheckboxProps, \"onChange\" | \"onClick\"> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/**\n * Properties for [[TreeNodeRenderer]].\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeNodeRendererProps extends CommonProps {\n /** Tree node to render. */\n node: TreeModelNode;\n\n /** Action handler. */\n treeActions: TreeActions;\n\n /** Properties used to highlight matches when tree is filtered. */\n nodeHighlightProps?: HighlightableTreeNodeProps;\n\n /** Specifies whether to show descriptions or not. */\n descriptionEnabled?: boolean;\n\n /** Image loader for node icons. */\n imageLoader?: ITreeImageLoader;\n\n /** Callback to render custom checkbox. */\n checkboxRenderer?: (props: CheckboxRendererProps) => React.ReactNode;\n\n /** Callback to render custom node editor when node is in editing mode. */\n nodeEditorRenderer?: TreeNodeEditorRenderer;\n\n /**\n * Callback used to detect when label is rendered. It is used by TreeRenderer for scrolling to active match.\n * @internal\n */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback that is invoked when context menu should be opened. */\n onContextMenu?: (e: React.MouseEvent, node: TreeModelNode) => void;\n\n /** Child components to render inside the node.*/\n children?: React.ReactNode;\n}\n\n/**\n * Default component for rendering tree node.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport const TreeNodeRenderer = React.memo(function TreeNodeRenderer(\n props: TreeNodeRendererProps\n) {\n const label = (\n <TreeNodeContent\n key={props.node.id}\n node={props.node}\n showDescription={props.descriptionEnabled}\n highlightProps={props.nodeHighlightProps}\n onLabelRendered={props.onLabelRendered}\n nodeEditorRenderer={props.nodeEditorRenderer}\n />\n );\n\n function onExpansionToggle() {\n if (props.node.isExpanded) props.treeActions.onNodeCollapsed(props.node.id);\n else props.treeActions.onNodeExpanded(props.node.id);\n }\n\n function onContextMenu(e: React.MouseEvent) {\n e.preventDefault();\n props.onContextMenu && props.onContextMenu(e, props.node);\n }\n\n const createCheckboxProps = (\n checkboxInfo: CheckBoxInfo\n ): NodeCheckboxProps => ({\n state: checkboxInfo.state,\n tooltip: checkboxInfo.tooltip,\n isDisabled: checkboxInfo.isDisabled,\n onClick: (newState) =>\n props.treeActions.onNodeCheckboxClicked(props.node.id, newState),\n });\n\n return (\n <TreeNode\n data-testid={TreeComponentTestId.Node}\n className={props.className}\n checkboxProps={\n props.node.checkbox.isVisible\n ? createCheckboxProps(props.node.checkbox)\n : undefined\n }\n style={props.style}\n isExpanded={props.node.isExpanded}\n isSelected={props.node.isSelected}\n isLoading={props.node.isLoading}\n isLeaf={props.node.numChildren === 0}\n icon={\n props.imageLoader ? (\n <TreeNodeIcon node={props.node} imageLoader={props.imageLoader} />\n ) : undefined\n }\n label={label}\n level={props.node.depth}\n onClick={(event) => props.treeActions.onNodeClicked(props.node.id, event)}\n onMouseDown={() => props.treeActions.onNodeMouseDown(props.node.id)}\n onMouseMove={() => props.treeActions.onNodeMouseMove(props.node.id)}\n onClickExpansionToggle={onExpansionToggle}\n onContextMenu={onContextMenu}\n renderOverrides={{ renderCheckbox: props.checkboxRenderer }}\n >\n {props.children}\n </TreeNode>\n );\n});\n\n/**\n * Props for [[TreeNodeIcon]] component.\n * @public\n * @deprecated in 4.17.0. Use `React.ComponentProps<typeof TreeNodeIcon>`\n */\nexport interface TreeNodeIconProps {\n /** Tree node to render icon for. */\n node: TreeModelNode;\n /** Image loader used to load tree node icon. */\n imageLoader: ITreeImageLoader;\n}\n\n/**\n * React component that renders icon for [[TreeNode]].\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport function TreeNodeIcon(props: TreeNodeIconProps) {\n const { imageLoader, node } = props;\n const image = imageLoader.load(node.item);\n\n if (!image) return null;\n\n const renderer = new ImageRenderer();\n return <>{renderer.render(image)}</>;\n}\n"]}
@@ -11,6 +11,7 @@ import type { TreeNodeRendererProps } from "./TreeNodeRenderer.js";
11
11
  /**
12
12
  * Data structure that describes range of rendered items in the tree.
13
13
  * @public
14
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
14
15
  */
15
16
  export interface RenderedItemsRange {
16
17
  overscanStartIndex: number;
@@ -21,6 +22,7 @@ export interface RenderedItemsRange {
21
22
  /**
22
23
  * Properties for [[TreeRenderer]] component.
23
24
  * @public
25
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
24
26
  */
25
27
  export interface TreeRendererProps {
26
28
  treeActions: TreeActions;
@@ -48,6 +50,7 @@ export interface TreeRendererProps {
48
50
  /**
49
51
  * Attributes found on TreeRenderer component
50
52
  * @public
53
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
51
54
  */
52
55
  export interface TreeRendererAttributes {
53
56
  /**
@@ -62,6 +65,7 @@ type Alignment = "auto" | "smart" | "center" | "end" | "start";
62
65
  /**
63
66
  * Default tree rendering component.
64
67
  * @public
68
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
65
69
  */
66
70
  export declare class TreeRenderer extends React.Component<TreeRendererProps> implements TreeRendererAttributes {
67
71
  private _ref;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAMnE;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;IAE5B,sDAAsD;IACtD,UAAU,EAAE,CACV,IAAI,EAAE,aAAa,GAAG,wBAAwB,EAC9C,KAAK,EAAE,MAAM,KACV,MAAM,CAAC;IAEZ,yCAAyC;IACzC,YAAY,EAAE,gBAAgB,CAAC;IAE/B,uCAAuC;IACvC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,KAAK,CAAC,SAAS,CAAC;IAEjE,qFAAqF;IACrF,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAE/C,iEAAiE;IACjE,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAE9D;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAEhC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC3D;AAED,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAC;AAqC/D;;;GAGG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CACzC,YAAW,sBAAsB;IAEjC,OAAO,CAAC,IAAI,CAA6C;IAEzD,kBAAkB;IACX,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS;IAIzC,MAAM;CAGvB"}
1
+ {"version":3,"file":"TreeRenderer.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,uBAAuB,CAAC;AAE/B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAMnE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B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ript-eslint/no-deprecated */
8
9
  import "./ControlledTree.scss";
9
10
  import classnames from "classnames";
10
11
  import * as React from "react";
@@ -29,6 +30,7 @@ useTreeRendererContext,] = createContextWithMandatoryProvider("TreeRendererConte
29
30
  /**
30
31
  * Default tree rendering component.
31
32
  * @public
33
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
32
34
  */
33
35
  export class TreeRenderer extends React.Component {
34
36
  _ref = React.createRef();
@@ -55,7 +57,6 @@ const TreeRendererInner = React.forwardRef((props, ref) => {
55
57
  variableSizeListRef.current.resetAfterIndex(0, false);
56
58
  }
57
59
  }
58
- // eslint-disable-next-line @typescript-eslint/no-deprecated
59
60
  const coreTreeRef = React.useRef(null);
60
61
  const onLabelRendered = useScrollToActiveMatch(coreTreeRef, props.nodeHighlightingProps);
61
62
  const highlightingEngine = React.useMemo(() => props.nodeHighlightingProps &&
@@ -145,7 +146,6 @@ const Node = React.memo(function Node(props) {
145
146
  nodeHighlightProps,
146
147
  });
147
148
  }
148
- // eslint-disable-next-line @typescript-eslint/no-deprecated
149
149
  return React.createElement(TreeNodePlaceholder, { level: node.depth });
150
150
  }, [
151
151
  node,
@@ -199,9 +199,7 @@ function getHighlightedNodeId(highlightableTreeProps) {
199
199
  ? highlightableTreeProps.activeMatch.nodeId
200
200
  : undefined;
201
201
  }
202
- function useScrollToActiveMatch(
203
- // eslint-disable-next-line @typescript-eslint/no-deprecated
204
- treeRef, highlightableTreeProps) {
202
+ function useScrollToActiveMatch(treeRef, highlightableTreeProps) {
205
203
  const scrollToActive = React.useRef(false);
206
204
  React.useEffect(() => {
207
205
  scrollToActive.current = true;
@@ -226,7 +224,6 @@ treeRef, highlightableTreeProps) {
226
224
  }, [highlightableTreeProps, treeRef]);
227
225
  return onLabelRendered;
228
226
  }
229
- // eslint-disable-next-line @typescript-eslint/no-deprecated
230
227
  function setFocusToSelected(treeRef) {
231
228
  if (treeRef.current)
232
229
  treeRef.current.setFocusByClassName(".core-tree-node.is-selected");
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,kCAAkC,EAAE,MAAM,oDAAoD,CAAC;AAExG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOjE,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,eAAe,GAAG,GAAG,CAAC;AAyF5B,mEAAmE;AACnE,MAAM;AACJ,4CAA4C;AAC5C,2BAA2B;AAE3B,4CAA4C;AAC5C,4BAA4B;AAE5B,mDAAmD;AACnD,sBAAsB,EACvB,GAAG,kCAAkC,CACpC,qBAAqB,CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,SAA4B;IAGlC,IAAI,GAAG,KAAK,CAAC,SAAS,EAA0B,CAAC;IAEzD,kBAAkB;IACX,YAAY,CAAC,MAAc,EAAE,SAAqB;QACvD,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,IAAI,C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Q,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS;YACjE,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;gBACzB,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;IACP,CAAC,EACD,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAClC,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,4DAA4D;AAC5D,SAAS,kBAAkB,CAAC,OAAyC;IACnE,IAAI,OAAO,CAAC,OAAO;QACjB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,6BAA6B,CAAC,CAAC;AACvE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat, timer } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { HighlightingEngine } from \"../../HighlightingEngine.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport { toRxjsObservable } from \"../Observable.js\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n {/* eslint-disable-next-line @typescript-eslint/no-deprecated */}\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo((): React.ReactNode => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList | null>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n treeRef: React.RefObject<CoreTree | null>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree | null>) {\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
1
+ {"version":3,"file":"TreeRenderer.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/component/TreeRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAq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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./ControlledTree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ListChildComponentProps,\n ListOnItemsRenderedProps,\n} from \"react-window\";\nimport { areEqual, VariableSizeList } from \"react-window\";\nimport { concat, timer } from \"rxjs\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { Tree as CoreTree, TreeNodePlaceholder } from \"@itwin/core-react\";\nimport { createContextWithMandatoryProvider } from \"../../../common/UseContextWithMandatoryProvider.js\";\nimport type { HighlightableTreeProps } from \"../../HighlightingEngine.js\";\nimport { HighlightingEngine } from \"../../HighlightingEngine.js\";\nimport type { TreeActions } from \"../TreeActions.js\";\nimport type {\n TreeModelNode,\n TreeModelNodePlaceholder,\n VisibleTreeNodes,\n} from \"../TreeModel.js\";\nimport {\n isTreeModelNode,\n isTreeModelNodePlaceholder,\n isTreeModelRootNode,\n} from \"../TreeModel.js\";\nimport type { ITreeNodeLoader } from \"../TreeNodeLoader.js\";\nimport type { TreeNodeRendererProps } from \"./TreeNodeRenderer.js\";\nimport { TreeNodeRenderer } from \"./TreeNodeRenderer.js\";\nimport { toRxjsObservable } from \"../Observable.js\";\n\nconst NODE_LOAD_DELAY = 500;\n\n/**\n * Data structure that describes range of rendered items in the tree.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface RenderedItemsRange {\n overscanStartIndex: number;\n overscanStopIndex: number;\n visibleStartIndex: number;\n visibleStopIndex: number;\n}\n\n/**\n * Properties for [[TreeRenderer]] component.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeRendererProps {\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Callback that is used to determine node height. */\n nodeHeight: (\n node: TreeModelNode | TreeModelNodePlaceholder,\n index: number\n ) => number;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Callback to render custom node. */\n nodeRenderer?: (props: TreeNodeRendererProps) => React.ReactNode;\n\n /** Properties used to highlight nodes and scroll to active match while filtering. */\n nodeHighlightingProps?: HighlightableTreeProps;\n\n /** Callback that is called when rendered items range changes. */\n onItemsRendered?: (renderedItems: RenderedItemsRange) => void;\n\n /**\n * Callback used when an editor closes\n * @internal\n */\n onNodeEditorClosed?: () => void;\n\n /** Width of the tree area. */\n width: number;\n\n /** Height of the tree area. */\n height: number;\n}\n\n/**\n * Attributes found on TreeRenderer component\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport interface TreeRendererAttributes {\n /**\n * Scroll to the specified node.\n * @param nodeId Id of the target node to scroll to.\n * @param alignment Controls scrolling behavior. See [react-window](https://github.com/bvaughn/react-window) documentation\n * on `scrollToItem` for details.\n */\n scrollToNode(nodeId: string, alignment?: Alignment): void;\n}\n\ntype Alignment = \"auto\" | \"smart\" | \"center\" | \"end\" | \"start\";\n\n/** [[TreeRenderer]] context that is provided to each rendered node. */\ninterface TreeRendererContext {\n /** Callback to render custom node. */\n nodeRenderer: (props: TreeNodeRendererProps) => React.ReactNode;\n\n treeActions: TreeActions;\n nodeLoader: ITreeNodeLoader;\n\n /** Flat list of nodes to be rendered. */\n visibleNodes: VisibleTreeNodes;\n\n /** Engine used to created node highlighting properties. */\n highlightingEngine?: HighlightingEngine;\n\n /** Callback used detect when label is rendered. It is used by TreeRenderer for scrolling to active match. */\n onLabelRendered?: (node: TreeModelNode) => void;\n\n /** Callback used when an editor closes */\n onNodeEditorClosed?: () => void;\n}\n\n/** [[TreeRenderer]] context provider, consumer and custom hook. */\nconst [\n /** Context of [[TreeRenderer]] provider. */\n TreeRendererContextProvider,\n\n /** Context of [[TreeRenderer]] consumer. */\n _TreeRendererContextConsumer,\n\n /** Custom hook to use [[TreeRenderer]] context. */\n useTreeRendererContext,\n] = createContextWithMandatoryProvider<TreeRendererContext>(\n \"TreeRendererContext\"\n);\n\n/**\n * Default tree rendering component.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport class TreeRenderer\n extends React.Component<TreeRendererProps>\n implements TreeRendererAttributes\n{\n private _ref = React.createRef<TreeRendererAttributes>();\n\n /** @inheritdoc */\n public scrollToNode(nodeId: string, alignment?: Alignment) {\n if (this._ref.current) this._ref.current.scrollToNode(nodeId, alignment);\n }\n\n public override render() {\n return <TreeRendererInner ref={this._ref} {...this.props} />;\n }\n}\n\n// eslint-disable-next-line react/display-name\nconst TreeRendererInner = React.forwardRef<\n TreeRendererAttributes,\n TreeRendererProps\n>((props, ref) => {\n const variableSizeListRef = React.useRef<VariableSizeList>(null);\n useTreeRendererAttributes(ref, variableSizeListRef, props.visibleNodes);\n\n const previousVisibleNodes = usePrevious(props.visibleNodes);\n const previousNodeHeight = usePrevious(props.nodeHeight);\n if (\n (previousVisibleNodes !== undefined &&\n previousVisibleNodes !== props.visibleNodes) ||\n (previousNodeHeight !== undefined &&\n previousNodeHeight !== props.nodeHeight)\n ) {\n if (variableSizeListRef.current) {\n variableSizeListRef.current.resetAfterIndex(0, false);\n }\n }\n\n const coreTreeRef = React.useRef<CoreTree>(null);\n const onLabelRendered = useScrollToActiveMatch(\n coreTreeRef,\n props.nodeHighlightingProps\n );\n const highlightingEngine = React.useMemo(\n () =>\n props.nodeHighlightingProps &&\n new HighlightingEngine(props.nodeHighlightingProps),\n [props.nodeHighlightingProps]\n );\n\n const rendererContext = React.useMemo<TreeRendererContext>(\n () => ({\n nodeRenderer: props.nodeRenderer\n ? props.nodeRenderer\n : (nodeProps) => <TreeNodeRenderer {...nodeProps} />,\n treeActions: props.treeActions,\n nodeLoader: props.nodeLoader,\n visibleNodes: props.visibleNodes,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed: () => {\n setFocusToSelected(coreTreeRef);\n props.onNodeEditorClosed && props.onNodeEditorClosed();\n },\n }),\n [props, onLabelRendered, highlightingEngine]\n );\n\n const itemKey = React.useCallback(\n (index: number) => getNodeKey(props.visibleNodes.getAtIndex(index)!),\n [props.visibleNodes]\n );\n\n const { nodeHeight, visibleNodes } = props;\n const itemSize = React.useCallback(\n (index: number) => nodeHeight(visibleNodes.getAtIndex(index)!, index),\n [nodeHeight, visibleNodes]\n );\n\n const { nodeHighlightingProps } = props;\n React.useEffect(() => {\n const highlightedNodeId = getHighlightedNodeId(nodeHighlightingProps);\n if (!highlightedNodeId) return;\n\n let index = 0;\n for (const node of visibleNodes) {\n if (isTreeModelNode(node) && node.id === highlightedNodeId) break;\n\n index++;\n }\n\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(index);\n }, [nodeHighlightingProps]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyDown(e);\n },\n [props.treeActions]\n );\n\n const handleKeyUp = React.useCallback(\n (e: React.KeyboardEvent) => {\n props.treeActions.onTreeKeyUp(e);\n },\n [props.treeActions]\n );\n\n const onItemsRendered = props.onItemsRendered;\n const handleRenderedItemsChange = React.useCallback(\n (onItemsRenderedProps: ListOnItemsRenderedProps) => {\n onItemsRendered && onItemsRendered({ ...onItemsRenderedProps });\n },\n [onItemsRendered]\n );\n\n return (\n <TreeRendererContextProvider value={rendererContext}>\n <CoreTree\n ref={coreTreeRef}\n className={classnames(\n \"components-controlledTree\",\n \"components-smallEditor-host\"\n )}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n >\n <VariableSizeList\n ref={variableSizeListRef}\n className={\"ReactWindow__VariableSizeList\"}\n width={props.width}\n height={props.height}\n itemCount={props.visibleNodes.getNumNodes()}\n itemSize={itemSize}\n estimatedItemSize={25}\n overscanCount={10}\n itemKey={itemKey}\n onItemsRendered={handleRenderedItemsChange}\n >\n {Node}\n </VariableSizeList>\n </CoreTree>\n </TreeRendererContextProvider>\n );\n});\n\nfunction getNodeKey(node: TreeModelNode | TreeModelNodePlaceholder): string {\n if (isTreeModelNode(node)) {\n return node.id;\n }\n return `${node.parentId || \"\"}-${node.childIndex}`;\n}\n\nconst Node = React.memo<React.FC<ListChildComponentProps>>(function Node(\n props: ListChildComponentProps\n) {\n const { index, style } = props;\n\n const {\n nodeRenderer,\n visibleNodes,\n treeActions,\n nodeLoader,\n onLabelRendered,\n highlightingEngine,\n onNodeEditorClosed,\n } = useTreeRendererContext(Node);\n const node = visibleNodes.getAtIndex(index)!;\n\n useNodeLoading(node, visibleNodes, nodeLoader);\n\n // Mark selected node's wrapper to make detecting consecutively selected nodes with css selectors possible\n const className = classnames(\"node-wrapper\", {\n \"is-selected\": isTreeModelNode(node) && node.isSelected,\n });\n\n const isEditing = React.useRef(false);\n React.useEffect(() => {\n if (!isTreeModelNode(node)) return;\n\n if (!isEditing.current && node.editingInfo) {\n isEditing.current = true;\n } else if (isEditing.current && node.editingInfo === undefined) {\n isEditing.current = false;\n\n if (onNodeEditorClosed) onNodeEditorClosed();\n }\n }, [node, onNodeEditorClosed]);\n\n return (\n <div className={className} style={style}>\n {React.useMemo((): React.ReactNode => {\n if (isTreeModelNode(node)) {\n const nodeHighlightProps = highlightingEngine\n ? highlightingEngine.createRenderProps(node)\n : undefined;\n return nodeRenderer({\n node,\n treeActions,\n onLabelRendered,\n nodeHighlightProps,\n });\n }\n\n return <TreeNodePlaceholder level={node.depth} />;\n }, [\n node,\n treeActions,\n nodeRenderer,\n onLabelRendered,\n highlightingEngine,\n ])}\n </div>\n );\n},\nareEqual);\n\nfunction useNodeLoading(\n node: TreeModelNode | TreeModelNodePlaceholder,\n visibleNodes: VisibleTreeNodes,\n nodeLoader: ITreeNodeLoader\n): void {\n React.useEffect(\n () => {\n if (!isTreeModelNodePlaceholder(node)) {\n return;\n }\n\n const treeModel = visibleNodes.getModel();\n const parentNode = node.parentId\n ? treeModel.getNode(node.parentId)\n : treeModel.getRootNode();\n if (!isTreeModelNode(parentNode) && !isTreeModelRootNode(parentNode)) {\n return;\n }\n\n const subscription = concat(\n timer(NODE_LOAD_DELAY),\n toRxjsObservable(nodeLoader.loadNode(parentNode, node.childIndex))\n ).subscribe();\n return () => subscription.unsubscribe();\n },\n // Mounted node component never changes its node key, thus it's safe to run this effect only once for every\n // nodeLoader change.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [nodeLoader]\n );\n}\n\nfunction useTreeRendererAttributes(\n ref: React.Ref<TreeRendererAttributes>,\n variableSizeListRef: React.RefObject<VariableSizeList | null>,\n visibleNodes: VisibleTreeNodes\n) {\n const visibleNodesRef = React.useRef(visibleNodes);\n visibleNodesRef.current = visibleNodes;\n React.useImperativeHandle(\n ref,\n () => ({\n scrollToNode: (nodeId, alignment) => {\n assert(variableSizeListRef.current !== null);\n variableSizeListRef.current.scrollToItem(\n visibleNodesRef.current.getIndexOfNode(nodeId),\n alignment\n );\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = React.useRef<T | undefined>(undefined);\n\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nfunction getHighlightedNodeId(highlightableTreeProps?: HighlightableTreeProps) {\n return highlightableTreeProps && highlightableTreeProps.activeMatch\n ? highlightableTreeProps.activeMatch.nodeId\n : undefined;\n}\n\nfunction useScrollToActiveMatch(\n treeRef: React.RefObject<CoreTree | null>,\n highlightableTreeProps?: HighlightableTreeProps\n) {\n const scrollToActive = React.useRef(false);\n React.useEffect(() => {\n scrollToActive.current = true;\n }, [highlightableTreeProps]);\n\n const onLabelRendered = React.useCallback(\n (node: TreeModelNode) => {\n const highlightedNodeId = getHighlightedNodeId(highlightableTreeProps);\n if (\n !treeRef.current ||\n !scrollToActive.current ||\n !highlightedNodeId ||\n highlightedNodeId !== node.id\n )\n return;\n\n scrollToActive.current = false;\n const scrollTo = [\n ...treeRef.current.getElementsByClassName(\n HighlightingEngine.ACTIVE_CLASS_NAME\n ),\n ];\n if (scrollTo.length > 0 && scrollTo[0].scrollIntoView !== undefined)\n scrollTo[0].scrollIntoView({\n behavior: \"auto\",\n block: \"nearest\",\n inline: \"end\",\n });\n },\n [highlightableTreeProps, treeRef]\n );\n\n return onLabelRendered;\n}\n\nfunction setFocusToSelected(treeRef: React.RefObject<CoreTree | null>) {\n if (treeRef.current)\n treeRef.current.setFocusByClassName(\".core-tree-node.is-selected\");\n}\n"]}
@@ -35,6 +35,7 @@ export declare class SparseTree<T extends Node> {
35
35
  * this class does not need to check each index when iterating values that are
36
36
  * stored in the array.
37
37
  * @public
38
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
38
39
  */
39
40
  export declare class SparseArray<T> implements Iterable<T | undefined> {
40
41
  [immerable]: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"SparseTree.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,gBAAgB;AAChB,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,UAAU,CAAC,CAAC,SAAS,IAAI;IAC7B,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE5B,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,iBAAiB,CAA2C;IACpE,OAAO,CAAC,SAAS,CAAyB;;IAMnC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAItC,cAAc,CACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS;IAOd,WAAW,CAChB,QAAQ,EAAE,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;IAClE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAWrC,wEAAwE;IACjE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAelC;;;OAGG;IACI,aAAa,IAAI,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAIrD,kEAAkE;IAC3D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,GAAG,SAAS,CAAC;IAoB3D,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,MAAM,CAAC,OAAO;CAGvB"}
@@ -5,6 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module Tree
7
7
  */
8
+ /* eslint-disable @typescript-eslint/no-deprecated */
8
9
  import { immerable } from "immer";
9
10
  import { assert, compareNumbers, lowerBound } from "@itwin/core-bentley";
10
11
  /**
@@ -140,6 +141,7 @@ export class SparseTree {
140
141
  * this class does not need to check each index when iterating values that are
141
142
  * stored in the array.
142
143
  * @public
144
+ * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.
143
145
  */
144
146
  export class SparseArray {
145
147
  [immerable];
@@ -1 +1 @@
1
- {"version":3,"file":"SparseTree.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACd,CAAC,SAAS,CAAC,CAAU;IAEpB,UAAU,GAAG,IAAI,WAAW,EAAU,CAAC;IACvC,iBAAiB,GAAwC,EAAE,CAAC;IAC5D,SAAS,GAAsB,EAAE,CAAC;IAE1C;QACE,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IAEM,OA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EAAE,CAAC;QACtB,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,aAAa;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACxC,CAAC;IAED,kEAAkE;IAC3D,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;gBACnC,OAAO,YAAY,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC;oBAC5C,MAAM,SAAS,CAAC;gBAClB,CAAC;gBAED,MAAM,KAAK,CAAC;gBACZ,EAAE,YAAY,CAAC;YACjB,CAAC;YAED,OAAO,YAAY,GAAG,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;gBAC7C,MAAM,SAAS,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAEO,UAAU,CAAC,KAAa;QAI9B,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,MAAM,CAAC,OAAO,CAAI,KAAa,EAAE,KAAkB;QACzD,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { immerable } from \"immer\";\nimport { assert, compareNumbers, lowerBound } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport interface Node {\n readonly id: string;\n}\n\n/**\n * Structure for sparse tree storage.\n * It uses SparseArray to store children ids for parent. This allows\n * having tree structure with some nodes missing in the tree branch.\n * @internal\n */\nexport class SparseTree<T extends Node> {\n public [immerable]: boolean;\n\n private _rootNodes = new SparseArray<string>();\n private _parentToChildren: Record<string, SparseArray<string>> = {};\n private _idToNode: Record<string, T> = {};\n\n constructor() {\n this[immerable] = true;\n }\n\n public getNode(nodeId: string): T | undefined {\n return this._idToNode[nodeId];\n }\n\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n const children = this.getChildren(parentId);\n if (!children) return undefined;\n\n return children.getIndex(childId);\n }\n\n public getChildren(\n parentId: string | undefined,\n createIfNotExist: boolean = false\n ): SparseArray<string> | undefined {\n if (parentId === undefined) {\n return this._rootNodes;\n }\n\n if (this._parentToChildren[parentId] === undefined && createIfNotExist) {\n this._parentToChildren[parentId] = new SparseArray<string>();\n }\n\n return this._parentToChildren[parentId];\n }\n\n public setChildren(\n parentId: string | undefined,\n children: T[],\n offset: number\n ) {\n const existingChildren = this.getChildren(parentId, true)!;\n children.forEach((child, index) => {\n const existingChildId = existingChildren.get(offset + index);\n if (existingChildId !== undefined) {\n this.deleteSubtree(existingChildId);\n }\n\n existingChildren.set(offset + index, child.id);\n this._idToNode[child.id] = child;\n });\n }\n\n public insertChild(parentId: string | undefined, child: T, offset: number) {\n const existingChildren = this.getChildren(parentId, true)!;\n existingChildren.insert(offset, child.id);\n this._idToNode[child.id] = child;\n }\n\n public setNodeId(\n parentId: string | undefined,\n index: number,\n newId: string\n ): boolean {\n const previousNodeId = this.getChildren(parentId)?.get(index);\n if (previousNodeId === undefined) {\n return false;\n }\n\n if (previousNodeId === newId) {\n return true;\n }\n\n if (this.getNode(newId) !== undefined) {\n return false;\n }\n\n this._idToNode[newId] = this._idToNode[previousNodeId];\n delete this._idToNode[previousNodeId];\n\n this._parentToChildren[newId] = this._parentToChildren[previousNodeId];\n delete this._parentToChildren[previousNodeId];\n\n if (parentId === undefined) {\n this._rootNodes.set(index, newId);\n } else {\n this._parentToChildren[parentId].set(index, newId);\n }\n\n return true;\n }\n\n public moveNode(\n sourceParentId: string | undefined,\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): void {\n const sourceNodeSiblings = this.getChildren(sourceParentId);\n assert(sourceNodeSiblings !== undefined);\n\n const sourceIndex = this.getChildOffset(sourceParentId, sourceNodeId);\n assert(sourceIndex !== undefined);\n\n sourceNodeSiblings.remove(sourceIndex);\n if (targetParentId === sourceParentId && targetIndex > sourceIndex) {\n targetIndex -= 1;\n }\n\n const targetNodeSiblings = this.getChildren(targetParentId, true);\n assert(targetNodeSiblings !== undefined);\n targetNodeSiblings.insert(targetIndex, sourceNodeId);\n }\n\n public setNumChildren(parentId: string | undefined, numChildren: number) {\n const children = this.getChildren(parentId, true)!;\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n\n children.setLength(numChildren);\n }\n\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const children = this.getChildren(parentId);\n if (children === undefined) return;\n\n if (typeof child === \"string\") {\n const childIndex = children.getIndex(child);\n if (childIndex !== undefined) {\n children.remove(childIndex);\n }\n\n this.deleteSubtree(child);\n } else {\n const childId = children.get(child);\n children.remove(child);\n if (childId !== undefined) {\n this.deleteSubtree(childId);\n }\n }\n }\n\n public deleteSubtree(\n parentId: string | undefined,\n deleteParent: boolean = true\n ) {\n const children = this.getChildren(parentId);\n if (children !== undefined) {\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n }\n\n if (parentId === undefined) {\n this._rootNodes.setLength(0);\n return;\n }\n if (deleteParent) {\n delete this._idToNode[parentId];\n }\n delete this._parentToChildren[parentId];\n }\n}\n\n/**\n * Structure for sparse array value storage.\n * The main advantage of this class over the standard javascript array is that\n * this class does not need to check each index when iterating values that are\n * stored in the array.\n * @public\n */\nexport class SparseArray<T> implements Iterable<T | undefined> {\n public [immerable]: boolean;\n\n private _length = 0;\n private _array: Array<[T, number]> = [];\n\n constructor() {\n this[immerable] = true;\n }\n\n /** Returns length of array including intermediate 'undefined' values */\n public getLength(): number {\n return this._length;\n }\n\n /** Sets length of array. */\n public setLength(length: number) {\n const { index } = this.lowerBound(length);\n this._array.length = index;\n this._length = length;\n }\n\n /** Returns index of supplied value.\n *\n * @returns index of value or undefined if value is not found.\n */\n public getIndex(lookupValue: T): number | undefined {\n for (const [value, index] of this._array) {\n if (value === lookupValue) return index;\n }\n return undefined;\n }\n\n /** Returns value at specific position.\n *\n * @returns stored value or undefined.\n */\n public get(index: number): T | undefined {\n const { index: i, equal } = this.lowerBound(index);\n return equal ? this._array[i][0] : undefined;\n }\n\n /** Sets value at specific position. Overrides any existing value. */\n public set(index: number, value: T) {\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0, [value, index]);\n this._length = Math.max(this._length, index + 1);\n }\n\n /** Inserts value at specific position. Increases array length by one. */\n public insert(index: number, value: T) {\n const { index: i } = this.lowerBound(index);\n this._array.splice(i, 0, [value, index]);\n\n for (let j = i + 1; j < this._array.length; j++) {\n this._array[j][1]++;\n }\n\n this._length = Math.max(this._length + 1, index + 1);\n }\n\n /** Removes value at specified index and reduces array length by one. */\n public remove(index: number): void {\n if (index >= this._length) {\n return;\n }\n\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0);\n\n for (let j = i; j < this._array.length; j++) {\n this._array[j][1]--;\n }\n\n this._length = Math.max(0, this._length - 1);\n }\n\n /**\n * Iterates values that are stored in the array\n * @returns `[value, index]` tuples.\n */\n public iterateValues(): IterableIterator<[T, number]> {\n return this._array[Symbol.iterator]();\n }\n\n /** Iterates the array with all intermediate `undefined` values */\n public [Symbol.iterator](): IterableIterator<T | undefined> {\n const array = this._array;\n const length = this._length;\n return (function* () {\n let currentIndex = 0;\n for (const [value, index] of array) {\n for (; currentIndex < index; ++currentIndex) {\n yield undefined;\n }\n\n yield value;\n ++currentIndex;\n }\n\n for (; currentIndex < length; ++currentIndex) {\n yield undefined;\n }\n })();\n }\n\n private lowerBound(index: number): {\n index: number;\n equal: boolean;\n } {\n return lowerBound(index, this._array, SparseArray.compare);\n }\n\n private static compare<T>(index: number, value: [T, number]): number {\n return compareNumbers(index, value[1]);\n }\n}\n"]}
1
+ {"version":3,"file":"SparseTree.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/SparseTree.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACd,CAAC,SAAS,CAAC,CAAU;IAEpB,UAAU,GAAG,IAAI,WAAW,EAAU,CAAC;IACvC,iBAAiB,GAAwC,EAAE,CAAC;IAC5D,SAAS,GAAsB,EAAE,CAAC;IAE1C;QACE,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACzB,CAAC;IAEM,OAAO,CAAC,MAAc;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEM,cAAc,CACnB,QAA4B,EAC5B,OAAe;QAEf,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAEhC,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEM,WAAW,CAChB,QAA4B,EAC5B,mBAA4B,KAAK;QAEjC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;Y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;QAC5B,OAAO,CAAC,QAAQ,CAAC;YACf,IAAI,YAAY,GAAG,CAAC,CAAC;YACrB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;gBACnC,OAAO,YAAY,GAAG,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC;oBAC5C,MAAM,SAAS,CAAC;gBAClB,CAAC;gBAED,MAAM,KAAK,CAAC;gBACZ,EAAE,YAAY,CAAC;YACjB,CAAC;YAED,OAAO,YAAY,GAAG,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;gBAC7C,MAAM,SAAS,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;IAEO,UAAU,CAAC,KAAa;QAI9B,OAAO,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7D,CAAC;IAEO,MAAM,CAAC,OAAO,CAAI,KAAa,EAAE,KAAkB;QACzD,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport { immerable } from \"immer\";\nimport { assert, compareNumbers, lowerBound } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport interface Node {\n readonly id: string;\n}\n\n/**\n * Structure for sparse tree storage.\n * It uses SparseArray to store children ids for parent. This allows\n * having tree structure with some nodes missing in the tree branch.\n * @internal\n */\nexport class SparseTree<T extends Node> {\n public [immerable]: boolean;\n\n private _rootNodes = new SparseArray<string>();\n private _parentToChildren: Record<string, SparseArray<string>> = {};\n private _idToNode: Record<string, T> = {};\n\n constructor() {\n this[immerable] = true;\n }\n\n public getNode(nodeId: string): T | undefined {\n return this._idToNode[nodeId];\n }\n\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n const children = this.getChildren(parentId);\n if (!children) return undefined;\n\n return children.getIndex(childId);\n }\n\n public getChildren(\n parentId: string | undefined,\n createIfNotExist: boolean = false\n ): SparseArray<string> | undefined {\n if (parentId === undefined) {\n return this._rootNodes;\n }\n\n if (this._parentToChildren[parentId] === undefined && createIfNotExist) {\n this._parentToChildren[parentId] = new SparseArray<string>();\n }\n\n return this._parentToChildren[parentId];\n }\n\n public setChildren(\n parentId: string | undefined,\n children: T[],\n offset: number\n ) {\n const existingChildren = this.getChildren(parentId, true)!;\n children.forEach((child, index) => {\n const existingChildId = existingChildren.get(offset + index);\n if (existingChildId !== undefined) {\n this.deleteSubtree(existingChildId);\n }\n\n existingChildren.set(offset + index, child.id);\n this._idToNode[child.id] = child;\n });\n }\n\n public insertChild(parentId: string | undefined, child: T, offset: number) {\n const existingChildren = this.getChildren(parentId, true)!;\n existingChildren.insert(offset, child.id);\n this._idToNode[child.id] = child;\n }\n\n public setNodeId(\n parentId: string | undefined,\n index: number,\n newId: string\n ): boolean {\n const previousNodeId = this.getChildren(parentId)?.get(index);\n if (previousNodeId === undefined) {\n return false;\n }\n\n if (previousNodeId === newId) {\n return true;\n }\n\n if (this.getNode(newId) !== undefined) {\n return false;\n }\n\n this._idToNode[newId] = this._idToNode[previousNodeId];\n delete this._idToNode[previousNodeId];\n\n this._parentToChildren[newId] = this._parentToChildren[previousNodeId];\n delete this._parentToChildren[previousNodeId];\n\n if (parentId === undefined) {\n this._rootNodes.set(index, newId);\n } else {\n this._parentToChildren[parentId].set(index, newId);\n }\n\n return true;\n }\n\n public moveNode(\n sourceParentId: string | undefined,\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): void {\n const sourceNodeSiblings = this.getChildren(sourceParentId);\n assert(sourceNodeSiblings !== undefined);\n\n const sourceIndex = this.getChildOffset(sourceParentId, sourceNodeId);\n assert(sourceIndex !== undefined);\n\n sourceNodeSiblings.remove(sourceIndex);\n if (targetParentId === sourceParentId && targetIndex > sourceIndex) {\n targetIndex -= 1;\n }\n\n const targetNodeSiblings = this.getChildren(targetParentId, true);\n assert(targetNodeSiblings !== undefined);\n targetNodeSiblings.insert(targetIndex, sourceNodeId);\n }\n\n public setNumChildren(parentId: string | undefined, numChildren: number) {\n const children = this.getChildren(parentId, true)!;\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n\n children.setLength(numChildren);\n }\n\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const children = this.getChildren(parentId);\n if (children === undefined) return;\n\n if (typeof child === \"string\") {\n const childIndex = children.getIndex(child);\n if (childIndex !== undefined) {\n children.remove(childIndex);\n }\n\n this.deleteSubtree(child);\n } else {\n const childId = children.get(child);\n children.remove(child);\n if (childId !== undefined) {\n this.deleteSubtree(childId);\n }\n }\n }\n\n public deleteSubtree(\n parentId: string | undefined,\n deleteParent: boolean = true\n ) {\n const children = this.getChildren(parentId);\n if (children !== undefined) {\n for (const [childId] of children.iterateValues()) {\n this.deleteSubtree(childId);\n }\n }\n\n if (parentId === undefined) {\n this._rootNodes.setLength(0);\n return;\n }\n if (deleteParent) {\n delete this._idToNode[parentId];\n }\n delete this._parentToChildren[parentId];\n }\n}\n\n/**\n * Structure for sparse array value storage.\n * The main advantage of this class over the standard javascript array is that\n * this class does not need to check each index when iterating values that are\n * stored in the array.\n * @public\n * @deprecated in 5.28.0. Use Tree component from `@stratakit/structures` instead.\n */\nexport class SparseArray<T> implements Iterable<T | undefined> {\n public [immerable]: boolean;\n\n private _length = 0;\n private _array: Array<[T, number]> = [];\n\n constructor() {\n this[immerable] = true;\n }\n\n /** Returns length of array including intermediate 'undefined' values */\n public getLength(): number {\n return this._length;\n }\n\n /** Sets length of array. */\n public setLength(length: number) {\n const { index } = this.lowerBound(length);\n this._array.length = index;\n this._length = length;\n }\n\n /** Returns index of supplied value.\n *\n * @returns index of value or undefined if value is not found.\n */\n public getIndex(lookupValue: T): number | undefined {\n for (const [value, index] of this._array) {\n if (value === lookupValue) return index;\n }\n return undefined;\n }\n\n /** Returns value at specific position.\n *\n * @returns stored value or undefined.\n */\n public get(index: number): T | undefined {\n const { index: i, equal } = this.lowerBound(index);\n return equal ? this._array[i][0] : undefined;\n }\n\n /** Sets value at specific position. Overrides any existing value. */\n public set(index: number, value: T) {\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0, [value, index]);\n this._length = Math.max(this._length, index + 1);\n }\n\n /** Inserts value at specific position. Increases array length by one. */\n public insert(index: number, value: T) {\n const { index: i } = this.lowerBound(index);\n this._array.splice(i, 0, [value, index]);\n\n for (let j = i + 1; j < this._array.length; j++) {\n this._array[j][1]++;\n }\n\n this._length = Math.max(this._length + 1, index + 1);\n }\n\n /** Removes value at specified index and reduces array length by one. */\n public remove(index: number): void {\n if (index >= this._length) {\n return;\n }\n\n const { index: i, equal } = this.lowerBound(index);\n this._array.splice(i, equal ? 1 : 0);\n\n for (let j = i; j < this._array.length; j++) {\n this._array[j][1]--;\n }\n\n this._length = Math.max(0, this._length - 1);\n }\n\n /**\n * Iterates values that are stored in the array\n * @returns `[value, index]` tuples.\n */\n public iterateValues(): IterableIterator<[T, number]> {\n return this._array[Symbol.iterator]();\n }\n\n /** Iterates the array with all intermediate `undefined` values */\n public [Symbol.iterator](): IterableIterator<T | undefined> {\n const array = this._array;\n const length = this._length;\n return (function* () {\n let currentIndex = 0;\n for (const [value, index] of array) {\n for (; currentIndex < index; ++currentIndex) {\n yield undefined;\n }\n\n yield value;\n ++currentIndex;\n }\n\n for (; currentIndex < length; ++currentIndex) {\n yield undefined;\n }\n })();\n }\n\n private lowerBound(index: number): {\n index: number;\n equal: boolean;\n } {\n return lowerBound(index, this._array, SparseArray.compare);\n }\n\n private static compare<T>(index: number, value: [T, number]): number {\n return compareNumbers(index, value[1]);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeModelMutator.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,iCAAiC,CAAU;gBAGjD,WAAW,EAAE,eAAe,EAC5B,UAAU,EAAE,eAAe,EAC3B,gCAAgC,EAAE,OAAO;IAO3C,IAAW,WAAW,oBAErB;IAEM,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAsB1D,YAAY,CAAC,MAAM,EAAE,MAAM;IAc3B,eAAe,CACpB,aAAa,EAAE,YAAY,EAAE,EAC7B,eAAe,EAAE,YAAY,EAAE;IAmB1B,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE;IAe9C,kBAAkB;IAQlB,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,EAAE;IAWrD,eAAe,CACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;IAY3D,OAAO,CAAC,qBAAqB;CAmB9B"}
1
+ {"version":3,"file":"TreeModelMutator.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,iCAAiC,CAAU;gBAGjD,WAAW,EAAE,eAAe,EAC5B,UAAU,EAAE,eAAe,EAC3B,gCAAgC,EAAE,OAAO;IAO3C,IAAW,WAAW,oBAErB;IAEM,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,kBAAkB,CAAC;IAsB1D,YAAY,CAAC,MAAM,EAAE,MAAM;IAc3B,eAAe,CACpB,aAAa,EAAE,YAAY,EAAE,EAC7B,eAAe,EAAE,YAAY,EAAE;IAmB1B,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE;IAe9C,kBAAkB;IAQlB,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,EAAE;IAWrD,eAAe,CACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;IAY3D,OAAO,CAAC,qBAAqB;CAmB9B"}
@@ -5,6 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module Tree
7
7
  */
8
+ /* eslint-disable @typescript-eslint/no-deprecated */
8
9
  import { EMPTY } from "rxjs";
9
10
  /**
10
11
  * Provides basic tree manipulation implementation for various cases like
@@ -1 +1 @@
1
- {"version":3,"file":"TreeModelMutator.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAQ7B;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACnB,YAAY,CAAkB;IAC9B,WAAW,CAAkB;IAC7B,iCAAiC,CAAU;IAEnD,YACE,WAA4B,EAC5B,UAA2B,EAC3B,gCAAyC;QAEzC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,iCAAiC,GAAG,gCAAgC,CAAC;IAC5E,CAAC;IAED,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAEM,UAAU,CAAC,MAAc;QAC9B,IAAI,kBAAkB,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC1C,OAAO;YACT,CAAC;YAED,kBAAkB,GAAG,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC;YAEpD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,kBAAkB,EAAE,CAAC;gBACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACxB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClE,OAAO,kBAAkB,IAAI,YAAY;YACvC,CA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,OAAO,CAAC,MAAM,CAAC,CAAC;YACnC,IAAI,CAAC,IAAI;gBAAE,OAAO;YAElB,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAClE,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,qBAAqB,CAC3B,MAAc,EACd,QAAyD;QAEzD,MAAM,YAAY,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACnC,IAAI,CAAC,IAAI;oBAAE,OAAO;gBAClB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,IAAmB,EAAE,QAAgB,EAAE,EAAE;YAChE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzB,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { EMPTY } from \"rxjs\";\nimport type { TreeNodeItem } from \"../../TreeDataProvider.js\";\nimport type { Observable } from \"../Observable.js\";\nimport type { CheckboxStateChange } from \"../TreeEvents.js\";\nimport type { TreeModelNode, TreeModelNodeEditingInfo } from \"../TreeModel.js\";\nimport type { TreeModelSource } from \"../TreeModelSource.js\";\nimport type { ITreeNodeLoader, TreeNodeLoadResult } from \"../TreeNodeLoader.js\";\n\n/**\n * Provides basic tree manipulation implementation for various cases like\n * expand/collapse node, modify/replace/clear selection. It is used by default\n * tree event handler to modify model when events occur.\n * @internal\n */\nexport class TreeModelMutator {\n private _modelSource: TreeModelSource;\n private _nodeLoader: ITreeNodeLoader;\n private _collapsedChildrenDisposalEnabled: boolean;\n\n constructor(\n modelSource: TreeModelSource,\n nodeLoader: ITreeNodeLoader,\n collapsedChildrenDisposalEnabled: boolean\n ) {\n this._modelSource = modelSource;\n this._nodeLoader = nodeLoader;\n this._collapsedChildrenDisposalEnabled = collapsedChildrenDisposalEnabled;\n }\n\n public get modelSource() {\n return this._modelSource;\n }\n\n public expandNode(nodeId: string): Observable<TreeNodeLoadResult> {\n let needToLoadChildren = false;\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || node.isExpanded) {\n return;\n }\n\n needToLoadChildren = node.numChildren === undefined;\n\n node.isExpanded = true;\n if (needToLoadChildren) {\n node.isLoading = true;\n }\n });\n\n const expandedNode = this._modelSource.getModel().getNode(nodeId);\n return needToLoadChildren && expandedNode\n ? this._nodeLoader.loadNode(expandedNode, 0)\n : EMPTY;\n }\n\n public collapseNode(nodeId: string) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || !node.isExpanded) {\n return;\n }\n\n node.isExpanded = false;\n if (this._collapsedChildrenDisposalEnabled) {\n model.clearChildren(node.id);\n }\n });\n }\n\n public modifySelection(\n nodesToSelect: TreeNodeItem[],\n nodesToDeselect: TreeNodeItem[]\n ) {\n this._modelSource.modifyModel((model) => {\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n\n for (const nodeItem of nodesToDeselect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = false;\n }\n }\n });\n }\n\n public replaceSelection(nodesToSelect: TreeNodeItem[]) {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n });\n }\n\n public clearNodeSelection() {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n });\n }\n\n public setCheckboxStates(stateChanges: CheckboxStateChange[]) {\n this._modelSource.modifyModel((model) => {\n for (const { nodeItem, newState } of stateChanges) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.checkbox.state = newState;\n }\n }\n });\n }\n\n public activateEditing(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (!node) return;\n\n if (node.item.isEditable) {\n node.editingInfo = this.createNodeEditingInfo(nodeId, onCommit);\n }\n });\n }\n\n private createNodeEditingInfo(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ): TreeModelNodeEditingInfo {\n const closeEditing = () => {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (!node) return;\n node.editingInfo = undefined;\n });\n };\n\n const onEditCommitted = (node: TreeModelNode, newValue: string) => {\n onCommit(node, newValue);\n closeEditing();\n };\n\n return { onCommit: onEditCommitted, onCancel: closeEditing };\n }\n}\n"]}
1
+ {"version":3,"file":"TreeModelMutator.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeModelMutator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,qDAAqD;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAQ7B;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACnB,YAAY,CAAkB;IAC9B,WAAW,CAAkB;IAC7B,iCAAiC,CAAU;IAEnD,YACE,WAA4B,EAC5B,UAA2B,EAC3B,gCAAyC;QAEzC,IAAI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EAAE;gBACtC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACnC,IAAI,CAAC,IAAI;oBAAE,OAAO;gBAClB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,IAAmB,EAAE,QAAgB,EAAE,EAAE;YAChE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACzB,YAAY,EAAE,CAAC;QACjB,CAAC,CAAC;QAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAC/D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport { EMPTY } from \"rxjs\";\nimport type { TreeNodeItem } from \"../../TreeDataProvider.js\";\nimport type { Observable } from \"../Observable.js\";\nimport type { CheckboxStateChange } from \"../TreeEvents.js\";\nimport type { TreeModelNode, TreeModelNodeEditingInfo } from \"../TreeModel.js\";\nimport type { TreeModelSource } from \"../TreeModelSource.js\";\nimport type { ITreeNodeLoader, TreeNodeLoadResult } from \"../TreeNodeLoader.js\";\n\n/**\n * Provides basic tree manipulation implementation for various cases like\n * expand/collapse node, modify/replace/clear selection. It is used by default\n * tree event handler to modify model when events occur.\n * @internal\n */\nexport class TreeModelMutator {\n private _modelSource: TreeModelSource;\n private _nodeLoader: ITreeNodeLoader;\n private _collapsedChildrenDisposalEnabled: boolean;\n\n constructor(\n modelSource: TreeModelSource,\n nodeLoader: ITreeNodeLoader,\n collapsedChildrenDisposalEnabled: boolean\n ) {\n this._modelSource = modelSource;\n this._nodeLoader = nodeLoader;\n this._collapsedChildrenDisposalEnabled = collapsedChildrenDisposalEnabled;\n }\n\n public get modelSource() {\n return this._modelSource;\n }\n\n public expandNode(nodeId: string): Observable<TreeNodeLoadResult> {\n let needToLoadChildren = false;\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || node.isExpanded) {\n return;\n }\n\n needToLoadChildren = node.numChildren === undefined;\n\n node.isExpanded = true;\n if (needToLoadChildren) {\n node.isLoading = true;\n }\n });\n\n const expandedNode = this._modelSource.getModel().getNode(nodeId);\n return needToLoadChildren && expandedNode\n ? this._nodeLoader.loadNode(expandedNode, 0)\n : EMPTY;\n }\n\n public collapseNode(nodeId: string) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (node === undefined || !node.isExpanded) {\n return;\n }\n\n node.isExpanded = false;\n if (this._collapsedChildrenDisposalEnabled) {\n model.clearChildren(node.id);\n }\n });\n }\n\n public modifySelection(\n nodesToSelect: TreeNodeItem[],\n nodesToDeselect: TreeNodeItem[]\n ) {\n this._modelSource.modifyModel((model) => {\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n\n for (const nodeItem of nodesToDeselect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = false;\n }\n }\n });\n }\n\n public replaceSelection(nodesToSelect: TreeNodeItem[]) {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n\n for (const nodeItem of nodesToSelect) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.isSelected = true;\n }\n }\n });\n }\n\n public clearNodeSelection() {\n this._modelSource.modifyModel((model) => {\n for (const node of model.iterateTreeModelNodes()) {\n node.isSelected = false;\n }\n });\n }\n\n public setCheckboxStates(stateChanges: CheckboxStateChange[]) {\n this._modelSource.modifyModel((model) => {\n for (const { nodeItem, newState } of stateChanges) {\n const node = model.getNode(nodeItem.id);\n if (node !== undefined) {\n node.checkbox.state = newState;\n }\n }\n });\n }\n\n public activateEditing(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ) {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (!node) return;\n\n if (node.item.isEditable) {\n node.editingInfo = this.createNodeEditingInfo(nodeId, onCommit);\n }\n });\n }\n\n private createNodeEditingInfo(\n nodeId: string,\n onCommit: (node: TreeModelNode, newValue: string) => void\n ): TreeModelNodeEditingInfo {\n const closeEditing = () => {\n this._modelSource.modifyModel((model) => {\n const node = model.getNode(nodeId);\n if (!node) return;\n node.editingInfo = undefined;\n });\n };\n\n const onEditCommitted = (node: TreeModelNode, newValue: string) => {\n onCommit(node, newValue);\n closeEditing();\n };\n\n return { onCommit: onEditCommitted, onCancel: closeEditing };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeSelectionManager.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAUhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIvE,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,mBAAmB,GAAG,cAAc,CAAC;CACvD;AAED,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,mBAAmB,GAAG,cAAc,CAAC;IACpD,eAAe,EAAE,mBAAmB,CAAC;CACtC;AAED,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;CAC1D;AAED,gBAAgB;AAChB,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAC;AAE3C,gBAAgB;AAChB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,gBAAgB;AAChB,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI,cAAc,CAM5E;AAED,gBAAgB;AAChB,qBAAa,oBACX,YACE,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;IAE5E,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,uBAAuB,CAAC,CAAsC;IACtE,OAAO,CAAC,aAAa,CAA+C;IAEpE,OAAO,CAAC,gBAAgB,CAAyB;IAE1C,kBAAkB,wCAA+C;IACjE,mBAAmB,uCAA8C;IACjE,eAAe,qCAA4C;gBAGhE,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,MAAM,gBAAgB;IAoEzC,OAAO,CAAC,qBAAqB;IAQtB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU;IAOrD,eAAe,CAAC,MAAM,EAAE,MAAM;IAoB9B,eAAe,CAAC,MAAM,EAAE,MAAM;IAIrC,OAAO,CAAC,uBAAuB;IAgDxB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAIrE,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAI1E,OAAO,CAAC,gBAAgB,CA6DtB;CACH"}
1
+ {"version":3,"file":"TreeSelectionManager.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC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