@itwin/components-react 4.5.0 → 4.6.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 (188) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/components-react/common/DelayedSpinner.js +3 -2
  3. package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
  4. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +2 -1
  5. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  6. package/lib/cjs/components-react/converters/NumericTypeConverter.js +4 -2
  7. package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
  8. package/lib/cjs/components-react/converters/TypeConverter.js +2 -1
  9. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  10. package/lib/cjs/components-react/datepicker/DateField.js +1 -1
  11. package/lib/cjs/components-react/datepicker/DateField.js.map +1 -1
  12. package/lib/cjs/components-react/editors/CustomNumberEditor.js +8 -6
  13. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  14. package/lib/cjs/components-react/editors/DateTimeEditor.js +3 -2
  15. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  16. package/lib/cjs/components-react/editors/PopupButton.js +4 -3
  17. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  18. package/lib/cjs/components-react/editors/TextEditor.js +4 -2
  19. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  20. package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
  21. package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
  22. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  23. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  24. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  25. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  26. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  27. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  28. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +2 -2
  29. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  30. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  31. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  32. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  33. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  34. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +3 -2
  35. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  36. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  37. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  38. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +2 -1
  39. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  40. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +6 -3
  41. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  42. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +2 -1
  43. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  44. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  45. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  46. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  47. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  48. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  49. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  50. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  51. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  52. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  53. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  54. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +54 -48
  55. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  56. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  57. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  58. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  59. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  60. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  61. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  62. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  63. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  64. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  65. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  66. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  67. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  68. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  69. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  70. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  71. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  72. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +7 -5
  73. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  74. package/lib/cjs/components-react/selectable-content/SelectableContent.js +3 -2
  75. package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
  76. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js +6 -4
  77. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  78. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  79. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  80. package/lib/cjs/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  81. package/lib/cjs/components-react/tree/controlled/TreeHooks.js +7 -4
  82. package/lib/cjs/components-react/tree/controlled/TreeHooks.js.map +1 -1
  83. package/lib/cjs/components-react/tree/controlled/TreeModel.js +8 -7
  84. package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
  85. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  86. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  87. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +2 -1
  88. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  89. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +4 -2
  90. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  91. package/lib/esm/components-react/common/DelayedSpinner.js +3 -2
  92. package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
  93. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +2 -1
  94. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  95. package/lib/esm/components-react/converters/NumericTypeConverter.js +4 -2
  96. package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
  97. package/lib/esm/components-react/converters/TypeConverter.js +2 -1
  98. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  99. package/lib/esm/components-react/datepicker/DateField.js +1 -1
  100. package/lib/esm/components-react/datepicker/DateField.js.map +1 -1
  101. package/lib/esm/components-react/editors/CustomNumberEditor.js +8 -6
  102. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  103. package/lib/esm/components-react/editors/DateTimeEditor.js +3 -2
  104. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  105. package/lib/esm/components-react/editors/PopupButton.js +4 -3
  106. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  107. package/lib/esm/components-react/editors/TextEditor.js +4 -2
  108. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  109. package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
  110. package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
  111. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  112. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  113. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  114. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  115. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  116. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  117. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +2 -2
  118. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  119. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  120. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  121. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  122. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  123. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +3 -2
  124. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  125. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  126. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  127. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +2 -1
  128. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  129. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +6 -3
  130. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  131. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +2 -1
  132. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  133. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  134. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  135. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  136. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  137. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  138. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  139. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  140. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  141. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  142. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  143. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +54 -48
  144. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  145. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  146. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  147. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  148. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  149. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  150. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  151. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  152. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  153. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  154. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  155. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  156. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  157. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  158. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  159. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  160. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  161. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +7 -5
  162. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  163. package/lib/esm/components-react/selectable-content/SelectableContent.js +3 -2
  164. package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
  165. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js +6 -4
  166. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  167. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  168. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  169. package/lib/esm/components-react/tree/controlled/TreeHooks.d.ts.map +1 -1
  170. package/lib/esm/components-react/tree/controlled/TreeHooks.js +8 -5
  171. package/lib/esm/components-react/tree/controlled/TreeHooks.js.map +1 -1
  172. package/lib/esm/components-react/tree/controlled/TreeModel.js +8 -7
  173. package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
  174. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  175. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  176. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +2 -1
  177. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  178. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +4 -2
  179. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  180. package/package.json +4 -4
  181. package/lib/cjs/components-react/common/UseRerender.d.ts +0 -22
  182. package/lib/cjs/components-react/common/UseRerender.d.ts.map +0 -1
  183. package/lib/cjs/components-react/common/UseRerender.js +0 -36
  184. package/lib/cjs/components-react/common/UseRerender.js.map +0 -1
  185. package/lib/esm/components-react/common/UseRerender.d.ts +0 -22
  186. package/lib/esm/components-react/common/UseRerender.d.ts.map +0 -1
  187. package/lib/esm/components-react/common/UseRerender.js +0 -32
  188. package/lib/esm/components-react/common/UseRerender.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"InternalToolbarComponent.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/InternalToolbarComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB,4DAAo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;QAAE,OAAO,KAAK,CAAC;IACxB,uBAAuB;IACvB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;KAC3B;IACD,OAAO,IAAI,CAAC;AACd,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 Toolbar\n */\n\nimport \"./Toolbar.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ActionButton,\n CommonToolbarItem,\n CustomButtonDefinition,\n GroupButton,\n OnItemExecutedFunc,\n} from \"@itwin/appui-abstract\";\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n ToolbarItemUtilities,\n} from \"@itwin/appui-abstract\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\nimport { BadgeUtilities, Icon, IconHelper } from \"@itwin/core-react\";\nimport { ToolbarButtonItem } from \"./Item\";\nimport { ToolbarItems } from \"./Items\";\nimport { ItemWrapper, useResizeObserverSingleDimension } from \"./ItemWrapper\";\nimport { ToolbarOverflowButton } from \"./Overflow\";\nimport { ToolbarOverflowPanel } from \"./OverflowPanel\";\nimport { PopupItem } from \"./PopupItem\";\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\nimport { PopupItemWithDrag } from \"./PopupItemWithDrag\";\nimport {\n Direction,\n DirectionHelpers,\n OrthogonalDirection,\n OrthogonalDirectionHelpers,\n} from \"./utilities/Direction\";\nimport { UiComponents } from \"../UiComponents\";\nimport { SvgPlaceholder } from \"@itwin/itwinui-icons-react\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport { useConditionalSynchedItems } from \"./useConditionalSynchedItems\";\n\n/** Describes the data needed to insert a custom `React` button into an ToolbarWithOverflow.\n * @public\n * @deprecated in 4.0. Use [ToolbarCustomItem]($appui-react) instead.\n */\nexport interface CustomToolbarItem extends CustomButtonDefinition {\n /** defines the content to display in popup panel */\n panelContentNode?: React.ReactNode;\n /** If true the popup panel is mounted once and unmounted when button is unmounted. If false the\n * content node is unmounted each time the popup is closed. */\n keepContentsLoaded?: boolean;\n}\n\n/**\n * Context used by Toolbar items to know if popup panel should be hidden - via AutoHide.\n * @public\n */\nexport const ToolbarPopupAutoHideContext = React.createContext<boolean>(false);\n\n/**\n * React hook used to retrieve the ToolbarPopupAutoHideContext.\n * @public\n */\nexport function useToolbarPopupAutoHideContext() {\n return React.useContext(ToolbarPopupAutoHideContext);\n}\n\n/** Describes toolbar item.\n * @public\n * @deprecated in 4.0. Use [ToolbarItem]($appui-react) instead.\n */\nexport type ToolbarItem = ActionButton | GroupButton | CustomToolbarItem; // eslint-disable-line deprecation/deprecation\n\n/** CustomToolbarItem type guard.\n * @internal\n */\nexport function isCustomToolbarItem(\n // eslint-disable-next-line deprecation/deprecation\n item: ToolbarItem\n // eslint-disable-next-line deprecation/deprecation\n): item is CustomToolbarItem {\n return !!(item as CustomToolbarItem).isCustom && \"panelContentNode\" in item; // eslint-disable-line deprecation/deprecation\n}\n\n/** @internal */\nexport const getToolbarDirection = (\n expandsTo: Direction\n): OrthogonalDirection => {\n const orthogonalDirection =\n DirectionHelpers.getOrthogonalDirection(expandsTo);\n return OrthogonalDirectionHelpers.inverse(orthogonalDirection);\n};\n\n/** Available alignment modes of [[Toolbar]] panels.\n * @public\n */\nexport enum ToolbarPanelAlignment {\n Start,\n End,\n}\n\n/** Enumeration of Toolbar Opacity setting.\n * @public\n */\nexport enum ToolbarOpacitySetting {\n /** Use the default background, box-shadow opacity and backdrop-filter blur */\n Defaults,\n /** Alter the opacity from transparent to the defaults based on mouse proximity */\n Proximity,\n /** Use a transparent background, box-shadow opacity and backdrop-filter blur */\n Transparent,\n}\n\n/** Helpers for [[ToolbarPanelAlignment]].\n * @internal\n */\nexport class ToolbarPanelAlignmentHelpers {\n /** Class name of [[ToolbarPanelAlignment.Start]] */\n public static readonly START_CLASS_NAME = \"components-panel-alignment-start\";\n /** Class name of [[ToolbarPanelAlignment.End]] */\n public static readonly END_CLASS_NAME = \"components-panel-alignment-end\";\n\n /** @returns Class name of specified [[ToolbarPanelAlignment]] */\n public static getCssClassName(panelAlignment: ToolbarPanelAlignment): string {\n switch (panelAlignment) {\n case ToolbarPanelAlignment.Start:\n return ToolbarPanelAlignmentHelpers.START_CLASS_NAME;\n case ToolbarPanelAlignment.End:\n return ToolbarPanelAlignmentHelpers.END_CLASS_NAME;\n }\n }\n}\n\n/** @internal */\nexport interface ToolbarOverflowContextProps {\n readonly expandsTo: Direction;\n readonly direction: OrthogonalDirection;\n readonly overflowExpandsTo: Direction;\n readonly overflowDirection: OrthogonalDirection;\n readonly panelAlignment: ToolbarPanelAlignment;\n readonly useDragInteraction: boolean;\n readonly toolbarOpacitySetting: ToolbarOpacitySetting;\n readonly openPopupCount: number;\n readonly onPopupPanelOpenClose: (isOpening: boolean) => void;\n readonly overflowDisplayActive: boolean;\n readonly onItemExecuted: OnItemExecutedFunc;\n readonly onKeyDown: (e: React.KeyboardEvent) => void;\n}\n\n/**\n * Context used by Toolbar component to provide Direction to child components.\n * @internal\n */\nexport const ToolbarWithOverflowDirectionContext =\n React.createContext<ToolbarOverflowContextProps>({\n expandsTo: Direction.Bottom,\n direction: OrthogonalDirection.Horizontal,\n overflowExpandsTo: Direction.Right,\n overflowDirection: OrthogonalDirection.Vertical,\n panelAlignment: ToolbarPanelAlignment.Start,\n useDragInteraction: false,\n toolbarOpacitySetting: ToolbarOpacitySetting.Proximity,\n openPopupCount: 0,\n onPopupPanelOpenClose: /* istanbul ignore next */ (\n _isOpening: boolean\n ) => {},\n overflowDisplayActive: false,\n onItemExecuted: /* istanbul ignore next */ (_item: any) => void {},\n onKeyDown: /* istanbul ignore next */ (_e: React.KeyboardEvent) => void {},\n });\n\n/** @internal */\nfunction CustomItem({\n item,\n addGroupSeparator,\n}: {\n // eslint-disable-next-line deprecation/deprecation\n item: CustomToolbarItem;\n addGroupSeparator: boolean;\n}) {\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\n const icon = React.useMemo(\n () =>\n (item.icon &&\n IconHelper.getIconReactNode(item.icon, item.internalData)) || (\n // istanbul ignore next\n <Icon className=\"icon\" iconSpec={<SvgPlaceholder />} />\n ),\n [item.icon, item.internalData]\n );\n const isDisabled = React.useMemo(\n () => ConditionalBooleanValue.getValue(item.isDisabled),\n [item.isDisabled]\n );\n const title = React.useMemo(\n () =>\n /* istanbul ignore next */ ConditionalStringValue.getValue(item.label) ??\n item.id,\n [item.id, item.label]\n );\n const badge = React.useMemo(\n () => BadgeUtilities.getComponentForBadgeType(item.badgeType),\n [item.badgeType]\n );\n\n return (\n <PopupItem\n key={item.id}\n itemId={item.id}\n icon={icon}\n isDisabled={isDisabled}\n title={title}\n panel={item.panelContentNode}\n hideIndicator={useDragInteraction}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n keepContentsMounted={item.keepContentsLoaded}\n />\n );\n}\n\n/** @internal */\nfunction GroupPopupItem({\n item,\n addGroupSeparator,\n}: {\n item: GroupButton;\n addGroupSeparator: boolean;\n}) {\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\n const title = ConditionalStringValue.getValue(item.label)!;\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\n const panel = React.useMemo(\n () => <PopupItemsPanel groupItem={item} activateOnPointerUp={false} />,\n [item]\n );\n // istanbul ignore next\n const providerId =\n \"providerId\" in item ? (item.providerId as string) : undefined;\n if (useDragInteraction) {\n return (\n <PopupItemWithDrag\n key={item.id}\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n groupItem={item}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n />\n );\n }\n return (\n <PopupItem\n key={item.id}\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n panel={panel}\n badge={badge}\n hideIndicator={useDragInteraction}\n addGroupSeparator={addGroupSeparator}\n />\n );\n}\n\n/** @internal */\nfunction ActionItem({\n item,\n addGroupSeparator,\n}: {\n item: ActionButton;\n addGroupSeparator: boolean;\n}) {\n const title = ConditionalStringValue.getValue(item.label)!;\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\n const { onItemExecuted } = useToolbarWithOverflowDirectionContext();\n const onExecute = React.useCallback(() => {\n item.execute();\n onItemExecuted(item);\n }, [item, onItemExecuted]);\n\n // istanbul ignore next\n const providerId =\n \"providerId\" in item ? (item.providerId as string) : undefined;\n return (\n <ToolbarButtonItem\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n key={item.id}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isActive={item.isActive}\n onClick={onExecute}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n />\n );\n}\n\n/** @internal */\nexport function ToolbarItemComponent({\n item,\n addGroupSeparator,\n}: {\n // eslint-disable-next-line deprecation/deprecation\n item: ToolbarItem;\n addGroupSeparator: boolean;\n}) {\n if (ToolbarItemUtilities.isGroupButton(item)) {\n return <GroupPopupItem item={item} addGroupSeparator={addGroupSeparator} />;\n } else if (isCustomToolbarItem(item)) {\n return <CustomItem item={item} addGroupSeparator={addGroupSeparator} />;\n } else {\n // istanbul ignore else\n if (ToolbarItemUtilities.isActionButton(item)) {\n return <ActionItem item={item} addGroupSeparator={addGroupSeparator} />;\n }\n }\n // istanbul ignore next\n return null;\n}\n\n/** @internal */\nexport function useToolbarWithOverflowDirectionContext() {\n return React.useContext(ToolbarWithOverflowDirectionContext);\n}\n\nfunction OverflowItemsContainer(p: { children: React.ReactNode }) {\n return <>{p.children}</>;\n}\n\nfunction getItemWrapperClass(child: React.ReactNode) {\n // istanbul ignore else\n if (React.isValidElement(child)) {\n if (child.props && child.props.addGroupSeparator)\n return \"components-toolbar-button-add-gap-before\";\n }\n return undefined;\n}\n\n/**\n * Recursively looks through all items and groups and removes the hidden items\n * from the working object.\n * @param items List of object to analyse\n * @returns Copy of the provided items, minus the hidden ones.\n */\nfunction filterHiddenItems<T extends CommonToolbarItem>(\n items: ReadonlyArray<T>\n): T[] {\n return items\n .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))\n .map((i) => {\n if (\"items\" in i) {\n return { ...i, items: filterHiddenItems(i.items) };\n }\n return i;\n });\n}\n\n/** Properties of [[ToolbarComponent]] component.\n * @internal\n */\nexport interface InternalToolbarComponentProps\n extends CommonProps,\n NoChildrenProps {\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\n expandsTo?: Direction;\n /** Describes if items that do not fit available space should move to an expandable panel. Defaults to: false */\n enableOverflow?:\n | boolean\n | {\n /** Describes to which direction the overflow popup panels are expanded if overflow is enabled. Defaults to: [[Direction.Right]] */\n overflowExpandsTo?: Direction;\n };\n /** Definitions for items of the toolbar. Items are expected to be already sorted by group and item. */\n items: CommonToolbarItem[];\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\n panelAlignment?: ToolbarPanelAlignment;\n /** Use Drag Interaction to open popups with nest action buttons */\n useDragInteraction?: boolean;\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\n toolbarOpacitySetting?: ToolbarOpacitySetting;\n /** Optional function to call on any item execution */\n onItemExecuted?: OnItemExecutedFunc;\n /** Optional function to call on any KeyDown events processed by toolbar */\n onKeyDown?: (e: React.KeyboardEvent) => void;\n /** SyncEvents on which the conditional should listen to */\n syncUiEvent?: BeEvent<(args: { eventIds: Set<string> }) => void>;\n}\n\n/** Component that displays toolbar items.\n * @internal\n */\nexport function InternalToolbarComponent(props: InternalToolbarComponentProps) {\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\n const useDragInteraction = !!props.useDragInteraction;\n const panelAlignment = props.panelAlignment\n ? props.panelAlignment\n : ToolbarPanelAlignment.Start;\n const useHeight =\n expandsTo === Direction.Right || expandsTo === Direction.Left;\n const [isOverflowPanelOpen, setIsOverflowPanelOpen] = React.useState(false);\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\n const overflowTitle = React.useRef(\n UiComponents.translate(\"toolbar.overflow\")\n );\n const isMounted = React.useRef(false);\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\n // use setTimeout to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag\n setTimeout(() => {\n // istanbul ignore next\n if (!isMounted.current) return;\n setPopupPanelCount((prev) => {\n /* istanbul ignore next */\n const nextCount = isOpening ? prev + 1 : prev - 1;\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\n });\n });\n }, []);\n\n const width = React.useRef<number | undefined>(undefined);\n\n const eventSynchedItems = useConditionalSynchedItems(\n props.items,\n props.syncUiEvent\n );\n\n const availableNodes = React.useMemo<React.ReactNode>(() => {\n const filteredItems = filterHiddenItems(eventSynchedItems);\n return filteredItems.map((item, index) => {\n let addGroupSeparator = false;\n if (index > 0)\n addGroupSeparator =\n item.groupPriority !== filteredItems[index - 1].groupPriority;\n return (\n <ToolbarItemComponent\n key={item.id}\n item={item}\n addGroupSeparator={!!addGroupSeparator}\n />\n );\n });\n }, [eventSynchedItems]);\n /* overflowItemKeys - keys of items to show in overflow panel\n * handleContainerResize - handler called when container <div> is resized.\n * handleOverflowResize - handler called when determining size of overflow indicator/button.\n * handleEntryResize - handler called when determining size of each item/button. */\n const [\n overflowItemKeys,\n handleContainerResize,\n handleOverflowResize,\n handleEntryResize,\n ] = useOverflow(availableNodes, panelAlignment === ToolbarPanelAlignment.End);\n // handler called by ResizeObserver\n const handleResize = React.useCallback(\n (w: number) => {\n width.current = w;\n width.current !== undefined && handleContainerResize(width.current);\n },\n [handleContainerResize]\n );\n const resizeObserverRef = useResizeObserverSingleDimension(\n handleResize,\n useHeight\n );\n const handleClick = React.useCallback(() => {\n setIsOverflowPanelOpen((prev) => !prev);\n }, []);\n // istanbul ignore next - NEEDSWORK add complete tests\n const handleClose = React.useCallback(() => {\n setIsOverflowPanelOpen(false);\n }, []);\n\n // Not setting the ref will disable overflow management, but will keep proper refresh of items.\n const ref = props.enableOverflow ? resizeObserverRef : undefined;\n const availableItems = React.Children.toArray(availableNodes);\n const displayedItems = availableItems.reduce<\n Array<[string, React.ReactNode]>\n >((acc, child, index) => {\n const key = getChildKey(child, index);\n if (!overflowItemKeys || overflowItemKeys.indexOf(key) < 0) {\n acc.push([key, child]);\n }\n return acc;\n }, []);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const overflowPanelItems = overflowItemKeys\n ? availableItems.reduce<Array<[string, React.ReactNode]>>(\n (acc, child, index) => {\n const key = getChildKey(child, index);\n if (overflowItemKeys.indexOf(key) >= 0) {\n acc.push([key, child]);\n }\n return acc;\n },\n []\n )\n : [];\n\n const direction = getToolbarDirection(expandsTo);\n const overflowExpandsTo =\n (typeof props.enableOverflow !== \"boolean\" &&\n props.enableOverflow?.overflowExpandsTo) ||\n Direction.Right;\n const addOverflowButton = React.useCallback(\n (atStart: boolean) => {\n const overflowItems = !!atStart\n ? overflowPanelItems.reverse()\n : overflowPanelItems;\n return (\n <ToolbarItemContext.Provider\n value={{\n hasOverflow: false,\n useHeight,\n onResize: handleOverflowResize,\n }}\n >\n <ToolbarOverflowButton\n expandsTo={expandsTo}\n onClick={handleClick}\n onClose={handleClose}\n open={overflowItems.length > 0 && isOverflowPanelOpen}\n panelNode={\n <ToolbarOverflowPanel>\n <OverflowItemsContainer>\n {overflowItems.map(([key, child]) => {\n return (\n <ToolbarItemContext.Provider\n key={key}\n value={{\n hasOverflow: true,\n useHeight,\n onResize: () => {},\n }}\n >\n {\n <ItemWrapper className={getItemWrapperClass(child)}>\n {child}\n </ItemWrapper>\n }\n </ToolbarItemContext.Provider>\n );\n })}\n </OverflowItemsContainer>\n </ToolbarOverflowPanel>\n }\n title={overflowTitle.current}\n />\n </ToolbarItemContext.Provider>\n );\n },\n [\n handleClick,\n handleClose,\n handleOverflowResize,\n isOverflowPanelOpen,\n expandsTo,\n overflowPanelItems,\n useHeight,\n ]\n );\n\n const className = classnames(\n \"components-toolbar-overflow-sizer\",\n OrthogonalDirectionHelpers.getCssClassName(direction),\n props.className\n );\n\n const showOverflowAtStart =\n direction === OrthogonalDirection.Horizontal &&\n panelAlignment === ToolbarPanelAlignment.End;\n /* The ItemWrapper is used to wrap the <Item> <ExpandableItem> with a <div> that specifies a ref that the sizing logic uses to determine the\n size of the item. */\n return (\n <ToolbarWithOverflowDirectionContext.Provider\n value={{\n expandsTo,\n direction,\n overflowExpandsTo,\n panelAlignment,\n useDragInteraction,\n toolbarOpacitySetting:\n undefined !== props.toolbarOpacitySetting\n ? props.toolbarOpacitySetting\n : ToolbarOpacitySetting.Proximity,\n overflowDirection:\n direction === OrthogonalDirection.Horizontal\n ? OrthogonalDirection.Vertical\n : OrthogonalDirection.Horizontal,\n openPopupCount: popupPanelCount,\n onPopupPanelOpenClose: handlePopupPanelOpenClose,\n overflowDisplayActive:\n overflowPanelItems.length > 0 && isOverflowPanelOpen,\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : () => {},\n onKeyDown: props.onKeyDown\n ? props.onKeyDown\n : /* istanbul ignore next */ (_e: React.KeyboardEvent) => {},\n }}\n >\n {availableItems.length > 0 && (\n <div\n className={className}\n ref={ref}\n style={props.style}\n onKeyDown={props.onKeyDown}\n role=\"presentation\"\n >\n <ToolbarItems className=\"components-items\" direction={direction}>\n {props.enableOverflow &&\n (!overflowItemKeys || overflowItemKeys.length > 0) &&\n showOverflowAtStart &&\n addOverflowButton(true)}\n {displayedItems.map(([key, child]) => {\n const onEntryResize = handleEntryResize(key);\n return (\n <ToolbarItemContext.Provider\n key={key}\n value={{\n hasOverflow: false,\n useHeight,\n onResize: onEntryResize,\n }}\n >\n <ItemWrapper className={getItemWrapperClass(child)}>\n {child}\n </ItemWrapper>\n </ToolbarItemContext.Provider>\n );\n })}\n {props.enableOverflow &&\n (!overflowItemKeys || overflowItemKeys.length > 0) &&\n !showOverflowAtStart &&\n addOverflowButton(false)}\n </ToolbarItems>\n </div>\n )}\n </ToolbarWithOverflowDirectionContext.Provider>\n );\n}\n\n/** Returns key of a child. Must be used along with React.Children.toArray to preserve the semantics of availableItems.\n * @internal\n */\nfunction getChildKey(child: React.ReactNode, index: number) {\n // istanbul ignore else\n if (React.isValidElement(child) && child.key !== null) {\n return child.key.toString();\n }\n // istanbul ignore next\n return index.toString();\n}\n\n/** Returns a subset of toolbar item entry keys that exceed given width and should be overflowItemKeys.\n * @internal\n */\nfunction determineOverflowItems(\n size: number,\n entries: ReadonlyArray<readonly [string, number]>,\n overflowButtonSize: number,\n overflowButtonAtStart: boolean\n): string[] {\n let toolbarSize = 0;\n const buttonPadding = 2;\n if (overflowButtonAtStart && entries.length > 0) {\n let i = entries.length - 1;\n for (; i >= 0; i--) {\n const w = entries[i][1] + buttonPadding;\n const newSettingsWidth = toolbarSize + w;\n if (newSettingsWidth > size) {\n toolbarSize += overflowButtonSize + buttonPadding;\n break;\n }\n toolbarSize = newSettingsWidth;\n }\n if (i >= 0) {\n let j = i + 1;\n for (; j < entries.length; j++) {\n if (toolbarSize <= size) break;\n const w = entries[j][1] + buttonPadding;\n toolbarSize -= w;\n }\n\n return entries.slice(0, j).map((e) => e[0]);\n } else {\n return [];\n }\n } else {\n let i = 0;\n for (; i < entries.length; i++) {\n const w = entries[i][1] + buttonPadding;\n const newSettingsWidth = toolbarSize + w;\n if (newSettingsWidth > size) {\n toolbarSize += overflowButtonSize + buttonPadding;\n break;\n }\n toolbarSize = newSettingsWidth;\n }\n let j = i;\n for (; j > 0; j--) {\n if (toolbarSize <= size) break;\n const w = entries[j][1] + buttonPadding;\n toolbarSize -= w;\n }\n\n return entries.slice(j).map((e) => e[0]);\n }\n}\n\n/** Hook that returns a list of overflowItemKeys availableItems.\n * @internal\n */\nfunction useOverflow(\n availableItems: React.ReactNode,\n overflowButtonAtStart: boolean\n): [\n ReadonlyArray<string> | undefined,\n (size: number) => void,\n (size: number) => void,\n (key: string) => (size: number) => void\n] {\n const [overflowItemKeys, setOverflown] =\n React.useState<ReadonlyArray<string>>();\n const itemSizes = React.useRef(new Map<string, number | undefined>());\n const size = React.useRef<number | undefined>(undefined);\n const overflowButtonSize = React.useRef<number | undefined>(undefined);\n\n const calculateOverflow = React.useCallback(() => {\n const sizes = verifiedMapEntries(itemSizes.current);\n if (\n size.current === undefined ||\n sizes === undefined ||\n overflowButtonSize.current === undefined\n ) {\n setOverflown(undefined);\n return;\n }\n\n // Calculate overflow.\n const newOverflown = determineOverflowItems(\n size.current,\n [...sizes.entries()],\n overflowButtonSize.current,\n overflowButtonAtStart\n );\n setOverflown((prevOverflown) => {\n return eql(prevOverflown, newOverflown) ? prevOverflown : newOverflown;\n });\n }, [overflowButtonAtStart]);\n\n React.useLayoutEffect(() => {\n const newEntryWidths = new Map<string, number | undefined>();\n const array = React.Children.toArray(availableItems);\n for (let i = 0; i < array.length; i++) {\n const child = array[i];\n const key = getChildKey(child, i);\n const lastW = itemSizes.current.get(key);\n newEntryWidths.set(key, lastW);\n }\n itemSizes.current = newEntryWidths;\n calculateOverflow();\n }, [availableItems, calculateOverflow]);\n\n const handleContainerResize = React.useCallback(\n (w: number) => {\n const calculate = size.current !== w;\n size.current = w;\n calculate && calculateOverflow();\n },\n [calculateOverflow]\n );\n\n const handleOverflowResize = React.useCallback(\n (w: number) => {\n const calculate = overflowButtonSize.current !== w;\n overflowButtonSize.current = w;\n calculate && calculateOverflow();\n },\n [calculateOverflow]\n );\n\n const handleEntryResize = React.useCallback(\n (key: string) => (w: number) => {\n const oldW = itemSizes.current.get(key);\n if (oldW !== w) {\n itemSizes.current.set(key, w);\n calculateOverflow();\n }\n },\n [calculateOverflow]\n );\n\n return [\n overflowItemKeys,\n handleContainerResize,\n handleOverflowResize,\n handleEntryResize,\n ];\n}\n\n/** Interface toolbars use to define context for its items.\n * @internal\n */\nexport interface ToolbarItemContextArgs {\n readonly hasOverflow: boolean;\n readonly useHeight: boolean;\n readonly onResize: (w: number) => void;\n}\n\n/** Interface toolbars use to define context for its items.\n * @internal\n */\nexport const ToolbarItemContext = React.createContext<ToolbarItemContextArgs>({\n hasOverflow: false,\n useHeight: false,\n onResize: () => {\n // intentionally do nothing by default.\n },\n});\n\n/** @internal */\nexport function useToolItemEntryContext() {\n return React.useContext(ToolbarItemContext);\n}\n\nfunction verifiedMapEntries<T>(map: Map<string, T | undefined>) {\n for (const [, val] of map) {\n // istanbul ignore next during unit testing\n if (val === undefined) return undefined;\n }\n return map as Map<string, T>;\n}\n\nfunction eql(prev: readonly string[] | undefined, value: readonly string[]) {\n if (!prev) return false;\n // istanbul ignore next\n if (prev.length !== value.length) return false;\n for (let i = 0; i < prev.length; i++) {\n const p = prev[i];\n const v = value[i];\n // istanbul ignore next\n if (p !== v) return false;\n }\n return true;\n}\n"]}
1
+ {"version":3,"file":"InternalToolbarComponent.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/InternalToolbarComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAAwB;AACxB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AAC,IAAmC,EAAE,KAAwB;IACxE,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,uBAAuB;IACvB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;KAC3B;IACD,OAAO,IAAI,CAAC;AACd,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 Toolbar\n */\n\nimport \"./Toolbar.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ActionButton,\n CommonToolbarItem,\n CustomButtonDefinition,\n GroupButton,\n OnItemExecutedFunc,\n} from \"@itwin/appui-abstract\";\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n ToolbarItemUtilities,\n} from \"@itwin/appui-abstract\";\nimport type { CommonProps, NoChildrenProps } from \"@itwin/core-react\";\nimport { BadgeUtilities, Icon, IconHelper } from \"@itwin/core-react\";\nimport { ToolbarButtonItem } from \"./Item\";\nimport { ToolbarItems } from \"./Items\";\nimport { ItemWrapper, useResizeObserverSingleDimension } from \"./ItemWrapper\";\nimport { ToolbarOverflowButton } from \"./Overflow\";\nimport { ToolbarOverflowPanel } from \"./OverflowPanel\";\nimport { PopupItem } from \"./PopupItem\";\nimport { PopupItemsPanel } from \"./PopupItemsPanel\";\nimport { PopupItemWithDrag } from \"./PopupItemWithDrag\";\nimport {\n Direction,\n DirectionHelpers,\n OrthogonalDirection,\n OrthogonalDirectionHelpers,\n} from \"./utilities/Direction\";\nimport { UiComponents } from \"../UiComponents\";\nimport { SvgPlaceholder } from \"@itwin/itwinui-icons-react\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport { useConditionalSynchedItems } from \"./useConditionalSynchedItems\";\n\n/** Describes the data needed to insert a custom `React` button into an ToolbarWithOverflow.\n * @public\n * @deprecated in 4.0. Use [ToolbarCustomItem]($appui-react) instead.\n */\nexport interface CustomToolbarItem extends CustomButtonDefinition {\n /** defines the content to display in popup panel */\n panelContentNode?: React.ReactNode;\n /** If true the popup panel is mounted once and unmounted when button is unmounted. If false the\n * content node is unmounted each time the popup is closed. */\n keepContentsLoaded?: boolean;\n}\n\n/**\n * Context used by Toolbar items to know if popup panel should be hidden - via AutoHide.\n * @public\n */\nexport const ToolbarPopupAutoHideContext = React.createContext<boolean>(false);\n\n/**\n * React hook used to retrieve the ToolbarPopupAutoHideContext.\n * @public\n */\nexport function useToolbarPopupAutoHideContext() {\n return React.useContext(ToolbarPopupAutoHideContext);\n}\n\n/** Describes toolbar item.\n * @public\n * @deprecated in 4.0. Use [ToolbarItem]($appui-react) instead.\n */\nexport type ToolbarItem = ActionButton | GroupButton | CustomToolbarItem; // eslint-disable-line deprecation/deprecation\n\n/** CustomToolbarItem type guard.\n * @internal\n */\nexport function isCustomToolbarItem(\n // eslint-disable-next-line deprecation/deprecation\n item: ToolbarItem\n // eslint-disable-next-line deprecation/deprecation\n): item is CustomToolbarItem {\n return !!(item as CustomToolbarItem).isCustom && \"panelContentNode\" in item; // eslint-disable-line deprecation/deprecation\n}\n\n/** @internal */\nexport const getToolbarDirection = (\n expandsTo: Direction\n): OrthogonalDirection => {\n const orthogonalDirection =\n DirectionHelpers.getOrthogonalDirection(expandsTo);\n return OrthogonalDirectionHelpers.inverse(orthogonalDirection);\n};\n\n/** Available alignment modes of [[Toolbar]] panels.\n * @public\n */\nexport enum ToolbarPanelAlignment {\n Start,\n End,\n}\n\n/** Enumeration of Toolbar Opacity setting.\n * @public\n */\nexport enum ToolbarOpacitySetting {\n /** Use the default background, box-shadow opacity and backdrop-filter blur */\n Defaults,\n /** Alter the opacity from transparent to the defaults based on mouse proximity */\n Proximity,\n /** Use a transparent background, box-shadow opacity and backdrop-filter blur */\n Transparent,\n}\n\n/** Helpers for [[ToolbarPanelAlignment]].\n * @internal\n */\nexport class ToolbarPanelAlignmentHelpers {\n /** Class name of [[ToolbarPanelAlignment.Start]] */\n public static readonly START_CLASS_NAME = \"components-panel-alignment-start\";\n /** Class name of [[ToolbarPanelAlignment.End]] */\n public static readonly END_CLASS_NAME = \"components-panel-alignment-end\";\n\n /** @returns Class name of specified [[ToolbarPanelAlignment]] */\n public static getCssClassName(panelAlignment: ToolbarPanelAlignment): string {\n switch (panelAlignment) {\n case ToolbarPanelAlignment.Start:\n return ToolbarPanelAlignmentHelpers.START_CLASS_NAME;\n case ToolbarPanelAlignment.End:\n return ToolbarPanelAlignmentHelpers.END_CLASS_NAME;\n }\n }\n}\n\n/** @internal */\nexport interface ToolbarOverflowContextProps {\n readonly expandsTo: Direction;\n readonly direction: OrthogonalDirection;\n readonly overflowExpandsTo: Direction;\n readonly overflowDirection: OrthogonalDirection;\n readonly panelAlignment: ToolbarPanelAlignment;\n readonly useDragInteraction: boolean;\n readonly toolbarOpacitySetting: ToolbarOpacitySetting;\n readonly openPopupCount: number;\n readonly onPopupPanelOpenClose: (isOpening: boolean) => void;\n readonly overflowDisplayActive: boolean;\n readonly onItemExecuted: OnItemExecutedFunc;\n readonly onKeyDown: (e: React.KeyboardEvent) => void;\n}\n\n/**\n * Context used by Toolbar component to provide Direction to child components.\n * @internal\n */\nexport const ToolbarWithOverflowDirectionContext =\n React.createContext<ToolbarOverflowContextProps>({\n expandsTo: Direction.Bottom,\n direction: OrthogonalDirection.Horizontal,\n overflowExpandsTo: Direction.Right,\n overflowDirection: OrthogonalDirection.Vertical,\n panelAlignment: ToolbarPanelAlignment.Start,\n useDragInteraction: false,\n toolbarOpacitySetting: ToolbarOpacitySetting.Proximity,\n openPopupCount: 0,\n onPopupPanelOpenClose: /* istanbul ignore next */ (\n _isOpening: boolean\n ) => {},\n overflowDisplayActive: false,\n onItemExecuted: /* istanbul ignore next */ (_item: any) => void {},\n onKeyDown: /* istanbul ignore next */ (_e: React.KeyboardEvent) => void {},\n });\n\n/** @internal */\nfunction CustomItem({\n item,\n addGroupSeparator,\n}: {\n // eslint-disable-next-line deprecation/deprecation\n item: CustomToolbarItem;\n addGroupSeparator: boolean;\n}) {\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\n const icon = React.useMemo(\n () =>\n (item.icon &&\n IconHelper.getIconReactNode(item.icon, item.internalData)) || (\n // istanbul ignore next\n <Icon className=\"icon\" iconSpec={<SvgPlaceholder />} />\n ),\n [item.icon, item.internalData]\n );\n const isDisabled = React.useMemo(\n () => ConditionalBooleanValue.getValue(item.isDisabled),\n [item.isDisabled]\n );\n const title = React.useMemo(\n () =>\n /* istanbul ignore next */ ConditionalStringValue.getValue(item.label) ??\n item.id,\n [item.id, item.label]\n );\n const badge = React.useMemo(\n () => BadgeUtilities.getComponentForBadgeType(item.badgeType),\n [item.badgeType]\n );\n\n return (\n <PopupItem\n key={item.id}\n itemId={item.id}\n icon={icon}\n isDisabled={isDisabled}\n title={title}\n panel={item.panelContentNode}\n hideIndicator={useDragInteraction}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n keepContentsMounted={item.keepContentsLoaded}\n />\n );\n}\n\n/** @internal */\nfunction GroupPopupItem({\n item,\n addGroupSeparator,\n}: {\n item: GroupButton;\n addGroupSeparator: boolean;\n}) {\n const { useDragInteraction } = useToolbarWithOverflowDirectionContext();\n const title = ConditionalStringValue.getValue(item.label)!;\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\n const panel = React.useMemo(\n () => <PopupItemsPanel groupItem={item} activateOnPointerUp={false} />,\n [item]\n );\n // istanbul ignore next\n const providerId =\n \"providerId\" in item ? (item.providerId as string) : undefined;\n if (useDragInteraction) {\n return (\n <PopupItemWithDrag\n key={item.id}\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n groupItem={item}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n />\n );\n }\n return (\n <PopupItem\n key={item.id}\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n panel={panel}\n badge={badge}\n hideIndicator={useDragInteraction}\n addGroupSeparator={addGroupSeparator}\n />\n );\n}\n\n/** @internal */\nfunction ActionItem({\n item,\n addGroupSeparator,\n}: {\n item: ActionButton;\n addGroupSeparator: boolean;\n}) {\n const title = ConditionalStringValue.getValue(item.label)!;\n const badge = BadgeUtilities.getComponentForBadgeType(item.badgeType);\n const { onItemExecuted } = useToolbarWithOverflowDirectionContext();\n const onExecute = React.useCallback(() => {\n item.execute();\n onItemExecuted(item);\n }, [item, onItemExecuted]);\n\n // istanbul ignore next\n const providerId =\n \"providerId\" in item ? (item.providerId as string) : undefined;\n return (\n <ToolbarButtonItem\n itemId={item.id}\n providerId={providerId}\n itemPriority={item.itemPriority}\n groupPriority={item.groupPriority}\n key={item.id}\n isDisabled={ConditionalBooleanValue.getValue(item.isDisabled)}\n title={title}\n icon={IconHelper.getIconReactNode(item.icon, item.internalData)}\n isActive={item.isActive}\n onClick={onExecute}\n badge={badge}\n addGroupSeparator={addGroupSeparator}\n />\n );\n}\n\n/** @internal */\nexport function ToolbarItemComponent({\n item,\n addGroupSeparator,\n}: {\n // eslint-disable-next-line deprecation/deprecation\n item: ToolbarItem;\n addGroupSeparator: boolean;\n}) {\n if (ToolbarItemUtilities.isGroupButton(item)) {\n return <GroupPopupItem item={item} addGroupSeparator={addGroupSeparator} />;\n } else if (isCustomToolbarItem(item)) {\n return <CustomItem item={item} addGroupSeparator={addGroupSeparator} />;\n } else {\n // istanbul ignore else\n if (ToolbarItemUtilities.isActionButton(item)) {\n return <ActionItem item={item} addGroupSeparator={addGroupSeparator} />;\n }\n }\n // istanbul ignore next\n return null;\n}\n\n/** @internal */\nexport function useToolbarWithOverflowDirectionContext() {\n return React.useContext(ToolbarWithOverflowDirectionContext);\n}\n\nfunction OverflowItemsContainer(p: { children: React.ReactNode }) {\n return <>{p.children}</>;\n}\n\nfunction getItemWrapperClass(child: React.ReactNode) {\n // istanbul ignore else\n if (React.isValidElement(child)) {\n if (child.props && child.props.addGroupSeparator)\n return \"components-toolbar-button-add-gap-before\";\n }\n return undefined;\n}\n\n/**\n * Recursively looks through all items and groups and removes the hidden items\n * from the working object.\n * @param items List of object to analyse\n * @returns Copy of the provided items, minus the hidden ones.\n */\nfunction filterHiddenItems<T extends CommonToolbarItem>(\n items: ReadonlyArray<T>\n): T[] {\n return items\n .filter((item) => !ConditionalBooleanValue.getValue(item.isHidden))\n .map((i) => {\n if (\"items\" in i) {\n return { ...i, items: filterHiddenItems(i.items) };\n }\n return i;\n });\n}\n\n/** Properties of [[ToolbarComponent]] component.\n * @internal\n */\nexport interface InternalToolbarComponentProps\n extends CommonProps,\n NoChildrenProps {\n /** Describes to which direction the popup panels are expanded. Defaults to: [[Direction.Bottom]] */\n expandsTo?: Direction;\n /** Describes if items that do not fit available space should move to an expandable panel. Defaults to: false */\n enableOverflow?:\n | boolean\n | {\n /** Describes to which direction the overflow popup panels are expanded if overflow is enabled. Defaults to: [[Direction.Right]] */\n overflowExpandsTo?: Direction;\n };\n /** Definitions for items of the toolbar. Items are expected to be already sorted by group and item. */\n items: CommonToolbarItem[];\n /** Describes how expanded panels are aligned. Defaults to: [[ToolbarPanelAlignment.Start]] */\n panelAlignment?: ToolbarPanelAlignment;\n /** Use Drag Interaction to open popups with nest action buttons */\n useDragInteraction?: boolean;\n /** Determines whether to use mouse proximity to alter the opacity of the toolbar */\n toolbarOpacitySetting?: ToolbarOpacitySetting;\n /** Optional function to call on any item execution */\n onItemExecuted?: OnItemExecutedFunc;\n /** Optional function to call on any KeyDown events processed by toolbar */\n onKeyDown?: (e: React.KeyboardEvent) => void;\n /** SyncEvents on which the conditional should listen to */\n syncUiEvent?: BeEvent<(args: { eventIds: Set<string> }) => void>;\n}\n\n/** Component that displays toolbar items.\n * @internal\n */\nexport function InternalToolbarComponent(props: InternalToolbarComponentProps) {\n const expandsTo = props.expandsTo ? props.expandsTo : Direction.Bottom;\n const useDragInteraction = !!props.useDragInteraction;\n const panelAlignment = props.panelAlignment\n ? props.panelAlignment\n : ToolbarPanelAlignment.Start;\n const useHeight =\n expandsTo === Direction.Right || expandsTo === Direction.Left;\n const [isOverflowPanelOpen, setIsOverflowPanelOpen] = React.useState(false);\n const [popupPanelCount, setPopupPanelCount] = React.useState(0);\n const overflowTitle = React.useRef(\n UiComponents.translate(\"toolbar.overflow\")\n );\n const isMounted = React.useRef(false);\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n const handlePopupPanelOpenClose = React.useCallback((isOpening: boolean) => {\n // use setTimeout to avoid warning about setting state in ToolbarWithOverflow from render method of PopupItem/PopupItemWithDrag\n setTimeout(() => {\n // istanbul ignore next\n if (!isMounted.current) return;\n setPopupPanelCount((prev) => {\n /* istanbul ignore next */\n const nextCount = isOpening ? prev + 1 : prev - 1;\n return nextCount < 0 ? /* istanbul ignore next */ 0 : nextCount;\n });\n });\n }, []);\n\n const width = React.useRef<number | undefined>(undefined);\n\n const eventSynchedItems = useConditionalSynchedItems(\n props.items,\n props.syncUiEvent\n );\n\n const availableNodes = React.useMemo<React.ReactNode>(() => {\n const filteredItems = filterHiddenItems(eventSynchedItems);\n return filteredItems.map((item, index) => {\n let addGroupSeparator = false;\n if (index > 0)\n addGroupSeparator =\n item.groupPriority !== filteredItems[index - 1].groupPriority;\n return (\n <ToolbarItemComponent\n key={item.id}\n item={item}\n addGroupSeparator={!!addGroupSeparator}\n />\n );\n });\n }, [eventSynchedItems]);\n /* overflowItemKeys - keys of items to show in overflow panel\n * handleContainerResize - handler called when container <div> is resized.\n * handleOverflowResize - handler called when determining size of overflow indicator/button.\n * handleEntryResize - handler called when determining size of each item/button. */\n const [\n overflowItemKeys,\n handleContainerResize,\n handleOverflowResize,\n handleEntryResize,\n ] = useOverflow(availableNodes, panelAlignment === ToolbarPanelAlignment.End);\n // handler called by ResizeObserver\n const handleResize = React.useCallback(\n (w: number) => {\n width.current = w;\n width.current !== undefined && handleContainerResize(width.current);\n },\n [handleContainerResize]\n );\n const resizeObserverRef = useResizeObserverSingleDimension(\n handleResize,\n useHeight\n );\n const handleClick = React.useCallback(() => {\n setIsOverflowPanelOpen((prev) => !prev);\n }, []);\n // istanbul ignore next - NEEDSWORK add complete tests\n const handleClose = React.useCallback(() => {\n setIsOverflowPanelOpen(false);\n }, []);\n\n // Not setting the ref will disable overflow management, but will keep proper refresh of items.\n const ref = props.enableOverflow ? resizeObserverRef : undefined;\n const availableItems = React.Children.toArray(availableNodes);\n const displayedItems = availableItems.reduce<\n Array<[string, React.ReactNode]>\n >((acc, child, index) => {\n const key = getChildKey(child, index);\n if (!overflowItemKeys || overflowItemKeys.indexOf(key) < 0) {\n acc.push([key, child]);\n }\n return acc;\n }, []);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const overflowPanelItems = overflowItemKeys\n ? availableItems.reduce<Array<[string, React.ReactNode]>>(\n (acc, child, index) => {\n const key = getChildKey(child, index);\n if (overflowItemKeys.indexOf(key) >= 0) {\n acc.push([key, child]);\n }\n return acc;\n },\n []\n )\n : [];\n\n const direction = getToolbarDirection(expandsTo);\n const overflowExpandsTo =\n (typeof props.enableOverflow !== \"boolean\" &&\n props.enableOverflow?.overflowExpandsTo) ||\n Direction.Right;\n const addOverflowButton = React.useCallback(\n (atStart: boolean) => {\n const overflowItems = !!atStart\n ? overflowPanelItems.reverse()\n : overflowPanelItems;\n return (\n <ToolbarItemContext.Provider\n value={{\n hasOverflow: false,\n useHeight,\n onResize: handleOverflowResize,\n }}\n >\n <ToolbarOverflowButton\n expandsTo={expandsTo}\n onClick={handleClick}\n onClose={handleClose}\n open={overflowItems.length > 0 && isOverflowPanelOpen}\n panelNode={\n <ToolbarOverflowPanel>\n <OverflowItemsContainer>\n {overflowItems.map(([key, child]) => {\n return (\n <ToolbarItemContext.Provider\n key={key}\n value={{\n hasOverflow: true,\n useHeight,\n onResize: () => {},\n }}\n >\n {\n <ItemWrapper className={getItemWrapperClass(child)}>\n {child}\n </ItemWrapper>\n }\n </ToolbarItemContext.Provider>\n );\n })}\n </OverflowItemsContainer>\n </ToolbarOverflowPanel>\n }\n title={overflowTitle.current}\n />\n </ToolbarItemContext.Provider>\n );\n },\n [\n handleClick,\n handleClose,\n handleOverflowResize,\n isOverflowPanelOpen,\n expandsTo,\n overflowPanelItems,\n useHeight,\n ]\n );\n\n const className = classnames(\n \"components-toolbar-overflow-sizer\",\n OrthogonalDirectionHelpers.getCssClassName(direction),\n props.className\n );\n\n const showOverflowAtStart =\n direction === OrthogonalDirection.Horizontal &&\n panelAlignment === ToolbarPanelAlignment.End;\n /* The ItemWrapper is used to wrap the <Item> <ExpandableItem> with a <div> that specifies a ref that the sizing logic uses to determine the\n size of the item. */\n return (\n <ToolbarWithOverflowDirectionContext.Provider\n value={{\n expandsTo,\n direction,\n overflowExpandsTo,\n panelAlignment,\n useDragInteraction,\n toolbarOpacitySetting:\n undefined !== props.toolbarOpacitySetting\n ? props.toolbarOpacitySetting\n : ToolbarOpacitySetting.Proximity,\n overflowDirection:\n direction === OrthogonalDirection.Horizontal\n ? OrthogonalDirection.Vertical\n : OrthogonalDirection.Horizontal,\n openPopupCount: popupPanelCount,\n onPopupPanelOpenClose: handlePopupPanelOpenClose,\n overflowDisplayActive:\n overflowPanelItems.length > 0 && isOverflowPanelOpen,\n onItemExecuted: props.onItemExecuted ? props.onItemExecuted : () => {},\n onKeyDown: props.onKeyDown\n ? props.onKeyDown\n : /* istanbul ignore next */ (_e: React.KeyboardEvent) => {},\n }}\n >\n {availableItems.length > 0 && (\n <div\n className={className}\n ref={ref}\n style={props.style}\n onKeyDown={props.onKeyDown}\n role=\"presentation\"\n >\n <ToolbarItems className=\"components-items\" direction={direction}>\n {props.enableOverflow &&\n (!overflowItemKeys || overflowItemKeys.length > 0) &&\n showOverflowAtStart &&\n addOverflowButton(true)}\n {displayedItems.map(([key, child]) => {\n const onEntryResize = handleEntryResize(key);\n return (\n <ToolbarItemContext.Provider\n key={key}\n value={{\n hasOverflow: false,\n useHeight,\n onResize: onEntryResize,\n }}\n >\n <ItemWrapper className={getItemWrapperClass(child)}>\n {child}\n </ItemWrapper>\n </ToolbarItemContext.Provider>\n );\n })}\n {props.enableOverflow &&\n (!overflowItemKeys || overflowItemKeys.length > 0) &&\n !showOverflowAtStart &&\n addOverflowButton(false)}\n </ToolbarItems>\n </div>\n )}\n </ToolbarWithOverflowDirectionContext.Provider>\n );\n}\n\n/** Returns key of a child. Must be used along with React.Children.toArray to preserve the semantics of availableItems.\n * @internal\n */\nfunction getChildKey(child: React.ReactNode, index: number) {\n // istanbul ignore else\n if (React.isValidElement(child) && child.key !== null) {\n return child.key.toString();\n }\n // istanbul ignore next\n return index.toString();\n}\n\n/** Returns a subset of toolbar item entry keys that exceed given width and should be overflowItemKeys.\n * @internal\n */\nfunction determineOverflowItems(\n size: number,\n entries: ReadonlyArray<readonly [string, number]>,\n overflowButtonSize: number,\n overflowButtonAtStart: boolean\n): string[] {\n let toolbarSize = 0;\n const buttonPadding = 2;\n if (overflowButtonAtStart && entries.length > 0) {\n let i = entries.length - 1;\n for (; i >= 0; i--) {\n const w = entries[i][1] + buttonPadding;\n const newSettingsWidth = toolbarSize + w;\n if (newSettingsWidth > size) {\n toolbarSize += overflowButtonSize + buttonPadding;\n break;\n }\n toolbarSize = newSettingsWidth;\n }\n if (i >= 0) {\n let j = i + 1;\n for (; j < entries.length; j++) {\n if (toolbarSize <= size) break;\n const w = entries[j][1] + buttonPadding;\n toolbarSize -= w;\n }\n\n return entries.slice(0, j).map((e) => e[0]);\n } else {\n return [];\n }\n } else {\n let i = 0;\n for (; i < entries.length; i++) {\n const w = entries[i][1] + buttonPadding;\n const newSettingsWidth = toolbarSize + w;\n if (newSettingsWidth > size) {\n toolbarSize += overflowButtonSize + buttonPadding;\n break;\n }\n toolbarSize = newSettingsWidth;\n }\n let j = i;\n for (; j > 0; j--) {\n if (toolbarSize <= size) break;\n const w = entries[j][1] + buttonPadding;\n toolbarSize -= w;\n }\n\n return entries.slice(j).map((e) => e[0]);\n }\n}\n\n/** Hook that returns a list of overflowItemKeys availableItems.\n * @internal\n */\nfunction useOverflow(\n availableItems: React.ReactNode,\n overflowButtonAtStart: boolean\n): [\n ReadonlyArray<string> | undefined,\n (size: number) => void,\n (size: number) => void,\n (key: string) => (size: number) => void\n] {\n const [overflowItemKeys, setOverflown] =\n React.useState<ReadonlyArray<string>>();\n const itemSizes = React.useRef(new Map<string, number | undefined>());\n const size = React.useRef<number | undefined>(undefined);\n const overflowButtonSize = React.useRef<number | undefined>(undefined);\n\n const calculateOverflow = React.useCallback(() => {\n const sizes = verifiedMapEntries(itemSizes.current);\n if (\n size.current === undefined ||\n sizes === undefined ||\n overflowButtonSize.current === undefined\n ) {\n setOverflown(undefined);\n return;\n }\n\n // Calculate overflow.\n const newOverflown = determineOverflowItems(\n size.current,\n [...sizes.entries()],\n overflowButtonSize.current,\n overflowButtonAtStart\n );\n setOverflown((prevOverflown) => {\n return eql(prevOverflown, newOverflown) ? prevOverflown : newOverflown;\n });\n }, [overflowButtonAtStart]);\n\n React.useLayoutEffect(() => {\n const newEntryWidths = new Map<string, number | undefined>();\n const array = React.Children.toArray(availableItems);\n for (let i = 0; i < array.length; i++) {\n const child = array[i];\n const key = getChildKey(child, i);\n const lastW = itemSizes.current.get(key);\n newEntryWidths.set(key, lastW);\n }\n itemSizes.current = newEntryWidths;\n calculateOverflow();\n }, [availableItems, calculateOverflow]);\n\n const handleContainerResize = React.useCallback(\n (w: number) => {\n const calculate = size.current !== w;\n size.current = w;\n calculate && calculateOverflow();\n },\n [calculateOverflow]\n );\n\n const handleOverflowResize = React.useCallback(\n (w: number) => {\n const calculate = overflowButtonSize.current !== w;\n overflowButtonSize.current = w;\n calculate && calculateOverflow();\n },\n [calculateOverflow]\n );\n\n const handleEntryResize = React.useCallback(\n (key: string) => (w: number) => {\n const oldW = itemSizes.current.get(key);\n if (oldW !== w) {\n itemSizes.current.set(key, w);\n calculateOverflow();\n }\n },\n [calculateOverflow]\n );\n\n return [\n overflowItemKeys,\n handleContainerResize,\n handleOverflowResize,\n handleEntryResize,\n ];\n}\n\n/** Interface toolbars use to define context for its items.\n * @internal\n */\nexport interface ToolbarItemContextArgs {\n readonly hasOverflow: boolean;\n readonly useHeight: boolean;\n readonly onResize: (w: number) => void;\n}\n\n/** Interface toolbars use to define context for its items.\n * @internal\n */\nexport const ToolbarItemContext = React.createContext<ToolbarItemContextArgs>({\n hasOverflow: false,\n useHeight: false,\n onResize: () => {\n // intentionally do nothing by default.\n },\n});\n\n/** @internal */\nexport function useToolItemEntryContext() {\n return React.useContext(ToolbarItemContext);\n}\n\nfunction verifiedMapEntries<T>(map: Map<string, T | undefined>) {\n for (const [, val] of map) {\n // istanbul ignore next during unit testing\n if (val === undefined) return undefined;\n }\n return map as Map<string, T>;\n}\n\nfunction eql(prev: readonly string[] | undefined, value: readonly string[]) {\n if (!prev) return false;\n // istanbul ignore next\n if (prev.length !== value.length) return false;\n for (let i = 0; i < prev.length; i++) {\n const p = prev[i];\n const v = value[i];\n // istanbul ignore next\n if (p !== v) return false;\n }\n return true;\n}\n"]}
@@ -72,9 +72,9 @@ function refreshItems(items, eventIds) {
72
72
  const childItems = refreshItems(updatedItem.items, eventIds);
73
73
  updatedItem = {
74
74
  ...updatedItem,
75
- items: childItems ?? updatedItem.items,
75
+ items: childItems !== null && childItems !== void 0 ? childItems : updatedItem.items,
76
76
  };
77
- itemsUpdated ||= !!childItems;
77
+ itemsUpdated || (itemsUpdated = !!childItems);
78
78
  }
79
79
  for (const [, entry] of Object.entries(updatedItem)) {
80
80
  if ((entry instanceof appui_abstract_1.ConditionalBooleanValue &&
@@ -100,15 +100,16 @@ function refreshItems(items, eventIds) {
100
100
  function useConditionalSynchedItems(items, syncUiEvent) {
101
101
  const [eventSynchedItems, setEventSynchedItems] = React.useState([]);
102
102
  React.useEffect(() => {
103
+ var _a;
103
104
  const ids = new Set();
104
105
  gatherSyncIds(ids, items);
105
- setEventSynchedItems(refreshItems(items, ids) ?? items);
106
+ setEventSynchedItems((_a = refreshItems(items, ids)) !== null && _a !== void 0 ? _a : items);
106
107
  const syncIdsOfInterest = [...ids.values()];
107
- return syncUiEvent?.addListener((args) => {
108
+ return syncUiEvent === null || syncUiEvent === void 0 ? void 0 : syncUiEvent.addListener((args) => {
108
109
  if (0 === syncIdsOfInterest.length)
109
110
  return;
110
111
  if (syncIdsOfInterest.some((value) => args.eventIds.has(value.toLowerCase()))) {
111
- setEventSynchedItems((current) => refreshItems(current, args.eventIds) ?? current);
112
+ setEventSynchedItems((current) => { var _a; return (_a = refreshItems(current, args.eventIds)) !== null && _a !== void 0 ? _a : current; });
112
113
  }
113
114
  });
114
115
  }, [syncUiEvent, items]);
@@ -1 +1 @@
1
- {"version":3,"file":"useConditionalSynchedItems.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/useConditionalSynchedItems.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,0DAG+B;AAE/B,kDAAwD;AACxD,6CAA+B;AAE/B;;;;;GAKG;AACH,SAAS,aAAa,CACpB,QAAqB,EACrB,KAAmB;IAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAA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,IACE,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAa,EAAW,EAAE,CAChD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACvC,EACD;gBACA,oBAAoB,CAClB,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,OAAO,CAC7D,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACzB,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AA3BD,gEA2BC","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 *--------------------------------------------------------------------------------------------*/\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport { ConditionalIconItem } from \"@itwin/core-react\";\nimport * as React from \"react\";\n\n/**\n * From a list of ToolbarItem, recursively return the list of syncIds\n * that are relevant to every Conditional members used in the items.\n * @param eventIds Set to fill with syncIds\n * @param items ToolbarItems list to search through\n */\nfunction gatherSyncIds<T extends {} | { items: T[] }>(\n eventIds: Set<string>,\n items: readonly T[]\n) {\n for (const item of items) {\n for (const [, entry] of Object.entries(item)) {\n if (entry instanceof ConditionalBooleanValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (entry instanceof ConditionalStringValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (ConditionalIconItem.isConditionalIconItem(entry)) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n if (\"items\" in item) {\n gatherSyncIds(eventIds, item.items);\n }\n }\n}\n\n/**\n * Refresh all conditional values interested by the provided eventIds.\n * @param items List of ToolbarItems that may content Conditional properties.\n * @param eventIds Set of triggered eventIds.\n * @returns null if no updates occurred, or the provided items with updated values if ANY were updated.\n */\nfunction refreshItems<T extends {} | { items: T[] }>(\n items: readonly T[],\n eventIds: Set<string>\n): T[] | null {\n if (0 === eventIds.size) return null;\n let itemsUpdated = false;\n const updatedItems: T[] = [];\n\n for (const item of items) {\n let updatedItem = { ...item };\n if (\"items\" in updatedItem) {\n const childItems = refreshItems(updatedItem.items, eventIds);\n updatedItem = {\n ...updatedItem,\n items: childItems ?? updatedItem.items,\n };\n itemsUpdated ||= !!childItems;\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (\n (entry instanceof ConditionalBooleanValue &&\n ConditionalBooleanValue.refreshValue(entry, eventIds)) ||\n (entry instanceof ConditionalStringValue &&\n ConditionalStringValue.refreshValue(entry, eventIds)) ||\n (ConditionalIconItem.isConditionalIconItem(entry) &&\n ConditionalIconItem.refreshValue(entry, eventIds))\n ) {\n itemsUpdated = true;\n }\n }\n updatedItems.push(updatedItem);\n }\n return itemsUpdated ? updatedItems : null;\n}\n\n/**\n * Register a listener on the syncUiEVent and updates all conditionals within the provided items.\n * @param items Items to keep up to date\n * @param syncUiEvent Event to attach to (because we don't depend on appui-react);\n * @returns Synched items\n * @internal\n */\nexport function useConditionalSynchedItems<T extends {} | { items: T[] }>(\n items: readonly T[],\n syncUiEvent: undefined | BeEvent<(args: { eventIds: Set<string> }) => void>\n) {\n const [eventSynchedItems, setEventSynchedItems] = React.useState<\n readonly T[]\n >([]);\n React.useEffect(() => {\n const ids = new Set<string>();\n gatherSyncIds(ids, items);\n setEventSynchedItems(refreshItems(items, ids) ?? items);\n const syncIdsOfInterest = [...ids.values()];\n return syncUiEvent?.addListener((args) => {\n if (0 === syncIdsOfInterest.length) return;\n\n if (\n syncIdsOfInterest.some((value: string): boolean =>\n args.eventIds.has(value.toLowerCase())\n )\n ) {\n setEventSynchedItems(\n (current) => refreshItems(current, args.eventIds) ?? current\n );\n }\n });\n }, [syncUiEvent, items]);\n return eventSynchedItems;\n}\n"]}
1
+ {"version":3,"file":"useConditionalSynchedItems.js","sourceRoot":"","sources":["../../../../src/components-react/toolbar/useConditionalSynchedItems.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,0DAG+B;AAE/B,kDAAwD;AACxD,6CAA+B;AAE/B;;;;;GAKG;AACH,SAAS,aAAa,CACpB,QAAqB,EACrB,KAAmB;IAEnB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC5C,IAAI,KAAK,YAAY,wCAAuB,EAAE;gBAC5C,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE,CAC7C,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CACpC,CAAC;aACH;iBAAM,IAAI,KAAK,YAAY,uCAAsB,EAAE;gBAClD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE,CAC7C,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CACpC,CAAC;aACH;iBAAM,IAAI,gCAAmB,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE;gBAC3D,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,OAAe,EAAE,EAAE,CAC7C,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CACpC,CAAC;aACH;SACF;QACD,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;KACF;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CACnB,KAAmB,EACnB,QAAqB;IAErB,IAAI,CAAC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AG,KAAK,CAAC,QAAQ,CAE9D,EAAE,CAAC,CAAC;IACN,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;;QACnB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;QAC9B,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,oBAAoB,CAAC,MAAA,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,mCAAI,KAAK,CAAC,CAAC;QACxD,MAAM,iBAAiB,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QAC5C,OAAO,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACvC,IAAI,CAAC,KAAK,iBAAiB,CAAC,MAAM;gBAAE,OAAO;YAE3C,IACE,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAa,EAAW,EAAE,CAChD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACvC,EACD;gBACA,oBAAoB,CAClB,CAAC,OAAO,EAAE,EAAE,WAAC,OAAA,MAAA,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,mCAAI,OAAO,CAAA,EAAA,CAC7D,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IACzB,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AA3BD,gEA2BC","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 *--------------------------------------------------------------------------------------------*/\nimport {\n ConditionalBooleanValue,\n ConditionalStringValue,\n} from \"@itwin/appui-abstract\";\nimport type { BeEvent } from \"@itwin/core-bentley\";\nimport { ConditionalIconItem } from \"@itwin/core-react\";\nimport * as React from \"react\";\n\n/**\n * From a list of ToolbarItem, recursively return the list of syncIds\n * that are relevant to every Conditional members used in the items.\n * @param eventIds Set to fill with syncIds\n * @param items ToolbarItems list to search through\n */\nfunction gatherSyncIds<T extends {} | { items: T[] }>(\n eventIds: Set<string>,\n items: readonly T[]\n) {\n for (const item of items) {\n for (const [, entry] of Object.entries(item)) {\n if (entry instanceof ConditionalBooleanValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (entry instanceof ConditionalStringValue) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n } else if (ConditionalIconItem.isConditionalIconItem(entry)) {\n entry.syncEventIds.forEach((eventId: string) =>\n eventIds.add(eventId.toLowerCase())\n );\n }\n }\n if (\"items\" in item) {\n gatherSyncIds(eventIds, item.items);\n }\n }\n}\n\n/**\n * Refresh all conditional values interested by the provided eventIds.\n * @param items List of ToolbarItems that may content Conditional properties.\n * @param eventIds Set of triggered eventIds.\n * @returns null if no updates occurred, or the provided items with updated values if ANY were updated.\n */\nfunction refreshItems<T extends {} | { items: T[] }>(\n items: readonly T[],\n eventIds: Set<string>\n): T[] | null {\n if (0 === eventIds.size) return null;\n let itemsUpdated = false;\n const updatedItems: T[] = [];\n\n for (const item of items) {\n let updatedItem = { ...item };\n if (\"items\" in updatedItem) {\n const childItems = refreshItems(updatedItem.items, eventIds);\n updatedItem = {\n ...updatedItem,\n items: childItems ?? updatedItem.items,\n };\n itemsUpdated ||= !!childItems;\n }\n\n for (const [, entry] of Object.entries(updatedItem)) {\n if (\n (entry instanceof ConditionalBooleanValue &&\n ConditionalBooleanValue.refreshValue(entry, eventIds)) ||\n (entry instanceof ConditionalStringValue &&\n ConditionalStringValue.refreshValue(entry, eventIds)) ||\n (ConditionalIconItem.isConditionalIconItem(entry) &&\n ConditionalIconItem.refreshValue(entry, eventIds))\n ) {\n itemsUpdated = true;\n }\n }\n updatedItems.push(updatedItem);\n }\n return itemsUpdated ? updatedItems : null;\n}\n\n/**\n * Register a listener on the syncUiEVent and updates all conditionals within the provided items.\n * @param items Items to keep up to date\n * @param syncUiEvent Event to attach to (because we don't depend on appui-react);\n * @returns Synched items\n * @internal\n */\nexport function useConditionalSynchedItems<T extends {} | { items: T[] }>(\n items: readonly T[],\n syncUiEvent: undefined | BeEvent<(args: { eventIds: Set<string> }) => void>\n) {\n const [eventSynchedItems, setEventSynchedItems] = React.useState<\n readonly T[]\n >([]);\n React.useEffect(() => {\n const ids = new Set<string>();\n gatherSyncIds(ids, items);\n setEventSynchedItems(refreshItems(items, ids) ?? items);\n const syncIdsOfInterest = [...ids.values()];\n return syncUiEvent?.addListener((args) => {\n if (0 === syncIdsOfInterest.length) return;\n\n if (\n syncIdsOfInterest.some((value: string): boolean =>\n args.eventIds.has(value.toLowerCase())\n )\n ) {\n setEventSynchedItems(\n (current) => refreshItems(current, args.eventIds) ?? current\n );\n }\n });\n }, [syncUiEvent, items]);\n return eventSynchedItems;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeHooks.d.ts","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeHooks.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,eAAe,GAAG,SAAS,CAMpE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,SAAS,gBAAgB,EACtE,YAAY,EAAE,aAAa,EAC3B,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AY,EAAE,gBAAgB,mBAGhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,SAAS,gBAAgB,EAC1E,eAAe,EAAE,CAAC,MAAM,cAAc,CAAC,GAAG,sBAAsB,oBAOjE"}
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.useTreeEventsHandler = exports.useTreeModelSource = exports.usePagedTreeNodeLoader = exports.useTreeNodeLoader = exports.useTreeModel = void 0;
11
11
  const react_1 = require("react");
12
12
  const core_react_1 = require("@itwin/core-react");
13
- const UseRerender_1 = require("../../common/UseRerender");
14
13
  const TreeEventHandler_1 = require("./TreeEventHandler");
15
14
  const TreeModelSource_1 = require("./TreeModelSource");
16
15
  const TreeNodeLoader_1 = require("./TreeNodeLoader");
@@ -21,10 +20,14 @@ const TreeNodeLoader_1 = require("./TreeNodeLoader");
21
20
  * @public
22
21
  */
23
22
  function useTreeModel(modelSource) {
24
- const { rerender } = (0, UseRerender_1.useRerender)();
23
+ const [_, setState] = (0, react_1.useState)({});
25
24
  (0, react_1.useEffect)(() => {
26
- return modelSource.onModelChanged.addListener(rerender);
27
- }, [modelSource, rerender]);
25
+ const forceRender = () => setState({});
26
+ // force one more render when `modelSource` changes in case there were some tree model modifications
27
+ // before listener is added on `onModelChanged` event.
28
+ forceRender();
29
+ return modelSource.onModelChanged.addListener(forceRender);
30
+ }, [modelSource]);
28
31
  return modelSource.getModel();
29
32
  }
30
33
  exports.useTreeModel = useTreeModel;
@@ -1 +1 @@
1
- {"version":3,"file":"TreeHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeHooks.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAwD;AACxD,kDAAkD;AAClD,0DAAuD;AAGvD,yDAAsD;AAEtD,uDAAoD;AACpD,qDAAuE;AAEvE;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,WAA4B;IACvD,MAAM,EAAE,QAAQ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AC,eAAe,CAAC,CAAC,CAAC;IACtB,OAAO,IAAA,0BAAa,EAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AARD,oDAQC","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 { useCallback, useEffect, useMemo } from \"react\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport { useRerender } from \"../../common/UseRerender\";\nimport type { TreeDataProvider } from \"../TreeDataProvider\";\nimport type { TreeEventHandlerParams } from \"./TreeEventHandler\";\nimport { TreeEventHandler } from \"./TreeEventHandler\";\nimport type { TreeModel } from \"./TreeModel\";\nimport { TreeModelSource } from \"./TreeModelSource\";\nimport { PagedTreeNodeLoader, TreeNodeLoader } from \"./TreeNodeLoader\";\n\n/**\n * React hook that returns an immutable `TreeModel` whenever it changes in the given\n * `TreeModelSource`.\n *\n * @public\n */\nexport function useTreeModel(modelSource: TreeModelSource): TreeModel {\n const { rerender } = useRerender();\n useEffect(() => {\n return modelSource.onModelChanged.addListener(rerender);\n }, [modelSource, rerender]);\n return modelSource.getModel();\n}\n\n/**\n * Custom hook which creates a nodes' loader using the supplied data provider and model source. The\n * loader pulls nodes from the data provider and puts them into the model source.\n *\n * @public\n */\nexport function useTreeNodeLoader<TDataProvider extends TreeDataProvider>(\n dataProvider: TDataProvider,\n modelSource: TreeModelSource\n) {\n return useMemo(\n () => new TreeNodeLoader(dataProvider, modelSource),\n [dataProvider, modelSource]\n );\n}\n\n/**\n * Custom hook which creates a paging nodes' loader using the supplied data provider and model source. The loader pulls\n * nodes from the data provider and puts them into the model source.\n * @public\n */\nexport function usePagedTreeNodeLoader<TDataProvider extends TreeDataProvider>(\n dataProvider: TDataProvider,\n pageSize: number,\n modelSource: TreeModelSource\n) {\n return useMemo(\n () => new PagedTreeNodeLoader(dataProvider, modelSource, pageSize),\n [dataProvider, modelSource, pageSize]\n );\n}\n\n/**\n * Custom hook which creates a `TreeModelSource`.\n *\n * @note The model source has no direct dependency on the data provider, but we want a fresh model\n * source whenever the data provider changes - that's the reason the hook takes a data provider.\n *\n * @public\n */\nexport function useTreeModelSource(dataProvider: TreeDataProvider) {\n // need to create new model source every time data provider changes although it does not need data provider to be created.\n return useMemo(() => new TreeModelSource(), [dataProvider]); // eslint-disable-line react-hooks/exhaustive-deps\n}\n\n/**\n * Custom hook which creates and takes care of disposing a TreeEventsHandler. The input is either a factory method\n * for a custom `TreeEventHandler` implementation or parameters for the default implementation.\n *\n * @note Caller must ensure `factoryOrParams` changes only when a new handler needs to be created. `useCallback` or `useMemo` can\n * be used for that purpose based on whether the input is a factory function or params object.\n *\n * @public\n */\nexport function useTreeEventsHandler<TEventsHandler extends TreeEventHandler>(\n factoryOrParams: (() => TEventsHandler) | TreeEventHandlerParams\n) {\n const factory = useCallback((): TreeEventHandler => {\n if (typeof factoryOrParams === \"function\") return factoryOrParams();\n return new TreeEventHandler(factoryOrParams);\n }, [factoryOrParams]);\n return useDisposable(factory);\n}\n"]}
1
+ {"version":3,"file":"TreeHooks.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeHooks.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,iCAAkE;AAClE,kDAAkD;AAGlD,yDAAsD;AAEtD,uDAAoD;AACpD,qDAAuE;AAEvE;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,WAA4B;IACvD,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IACnC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvC,oGAAoG;QACpG,sDAAsD;QACtD,WAAW,EAAE,CAAC;QACd,OAAO,WAAW,CAAC,cAAc,CAAC,WAA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------------------\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 { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useDisposable } from \"@itwin/core-react\";\nimport type { TreeDataProvider } from \"../TreeDataProvider\";\nimport type { TreeEventHandlerParams } from \"./TreeEventHandler\";\nimport { TreeEventHandler } from \"./TreeEventHandler\";\nimport type { TreeModel } from \"./TreeModel\";\nimport { TreeModelSource } from \"./TreeModelSource\";\nimport { PagedTreeNodeLoader, TreeNodeLoader } from \"./TreeNodeLoader\";\n\n/**\n * React hook that returns an immutable `TreeModel` whenever it changes in the given\n * `TreeModelSource`.\n *\n * @public\n */\nexport function useTreeModel(modelSource: TreeModelSource): TreeModel {\n const [_, setState] = useState({});\n useEffect(() => {\n const forceRender = () => setState({});\n // force one more render when `modelSource` changes in case there were some tree model modifications\n // before listener is added on `onModelChanged` event.\n forceRender();\n return modelSource.onModelChanged.addListener(forceRender);\n }, [modelSource]);\n return modelSource.getModel();\n}\n\n/**\n * Custom hook which creates a nodes' loader using the supplied data provider and model source. The\n * loader pulls nodes from the data provider and puts them into the model source.\n *\n * @public\n */\nexport function useTreeNodeLoader<TDataProvider extends TreeDataProvider>(\n dataProvider: TDataProvider,\n modelSource: TreeModelSource\n) {\n return useMemo(\n () => new TreeNodeLoader(dataProvider, modelSource),\n [dataProvider, modelSource]\n );\n}\n\n/**\n * Custom hook which creates a paging nodes' loader using the supplied data provider and model source. The loader pulls\n * nodes from the data provider and puts them into the model source.\n * @public\n */\nexport function usePagedTreeNodeLoader<TDataProvider extends TreeDataProvider>(\n dataProvider: TDataProvider,\n pageSize: number,\n modelSource: TreeModelSource\n) {\n return useMemo(\n () => new PagedTreeNodeLoader(dataProvider, modelSource, pageSize),\n [dataProvider, modelSource, pageSize]\n );\n}\n\n/**\n * Custom hook which creates a `TreeModelSource`.\n *\n * @note The model source has no direct dependency on the data provider, but we want a fresh model\n * source whenever the data provider changes - that's the reason the hook takes a data provider.\n *\n * @public\n */\nexport function useTreeModelSource(dataProvider: TreeDataProvider) {\n // need to create new model source every time data provider changes although it does not need data provider to be created.\n return useMemo(() => new TreeModelSource(), [dataProvider]); // eslint-disable-line react-hooks/exhaustive-deps\n}\n\n/**\n * Custom hook which creates and takes care of disposing a TreeEventsHandler. The input is either a factory method\n * for a custom `TreeEventHandler` implementation or parameters for the default implementation.\n *\n * @note Caller must ensure `factoryOrParams` changes only when a new handler needs to be created. `useCallback` or `useMemo` can\n * be used for that purpose based on whether the input is a factory function or params object.\n *\n * @public\n */\nexport function useTreeEventsHandler<TEventsHandler extends TreeEventHandler>(\n factoryOrParams: (() => TEventsHandler) | TreeEventHandlerParams\n) {\n const factory = useCallback((): TreeEventHandler => {\n if (typeof factoryOrParams === \"function\") return factoryOrParams();\n return new TreeEventHandler(factoryOrParams);\n }, [factoryOrParams]);\n return useDisposable(factory);\n}\n"]}
@@ -127,6 +127,7 @@ class MutableTreeModel {
127
127
  * @returns `true` on success, `false` otherwise.
128
128
  */
129
129
  changeNodeId(currentId, newId) {
130
+ var _b, _c;
130
131
  const node = this.getNode(currentId);
131
132
  if (node === undefined) {
132
133
  return false;
@@ -140,7 +141,7 @@ class MutableTreeModel {
140
141
  return false;
141
142
  }
142
143
  node.id = newId; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion
143
- for (const [childId] of this.getChildren(newId)?.iterateValues() ?? []) {
144
+ for (const [childId] of (_c = (_b = this.getChildren(newId)) === null || _b === void 0 ? void 0 : _b.iterateValues()) !== null && _c !== void 0 ? _c : []) {
144
145
  const child = this.getNode(childId);
145
146
  (0, core_bentley_1.assert)(child !== undefined);
146
147
  child.parentId = newId;
@@ -179,12 +180,12 @@ class MutableTreeModel {
179
180
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
180
181
  sourceNode.parentId = targetParentId;
181
182
  const updateDepths = (parentId, depth) => {
183
+ var _b, _c;
182
184
  const node = this.getNode(parentId);
183
185
  (0, core_bentley_1.assert)(node !== undefined);
184
186
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
185
187
  node.depth = depth;
186
- for (const [nodeId] of this.getChildren(parentId)?.iterateValues() ??
187
- []) {
188
+ for (const [nodeId] of (_c = (_b = this.getChildren(parentId)) === null || _b === void 0 ? void 0 : _b.iterateValues()) !== null && _c !== void 0 ? _c : []) {
188
189
  updateDepths(nodeId, depth + 1);
189
190
  }
190
191
  };
@@ -211,7 +212,7 @@ class MutableTreeModel {
211
212
  }
212
213
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
213
214
  parentNode.numChildren = numChildren;
214
- this._tree.setNumChildren(parentId, numChildren ?? 0);
215
+ this._tree.setNumChildren(parentId, numChildren !== null && numChildren !== void 0 ? numChildren : 0);
215
216
  }
216
217
  /** Removes children specified by id.
217
218
  * @param parentId id of the parent node.
@@ -345,11 +346,11 @@ function getVisibleDescendants(model, parentNode, result = []) {
345
346
  }
346
347
  exports.getVisibleDescendants = getVisibleDescendants;
347
348
  function cloneSubree(source, target, parentId) {
349
+ var _b, _c;
348
350
  target.setNumChildren(parentId, (parentId === undefined ? source.getRootNode() : source.getNode(parentId))
349
351
  .numChildren);
350
- for (const [childId, index] of source
351
- .getChildren(parentId)
352
- ?.iterateValues() ?? []) {
352
+ for (const [childId, index] of (_c = (_b = source
353
+ .getChildren(parentId)) === null || _b === void 0 ? void 0 : _b.iterateValues()) !== null && _c !== void 0 ? _c : []) {
353
354
  const node = source.getNode(childId);
354
355
  target.setChildren(parentId, [{ ...node, isLoading: !!node.isLoading }], index);
355
356
  cloneSubree(source, target, childId);
@@ -1 +1 @@
1
- {"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeModel.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;AAEH,iCAAkC;AAClC,mCAAmC;AACnC,sDAA6C;AAE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AC;AAtCD,sDAsCC;AAED,SAAS,WAAW,CAClB,MAAiB,EACjB,MAAwB,EACxB,QAA4B;IAE5B,MAAM,CAAC,cAAc,CACnB,QAAQ,EACR,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAE,CAAC;SACxE,WAAW,CACf,CAAC;IACF,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM;SAClC,WAAW,CAAC,QAAQ,CAAC;QACtB,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC;QACtC,MAAM,CAAC,WAAW,CAChB,QAAQ,EACR,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,EAC1C,KAAK,CACN,CAAC;QACF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC;AACH,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 { immerable } from \"immer\";\nimport { cloneDeep } from \"lodash\";\nimport { assert } from \"@itwin/core-bentley\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport type {\n DelayLoadedTreeNodeItem,\n ImmediatelyLoadedTreeNodeItem,\n TreeNodeItem,\n} from \"../TreeDataProvider\";\nimport type { SparseArray } from \"./internal/SparseTree\";\nimport { SparseTree } from \"./internal/SparseTree\";\n\n/**\n * Immutable data structure that describes tree node.\n * @public\n */\nexport interface TreeModelNode {\n readonly id: string;\n readonly parentId: string | undefined;\n readonly depth: number;\n\n readonly isLoading?: boolean;\n readonly numChildren: number | undefined;\n\n readonly description: string | undefined;\n readonly isExpanded: boolean;\n readonly label: PropertyRecord;\n readonly isSelected: boolean;\n readonly isSelectionDisabled?: boolean;\n\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\n readonly editingInfo?: TreeModelNodeEditingInfo;\n\n readonly checkbox: CheckBoxInfo;\n\n readonly item: TreeNodeItem;\n}\n\n/**\n * Immutable data structure that describes checkbox info.\n * @public\n */\nexport interface CheckBoxInfo {\n readonly state: CheckBoxState;\n readonly tooltip?: string;\n readonly isDisabled: boolean;\n readonly isVisible: boolean;\n}\n\n/**\n * Mutable data structure that describes tree node.\n * @public\n */\nexport interface MutableTreeModelNode extends TreeModelNode {\n isLoading: boolean;\n\n description: string;\n isExpanded: boolean;\n label: PropertyRecord;\n isSelected: boolean;\n isSelectionDisabled?: boolean;\n\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\n editingInfo?: TreeModelNodeEditingInfo;\n\n checkbox: MutableCheckBoxInfo;\n\n item: TreeNodeItem;\n}\n\n/**\n * Data structure that holds callbacks used for tree node editing.\n * @public\n */\nexport interface TreeModelNodeEditingInfo {\n onCommit: (node: TreeModelNode, newValue: string) => void;\n onCancel: () => void;\n}\n\n/**\n * Mutable data structure that describes checkbox info.\n * @public\n */\nexport interface MutableCheckBoxInfo extends CheckBoxInfo {\n state: CheckBoxState;\n tooltip?: string;\n isDisabled: boolean;\n isVisible: boolean;\n}\n\n/**\n * Data structure that describes tree node placeholder.\n * @public\n */\nexport interface TreeModelNodePlaceholder {\n readonly childIndex: number;\n readonly depth: number;\n readonly parentId?: string;\n}\n\n/**\n * Data structure that describes tree root node.\n * @public\n */\nexport interface TreeModelRootNode {\n readonly depth: -1;\n readonly id: undefined;\n readonly numChildren: number | undefined;\n}\n\n/**\n * Data structure that describes input used to create tree node.\n * @public\n */\nexport interface TreeModelNodeInput {\n readonly description?: string;\n readonly isExpanded: boolean;\n readonly id: string;\n readonly item: TreeNodeItem;\n readonly label: PropertyRecord;\n readonly isLoading: boolean;\n readonly numChildren?: number;\n readonly isSelected: boolean;\n}\n\n/**\n * Type definition of all tree model nodes.\n * @public\n */\nexport type TreeModelNodeType =\n | TreeModelNode\n | TreeModelNodePlaceholder\n | TreeModelRootNode;\n\n/**\n * Checks if object is [[TreeModelNode]]\n * @public\n */\nexport function isTreeModelNode(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelNode {\n return (\n obj !== undefined &&\n !isTreeModelNodePlaceholder(obj) &&\n !isTreeModelRootNode(obj)\n );\n}\n\n/**\n * Checks if object is [[TreeModelNodePlaceholder]]\n * @public\n */\nexport function isTreeModelNodePlaceholder(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelNodePlaceholder {\n return obj !== undefined && \"childIndex\" in obj;\n}\n\n/**\n * Checks if object is [[TreeModelRootNode]]\n * @public\n */\nexport function isTreeModelRootNode(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelRootNode {\n return (\n obj !== undefined &&\n (obj as TreeModelRootNode).id === undefined &&\n !(\"childIndex\" in obj)\n );\n}\n\n/**\n * Type definition of tree node item data.\n * @public\n */\nexport type TreeNodeItemData = ImmediatelyLoadedTreeNodeItem &\n DelayLoadedTreeNodeItem;\n\n/**\n * Data structure that describes set of visible tree nodes as a flat list.\n * @public\n */\nexport interface VisibleTreeNodes\n extends Iterable<TreeModelNode | TreeModelNodePlaceholder> {\n getNumNodes(): number;\n getAtIndex(\n index: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined;\n getModel(): TreeModel;\n getNumRootNodes(): number | undefined;\n getIndexOfNode(nodeId: string): number;\n}\n\n/**\n * Data structure that describes tree model.\n * @public\n */\nexport interface TreeModel {\n getRootNode(): TreeModelRootNode;\n\n getNode(id: string): TreeModelNode | undefined;\n getNode(\n parentId: string | undefined,\n childIndex: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined;\n getNode(\n nodeId: string | undefined,\n childIndex?: number\n ): TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode | undefined;\n\n getChildren(parentId: string | undefined): SparseArray<string> | undefined;\n getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined;\n\n iterateTreeModelNodes(parentId?: string): IterableIterator<TreeModelNode>;\n}\n\n/**\n * Mutable tree model which holds nodes and allows adding or removing them.\n * @public\n */\nexport class MutableTreeModel implements TreeModel {\n public [immerable] = true;\n\n private _tree = new SparseTree<MutableTreeModelNode>();\n private _rootNode: TreeModelRootNode = {\n depth: -1,\n id: undefined,\n numChildren: undefined,\n };\n\n public constructor(seed?: TreeModel) {\n if (!seed) {\n return;\n }\n\n cloneSubree(seed, this, undefined);\n }\n\n /** Returns root node of a tree. This node is not visible and is there to allow having multiple visible root nodes. */\n public getRootNode(): TreeModelRootNode {\n return this._rootNode;\n }\n\n /** Returns tree node or placeholder for node that is not loaded yet.\n * @returns node, node placeholder or undefined if node is not found in model.\n */\n public getNode(id: string): MutableTreeModelNode | undefined;\n public getNode(\n parentId: string | undefined,\n childIndex: number\n ): MutableTreeModelNode | TreeModelNodePlaceholder | undefined;\n public getNode(\n nodeId: string | undefined,\n childIndex?: number\n ): MutableTreeModelNode | TreeModelNodePlaceholder | undefined {\n if (childIndex === undefined) {\n return this._tree.getNode(nodeId!);\n }\n\n const children = this._tree.getChildren(nodeId);\n const childId =\n children !== undefined ? children.get(childIndex) : undefined;\n if (childId !== undefined) {\n return this._tree.getNode(childId);\n }\n\n const parentNode =\n nodeId === undefined ? this._rootNode : this._tree.getNode(nodeId);\n if (parentNode !== undefined) {\n return {\n childIndex,\n depth: parentNode.depth + 1,\n parentId: nodeId,\n };\n }\n\n return undefined;\n }\n\n /** Returns children for specific parent.\n * @param parentId id of parent node.\n * @returns children of parent node or root nodes if undefined is passed as parent id.\n */\n public getChildren(\n parentId: string | undefined\n ): SparseArray<string> | undefined {\n return this._tree.getChildren(parentId);\n }\n\n /** Returns children offset in children array for specific parent. */\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n return this._tree.getChildOffset(parentId, childId);\n }\n\n /**\n * Sets children for parent node starting from the specific offset.\n * If offset overlaps with already added nodes, the overlapping nodes are overwritten.\n */\n public setChildren(\n parentId: string | undefined,\n nodeInputs: TreeModelNodeInput[],\n offset: number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) return;\n\n const children: MutableTreeModelNode[] = [];\n for (const input of nodeInputs) {\n const child = MutableTreeModel.createTreeModelNode(parentNode, input);\n children.push(child);\n }\n\n this._tree.setChildren(parentNode.id, children, offset);\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /**\n * Inserts child in the specified position.\n * If offset is higher then current length of children array, the length is increased.\n */\n public insertChild(\n parentId: string | undefined,\n childNodeInput: TreeModelNodeInput,\n offset: number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) return;\n\n const child = MutableTreeModel.createTreeModelNode(\n parentNode,\n childNodeInput\n );\n\n this._tree.insertChild(parentNode.id, child, offset);\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /**\n * Changes the id of target node.\n * @returns `true` on success, `false` otherwise.\n */\n public changeNodeId(currentId: string, newId: string): boolean {\n const node = this.getNode(currentId);\n if (node === undefined) {\n return false;\n }\n\n if (currentId === newId) {\n return true;\n }\n\n const index = this.getChildOffset(node.parentId, currentId);\n assert(index !== undefined);\n\n if (!this._tree.setNodeId(node.parentId, index, newId)) {\n return false;\n }\n\n (node.id as string) = newId; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion\n for (const [childId] of this.getChildren(newId)?.iterateValues() ?? []) {\n const child = this.getNode(childId);\n assert(child !== undefined);\n (child.parentId as string) = newId;\n }\n\n return true;\n }\n\n /**\n * Transfers node along with its children to a new location. Fails if destination has undefined child count.\n * @param sourceNodeId Node that is being moved.\n * @param targetParentId Node that will receive a new child.\n * @param targetIndex Insertion location among target's *current* children.\n * @returns `true` on success, `false` otherwise.\n */\n public moveNode(\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): boolean {\n const sourceNode = this.getNode(sourceNodeId);\n if (sourceNode === undefined) {\n return false;\n }\n\n const targetParent =\n targetParentId === undefined\n ? this._rootNode\n : this.getNode(targetParentId);\n if (targetParent === undefined || targetParent.numChildren === undefined) {\n return false;\n }\n\n if (\n targetParentId !== undefined &&\n this.areNodesRelated(sourceNodeId, targetParentId)\n ) {\n return false;\n }\n\n this._tree.moveNode(\n sourceNode.parentId,\n sourceNodeId,\n targetParentId,\n targetIndex\n );\n\n const sourceParent =\n sourceNode.parentId === undefined\n ? this._rootNode\n : this.getNode(sourceNode.parentId);\n assert(sourceParent !== undefined);\n MutableTreeModel.setNumChildrenForNode(\n sourceParent,\n this._tree.getChildren(sourceNode.parentId)\n );\n MutableTreeModel.setNumChildrenForNode(\n targetParent,\n this._tree.getChildren(targetParentId)\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (sourceNode.parentId as string | undefined) = targetParentId;\n\n const updateDepths = (parentId: string, depth: number) => {\n const node = this.getNode(parentId);\n assert(node !== undefined);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (node.depth as number) = depth;\n for (const [nodeId] of this.getChildren(parentId)?.iterateValues() ??\n []) {\n updateDepths(nodeId, depth + 1);\n }\n };\n\n updateDepths(sourceNodeId, targetParent.depth + 1);\n return true;\n }\n\n private areNodesRelated(\n ancestorNodeId: string,\n descendantNodeId: string\n ): boolean {\n const node = this.getNode(descendantNodeId);\n if (node === undefined || node.parentId === undefined) {\n return false;\n }\n\n return node.parentId === ancestorNodeId\n ? true\n : this.areNodesRelated(ancestorNodeId, node.parentId);\n }\n\n /**\n * Sets the number of child nodes a parent is expected to contain. All child nodes of this parent will be subsequently\n * removed.\n */\n public setNumChildren(\n parentId: string | undefined,\n numChildren: number | undefined\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (parentNode.numChildren as number | undefined) = numChildren;\n this._tree.setNumChildren(parentId, numChildren ?? 0);\n }\n\n /** Removes children specified by id.\n * @param parentId id of the parent node.\n * @param child child node id or index that should be removed.\n */\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n this._tree.removeChild(parentId, child);\n\n // istanbul ignore else\n if (parentNode)\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /** Removes all children for parent specified by id.\n * @param parentId id of parent node or undefined to remove root nodes.\n */\n public clearChildren(parentId: string | undefined) {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (parentNode.numChildren as number | undefined) = undefined;\n }\n this._tree.deleteSubtree(parentId, false);\n }\n\n /** Iterates over all nodes present in the tree model. */\n public *iterateTreeModelNodes(\n parentId?: string\n ): IterableIterator<MutableTreeModelNode> {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n function* iterateDescendants(\n subParentId: string | undefined\n ): IterableIterator<MutableTreeModelNode> {\n const children = _this.getChildren(subParentId);\n if (children === undefined) {\n return;\n }\n\n for (const [nodeId] of children.iterateValues()) {\n const node = _this.getNode(nodeId);\n if (node !== undefined) {\n yield node;\n yield* iterateDescendants(nodeId);\n }\n }\n }\n\n yield* iterateDescendants(parentId);\n }\n\n private static setNumChildrenForNode(\n node: TreeModelRootNode | MutableTreeModelNode,\n children: SparseArray<string> | undefined\n ) {\n const numChildren = children ? children.getLength() : undefined;\n if (node.numChildren === numChildren) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (node.numChildren as number | undefined) = numChildren;\n }\n\n private static createTreeModelNode(\n parentNode: TreeModelNode | TreeModelRootNode,\n input: TreeModelNodeInput\n ): MutableTreeModelNode {\n return {\n id: input.id,\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n\n isLoading: input.isLoading,\n numChildren: input.numChildren,\n\n description: input.description || \"\",\n isExpanded: input.isExpanded,\n label: input.label,\n isSelected: input.isSelected,\n isSelectionDisabled: input.item.isSelectionDisabled,\n\n checkbox: {\n state: input.item.checkBoxState || CheckBoxState.Off,\n isDisabled: !!input.item.isCheckboxDisabled,\n isVisible: !!input.item.isCheckboxVisible,\n },\n\n item: cloneDeep(input.item),\n };\n }\n}\n\n/**\n * Generates flat list of visible nodes in the tree model.\n * @public\n */\nexport function computeVisibleNodes(model: TreeModel): VisibleTreeNodes {\n const result = getVisibleDescendants(model, model.getRootNode());\n return {\n getNumNodes: () => result.length,\n getAtIndex: (\n index: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined => {\n return result[index];\n },\n getModel: () => model,\n getNumRootNodes: () => model.getRootNode().numChildren,\n [Symbol.iterator]: () => result[Symbol.iterator](),\n getIndexOfNode: (nodeId: string): number => {\n return result.findIndex(\n (visibleNode) => (visibleNode as TreeModelNode).id === nodeId\n );\n },\n };\n}\n\n/**\n * Traverses the tree and collects visible descendants.\n * @public\n */\nexport function getVisibleDescendants(\n model: TreeModel,\n parentNode: TreeModelNode | TreeModelRootNode,\n result: Array<TreeModelNode | TreeModelNodePlaceholder> = []\n): Array<TreeModelNode | TreeModelNodePlaceholder> {\n const children = model.getChildren(parentNode.id);\n if (!children) {\n return result;\n }\n\n let index = 0;\n for (const childId of children) {\n if (childId === undefined) {\n result.push({\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n childIndex: index,\n });\n } else {\n const childNode = model.getNode(childId);\n if (childNode === undefined) {\n // node was disposed\n result.push({\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n childIndex: index,\n });\n } else {\n result.push(childNode);\n if (childNode.isExpanded && childNode.numChildren !== undefined) {\n getVisibleDescendants(model, childNode, result);\n }\n }\n }\n ++index;\n }\n\n return result;\n}\n\nfunction cloneSubree(\n source: TreeModel,\n target: MutableTreeModel,\n parentId: string | undefined\n): void {\n target.setNumChildren(\n parentId,\n (parentId === undefined ? source.getRootNode() : source.getNode(parentId)!)\n .numChildren\n );\n for (const [childId, index] of source\n .getChildren(parentId)\n ?.iterateValues() ?? []) {\n const node = source.getNode(childId)!;\n target.setChildren(\n parentId,\n [{ ...node, isLoading: !!node.isLoading }],\n index\n );\n cloneSubree(source, target, childId);\n }\n}\n"]}
1
+ {"version":3,"file":"TreeModel.js","sourceRoot":"","sources":["../../../../../src/components-react/tree/controlled/TreeModel.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;AAEH,iCAAkC;AAClC,mCAAmC;AACnC,sDAA6C;AAE7C,kDAAkD;AAOlD,sDAAmD;AA4HnD;;;GAGG;AACH,SAAgB,eAAe,CAC7B,GAAkC;IAElC,OAAO,CACL,GAAG,KAAK,SAAS;QACjB,CAAC,0BAA0B,CAAC,GAAG,CAAC;QAChC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAC1B,CAAC;AACJ,CAAC;AARD,0CAQC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CACxC,GAAkC;IAElC,OAAO,GAAG,KAAK,SAAS,IAAI,YAAY,IAAI,GAAG,CAAC;AAClD,CAAC;AAJD,gEAIC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,GAAkC;IAElC,OAAO,CACL,GAAG,KAAK,SAAS;QAChB,GAAyB,CAAC,EAAE,KAAK,SAAS;QAC3C,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC,CACvB,CAAC;AACJ,CAAC;AARD,kDAQC;AAkDD;;;GAGG;AACH,MAAa,gBAAgB;IAU3B,YAAmB,IAAgB;QAT5B,QAAW,GAAG,IAAI,CAAC;QAElB,UAAK,GAAG,IAAI,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AK,CACN,CAAC;QACF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC;AACH,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 { immerable } from \"immer\";\nimport { cloneDeep } from \"lodash\";\nimport { assert } from \"@itwin/core-bentley\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport type {\n DelayLoadedTreeNodeItem,\n ImmediatelyLoadedTreeNodeItem,\n TreeNodeItem,\n} from \"../TreeDataProvider\";\nimport type { SparseArray } from \"./internal/SparseTree\";\nimport { SparseTree } from \"./internal/SparseTree\";\n\n/**\n * Immutable data structure that describes tree node.\n * @public\n */\nexport interface TreeModelNode {\n readonly id: string;\n readonly parentId: string | undefined;\n readonly depth: number;\n\n readonly isLoading?: boolean;\n readonly numChildren: number | undefined;\n\n readonly description: string | undefined;\n readonly isExpanded: boolean;\n readonly label: PropertyRecord;\n readonly isSelected: boolean;\n readonly isSelectionDisabled?: boolean;\n\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\n readonly editingInfo?: TreeModelNodeEditingInfo;\n\n readonly checkbox: CheckBoxInfo;\n\n readonly item: TreeNodeItem;\n}\n\n/**\n * Immutable data structure that describes checkbox info.\n * @public\n */\nexport interface CheckBoxInfo {\n readonly state: CheckBoxState;\n readonly tooltip?: string;\n readonly isDisabled: boolean;\n readonly isVisible: boolean;\n}\n\n/**\n * Mutable data structure that describes tree node.\n * @public\n */\nexport interface MutableTreeModelNode extends TreeModelNode {\n isLoading: boolean;\n\n description: string;\n isExpanded: boolean;\n label: PropertyRecord;\n isSelected: boolean;\n isSelectionDisabled?: boolean;\n\n /** Specifies that node is in editing mode. It holds callbacks that are used by node editor. */\n editingInfo?: TreeModelNodeEditingInfo;\n\n checkbox: MutableCheckBoxInfo;\n\n item: TreeNodeItem;\n}\n\n/**\n * Data structure that holds callbacks used for tree node editing.\n * @public\n */\nexport interface TreeModelNodeEditingInfo {\n onCommit: (node: TreeModelNode, newValue: string) => void;\n onCancel: () => void;\n}\n\n/**\n * Mutable data structure that describes checkbox info.\n * @public\n */\nexport interface MutableCheckBoxInfo extends CheckBoxInfo {\n state: CheckBoxState;\n tooltip?: string;\n isDisabled: boolean;\n isVisible: boolean;\n}\n\n/**\n * Data structure that describes tree node placeholder.\n * @public\n */\nexport interface TreeModelNodePlaceholder {\n readonly childIndex: number;\n readonly depth: number;\n readonly parentId?: string;\n}\n\n/**\n * Data structure that describes tree root node.\n * @public\n */\nexport interface TreeModelRootNode {\n readonly depth: -1;\n readonly id: undefined;\n readonly numChildren: number | undefined;\n}\n\n/**\n * Data structure that describes input used to create tree node.\n * @public\n */\nexport interface TreeModelNodeInput {\n readonly description?: string;\n readonly isExpanded: boolean;\n readonly id: string;\n readonly item: TreeNodeItem;\n readonly label: PropertyRecord;\n readonly isLoading: boolean;\n readonly numChildren?: number;\n readonly isSelected: boolean;\n}\n\n/**\n * Type definition of all tree model nodes.\n * @public\n */\nexport type TreeModelNodeType =\n | TreeModelNode\n | TreeModelNodePlaceholder\n | TreeModelRootNode;\n\n/**\n * Checks if object is [[TreeModelNode]]\n * @public\n */\nexport function isTreeModelNode(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelNode {\n return (\n obj !== undefined &&\n !isTreeModelNodePlaceholder(obj) &&\n !isTreeModelRootNode(obj)\n );\n}\n\n/**\n * Checks if object is [[TreeModelNodePlaceholder]]\n * @public\n */\nexport function isTreeModelNodePlaceholder(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelNodePlaceholder {\n return obj !== undefined && \"childIndex\" in obj;\n}\n\n/**\n * Checks if object is [[TreeModelRootNode]]\n * @public\n */\nexport function isTreeModelRootNode(\n obj: TreeModelNodeType | undefined\n): obj is TreeModelRootNode {\n return (\n obj !== undefined &&\n (obj as TreeModelRootNode).id === undefined &&\n !(\"childIndex\" in obj)\n );\n}\n\n/**\n * Type definition of tree node item data.\n * @public\n */\nexport type TreeNodeItemData = ImmediatelyLoadedTreeNodeItem &\n DelayLoadedTreeNodeItem;\n\n/**\n * Data structure that describes set of visible tree nodes as a flat list.\n * @public\n */\nexport interface VisibleTreeNodes\n extends Iterable<TreeModelNode | TreeModelNodePlaceholder> {\n getNumNodes(): number;\n getAtIndex(\n index: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined;\n getModel(): TreeModel;\n getNumRootNodes(): number | undefined;\n getIndexOfNode(nodeId: string): number;\n}\n\n/**\n * Data structure that describes tree model.\n * @public\n */\nexport interface TreeModel {\n getRootNode(): TreeModelRootNode;\n\n getNode(id: string): TreeModelNode | undefined;\n getNode(\n parentId: string | undefined,\n childIndex: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined;\n getNode(\n nodeId: string | undefined,\n childIndex?: number\n ): TreeModelNode | TreeModelNodePlaceholder | TreeModelRootNode | undefined;\n\n getChildren(parentId: string | undefined): SparseArray<string> | undefined;\n getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined;\n\n iterateTreeModelNodes(parentId?: string): IterableIterator<TreeModelNode>;\n}\n\n/**\n * Mutable tree model which holds nodes and allows adding or removing them.\n * @public\n */\nexport class MutableTreeModel implements TreeModel {\n public [immerable] = true;\n\n private _tree = new SparseTree<MutableTreeModelNode>();\n private _rootNode: TreeModelRootNode = {\n depth: -1,\n id: undefined,\n numChildren: undefined,\n };\n\n public constructor(seed?: TreeModel) {\n if (!seed) {\n return;\n }\n\n cloneSubree(seed, this, undefined);\n }\n\n /** Returns root node of a tree. This node is not visible and is there to allow having multiple visible root nodes. */\n public getRootNode(): TreeModelRootNode {\n return this._rootNode;\n }\n\n /** Returns tree node or placeholder for node that is not loaded yet.\n * @returns node, node placeholder or undefined if node is not found in model.\n */\n public getNode(id: string): MutableTreeModelNode | undefined;\n public getNode(\n parentId: string | undefined,\n childIndex: number\n ): MutableTreeModelNode | TreeModelNodePlaceholder | undefined;\n public getNode(\n nodeId: string | undefined,\n childIndex?: number\n ): MutableTreeModelNode | TreeModelNodePlaceholder | undefined {\n if (childIndex === undefined) {\n return this._tree.getNode(nodeId!);\n }\n\n const children = this._tree.getChildren(nodeId);\n const childId =\n children !== undefined ? children.get(childIndex) : undefined;\n if (childId !== undefined) {\n return this._tree.getNode(childId);\n }\n\n const parentNode =\n nodeId === undefined ? this._rootNode : this._tree.getNode(nodeId);\n if (parentNode !== undefined) {\n return {\n childIndex,\n depth: parentNode.depth + 1,\n parentId: nodeId,\n };\n }\n\n return undefined;\n }\n\n /** Returns children for specific parent.\n * @param parentId id of parent node.\n * @returns children of parent node or root nodes if undefined is passed as parent id.\n */\n public getChildren(\n parentId: string | undefined\n ): SparseArray<string> | undefined {\n return this._tree.getChildren(parentId);\n }\n\n /** Returns children offset in children array for specific parent. */\n public getChildOffset(\n parentId: string | undefined,\n childId: string\n ): number | undefined {\n return this._tree.getChildOffset(parentId, childId);\n }\n\n /**\n * Sets children for parent node starting from the specific offset.\n * If offset overlaps with already added nodes, the overlapping nodes are overwritten.\n */\n public setChildren(\n parentId: string | undefined,\n nodeInputs: TreeModelNodeInput[],\n offset: number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) return;\n\n const children: MutableTreeModelNode[] = [];\n for (const input of nodeInputs) {\n const child = MutableTreeModel.createTreeModelNode(parentNode, input);\n children.push(child);\n }\n\n this._tree.setChildren(parentNode.id, children, offset);\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /**\n * Inserts child in the specified position.\n * If offset is higher then current length of children array, the length is increased.\n */\n public insertChild(\n parentId: string | undefined,\n childNodeInput: TreeModelNodeInput,\n offset: number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) return;\n\n const child = MutableTreeModel.createTreeModelNode(\n parentNode,\n childNodeInput\n );\n\n this._tree.insertChild(parentNode.id, child, offset);\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /**\n * Changes the id of target node.\n * @returns `true` on success, `false` otherwise.\n */\n public changeNodeId(currentId: string, newId: string): boolean {\n const node = this.getNode(currentId);\n if (node === undefined) {\n return false;\n }\n\n if (currentId === newId) {\n return true;\n }\n\n const index = this.getChildOffset(node.parentId, currentId);\n assert(index !== undefined);\n\n if (!this._tree.setNodeId(node.parentId, index, newId)) {\n return false;\n }\n\n (node.id as string) = newId; // eslint-disable-line @typescript-eslint/no-unnecessary-type-assertion\n for (const [childId] of this.getChildren(newId)?.iterateValues() ?? []) {\n const child = this.getNode(childId);\n assert(child !== undefined);\n (child.parentId as string) = newId;\n }\n\n return true;\n }\n\n /**\n * Transfers node along with its children to a new location. Fails if destination has undefined child count.\n * @param sourceNodeId Node that is being moved.\n * @param targetParentId Node that will receive a new child.\n * @param targetIndex Insertion location among target's *current* children.\n * @returns `true` on success, `false` otherwise.\n */\n public moveNode(\n sourceNodeId: string,\n targetParentId: string | undefined,\n targetIndex: number\n ): boolean {\n const sourceNode = this.getNode(sourceNodeId);\n if (sourceNode === undefined) {\n return false;\n }\n\n const targetParent =\n targetParentId === undefined\n ? this._rootNode\n : this.getNode(targetParentId);\n if (targetParent === undefined || targetParent.numChildren === undefined) {\n return false;\n }\n\n if (\n targetParentId !== undefined &&\n this.areNodesRelated(sourceNodeId, targetParentId)\n ) {\n return false;\n }\n\n this._tree.moveNode(\n sourceNode.parentId,\n sourceNodeId,\n targetParentId,\n targetIndex\n );\n\n const sourceParent =\n sourceNode.parentId === undefined\n ? this._rootNode\n : this.getNode(sourceNode.parentId);\n assert(sourceParent !== undefined);\n MutableTreeModel.setNumChildrenForNode(\n sourceParent,\n this._tree.getChildren(sourceNode.parentId)\n );\n MutableTreeModel.setNumChildrenForNode(\n targetParent,\n this._tree.getChildren(targetParentId)\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (sourceNode.parentId as string | undefined) = targetParentId;\n\n const updateDepths = (parentId: string, depth: number) => {\n const node = this.getNode(parentId);\n assert(node !== undefined);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (node.depth as number) = depth;\n for (const [nodeId] of this.getChildren(parentId)?.iterateValues() ??\n []) {\n updateDepths(nodeId, depth + 1);\n }\n };\n\n updateDepths(sourceNodeId, targetParent.depth + 1);\n return true;\n }\n\n private areNodesRelated(\n ancestorNodeId: string,\n descendantNodeId: string\n ): boolean {\n const node = this.getNode(descendantNodeId);\n if (node === undefined || node.parentId === undefined) {\n return false;\n }\n\n return node.parentId === ancestorNodeId\n ? true\n : this.areNodesRelated(ancestorNodeId, node.parentId);\n }\n\n /**\n * Sets the number of child nodes a parent is expected to contain. All child nodes of this parent will be subsequently\n * removed.\n */\n public setNumChildren(\n parentId: string | undefined,\n numChildren: number | undefined\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode === undefined) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (parentNode.numChildren as number | undefined) = numChildren;\n this._tree.setNumChildren(parentId, numChildren ?? 0);\n }\n\n /** Removes children specified by id.\n * @param parentId id of the parent node.\n * @param child child node id or index that should be removed.\n */\n public removeChild(\n parentId: string | undefined,\n child: string | number\n ): void {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n this._tree.removeChild(parentId, child);\n\n // istanbul ignore else\n if (parentNode)\n MutableTreeModel.setNumChildrenForNode(\n parentNode,\n this._tree.getChildren(parentNode.id)\n );\n }\n\n /** Removes all children for parent specified by id.\n * @param parentId id of parent node or undefined to remove root nodes.\n */\n public clearChildren(parentId: string | undefined) {\n const parentNode =\n parentId === undefined ? this._rootNode : this._tree.getNode(parentId);\n if (parentNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (parentNode.numChildren as number | undefined) = undefined;\n }\n this._tree.deleteSubtree(parentId, false);\n }\n\n /** Iterates over all nodes present in the tree model. */\n public *iterateTreeModelNodes(\n parentId?: string\n ): IterableIterator<MutableTreeModelNode> {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n function* iterateDescendants(\n subParentId: string | undefined\n ): IterableIterator<MutableTreeModelNode> {\n const children = _this.getChildren(subParentId);\n if (children === undefined) {\n return;\n }\n\n for (const [nodeId] of children.iterateValues()) {\n const node = _this.getNode(nodeId);\n if (node !== undefined) {\n yield node;\n yield* iterateDescendants(nodeId);\n }\n }\n }\n\n yield* iterateDescendants(parentId);\n }\n\n private static setNumChildrenForNode(\n node: TreeModelRootNode | MutableTreeModelNode,\n children: SparseArray<string> | undefined\n ) {\n const numChildren = children ? children.getLength() : undefined;\n if (node.numChildren === numChildren) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n (node.numChildren as number | undefined) = numChildren;\n }\n\n private static createTreeModelNode(\n parentNode: TreeModelNode | TreeModelRootNode,\n input: TreeModelNodeInput\n ): MutableTreeModelNode {\n return {\n id: input.id,\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n\n isLoading: input.isLoading,\n numChildren: input.numChildren,\n\n description: input.description || \"\",\n isExpanded: input.isExpanded,\n label: input.label,\n isSelected: input.isSelected,\n isSelectionDisabled: input.item.isSelectionDisabled,\n\n checkbox: {\n state: input.item.checkBoxState || CheckBoxState.Off,\n isDisabled: !!input.item.isCheckboxDisabled,\n isVisible: !!input.item.isCheckboxVisible,\n },\n\n item: cloneDeep(input.item),\n };\n }\n}\n\n/**\n * Generates flat list of visible nodes in the tree model.\n * @public\n */\nexport function computeVisibleNodes(model: TreeModel): VisibleTreeNodes {\n const result = getVisibleDescendants(model, model.getRootNode());\n return {\n getNumNodes: () => result.length,\n getAtIndex: (\n index: number\n ): TreeModelNode | TreeModelNodePlaceholder | undefined => {\n return result[index];\n },\n getModel: () => model,\n getNumRootNodes: () => model.getRootNode().numChildren,\n [Symbol.iterator]: () => result[Symbol.iterator](),\n getIndexOfNode: (nodeId: string): number => {\n return result.findIndex(\n (visibleNode) => (visibleNode as TreeModelNode).id === nodeId\n );\n },\n };\n}\n\n/**\n * Traverses the tree and collects visible descendants.\n * @public\n */\nexport function getVisibleDescendants(\n model: TreeModel,\n parentNode: TreeModelNode | TreeModelRootNode,\n result: Array<TreeModelNode | TreeModelNodePlaceholder> = []\n): Array<TreeModelNode | TreeModelNodePlaceholder> {\n const children = model.getChildren(parentNode.id);\n if (!children) {\n return result;\n }\n\n let index = 0;\n for (const childId of children) {\n if (childId === undefined) {\n result.push({\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n childIndex: index,\n });\n } else {\n const childNode = model.getNode(childId);\n if (childNode === undefined) {\n // node was disposed\n result.push({\n parentId: parentNode.id,\n depth: parentNode.depth + 1,\n childIndex: index,\n });\n } else {\n result.push(childNode);\n if (childNode.isExpanded && childNode.numChildren !== undefined) {\n getVisibleDescendants(model, childNode, result);\n }\n }\n }\n ++index;\n }\n\n return result;\n}\n\nfunction cloneSubree(\n source: TreeModel,\n target: MutableTreeModel,\n parentId: string | undefined\n): void {\n target.setNumChildren(\n parentId,\n (parentId === undefined ? source.getRootNode() : source.getNode(parentId)!)\n .numChildren\n );\n for (const [childId, index] of source\n .getChildren(parentId)\n ?.iterateValues() ?? []) {\n const node = source.getNode(childId)!;\n target.setChildren(\n parentId,\n [{ ...node, isLoading: !!node.isLoading }],\n index\n );\n cloneSubree(source, target, childId);\n }\n}\n"]}