@itwin/components-react 4.2.1 → 4.3.0-dev.1

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 (246) hide show
  1. package/CHANGELOG.md +1 -8
  2. package/lib/cjs/components-react/common/DelayedSpinner.js +2 -3
  3. package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
  4. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +1 -2
  5. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  6. package/lib/cjs/components-react/common/UseElementsScrollStorage.d.ts +13 -0
  7. package/lib/cjs/components-react/common/UseElementsScrollStorage.d.ts.map +1 -0
  8. package/lib/cjs/components-react/common/UseElementsScrollStorage.js +49 -0
  9. package/lib/cjs/components-react/common/UseElementsScrollStorage.js.map +1 -0
  10. package/lib/cjs/components-react/converters/NumericTypeConverter.js +2 -4
  11. package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
  12. package/lib/cjs/components-react/converters/TypeConverter.js +1 -2
  13. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  14. package/lib/cjs/components-react/datepicker/DatePicker.scss +3 -3
  15. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.scss +3 -3
  16. package/lib/cjs/components-react/datepicker/TimeField.scss +3 -3
  17. package/lib/cjs/components-react/editors/BooleanEditor.scss +3 -3
  18. package/lib/cjs/components-react/editors/CustomNumberEditor.js +6 -8
  19. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  20. package/lib/cjs/components-react/editors/DateTimeEditor.js +2 -3
  21. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  22. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.scss +3 -3
  23. package/lib/cjs/components-react/editors/IconEditor.scss +3 -3
  24. package/lib/cjs/components-react/editors/ImageCheckBoxEditor.scss +3 -3
  25. package/lib/cjs/components-react/editors/PopupButton.js +3 -4
  26. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  27. package/lib/cjs/components-react/editors/PopupButton.scss +3 -3
  28. package/lib/cjs/components-react/editors/TextEditor.js +2 -4
  29. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  30. package/lib/cjs/components-react/editors/ToggleEditor.scss +3 -3
  31. package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
  32. package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
  33. package/lib/cjs/components-react/filter-builder/FilterBuilderRule.scss +3 -3
  34. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleGroup.scss +3 -3
  35. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
  36. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  37. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  38. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  39. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  40. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  41. package/lib/cjs/components-react/filtering/ResultSelector.scss +3 -3
  42. package/lib/cjs/components-react/iconpicker/IconPickerButton.scss +3 -3
  43. package/lib/cjs/components-react/properties/renderers/ActionButtonList.scss +3 -3
  44. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
  45. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  46. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  47. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  48. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.scss +3 -3
  49. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
  50. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  51. package/lib/cjs/components-react/properties/renderers/PropertyView.scss +3 -3
  52. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  53. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  54. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.scss +3 -3
  55. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
  56. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  57. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
  58. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  59. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
  60. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  61. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
  62. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  63. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
  64. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  65. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
  66. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  67. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
  68. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  69. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  70. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  71. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +10 -0
  72. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  73. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +59 -55
  74. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  75. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +3 -3
  76. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
  77. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  78. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  79. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  80. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
  81. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  82. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
  83. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  84. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  85. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  86. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
  87. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  88. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  89. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  90. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  91. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  92. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
  93. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  94. package/lib/cjs/components-react/selectable-content/SelectableContent.js +2 -3
  95. package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
  96. package/lib/cjs/components-react/selectable-content/SelectableContent.scss +3 -3
  97. package/lib/cjs/components-react/toolbar/ItemWrapper.scss +3 -3
  98. package/lib/cjs/components-react/toolbar/Items.scss +3 -3
  99. package/lib/cjs/components-react/toolbar/Overflow.scss +3 -3
  100. package/lib/cjs/components-react/toolbar/OverflowPanel.scss +3 -3
  101. package/lib/cjs/components-react/toolbar/PopupItem.scss +3 -3
  102. package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js +3 -4
  103. package/lib/cjs/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  104. package/lib/cjs/components-react/toolbar/_variables.scss +3 -3
  105. package/lib/cjs/components-react/toolbar/groupPanel/BackArrow.scss +3 -3
  106. package/lib/cjs/components-react/toolbar/groupPanel/Column.scss +3 -3
  107. package/lib/cjs/components-react/toolbar/groupPanel/Columns.scss +3 -3
  108. package/lib/cjs/components-react/toolbar/groupPanel/Panel.scss +3 -3
  109. package/lib/cjs/components-react/toolbar/groupPanel/Title.scss +3 -3
  110. package/lib/cjs/components-react/toolbar/groupPanel/tool/Tool.scss +3 -3
  111. package/lib/cjs/components-react/tree/controlled/TreeModel.js +7 -8
  112. package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
  113. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +6 -8
  114. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  115. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts +10 -0
  116. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  117. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js +11 -1
  118. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  119. package/lib/cjs/components-react/tree/controlled/component/NodeContent.scss +3 -3
  120. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +1 -2
  121. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  122. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
  123. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  124. package/lib/esm/components-react/common/DelayedSpinner.js +2 -3
  125. package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
  126. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +1 -2
  127. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  128. package/lib/esm/components-react/common/UseElementsScrollStorage.d.ts +13 -0
  129. package/lib/esm/components-react/common/UseElementsScrollStorage.d.ts.map +1 -0
  130. package/lib/esm/components-react/common/UseElementsScrollStorage.js +45 -0
  131. package/lib/esm/components-react/common/UseElementsScrollStorage.js.map +1 -0
  132. package/lib/esm/components-react/converters/NumericTypeConverter.js +2 -4
  133. package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
  134. package/lib/esm/components-react/converters/TypeConverter.js +1 -2
  135. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  136. package/lib/esm/components-react/datepicker/DatePicker.scss +3 -3
  137. package/lib/esm/components-react/datepicker/DatePickerPopupButton.scss +3 -3
  138. package/lib/esm/components-react/datepicker/TimeField.scss +3 -3
  139. package/lib/esm/components-react/editors/BooleanEditor.scss +3 -3
  140. package/lib/esm/components-react/editors/CustomNumberEditor.js +6 -8
  141. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  142. package/lib/esm/components-react/editors/DateTimeEditor.js +2 -3
  143. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  144. package/lib/esm/components-react/editors/EnumButtonGroupEditor.scss +3 -3
  145. package/lib/esm/components-react/editors/IconEditor.scss +3 -3
  146. package/lib/esm/components-react/editors/ImageCheckBoxEditor.scss +3 -3
  147. package/lib/esm/components-react/editors/PopupButton.js +3 -4
  148. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  149. package/lib/esm/components-react/editors/PopupButton.scss +3 -3
  150. package/lib/esm/components-react/editors/TextEditor.js +2 -4
  151. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  152. package/lib/esm/components-react/editors/ToggleEditor.scss +3 -3
  153. package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
  154. package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
  155. package/lib/esm/components-react/filter-builder/FilterBuilderRule.scss +3 -3
  156. package/lib/esm/components-react/filter-builder/FilterBuilderRuleGroup.scss +3 -3
  157. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +1 -2
  158. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  159. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +3 -3
  160. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  161. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +1 -1
  162. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  163. package/lib/esm/components-react/filtering/ResultSelector.scss +3 -3
  164. package/lib/esm/components-react/iconpicker/IconPickerButton.scss +3 -3
  165. package/lib/esm/components-react/properties/renderers/ActionButtonList.scss +3 -3
  166. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +3 -4
  167. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  168. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  169. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  170. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.scss +3 -3
  171. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +2 -3
  172. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  173. package/lib/esm/components-react/properties/renderers/PropertyView.scss +3 -3
  174. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  175. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  176. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.scss +3 -3
  177. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -2
  178. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  179. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +3 -6
  180. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  181. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -2
  182. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  183. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +3 -6
  184. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  185. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +1 -2
  186. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  187. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +1 -2
  188. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  189. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +1 -2
  190. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  191. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  192. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  193. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +10 -0
  194. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  195. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +57 -54
  196. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  197. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.scss +3 -3
  198. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +11 -13
  199. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  200. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  201. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  202. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +1 -2
  203. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  204. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +1 -2
  205. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  206. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  207. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  208. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +2 -3
  209. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  210. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  211. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  212. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  213. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  214. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +5 -7
  215. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  216. package/lib/esm/components-react/selectable-content/SelectableContent.js +2 -3
  217. package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
  218. package/lib/esm/components-react/selectable-content/SelectableContent.scss +3 -3
  219. package/lib/esm/components-react/toolbar/ItemWrapper.scss +3 -3
  220. package/lib/esm/components-react/toolbar/Items.scss +3 -3
  221. package/lib/esm/components-react/toolbar/Overflow.scss +3 -3
  222. package/lib/esm/components-react/toolbar/OverflowPanel.scss +3 -3
  223. package/lib/esm/components-react/toolbar/PopupItem.scss +3 -3
  224. package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js +3 -4
  225. package/lib/esm/components-react/toolbar/ToolbarWithOverflow.js.map +1 -1
  226. package/lib/esm/components-react/toolbar/_variables.scss +3 -3
  227. package/lib/esm/components-react/toolbar/groupPanel/BackArrow.scss +3 -3
  228. package/lib/esm/components-react/toolbar/groupPanel/Column.scss +3 -3
  229. package/lib/esm/components-react/toolbar/groupPanel/Columns.scss +3 -3
  230. package/lib/esm/components-react/toolbar/groupPanel/Panel.scss +3 -3
  231. package/lib/esm/components-react/toolbar/groupPanel/Title.scss +3 -3
  232. package/lib/esm/components-react/toolbar/groupPanel/tool/Tool.scss +3 -3
  233. package/lib/esm/components-react/tree/controlled/TreeModel.js +7 -8
  234. package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
  235. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +6 -8
  236. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  237. package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts +10 -0
  238. package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  239. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js +9 -0
  240. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  241. package/lib/esm/components-react/tree/controlled/component/NodeContent.scss +3 -3
  242. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +1 -2
  243. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  244. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +2 -4
  245. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  246. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"TreeSelectionManager.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,uDAAoD;AACpD,mDAAgD;AAChD,sDAAgD;AAKhD,iFAA8E;AAK9E,4CAA+C;AAC/C,kDAI2B;AA2B3B,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,SAAc;IAC7C,OAAO,CACL,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAND,4CAMC;AAED,gBAAgB;AAChB,MAAa,oBAAoB;IAc/B,YACE,aAA4B,EAC5B,eAAwC;QANnC,uBAAkB,GAAG,IAAI,wBAAS,EAA8B,CAAC;QACjE,wBAAmB,GAAG,IAAI,wBAAS,EAA6B,CAAC;QACjE,oBAAe,GAAG,IAAI,wBAAS,EAA2B,CAAC;QAmL1D,qBAAgB,GAAG,CACzB,CAAsB,EACtB,OAAoB,EACpB,SAAkB,EAClB,EAAE;YACF,IAAI,IAAA,4BAAe,EAAC,CAAC,CAAC,GAAG,CAAC,EAAE;gBAC1B,uBAAuB;gBACvB,IAAI,CAAC,IAAI,CAAC,gBAAgB;oBAAE,OAAO;gBAEnC,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC;gBAE7D,MAAM,YAAY,GAAG,CAAC,IAAmB,EAAW,EAAE,CACpD,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;gBAC5C,MAAM,SAAS,GAAG,CAAC,IAAmB,EAAW,EAAE,CACjD,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC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BAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,WAAW,CAAC,KAA0B,EAAE,OAAoB;QACjE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;CAoGF;AAjSD,oDAiSC;AAID,SAAS,qBAAqB,CAC5B,SAAgC;IAEhC,OAAO,OAAO,SAAS,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,WAAW;IAGf,YAAY,IAA+B;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,gCAAgC;IACzB,SAAS,KAAI,CAAC;IAErB,gCAAgC;IACzB,MAAM,KAAI,CAAC;IAElB,gCAAgC;IACzB,QAAQ,KAAI,CAAC;IAEpB,6CAA6C;IACtC,UAAU;;QACf,uBAAuB;QACvB,OAAO,CAAC,CAAC,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,UAAU,CAAA,CAAC;IAClC,CAAC;IAEM,IAAI;;QACT,OAAO,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,EAAE,mCAAI,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Tree\n */\n\nimport { take } from \"rxjs/internal/operators/take\";\nimport { Subject } from \"rxjs/internal/Subject\";\nimport { BeUiEvent } from \"@itwin/core-bentley\";\nimport type {\n MultiSelectionHandler,\n SingleSelectionHandler,\n} from \"../../../common/selection/SelectionHandler\";\nimport { SelectionHandler } from \"../../../common/selection/SelectionHandler\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport type { Observable } from \"../Observable\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type { TreeModelNode, VisibleTreeNodes } from \"../TreeModel\";\nimport { isTreeModelNode } from \"../TreeModel\";\nimport {\n isNavigationKey,\n ItemKeyboardNavigator,\n Orientation,\n} from \"@itwin/core-react\";\n\n/** @internal */\nexport interface SelectionReplacementEvent {\n selectedNodeIds: IndividualSelection | RangeSelection;\n}\n\n/** @internal */\nexport interface SelectionModificationEvent {\n selectedNodes: IndividualSelection | RangeSelection;\n deselectedNodes: IndividualSelection;\n}\n\n/** @internal */\nexport interface DragSelectionStartEvent {\n selectionChanges: Observable<SelectionModificationEvent>;\n}\n\n/** @internal */\nexport type IndividualSelection = string[];\n\n/** @internal */\nexport interface RangeSelection {\n from: string;\n to: string;\n}\n\n/** @internal */\nexport function isRangeSelection(selection: any): selection is RangeSelection {\n return (\n selection &&\n typeof selection.from === \"string\" &&\n typeof selection.to === \"string\"\n );\n}\n\n/** @internal */\nexport class TreeSelectionManager\n implements\n Pick<TreeActions, \"onNodeClicked\" | \"onNodeMouseDown\" | \"onNodeMouseMove\">\n{\n private _selectionHandler: SelectionHandler<Selection>;\n private _dragSelectionOperation?: Subject<SelectionModificationEvent>;\n private _itemHandlers: Array<Array<SingleSelectionHandler<string>>>;\n\n private _getVisibleNodes: (() => VisibleTreeNodes) | undefined;\n\n public onSelectionChanged = new BeUiEvent<SelectionModificationEvent>();\n public onSelectionReplaced = new BeUiEvent<SelectionReplacementEvent>();\n public onDragSelection = new BeUiEvent<DragSelectionStartEvent>();\n\n constructor(\n selectionMode: SelectionMode,\n getVisibleNodes?: () => VisibleTreeNodes\n ) {\n this._getVisibleNodes = getVisibleNodes;\n\n const onItemsSelected = (selections: Selection[], replacement: boolean) => {\n // Assumes that `selections` will only contain either a list of\n // `IndividualSelection` items or a single `RangeSelection` item.\n if (isIndividualSelection(selections[0])) {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections as IndividualSelection,\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections as IndividualSelection,\n deselectedNodes: [],\n });\n }\n } else {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections[0],\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections[0],\n deselectedNodes: [],\n });\n }\n }\n };\n\n const onItemsDeselected = (deselections: Selection[]) => {\n // Assumes that this will be always called with `IndividualSelection` items\n this.onSelectionChanged.emit({\n selectedNodes: [],\n deselectedNodes: deselections as IndividualSelection,\n });\n };\n\n this._selectionHandler = new SelectionHandler(\n selectionMode,\n onItemsSelected,\n onItemsDeselected\n );\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n const itemHandlers = new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"length\") {\n return _this._getVisibleNodes === undefined\n ? 0\n : _this._getVisibleNodes().getNumNodes();\n }\n\n // istanbul ignore next\n if (_this._getVisibleNodes === undefined) return undefined;\n\n const index: number = +(prop as string);\n const node = _this.getVisibleNodeAtIndex(\n _this._getVisibleNodes(),\n index\n );\n return new ItemHandler(node);\n },\n }\n ) as Array<SingleSelectionHandler<string>>;\n this._itemHandlers = [itemHandlers];\n }\n\n private getVisibleNodeAtIndex(\n nodes: VisibleTreeNodes | undefined,\n index: number\n ): TreeModelNode | undefined {\n const foundNode =\n nodes !== undefined\n ? nodes.getAtIndex(index)\n : /* istanbul ignore next */ undefined;\n return isTreeModelNode(foundNode) ? foundNode : undefined;\n }\n\n public setVisibleNodes(visibleNodes: (() => VisibleTreeNodes) | undefined) {\n this._getVisibleNodes = visibleNodes;\n }\n\n public onNodeClicked(nodeId: string, event: React.MouseEvent) {\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(nodeId)\n );\n selectionFunc(event.shiftKey, event.ctrlKey);\n }\n\n public onNodeMouseDown(nodeId: string) {\n this._selectionHandler.createDragAction(\n this.createSelectionHandlers(nodeId)[0],\n this._itemHandlers,\n nodeId\n );\n window.addEventListener(\n \"mouseup\",\n () => {\n /* istanbul ignore else */\n if (this._dragSelectionOperation) {\n this._selectionHandler.completeDragAction();\n this._dragSelectionOperation.complete();\n this._dragSelectionOperation = undefined;\n }\n },\n { once: true }\n );\n this._dragSelectionOperation = new Subject();\n this._dragSelectionOperation.pipe(take(1)).subscribe((value) => {\n this.onDragSelection.emit({\n selectionChanges: this._dragSelectionOperation!,\n });\n this._dragSelectionOperation!.next(value);\n });\n }\n\n public onNodeMouseMove(nodeId: string) {\n this._selectionHandler.updateDragAction(nodeId);\n }\n\n private createSelectionHandlers(\n nodeId: string\n ): [MultiSelectionHandler<Selection>, SingleSelectionHandler<string>] {\n let deselectedAll = false;\n const multiSelectionHandler: MultiSelectionHandler<Selection> = {\n selectBetween: (item1, item2) => [\n { from: item1 as string, to: item2 as string },\n ],\n updateSelection: (selections, deselections) => {\n // Assumes `updateSelection` will never be called with selection ranges\n const selectedNodeIds = selections as string[];\n const deselectedNodeIds = deselections as string[];\n this._dragSelectionOperation!.next({\n selectedNodes: selectedNodeIds,\n deselectedNodes: deselectedNodeIds,\n });\n },\n deselectAll: () => {\n deselectedAll = true;\n },\n areEqual: (item1, item2) => item1 === item2,\n };\n\n const singleSelectionHandler: SingleSelectionHandler<string> = {\n preselect: () => {},\n select: () => {},\n deselect: () => {},\n isSelected: () => {\n if (deselectedAll || this._getVisibleNodes === undefined) {\n return false;\n }\n\n const node = this._getVisibleNodes().getModel().getNode(nodeId);\n return node !== undefined && node.isSelected;\n },\n item: () => nodeId,\n };\n\n return [multiSelectionHandler, singleSelectionHandler];\n }\n\n public onTreeKeyDown(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, true);\n }\n\n public onTreeKeyUp(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, false);\n }\n\n private _onKeyboardEvent = (\n e: React.KeyboardEvent,\n actions: TreeActions,\n isKeyDown: boolean\n ) => {\n if (isNavigationKey(e.key)) {\n // istanbul ignore next\n if (!this._getVisibleNodes) return;\n\n const processedNodeId = this._selectionHandler.processedItem;\n\n const isExpandable = (node: TreeModelNode): boolean =>\n !node.isLoading && node.numChildren !== 0;\n const isEditing = (node: TreeModelNode): boolean =>\n node.editingInfo !== undefined;\n\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const processedNode = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore next\n if (processedNode && isEditing(processedNode)) return;\n }\n\n const handleKeyboardSelectItem = (index: number) => {\n // istanbul ignore else\n if (this._getVisibleNodes) {\n const node = this.getVisibleNodeAtIndex(\n this._getVisibleNodes(),\n index\n );\n // istanbul ignore else\n if (node) {\n // istanbul ignore next\n if (isEditing(node)) return;\n\n const selectionFunc =\n this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(node.id)\n );\n selectionFunc(e.shiftKey, e.ctrlKey);\n }\n }\n };\n const handleKeyboardActivateItem = (_index: number) => {\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const node = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore else\n if (node) {\n if (isExpandable(node)) {\n if (!node.isExpanded) actions.onNodeExpanded(node.id);\n else actions.onNodeCollapsed(node.id);\n } else {\n actions.onNodeEditorActivated(node.id);\n }\n }\n }\n };\n const handleCrossAxisArrowKey = (forward: boolean) => {\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const node = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore else\n if (node) {\n if (isExpandable(node)) {\n if (forward && !node.isExpanded) actions.onNodeExpanded(node.id);\n else if (!forward && node.isExpanded)\n actions.onNodeCollapsed(node.id);\n }\n }\n }\n };\n\n // istanbul ignore else\n if (isIndividualSelection(processedNodeId)) {\n const itemKeyboardNavigator = new ItemKeyboardNavigator(\n handleKeyboardSelectItem,\n handleKeyboardActivateItem\n );\n itemKeyboardNavigator.orientation = Orientation.Vertical;\n itemKeyboardNavigator.crossAxisArrowKeyHandler =\n handleCrossAxisArrowKey;\n itemKeyboardNavigator.allowWrap = false;\n itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();\n\n const index = this._getVisibleNodes().getIndexOfNode(processedNodeId);\n isKeyDown\n ? itemKeyboardNavigator.handleKeyDownEvent(e, index)\n : itemKeyboardNavigator.handleKeyUpEvent(e, index);\n }\n }\n };\n}\n\ntype Selection = string | RangeSelection;\n\nfunction isIndividualSelection(\n selection: Selection | undefined\n): selection is string {\n return typeof selection === \"string\";\n}\n\nclass ItemHandler implements SingleSelectionHandler<string> {\n private _node: TreeModelNode | undefined;\n\n constructor(node: TreeModelNode | undefined) {\n this._node = node;\n }\n\n /* istanbul ignore next: noop */\n public preselect() {}\n\n /* istanbul ignore next: noop */\n public select() {}\n\n /* istanbul ignore next: noop */\n public deselect() {}\n\n // eslint-disable-next-line @itwin/prefer-get\n public isSelected(): boolean {\n // istanbul ignore next\n return !!this._node?.isSelected;\n }\n\n public item(): string {\n return this._node?.id ?? \"\";\n }\n}\n"]}
1
+ {"version":3,"file":"TreeSelectionManager.js","sourceRoot":"","sources":["../../../../../../src/components-react/tree/controlled/internal/TreeSelectionManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,uDAAoD;AACpD,mDAAgD;AAChD,sDAAgD;AAKhD,iFAA8E;AAK9E,4CAA+C;AAC/C,kDAI2B;AA2B3B,gBAAgB;AAChB,SAAgB,gBAAgB,CAAC,SAAc;IAC7C,OAAO,CACL,SAAS;QACT,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ;QAClC,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC;AAND,4CAMC;AAED,gBAAgB;AAChB,MAAa,oBAAoB;IAc/B,YACE,aAA4B,EAC5B,eAAwC;QANnC,uBAAkB,GAAG,IAAI,wBAAS,EAA8B,CAAC;QACjE,wBAAmB,GAAG,IAAI,wBAAS,EAA6B,CAAC;QACjE,oBAAe,GAAG,IAAI,wBAAS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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 { take } from \"rxjs/internal/operators/take\";\nimport { Subject } from \"rxjs/internal/Subject\";\nimport { BeUiEvent } from \"@itwin/core-bentley\";\nimport type {\n MultiSelectionHandler,\n SingleSelectionHandler,\n} from \"../../../common/selection/SelectionHandler\";\nimport { SelectionHandler } from \"../../../common/selection/SelectionHandler\";\nimport type { SelectionMode } from \"../../../common/selection/SelectionModes\";\nimport type { Observable } from \"../Observable\";\nimport type { TreeActions } from \"../TreeActions\";\nimport type { TreeModelNode, VisibleTreeNodes } from \"../TreeModel\";\nimport { isTreeModelNode } from \"../TreeModel\";\nimport {\n isNavigationKey,\n ItemKeyboardNavigator,\n Orientation,\n} from \"@itwin/core-react\";\n\n/** @internal */\nexport interface SelectionReplacementEvent {\n selectedNodeIds: IndividualSelection | RangeSelection;\n}\n\n/** @internal */\nexport interface SelectionModificationEvent {\n selectedNodes: IndividualSelection | RangeSelection;\n deselectedNodes: IndividualSelection;\n}\n\n/** @internal */\nexport interface DragSelectionStartEvent {\n selectionChanges: Observable<SelectionModificationEvent>;\n}\n\n/** @internal */\nexport type IndividualSelection = string[];\n\n/** @internal */\nexport interface RangeSelection {\n from: string;\n to: string;\n}\n\n/** @internal */\nexport function isRangeSelection(selection: any): selection is RangeSelection {\n return (\n selection &&\n typeof selection.from === \"string\" &&\n typeof selection.to === \"string\"\n );\n}\n\n/** @internal */\nexport class TreeSelectionManager\n implements\n Pick<TreeActions, \"onNodeClicked\" | \"onNodeMouseDown\" | \"onNodeMouseMove\">\n{\n private _selectionHandler: SelectionHandler<Selection>;\n private _dragSelectionOperation?: Subject<SelectionModificationEvent>;\n private _itemHandlers: Array<Array<SingleSelectionHandler<string>>>;\n\n private _getVisibleNodes: (() => VisibleTreeNodes) | undefined;\n\n public onSelectionChanged = new BeUiEvent<SelectionModificationEvent>();\n public onSelectionReplaced = new BeUiEvent<SelectionReplacementEvent>();\n public onDragSelection = new BeUiEvent<DragSelectionStartEvent>();\n\n constructor(\n selectionMode: SelectionMode,\n getVisibleNodes?: () => VisibleTreeNodes\n ) {\n this._getVisibleNodes = getVisibleNodes;\n\n const onItemsSelected = (selections: Selection[], replacement: boolean) => {\n // Assumes that `selections` will only contain either a list of\n // `IndividualSelection` items or a single `RangeSelection` item.\n if (isIndividualSelection(selections[0])) {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections as IndividualSelection,\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections as IndividualSelection,\n deselectedNodes: [],\n });\n }\n } else {\n if (replacement) {\n this.onSelectionReplaced.emit({\n selectedNodeIds: selections[0],\n });\n } else {\n this.onSelectionChanged.emit({\n selectedNodes: selections[0],\n deselectedNodes: [],\n });\n }\n }\n };\n\n const onItemsDeselected = (deselections: Selection[]) => {\n // Assumes that this will be always called with `IndividualSelection` items\n this.onSelectionChanged.emit({\n selectedNodes: [],\n deselectedNodes: deselections as IndividualSelection,\n });\n };\n\n this._selectionHandler = new SelectionHandler(\n selectionMode,\n onItemsSelected,\n onItemsDeselected\n );\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const _this = this;\n const itemHandlers = new Proxy(\n {},\n {\n get(_target, prop) {\n if (prop === \"length\") {\n return _this._getVisibleNodes === undefined\n ? 0\n : _this._getVisibleNodes().getNumNodes();\n }\n\n // istanbul ignore next\n if (_this._getVisibleNodes === undefined) return undefined;\n\n const index: number = +(prop as string);\n const node = _this.getVisibleNodeAtIndex(\n _this._getVisibleNodes(),\n index\n );\n return new ItemHandler(node);\n },\n }\n ) as Array<SingleSelectionHandler<string>>;\n this._itemHandlers = [itemHandlers];\n }\n\n private getVisibleNodeAtIndex(\n nodes: VisibleTreeNodes | undefined,\n index: number\n ): TreeModelNode | undefined {\n const foundNode =\n nodes !== undefined\n ? nodes.getAtIndex(index)\n : /* istanbul ignore next */ undefined;\n return isTreeModelNode(foundNode) ? foundNode : undefined;\n }\n\n public setVisibleNodes(visibleNodes: (() => VisibleTreeNodes) | undefined) {\n this._getVisibleNodes = visibleNodes;\n }\n\n public onNodeClicked(nodeId: string, event: React.MouseEvent) {\n const selectionFunc = this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(nodeId)\n );\n selectionFunc(event.shiftKey, event.ctrlKey);\n }\n\n public onNodeMouseDown(nodeId: string) {\n this._selectionHandler.createDragAction(\n this.createSelectionHandlers(nodeId)[0],\n this._itemHandlers,\n nodeId\n );\n window.addEventListener(\n \"mouseup\",\n () => {\n /* istanbul ignore else */\n if (this._dragSelectionOperation) {\n this._selectionHandler.completeDragAction();\n this._dragSelectionOperation.complete();\n this._dragSelectionOperation = undefined;\n }\n },\n { once: true }\n );\n this._dragSelectionOperation = new Subject();\n this._dragSelectionOperation.pipe(take(1)).subscribe((value) => {\n this.onDragSelection.emit({\n selectionChanges: this._dragSelectionOperation!,\n });\n this._dragSelectionOperation!.next(value);\n });\n }\n\n public onNodeMouseMove(nodeId: string) {\n this._selectionHandler.updateDragAction(nodeId);\n }\n\n private createSelectionHandlers(\n nodeId: string\n ): [MultiSelectionHandler<Selection>, SingleSelectionHandler<string>] {\n let deselectedAll = false;\n const multiSelectionHandler: MultiSelectionHandler<Selection> = {\n selectBetween: (item1, item2) => [\n { from: item1 as string, to: item2 as string },\n ],\n updateSelection: (selections, deselections) => {\n // Assumes `updateSelection` will never be called with selection ranges\n const selectedNodeIds = selections as string[];\n const deselectedNodeIds = deselections as string[];\n this._dragSelectionOperation!.next({\n selectedNodes: selectedNodeIds,\n deselectedNodes: deselectedNodeIds,\n });\n },\n deselectAll: () => {\n deselectedAll = true;\n },\n areEqual: (item1, item2) => item1 === item2,\n };\n\n const singleSelectionHandler: SingleSelectionHandler<string> = {\n preselect: () => {},\n select: () => {},\n deselect: () => {},\n isSelected: () => {\n if (deselectedAll || this._getVisibleNodes === undefined) {\n return false;\n }\n\n const node = this._getVisibleNodes().getModel().getNode(nodeId);\n return node !== undefined && node.isSelected;\n },\n item: () => nodeId,\n };\n\n return [multiSelectionHandler, singleSelectionHandler];\n }\n\n public onTreeKeyDown(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, true);\n }\n\n public onTreeKeyUp(event: React.KeyboardEvent, actions: TreeActions): void {\n this._onKeyboardEvent(event, actions, false);\n }\n\n private _onKeyboardEvent = (\n e: React.KeyboardEvent,\n actions: TreeActions,\n isKeyDown: boolean\n ) => {\n if (isNavigationKey(e.key)) {\n // istanbul ignore next\n if (!this._getVisibleNodes) return;\n\n const processedNodeId = this._selectionHandler.processedItem;\n\n const isExpandable = (node: TreeModelNode): boolean =>\n !node.isLoading && node.numChildren !== 0;\n const isEditing = (node: TreeModelNode): boolean =>\n node.editingInfo !== undefined;\n\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const processedNode = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore next\n if (processedNode && isEditing(processedNode)) return;\n }\n\n const handleKeyboardSelectItem = (index: number) => {\n // istanbul ignore else\n if (this._getVisibleNodes) {\n const node = this.getVisibleNodeAtIndex(\n this._getVisibleNodes(),\n index\n );\n // istanbul ignore else\n if (node) {\n // istanbul ignore next\n if (isEditing(node)) return;\n\n const selectionFunc =\n this._selectionHandler.createSelectionFunction(\n ...this.createSelectionHandlers(node.id)\n );\n selectionFunc(e.shiftKey, e.ctrlKey);\n }\n }\n };\n const handleKeyboardActivateItem = (_index: number) => {\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const node = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore else\n if (node) {\n if (isExpandable(node)) {\n if (!node.isExpanded) actions.onNodeExpanded(node.id);\n else actions.onNodeCollapsed(node.id);\n } else {\n actions.onNodeEditorActivated(node.id);\n }\n }\n }\n };\n const handleCrossAxisArrowKey = (forward: boolean) => {\n // istanbul ignore else\n if (this._getVisibleNodes && isIndividualSelection(processedNodeId)) {\n const node = this._getVisibleNodes()\n .getModel()\n .getNode(processedNodeId);\n // istanbul ignore else\n if (node) {\n if (isExpandable(node)) {\n if (forward && !node.isExpanded) actions.onNodeExpanded(node.id);\n else if (!forward && node.isExpanded)\n actions.onNodeCollapsed(node.id);\n }\n }\n }\n };\n\n // istanbul ignore else\n if (isIndividualSelection(processedNodeId)) {\n const itemKeyboardNavigator = new ItemKeyboardNavigator(\n handleKeyboardSelectItem,\n handleKeyboardActivateItem\n );\n itemKeyboardNavigator.orientation = Orientation.Vertical;\n itemKeyboardNavigator.crossAxisArrowKeyHandler =\n handleCrossAxisArrowKey;\n itemKeyboardNavigator.allowWrap = false;\n itemKeyboardNavigator.itemCount = this._getVisibleNodes().getNumNodes();\n\n const index = this._getVisibleNodes().getIndexOfNode(processedNodeId);\n isKeyDown\n ? itemKeyboardNavigator.handleKeyDownEvent(e, index)\n : itemKeyboardNavigator.handleKeyUpEvent(e, index);\n }\n }\n };\n}\n\ntype Selection = string | RangeSelection;\n\nfunction isIndividualSelection(\n selection: Selection | undefined\n): selection is string {\n return typeof selection === \"string\";\n}\n\nclass ItemHandler implements SingleSelectionHandler<string> {\n private _node: TreeModelNode | undefined;\n\n constructor(node: TreeModelNode | undefined) {\n this._node = node;\n }\n\n /* istanbul ignore next: noop */\n public preselect() {}\n\n /* istanbul ignore next: noop */\n public select() {}\n\n /* istanbul ignore next: noop */\n public deselect() {}\n\n // eslint-disable-next-line @itwin/prefer-get\n public isSelected(): boolean {\n // istanbul ignore next\n return !!this._node?.isSelected;\n }\n\n public item(): string {\n return this._node?.id ?? \"\";\n }\n}\n"]}
@@ -12,8 +12,7 @@ import { ProgressRadial } from "@itwin/itwinui-react";
12
12
  * @internal
13
13
  */
14
14
  export function DelayedSpinner(props) {
15
- var _a, _b;
16
- const delay = (_a = props.delay) !== null && _a !== void 0 ? _a : 500;
15
+ const delay = props.delay ?? 500;
17
16
  const [loadStart] = React.useState(props.loadStart || new Date());
18
17
  const currTime = new Date();
19
18
  const diff = currTime.getTime() - loadStart.getTime();
@@ -26,7 +25,7 @@ export function DelayedSpinner(props) {
26
25
  });
27
26
  if (diff < delay)
28
27
  return null;
29
- return React.createElement(ProgressRadial, { indeterminate: true, size: (_b = props.size) !== null && _b !== void 0 ? _b : "large" });
28
+ return React.createElement(ProgressRadial, { indeterminate: true, size: props.size ?? "large" });
30
29
  }
31
30
  const useForceUpdate = () => {
32
31
  const [value, set] = React.useState(true);
@@ -1 +1 @@
1
- {"version":3,"file":"DelayedSpinner.js","sourceRoot":"","sources":["../../../../src/components-react/common/DelayedSpinner.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAetD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;;IACvD,MAAM,KAAK,GAAG,MAAA,KAAK,CAAC,KAAK,mCAAI,GAAG,CAAC;IACjC,MAAM,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;IAElE,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IAEtD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,IAAI,IAAI,KAAK;YAAE,OAAO;QAC1B,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;QAC/C,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,GAAG,KAAK;QAAE,OAAO,IAAI,CAAC;IAE9B,OAAO,oBAAC,cAAc,IAAC,aAAa,QAAC,IAAI,EAAE,MAAA,KAAK,CAAC,IAAI,mCAAI,OAAO,GAAI,CAAC;AACvE,CAAC;AAED,MAAM,cAAc,GAAG,GAAG,EAAE;IAC1B,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC,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 Common\n */\n\nimport * as React from \"react\";\nimport type { ProgressRadialProps } from \"@itwin/itwinui-react\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\n\n/** Type for ProgressRadialProps.size */\ntype RadialSizeType = ProgressRadialProps[\"size\"];\n\n/**\n * Props for [[DelayedSpinner]] component.\n * @internal\n */\nexport interface DelayedSpinnerProps {\n loadStart?: Date;\n delay?: number;\n size?: RadialSizeType;\n}\n\n/**\n * Spinner that is rendered with delay.\n * @internal\n */\nexport function DelayedSpinner(props: DelayedSpinnerProps) {\n const delay = props.delay ?? 500;\n const [loadStart] = React.useState(props.loadStart || new Date());\n\n const currTime = new Date();\n const diff = currTime.getTime() - loadStart.getTime();\n\n const update = useForceUpdate();\n React.useEffect(() => {\n if (diff >= delay) return;\n const timer = setTimeout(update, delay - diff);\n return () => clearTimeout(timer);\n });\n\n if (diff < delay) return null;\n\n return <ProgressRadial indeterminate size={props.size ?? \"large\"} />;\n}\n\nconst useForceUpdate = () => {\n const [value, set] = React.useState(true);\n return () => set(!value);\n};\n"]}
1
+ {"version":3,"file":"DelayedSpinner.js","sour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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 Common\n */\n\nimport * as React from \"react\";\nimport type { ProgressRadialProps } from \"@itwin/itwinui-react\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\n\n/** Type for ProgressRadialProps.size */\ntype RadialSizeType = ProgressRadialProps[\"size\"];\n\n/**\n * Props for [[DelayedSpinner]] component.\n * @internal\n */\nexport interface DelayedSpinnerProps {\n loadStart?: Date;\n delay?: number;\n size?: RadialSizeType;\n}\n\n/**\n * Spinner that is rendered with delay.\n * @internal\n */\nexport function DelayedSpinner(props: DelayedSpinnerProps) {\n const delay = props.delay ?? 500;\n const [loadStart] = React.useState(props.loadStart || new Date());\n\n const currTime = new Date();\n const diff = currTime.getTime() - loadStart.getTime();\n\n const update = useForceUpdate();\n React.useEffect(() => {\n if (diff >= delay) return;\n const timer = setTimeout(update, delay - diff);\n return () => clearTimeout(timer);\n });\n\n if (diff < delay) return null;\n\n return <ProgressRadial indeterminate size={props.size ?? \"large\"} />;\n}\n\nconst useForceUpdate = () => {\n const [value, set] = React.useState(true);\n return () => set(!value);\n};\n"]}
@@ -20,7 +20,6 @@ import { scheduleSubscription, SubscriptionScheduler, } from "./SubscriptionSche
20
20
  * @beta
21
21
  */
22
22
  export function useDebouncedAsyncValue(valueToBeResolved) {
23
- var _a;
24
23
  const scheduler = useMemo(() => new SubscriptionScheduler(), []);
25
24
  const [value, setValue] = useState();
26
25
  const [inProgress, setInProgress] = useState(false);
@@ -53,7 +52,7 @@ export function useDebouncedAsyncValue(valueToBeResolved) {
53
52
  };
54
53
  }, [valueToBeResolved, scheduler]);
55
54
  if (errorState.hasError)
56
- throw ((_a = errorState.error) !== null && _a !== void 0 ? _a : new Error("Exception in `useDebouncedAsyncValue`"));
55
+ throw (errorState.error ?? new Error("Exception in `useDebouncedAsyncValue`"));
57
56
  return { value, inProgress };
58
57
  }
59
58
  //# sourceMappingURL=UseDebouncedAsyncValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,iBAAuD;;IAEvD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,qBAAqB,EAAW,EAAE,EAAE,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAW,CAAC;IAC9C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAGzC;QACD,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,iBAAiB,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,CAAC;YACpB,aAAa,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO;SACR;QAED,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,yFAAyF;QACzF,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC;aAC1C,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;aAC5D,SAAS,CAAC;YACT,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;gBACb,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACf,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;gBACb,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;IAEnC,IAAI,UAAU,CAAC,QAAQ;QACrB,MAAM,CACJ,MAAA,UAAU,CAAC,KAAK,mCAAI,IAAI,KAAK,CAAC,uCAAuC,CAAC,CACvE,CAAC;IAEJ,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,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 Common\n */\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { defer } from \"rxjs/internal/observable/defer\";\nimport { publish } from \"rxjs/internal/operators/publish\";\nimport { refCount } from \"rxjs/internal/operators/refCount\";\nimport {\n scheduleSubscription,\n SubscriptionScheduler,\n} from \"./SubscriptionScheduler\";\n\n/**\n * Custom hook for working with promise values.\n * Promises are debounced using trailing and leading edge.\n * The first promise will always be executed.\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\n * Once the first promise finishes resolving, the last passed promise starts resolving.\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\n * @beta\n */\nexport function useDebouncedAsyncValue<TReturn>(\n valueToBeResolved: undefined | (() => Promise<TReturn>)\n) {\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []);\n\n const [value, setValue] = useState<TReturn>();\n const [inProgress, setInProgress] = useState(false);\n const [errorState, setErrorState] = useState<{\n error: Error | undefined;\n hasError: boolean;\n }>({\n error: undefined,\n hasError: false,\n });\n\n useEffect(() => {\n if (!valueToBeResolved) {\n setValue(undefined);\n setInProgress(false);\n return;\n }\n\n setInProgress(true);\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\n const subscription = defer(valueToBeResolved)\n .pipe(publish(), refCount(), scheduleSubscription(scheduler))\n .subscribe({\n next: (data) => {\n setValue(data);\n setInProgress(false);\n },\n error: (err) => {\n setErrorState({ error: err, hasError: true });\n setInProgress(false);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [valueToBeResolved, scheduler]);\n\n if (errorState.hasError)\n throw (\n errorState.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\")\n );\n\n return { value, inProgress };\n}\n"]}
1
+ {"version":3,"file":"UseDebouncedAsyncValue.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseDebouncedAsyncValue.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,iBAAuD;IAEvD,MAAM,SAAS,GAAG,OAAO,CA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K,IAAI,IAAI,KAAK,CAAC,uCAAuC,CAAC,CACvE,CAAC;IAEJ,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,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 Common\n */\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { defer } from \"rxjs/internal/observable/defer\";\nimport { publish } from \"rxjs/internal/operators/publish\";\nimport { refCount } from \"rxjs/internal/operators/refCount\";\nimport {\n scheduleSubscription,\n SubscriptionScheduler,\n} from \"./SubscriptionScheduler\";\n\n/**\n * Custom hook for working with promise values.\n * Promises are debounced using trailing and leading edge.\n * The first promise will always be executed.\n * Any promises following the first while it is executing will be scheduled (and unscheduled), leaving only the last promise to be resolved.\n * Once the first promise finishes resolving, the last passed promise starts resolving.\n * @throws if/when `valueToBeResolved` promise is rejected. The error is thrown in the React's render loop, so it can be caught using an error boundary.\n * @beta\n */\nexport function useDebouncedAsyncValue<TReturn>(\n valueToBeResolved: undefined | (() => Promise<TReturn>)\n) {\n const scheduler = useMemo(() => new SubscriptionScheduler<TReturn>(), []);\n\n const [value, setValue] = useState<TReturn>();\n const [inProgress, setInProgress] = useState(false);\n const [errorState, setErrorState] = useState<{\n error: Error | undefined;\n hasError: boolean;\n }>({\n error: undefined,\n hasError: false,\n });\n\n useEffect(() => {\n if (!valueToBeResolved) {\n setValue(undefined);\n setInProgress(false);\n return;\n }\n\n setInProgress(true);\n // schedule and subscribe to the observable emitting value from valueToBeResolved promise\n const subscription = defer(valueToBeResolved)\n .pipe(publish(), refCount(), scheduleSubscription(scheduler))\n .subscribe({\n next: (data) => {\n setValue(data);\n setInProgress(false);\n },\n error: (err) => {\n setErrorState({ error: err, hasError: true });\n setInProgress(false);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [valueToBeResolved, scheduler]);\n\n if (errorState.hasError)\n throw (\n errorState.error ?? new Error(\"Exception in `useDebouncedAsyncValue`\")\n );\n\n return { value, inProgress };\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { Ref } from "react";
2
+ /**
3
+ * Returns callbacks for persisting and restoring elements `scrollTop` property value.
4
+ * This can be used to restore elements scroll position if it needs to be hidden and
5
+ * later shown again without unmounting React component.
6
+ * @internal
7
+ */
8
+ export declare function useElementsScrollStorage<T extends Element>(elementsClassName: string): {
9
+ ref: Ref<T>;
10
+ persist: () => void;
11
+ restore: () => void;
12
+ };
13
+ //# sourceMappingURL=UseElementsScrollStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseElementsScrollStorage.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/UseElementsScrollStorage.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,OAAO,EACxD,iBAAiB,EAAE,MAAM,GACxB;IACD,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACZ,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAqCA"}
@@ -0,0 +1,45 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import { useRef } from "react";
6
+ /**
7
+ * Returns callbacks for persisting and restoring elements `scrollTop` property value.
8
+ * This can be used to restore elements scroll position if it needs to be hidden and
9
+ * later shown again without unmounting React component.
10
+ * @internal
11
+ */
12
+ export function useElementsScrollStorage(elementsClassName) {
13
+ const ref = useRef(null);
14
+ const scrollTop = useRef([]);
15
+ const getElements = () => {
16
+ // istanbul ignore if
17
+ if (!ref.current) {
18
+ return [];
19
+ }
20
+ return ref.current.getElementsByClassName(elementsClassName);
21
+ };
22
+ /** Persists current `scrollTop` property value of elements. */
23
+ const persist = () => {
24
+ const elements = getElements();
25
+ const offsets = [];
26
+ for (const element of elements) {
27
+ offsets.push(element.scrollTop);
28
+ }
29
+ scrollTop.current = offsets;
30
+ };
31
+ /** Restores `scrollTop` property values back. If `persist` was not called does nothing. */
32
+ const restore = () => {
33
+ const elements = getElements();
34
+ if (elements.length !== scrollTop.current.length) {
35
+ scrollTop.current = [];
36
+ return;
37
+ }
38
+ for (let i = 0; i < scrollTop.current.length; i++) {
39
+ elements[i].scrollTop = scrollTop.current[i];
40
+ }
41
+ scrollTop.current = [];
42
+ };
43
+ return { ref, persist, restore };
44
+ }
45
+ //# sourceMappingURL=UseElementsScrollStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseElementsScrollStorage.js","sourceRoot":"","sources":["../../../../src/components-react/common/UseElementsScrollStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,iBAAyB;IAMzB,MAAM,GAAG,GAAG,MAAM,CAAI,IAAI,CAAC,CAAC;IAC5B,MAAM,SAAS,GAAG,MAAM,CAAW,EAAE,CAAC,CAAC;IAEvC,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,qBAAqB;QACrB,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YAChB,OAAO,EAAE,CAAC;SACX;QACD,OAAO,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC/D,CAAC,CAAC;IAEF,+DAA+D;IAC/D,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SACjC;QACD,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;IAC9B,CAAC,CAAC;IAEF,2FAA2F;IAC3F,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE;YAChD,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC;YACvB,OAAO;SACR;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjD,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SAC9C;QACD,SAAS,CAAC,OAAO,GAAG,EAAE,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACnC,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\nimport type { Ref } from \"react\";\nimport { useRef } from \"react\";\n\n/**\n * Returns callbacks for persisting and restoring elements `scrollTop` property value.\n * This can be used to restore elements scroll position if it needs to be hidden and\n * later shown again without unmounting React component.\n * @internal\n */\nexport function useElementsScrollStorage<T extends Element>(\n elementsClassName: string\n): {\n ref: Ref<T>;\n persist: () => void;\n restore: () => void;\n} {\n const ref = useRef<T>(null);\n const scrollTop = useRef<number[]>([]);\n\n const getElements = () => {\n // istanbul ignore if\n if (!ref.current) {\n return [];\n }\n return ref.current.getElementsByClassName(elementsClassName);\n };\n\n /** Persists current `scrollTop` property value of elements. */\n const persist = () => {\n const elements = getElements();\n const offsets: number[] = [];\n for (const element of elements) {\n offsets.push(element.scrollTop);\n }\n scrollTop.current = offsets;\n };\n\n /** Restores `scrollTop` property values back. If `persist` was not called does nothing. */\n const restore = () => {\n const elements = getElements();\n if (elements.length !== scrollTop.current.length) {\n scrollTop.current = [];\n return;\n }\n\n for (let i = 0; i < scrollTop.current.length; i++) {\n elements[i].scrollTop = scrollTop.current[i];\n }\n scrollTop.current = [];\n };\n\n return { ref, persist, restore };\n}\n"]}
@@ -42,7 +42,6 @@ export class FloatTypeConverter extends NumericTypeConverterBase {
42
42
  return Number.isNaN(parsedValue) ? undefined : parsedValue;
43
43
  }
44
44
  convertToString(value) {
45
- var _a;
46
45
  if (value === undefined)
47
46
  return "";
48
47
  let numericValue = 0;
@@ -52,7 +51,7 @@ export class FloatTypeConverter extends NumericTypeConverterBase {
52
51
  numericValue = 0;
53
52
  }
54
53
  else {
55
- numericValue = (_a = FloatTypeConverter.parseString(value)) !== null && _a !== void 0 ? _a : 0;
54
+ numericValue = FloatTypeConverter.parseString(value) ?? 0;
56
55
  }
57
56
  }
58
57
  else {
@@ -83,7 +82,6 @@ export class IntTypeConverter extends NumericTypeConverterBase {
83
82
  return Number.isNaN(parsedValue) ? undefined : parsedValue;
84
83
  }
85
84
  convertToString(value) {
86
- var _a;
87
85
  if (value === undefined)
88
86
  return "";
89
87
  let numericValue = 0;
@@ -93,7 +91,7 @@ export class IntTypeConverter extends NumericTypeConverterBase {
93
91
  numericValue = 0;
94
92
  }
95
93
  else {
96
- numericValue = (_a = IntTypeConverter.parseString(value)) !== null && _a !== void 0 ? _a : 0;
94
+ numericValue = IntTypeConverter.parseString(value) ?? 0;
97
95
  }
98
96
  }
99
97
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"NumericTypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/NumericTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CA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O,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,EAAE;gBACnD,sCAAsC;gBACtC,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM;gBACL,YAAY,GAAG,MAAA,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,mCAAI,CAAC,CAAC;aACzD;SACF;aAAM;YACL,YAAY,GAAG,KAAK,CAAC;SACtB;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7C,CAAC;IAEe,iBAAiB,CAAC,KAAa;QAC7C,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAChF,oBAAoB,CAAC,iBAAiB,CACpC,iBAAiB,CAAC,OAAO,EACzB,gBAAgB,CACjB,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 TypeConverters\n */\n\nimport type { Primitives } from \"@itwin/appui-abstract\";\nimport { StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type { LessGreaterOperatorProcessor } from \"./TypeConverter\";\nimport { TypeConverter } from \"./TypeConverter\";\nimport { TypeConverterManager } from \"./TypeConverterManager\";\n\n/**\n * Base Numeric Type Converter.\n * @public\n */\nexport abstract class NumericTypeConverterBase\n extends TypeConverter\n implements LessGreaterOperatorProcessor\n{\n public override get isLessGreaterType(): boolean {\n return true;\n }\n\n public isLessThan(a: Primitives.Numeric, b: Primitives.Numeric): boolean {\n return a < b;\n }\n\n public isLessThanOrEqualTo(\n a: Primitives.Numeric,\n b: Primitives.Numeric\n ): boolean {\n return a <= b;\n }\n\n public isGreaterThan(a: Primitives.Numeric, b: Primitives.Numeric): boolean {\n return a > b;\n }\n\n public isGreaterThanOrEqualTo(\n a: Primitives.Numeric,\n b: Primitives.Numeric\n ): boolean {\n return a >= b;\n }\n\n public sortCompare(\n a: Primitives.Numeric,\n b: Primitives.Numeric,\n _ignoreCase?: boolean\n ): number {\n return +a - +b;\n }\n}\n\n/**\n * Float Type Converter.\n * @public\n */\nexport class FloatTypeConverter extends NumericTypeConverterBase {\n private static parseString(value: string): number | undefined {\n const parsedValue = parseFloat(value);\n return Number.isNaN(parsedValue) ? undefined : parsedValue;\n }\n\n public override convertToString(value?: Primitives.Float) {\n if (value === undefined) return \"\";\n\n let numericValue = 0;\n if (typeof value === \"string\") {\n if (value === \"-\" || value === \"\" || value === \"-0.0\" || value === \"-0\") {\n // handle these semi-valid values as 0\n numericValue = 0;\n } else {\n numericValue = FloatTypeConverter.parseString(value) ?? 0;\n }\n } else {\n numericValue = value;\n }\n // this is close to calling `toFixed(2)`, but cuts of any trailing zeros\n let stringValue = (Math.round(100 * numericValue) / 100).toString();\n // because this is a _float_ converter, we want to emphasize the number is a float - make\n // sure there's a decimal part\n if (stringValue.indexOf(\".\") === -1) stringValue += \".0\";\n return stringValue;\n }\n\n public override convertFromString(value: string): number | undefined {\n return FloatTypeConverter.parseString(value);\n }\n}\nTypeConverterManager.registerConverter(\n StandardTypeNames.Float,\n FloatTypeConverter\n);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Double,\n FloatTypeConverter\n);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Number,\n FloatTypeConverter\n);\n\n/**\n * Int Type Converter.\n * @public\n */\nexport class IntTypeConverter extends NumericTypeConverterBase {\n private static parseString(value: string): number | undefined {\n const parsedValue = parseInt(value, 10);\n return Number.isNaN(parsedValue) ? undefined : parsedValue;\n }\n\n public override convertToString(value?: Primitives.Int) {\n if (value === undefined) return \"\";\n\n let numericValue = 0;\n if (typeof value === \"string\") {\n if (value === \"-\" || value === \"\" || value === \"-0\") {\n // handle these semi-valid values as 0\n numericValue = 0;\n } else {\n numericValue = IntTypeConverter.parseString(value) ?? 0;\n }\n } else {\n numericValue = value;\n }\n return Math.round(numericValue).toString();\n }\n\n public override convertFromString(value: string): number | undefined {\n return IntTypeConverter.parseString(value);\n }\n}\n\nTypeConverterManager.registerConverter(StandardTypeNames.Int, IntTypeConverter);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Integer,\n IntTypeConverter\n);\n"]}
1
+ {"version":3,"file":"NumericTypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/NumericTypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAgB,wBACpB,SAAQ,aAAa;IAGrB,IAAoB,iBAAiB;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,UAAU,CAAC,CAAqB,EAAE,CAAqB;QAC5D,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAEM,mBAAmB,CACxB,CAAqB,EACrB,CAAqB;QAErB,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,aAAa,CAAC,CAAqB,EAAE,CAAqB;QAC/D,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAEM,sBAAsB,CAC3B,CAAqB,EACrB,CAAqB;QAErB,OAAO,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,WAAW,CAChB,CAAqB,EACrB,CAAqB,EACrB,WAAqB;QAErB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACjB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,wBAAwB;IAC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B,CAAC,iBAAiB,CACpC,iBAAiB,CAAC,MAAM,EACxB,kBAAkB,CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,wBAAwB;IACpD,MAAM,CAAC,WAAW,CAAC,KAAa;QACtC,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAC7D,CAAC;IAEe,eAAe,CAAC,KAAsB;QACpD,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QAEnC,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,IAAI,EAAE;gBACnD,sCAAsC;gBACtC,YAAY,GAAG,CAAC,CAAC;aAClB;iBAAM;gBACL,YAAY,GAAG,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACzD;SACF;aAAM;YACL,YAAY,GAAG,KAAK,CAAC;SACtB;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7C,CAAC;IAEe,iBAAiB,CAAC,KAAa;QAC7C,OAAO,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,oBAAoB,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;AAChF,oBAAoB,CAAC,iBAAiB,CACpC,iBAAiB,CAAC,OAAO,EACzB,gBAAgB,CACjB,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 TypeConverters\n */\n\nimport type { Primitives } from \"@itwin/appui-abstract\";\nimport { StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type { LessGreaterOperatorProcessor } from \"./TypeConverter\";\nimport { TypeConverter } from \"./TypeConverter\";\nimport { TypeConverterManager } from \"./TypeConverterManager\";\n\n/**\n * Base Numeric Type Converter.\n * @public\n */\nexport abstract class NumericTypeConverterBase\n extends TypeConverter\n implements LessGreaterOperatorProcessor\n{\n public override get isLessGreaterType(): boolean {\n return true;\n }\n\n public isLessThan(a: Primitives.Numeric, b: Primitives.Numeric): boolean {\n return a < b;\n }\n\n public isLessThanOrEqualTo(\n a: Primitives.Numeric,\n b: Primitives.Numeric\n ): boolean {\n return a <= b;\n }\n\n public isGreaterThan(a: Primitives.Numeric, b: Primitives.Numeric): boolean {\n return a > b;\n }\n\n public isGreaterThanOrEqualTo(\n a: Primitives.Numeric,\n b: Primitives.Numeric\n ): boolean {\n return a >= b;\n }\n\n public sortCompare(\n a: Primitives.Numeric,\n b: Primitives.Numeric,\n _ignoreCase?: boolean\n ): number {\n return +a - +b;\n }\n}\n\n/**\n * Float Type Converter.\n * @public\n */\nexport class FloatTypeConverter extends NumericTypeConverterBase {\n private static parseString(value: string): number | undefined {\n const parsedValue = parseFloat(value);\n return Number.isNaN(parsedValue) ? undefined : parsedValue;\n }\n\n public override convertToString(value?: Primitives.Float) {\n if (value === undefined) return \"\";\n\n let numericValue = 0;\n if (typeof value === \"string\") {\n if (value === \"-\" || value === \"\" || value === \"-0.0\" || value === \"-0\") {\n // handle these semi-valid values as 0\n numericValue = 0;\n } else {\n numericValue = FloatTypeConverter.parseString(value) ?? 0;\n }\n } else {\n numericValue = value;\n }\n // this is close to calling `toFixed(2)`, but cuts of any trailing zeros\n let stringValue = (Math.round(100 * numericValue) / 100).toString();\n // because this is a _float_ converter, we want to emphasize the number is a float - make\n // sure there's a decimal part\n if (stringValue.indexOf(\".\") === -1) stringValue += \".0\";\n return stringValue;\n }\n\n public override convertFromString(value: string): number | undefined {\n return FloatTypeConverter.parseString(value);\n }\n}\nTypeConverterManager.registerConverter(\n StandardTypeNames.Float,\n FloatTypeConverter\n);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Double,\n FloatTypeConverter\n);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Number,\n FloatTypeConverter\n);\n\n/**\n * Int Type Converter.\n * @public\n */\nexport class IntTypeConverter extends NumericTypeConverterBase {\n private static parseString(value: string): number | undefined {\n const parsedValue = parseInt(value, 10);\n return Number.isNaN(parsedValue) ? undefined : parsedValue;\n }\n\n public override convertToString(value?: Primitives.Int) {\n if (value === undefined) return \"\";\n\n let numericValue = 0;\n if (typeof value === \"string\") {\n if (value === \"-\" || value === \"\" || value === \"-0\") {\n // handle these semi-valid values as 0\n numericValue = 0;\n } else {\n numericValue = IntTypeConverter.parseString(value) ?? 0;\n }\n } else {\n numericValue = value;\n }\n return Math.round(numericValue).toString();\n }\n\n public override convertFromString(value: string): number | undefined {\n return IntTypeConverter.parseString(value);\n }\n}\n\nTypeConverterManager.registerConverter(StandardTypeNames.Int, IntTypeConverter);\nTypeConverterManager.registerConverter(\n StandardTypeNames.Integer,\n IntTypeConverter\n);\n"]}
@@ -31,8 +31,7 @@ export class TypeConverter {
31
31
  }
32
32
  /** Converts a value associated with a property description to a string */
33
33
  convertPropertyToString(propertyDescription, value) {
34
- var _a;
35
- return this.convertToStringWithOptions(value, (_a = propertyDescription.converter) === null || _a === void 0 ? void 0 : _a.options);
34
+ return this.convertToStringWithOptions(value, propertyDescription.converter?.options);
36
35
  }
37
36
  /** Converts a string with a property record to a property value */
38
37
  async convertFromStringToPropertyValue(value, propertyRecord) {
@@ -1 +1 @@
1
- {"version":3,"file":"TypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/TypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAWH,OAAO,EAAE,mBAAmB,EAAE,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;QAExB,OAAO,MAAM,KAAK,MAAM,CAAC;IAC3B,CAAC;IAED,uDAAuD;IAChD,YAAY,CACjB,MAAwB,EACxB,MAAwB;QAExB,OAAO,MAAM,KAAK,MAAM,CAAC;IAC3B,CAAC;IAED,2DAA2D;IACpD,MAAM,CAAC,KAAuB;QACnC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC/C,CAAC;IAED,mEAAmE;IAC5D,SAAS,CAAC,KAAuB;QACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC/C,CAAC;IAED,uDAAuD;IACvD,IAAW,YAAY;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wDAAwD;IACxD,IAAW,iBAAiB;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wDAAwD;IACxD,IAAW,aAAa;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,yDAAyD;IACzD,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module TypeConverters\n */\n\n// cSpell:ignore valuetypes shortdate\n\nimport type {\n Primitives,\n PrimitiveValue,\n PropertyDescription,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes\";\n\n/** Sort compare method for types that support sorting\n * @public\n */\nexport interface SortComparer {\n /** Sort function for two primitive values */\n sortCompare(\n valueA: Primitives.Value,\n valueB: Primitives.Value,\n ignoreCase?: boolean\n ): number;\n}\n\n/** Operators for all filterable types\n * @public\n */\nexport interface OperatorProcessor {\n /** Determines if two primitive values are equal */\n isEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if two primitive values are not equal */\n isNotEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n}\n\n/** Operators for Numeric types, DateTime, TimeSpan, or any type that supports these comparisons\n * @public\n */\nexport interface LessGreaterOperatorProcessor {\n /** Determines if a primitive values is less than another primitive value */\n isLessThan(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is less than or equal to another primitive value */\n isLessThanOrEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is greater than another primitive value */\n isGreaterThan(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is greater than or equal to another primitive value */\n isGreaterThanOrEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n}\n\n/** Operators for all filterable null-able types\n * @public\n */\nexport interface NullableOperatorProcessor {\n /** Determines if a primitive value is null or undefined */\n isNull(value: Primitives.Value): boolean;\n /** Determines if a primitive value is not null or not undefined */\n isNotNull(value: Primitives.Value): boolean;\n}\n\n/**\n * Type Converter base class.\n * @public\n */\nexport abstract class TypeConverter\n implements SortComparer, OperatorProcessor, NullableOperatorProcessor\n{\n /** Converts a primitive value to a string */\n public convertToString(value?: Primitives.Value): string | Promise<string> {\n if (value === undefined) return \"\";\n return value.toString();\n }\n\n /** Default implementation just calls convertToString with no options */\n public convertToStringWithOptions(\n value?: Primitives.Value,\n _options?: { [key: string]: any }\n ): string | Promise<string> {\n return this.convertToString(value);\n }\n\n /** Converts a string to a primitive value */\n public convertFromString(\n _value: string\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n return undefined;\n }\n\n /** Default implementation just calls convertFromString with no options */\n public convertFromStringWithOptions(\n value: string,\n _options?: { [key: string]: any }\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n return this.convertFromString(value);\n }\n\n /** Converts a value associated with a property description to a string */\n public convertPropertyToString(\n propertyDescription: PropertyDescription,\n value?: Primitives.Value\n ): string | Promise<string> {\n return this.convertToStringWithOptions(\n value,\n propertyDescription.converter?.options\n );\n }\n\n /** Converts a string with a property record to a property value */\n public async convertFromStringToPropertyValue(\n value: string,\n propertyRecord?: PropertyRecord\n ): Promise<PropertyValue> {\n const converterOptions =\n propertyRecord && propertyRecord.property.converter\n ? propertyRecord.property.converter.options\n : undefined;\n const stringValue = await this.convertFromStringWithOptions(\n value,\n converterOptions\n );\n const propertyValue: PrimitiveValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: stringValue,\n displayValue: \"\",\n };\n return propertyValue;\n }\n\n /** Sort function for two primitive values */\n public abstract sortCompare(\n valueA: Primitives.Value,\n valueB: Primitives.Value,\n _ignoreCase?: boolean\n ): number;\n\n /** Determines if two primitive values are equal */\n public isEqualTo(\n valueA: Primitives.Value,\n valueB: Primitives.Value\n ): boolean {\n return valueA === valueB;\n }\n\n /** Determines if two primitive values are not equal */\n public isNotEqualTo(\n valueA: Primitives.Value,\n valueB: Primitives.Value\n ): boolean {\n return valueA !== valueB;\n }\n\n /** Determines if a primitive value is null or undefined */\n public isNull(value: Primitives.Value): boolean {\n return value === null || value === undefined;\n }\n\n /** Determines if a primitive value is not null or not undefined */\n public isNotNull(value: Primitives.Value): boolean {\n return value !== null && value !== undefined;\n }\n\n /** Determines if the converter is for a string type */\n public get isStringType(): boolean {\n return false;\n }\n /** Determines if the converter is for a numeric type */\n public get isLessGreaterType(): boolean {\n return false;\n }\n /** Determines if the converter is for a boolean type */\n public get isBooleanType(): boolean {\n return false;\n }\n /** Determines if the converter is for a nullable type */\n public get isNullableType(): boolean {\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"TypeConverter.js","sourceRoot":"","sources":["../../../../src/components-react/converters/TypeConverter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAWH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAiD5D;;;GAGG;AACH,MAAM,OAAgB,aAAa;IAGjC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CACjB,MAAwB,EACxB,MAAwB;QAExB,OAAO,MAAM,KAAK,MAAM,CAAC;IAC3B,CAAC;IAED,2DAA2D;IACpD,MAAM,CAAC,KAAuB;QACnC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC/C,CAAC;IAED,mEAAmE;IAC5D,SAAS,CAAC,KAAuB;QACtC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC/C,CAAC;IAED,uDAAuD;IACvD,IAAW,YAAY;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wDAAwD;IACxD,IAAW,iBAAiB;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,wDAAwD;IACxD,IAAW,aAAa;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,yDAAyD;IACzD,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module TypeConverters\n */\n\n// cSpell:ignore valuetypes shortdate\n\nimport type {\n Primitives,\n PrimitiveValue,\n PropertyDescription,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { ConvertedPrimitives } from \"./valuetypes/ConvertedTypes\";\n\n/** Sort compare method for types that support sorting\n * @public\n */\nexport interface SortComparer {\n /** Sort function for two primitive values */\n sortCompare(\n valueA: Primitives.Value,\n valueB: Primitives.Value,\n ignoreCase?: boolean\n ): number;\n}\n\n/** Operators for all filterable types\n * @public\n */\nexport interface OperatorProcessor {\n /** Determines if two primitive values are equal */\n isEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if two primitive values are not equal */\n isNotEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n}\n\n/** Operators for Numeric types, DateTime, TimeSpan, or any type that supports these comparisons\n * @public\n */\nexport interface LessGreaterOperatorProcessor {\n /** Determines if a primitive values is less than another primitive value */\n isLessThan(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is less than or equal to another primitive value */\n isLessThanOrEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is greater than another primitive value */\n isGreaterThan(a: Primitives.Value, b: Primitives.Value): boolean;\n /** Determines if a primitive values is greater than or equal to another primitive value */\n isGreaterThanOrEqualTo(a: Primitives.Value, b: Primitives.Value): boolean;\n}\n\n/** Operators for all filterable null-able types\n * @public\n */\nexport interface NullableOperatorProcessor {\n /** Determines if a primitive value is null or undefined */\n isNull(value: Primitives.Value): boolean;\n /** Determines if a primitive value is not null or not undefined */\n isNotNull(value: Primitives.Value): boolean;\n}\n\n/**\n * Type Converter base class.\n * @public\n */\nexport abstract class TypeConverter\n implements SortComparer, OperatorProcessor, NullableOperatorProcessor\n{\n /** Converts a primitive value to a string */\n public convertToString(value?: Primitives.Value): string | Promise<string> {\n if (value === undefined) return \"\";\n return value.toString();\n }\n\n /** Default implementation just calls convertToString with no options */\n public convertToStringWithOptions(\n value?: Primitives.Value,\n _options?: { [key: string]: any }\n ): string | Promise<string> {\n return this.convertToString(value);\n }\n\n /** Converts a string to a primitive value */\n public convertFromString(\n _value: string\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n return undefined;\n }\n\n /** Default implementation just calls convertFromString with no options */\n public convertFromStringWithOptions(\n value: string,\n _options?: { [key: string]: any }\n ):\n | ConvertedPrimitives.Value\n | undefined\n | Promise<ConvertedPrimitives.Value | undefined> {\n return this.convertFromString(value);\n }\n\n /** Converts a value associated with a property description to a string */\n public convertPropertyToString(\n propertyDescription: PropertyDescription,\n value?: Primitives.Value\n ): string | Promise<string> {\n return this.convertToStringWithOptions(\n value,\n propertyDescription.converter?.options\n );\n }\n\n /** Converts a string with a property record to a property value */\n public async convertFromStringToPropertyValue(\n value: string,\n propertyRecord?: PropertyRecord\n ): Promise<PropertyValue> {\n const converterOptions =\n propertyRecord && propertyRecord.property.converter\n ? propertyRecord.property.converter.options\n : undefined;\n const stringValue = await this.convertFromStringWithOptions(\n value,\n converterOptions\n );\n const propertyValue: PrimitiveValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: stringValue,\n displayValue: \"\",\n };\n return propertyValue;\n }\n\n /** Sort function for two primitive values */\n public abstract sortCompare(\n valueA: Primitives.Value,\n valueB: Primitives.Value,\n _ignoreCase?: boolean\n ): number;\n\n /** Determines if two primitive values are equal */\n public isEqualTo(\n valueA: Primitives.Value,\n valueB: Primitives.Value\n ): boolean {\n return valueA === valueB;\n }\n\n /** Determines if two primitive values are not equal */\n public isNotEqualTo(\n valueA: Primitives.Value,\n valueB: Primitives.Value\n ): boolean {\n return valueA !== valueB;\n }\n\n /** Determines if a primitive value is null or undefined */\n public isNull(value: Primitives.Value): boolean {\n return value === null || value === undefined;\n }\n\n /** Determines if a primitive value is not null or not undefined */\n public isNotNull(value: Primitives.Value): boolean {\n return value !== null && value !== undefined;\n }\n\n /** Determines if the converter is for a string type */\n public get isStringType(): boolean {\n return false;\n }\n /** Determines if the converter is for a numeric type */\n public get isLessGreaterType(): boolean {\n return false;\n }\n /** Determines if the converter is for a boolean type */\n public get isBooleanType(): boolean {\n return false;\n }\n /** Determines if the converter is for a nullable type */\n public get isNullableType(): boolean {\n return true;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
6
  @import "~@itwin/core-react/lib/cjs/core-react/style/opacity";
7
7
  @import "~@itwin/core-react/lib/cjs/core-react/icons/variables";
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  @import "~@itwin/core-react/lib/cjs/core-react/index";
6
6
 
7
7
  .components-date-picker-calendar-popup-button {
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  @import "~@itwin/core-react/lib/cjs/core-react/inputs/variables";
6
6
  @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
 
6
6
  $checkbox-size: calc(var(--iui-font-size-1) * 1.2);
7
7
 
@@ -31,12 +31,11 @@ export class CustomNumberEditor extends React.PureComponent {
31
31
  this._applyUpdatedValue(e.target.value);
32
32
  };
33
33
  this._onKeyPress = (e) => {
34
- var _a;
35
34
  // istanbul ignore else
36
35
  if (e.key === SpecialKey.Escape) {
37
- const initialDisplayValue = (_a = (this._lastValidValue &&
38
- this._lastValidValue.displayValue)) !== null && _a !== void 0 ? _a :
39
- /* istanbul ignore next */ this._getInitialDisplayValue();
36
+ const initialDisplayValue = (this._lastValidValue &&
37
+ this._lastValidValue.displayValue) ??
38
+ /* istanbul ignore next */ this._getInitialDisplayValue();
40
39
  if (initialDisplayValue !== this.state.inputValue) {
41
40
  e.preventDefault();
42
41
  e.stopPropagation();
@@ -230,10 +229,9 @@ export class CustomNumberEditor extends React.PureComponent {
230
229
  });
231
230
  }
232
231
  _resetToLastValidDisplayValue() {
233
- var _a;
234
- const initialDisplayValue = (_a = (this._lastValidValue &&
235
- this._lastValidValue.displayValue)) !== null && _a !== void 0 ? _a :
236
- /* istanbul ignore next */ this._getInitialDisplayValue();
232
+ const initialDisplayValue = (this._lastValidValue &&
233
+ this._lastValidValue.displayValue) ??
234
+ /* istanbul ignore next */ this._getInitialDisplayValue();
237
235
  this.setState({ inputValue: initialDisplayValue });
238
236
  }
239
237
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,YAA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;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,MAAM,EACxB,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CACjC,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 PropertyEditors\n */\n\n// cSpell:ignore customnumber testid\n\nimport \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n SpecialKey,\n StandardEditorNames,\n StandardTypeNames,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport type { InputProps } from \"@itwin/itwinui-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\nimport { UiComponents } from \"../UiComponents\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n /** @internal */\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n // istanbul ignore else\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n // istanbul ignore else\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : /* istanbul ignore next */ UiComponents.translate(\n \"errors.unable-to-parse-quantity\"\n )\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : /* istanbul ignore next */ UiComponents.translate(\n \"errors.unable-to-parse-quantity\"\n )\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : /* istanbul ignore next */ (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : /* istanbul ignore next */ {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n // istanbul ignore else\n if (record) {\n // istanbul ignore else\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : /* istanbul ignore next */ 0;\n // istanbul ignore else\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n // istanbul ignore next\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n // istanbul ignore else\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.CustomFormattedNumber\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n // istanbul ignore else\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize\n ) as InputEditorSizeParams;\n // istanbul ignore else\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialDisplayValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n /* istanbul ignore next */ this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Escape) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n /* istanbul ignore next */ this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n // istanbul ignore else\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n // istanbul ignore else\n if (e.key !== SpecialKey.Enter) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n // istanbul ignore next\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n setFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Number,\n CustomNumberPropertyEditor,\n StandardEditorNames.NumberCustom\n);\n"]}
1
+ {"version":3,"file":"CustomNumberEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/CustomNumberEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,oCAAoC;AAEpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAUjC;;GAEG;AACH,MAAM,OAAO,kBACX,SAAQ,KAAK,CAAC,aAA2D;IAD3E;;QAIU,eAAU,GAAG,KAAK,CAAC;QAEnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAG5D,gBAAgB;QACS,UAAK,GAAsC;YAClE,UAAU,EAAE,EAAE;SACf,CAAC;QA6GM,sBAAiB,GAAG,CAAC,CAAsC,E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KAAK,CAAC,SAAS;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,IAAI,CAAC,iBAAiB;YAChC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;YACzB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE;YAC/B,SAAS,EAAE,IAAI,CAAC,WAAW;SAC5B,CAAC;QAEF,IAAI,SAA0B,CAAC;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,MAAM,IAAI,GAAG,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAI,CAAC;YACrD,SAAS,GAAG,CACV,oBAAC,SAAS,OACJ,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,EACvB,IAAI,EAAE,IAAI,iBACE,gCAAgC,GAC5C,CACH,CAAC;SACH;aAAM;YACL,uFAAuF;YACvF,SAAS,GAAG,CACV,oBAAC,KAAK,OACA,UAAU,EACd,GAAG,EAAE,IAAI,CAAC,aAAa,iBACX,gCAAgC,EAC5C,IAAI,EAAC,OAAO,GACZ,CACH,CAAC;SACH;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,kBAAkB;IAChE,IAAW,SAAS;QAClB,OAAO,oBAAC,kBAAkB,OAAG,CAAC;IAChC,CAAC;IACD,IAAoB,sBAAsB;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AACD,qBAAqB,CAAC,cAAc,CAClC,iBAAiB,CAAC,MAAM,EACxB,0BAA0B,EAC1B,mBAAmB,CAAC,YAAY,CACjC,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 PropertyEditors\n */\n\n// cSpell:ignore customnumber testid\n\nimport \"./CustomNumberEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Logger } from \"@itwin/core-bentley\";\nimport type {\n CustomFormattedNumberParams,\n IconEditorParams,\n InputEditorSizeParams,\n PrimitiveValue,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n MessageSeverity,\n PropertyEditorParamTypes,\n PropertyValueFormat,\n SpecialKey,\n StandardEditorNames,\n StandardTypeNames,\n UiAdmin,\n} from \"@itwin/appui-abstract\";\nimport { Icon, IconInput } from \"@itwin/core-react\";\nimport type { InputProps } from \"@itwin/itwinui-react\";\nimport { Input } from \"@itwin/itwinui-react\";\n\nimport { UiComponents } from \"../UiComponents\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\n\n/** @internal */\ninterface CustomNumberEditorState {\n inputValue: string;\n size?: number;\n maxLength?: number;\n iconSpec?: string;\n}\n\n/** CustomNumberEditor is a React component that is a property editor for numbers that specify custom formatting and parsing functions.\n * @alpha\n */\nexport class CustomNumberEditor\n extends React.PureComponent<PropertyEditorProps, CustomNumberEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _formatParams: CustomFormattedNumberParams | undefined;\n private _inputElement = React.createRef<HTMLInputElement>();\n private _lastValidValue: PropertyValue | undefined;\n\n /** @internal */\n public override readonly state: Readonly<CustomNumberEditorState> = {\n inputValue: \"\",\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord as PropertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record.isReadonly) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: (record.value as PrimitiveValue).displayValue,\n };\n }\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const parseResults = (\n this._formatParams as CustomFormattedNumberParams\n ).parseFunction(this.state.inputValue);\n if (!parseResults.parseError && undefined !== parseResults.value) {\n const newDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(parseResults.value as number);\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: parseResults.value,\n displayValue: newDisplayValue,\n };\n this._lastValidValue = { ...propertyValue };\n // make sure the text in the input item matches the latest formatted text... this could get out if the input string say 1.5 === the display string of 1'-6\"\n // istanbul ignore else\n if (newDisplayValue !== this.state.inputValue) {\n this.setState({ inputValue: newDisplayValue });\n }\n } else {\n // istanbul ignore else\n if (this.htmlElement) {\n UiAdmin.messagePresenter.displayInputFieldMessage(\n this.htmlElement,\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : /* istanbul ignore next */ UiComponents.translate(\n \"errors.unable-to-parse-quantity\"\n )\n );\n this.htmlElement.focus();\n } else {\n UiAdmin.messagePresenter.displayMessage(\n MessageSeverity.Error,\n parseResults.parseError\n ? parseResults.parseError\n : /* istanbul ignore next */ UiComponents.translate(\n \"errors.unable-to-parse-quantity\"\n )\n );\n }\n\n const displayValue =\n record.value.displayValue && record.value.displayValue.length > 0\n ? record.value.displayValue\n : /* istanbul ignore next */ (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(record.value.value as number);\n propertyValue = this._lastValidValue\n ? { ...this._lastValidValue }\n : /* istanbul ignore next */ {\n valueFormat: PropertyValueFormat.Primitive,\n value: record.value.value,\n displayValue,\n };\n }\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private shouldSetFocus(): boolean {\n if (!this.props.setFocus) return false;\n\n const record = this.props.propertyRecord as PropertyRecord;\n const disabled = record && !record.isDisabled ? false : true;\n const readonly = record && !record.isReadonly ? false : true;\n\n return !disabled && !readonly;\n }\n\n private _applyUpdatedValue(userInput: string) {\n const record = this.props.propertyRecord as PropertyRecord;\n const readonly = record && !record.isReadonly ? false : true;\n const disabled = record && !record.isDisabled ? false : true;\n\n if (readonly || disabled) return;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: userInput,\n });\n }\n\n private _updateInputValue = (e: React.ChangeEvent<HTMLInputElement>) => {\n this._applyUpdatedValue(e.target.value);\n };\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private _getInitialDisplayValue(): string {\n const record = this.props.propertyRecord;\n let initialDisplayValue = \"\";\n let numberValue = 0;\n // istanbul ignore else\n if (record) {\n // istanbul ignore else\n if (record.value.valueFormat === PropertyValueFormat.Primitive) {\n const primitiveValue = record.value;\n numberValue =\n undefined !== primitiveValue.value\n ? (primitiveValue.value as number)\n : /* istanbul ignore next */ 0;\n // istanbul ignore else\n if (primitiveValue.displayValue)\n initialDisplayValue = primitiveValue.displayValue;\n else\n initialDisplayValue = (\n this._formatParams as CustomFormattedNumberParams\n ).formatFunction(numberValue);\n }\n }\n\n return initialDisplayValue;\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n // istanbul ignore next\n if (!record || !record.property) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n \"PropertyRecord must be defined to use CustomNumberPropertyEditor\"\n );\n return;\n }\n // istanbul ignore else\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n this._formatParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.CustomFormattedNumber\n ) as CustomFormattedNumberParams;\n }\n\n if (!this._formatParams) {\n Logger.logError(\n UiComponents.loggerCategory(this),\n `CustomFormattedNumberParams must be defined for property ${record.property.name}`\n );\n return;\n }\n\n const initialDisplayValue = this._getInitialDisplayValue();\n this._lastValidValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: (record.value as PrimitiveValue).value,\n displayValue: initialDisplayValue,\n };\n let size: number | undefined;\n let maxLength: number | undefined;\n let iconSpec: string | undefined;\n\n // istanbul ignore else\n if (\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const editorSizeParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.InputEditorSize\n ) as InputEditorSizeParams;\n // istanbul ignore else\n if (editorSizeParams) {\n // istanbul ignore else\n if (editorSizeParams.size) size = editorSizeParams.size;\n // istanbul ignore else\n if (editorSizeParams.maxLength) maxLength = editorSizeParams.maxLength;\n }\n\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.Icon\n ) as IconEditorParams;\n if (iconParams) {\n iconSpec = iconParams.definition.iconSpec;\n }\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n inputValue: initialDisplayValue,\n size,\n maxLength,\n iconSpec,\n });\n }\n\n private _resetToLastValidDisplayValue() {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n /* istanbul ignore next */ this._getInitialDisplayValue();\n this.setState({ inputValue: initialDisplayValue });\n }\n\n private _onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Escape) {\n const initialDisplayValue =\n (this._lastValidValue &&\n (this._lastValidValue as PrimitiveValue).displayValue) ??\n /* istanbul ignore next */ this._getInitialDisplayValue();\n if (initialDisplayValue !== this.state.inputValue) {\n e.preventDefault();\n e.stopPropagation();\n this._resetToLastValidDisplayValue();\n } else {\n // istanbul ignore else\n if (this.props.onCancel) this.props.onCancel();\n }\n }\n\n // istanbul ignore else\n if (e.key !== SpecialKey.Enter) {\n UiAdmin.messagePresenter.closeInputFieldMessage();\n }\n };\n\n // istanbul ignore next\n private _onFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n e.target.select();\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const minSize = this.state.size ? this.state.size : 8;\n const minWidthStyle: React.CSSProperties = {\n minWidth: `${minSize * 0.75}em`,\n };\n const record = this.props.propertyRecord as PropertyRecord;\n if (!record || !this._formatParams) return null;\n\n const readOnly = !record.isReadonly ? false : true;\n const disabled = !record.isDisabled ? false : true;\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-customnumber-editor\",\n this.props.className\n );\n\n const inputProps: Omit<InputProps, \"size\"> = {\n className,\n style: this.props.style ? this.props.style : minWidthStyle,\n readOnly,\n disabled,\n maxLength: this.state.maxLength,\n value: this.state.inputValue,\n onChange: this._updateInputValue,\n onBlur: this.props.onBlur,\n onFocus: this._onFocus,\n setFocus: this.shouldSetFocus(),\n onKeyDown: this._onKeyPress,\n };\n\n let reactNode: React.ReactNode;\n if (this.state.iconSpec) {\n const icon = <Icon iconSpec={this.state.iconSpec} />;\n reactNode = (\n <IconInput\n {...inputProps}\n ref={this._inputElement}\n icon={icon}\n data-testid=\"components-customnumber-editor\"\n />\n );\n } else {\n // NEEDSWORK: still using core-react Input component because of `nativeKeyHandler` prop\n reactNode = (\n <Input\n {...inputProps}\n ref={this._inputElement}\n data-testid=\"components-customnumber-editor\"\n size=\"small\"\n />\n );\n }\n\n return reactNode;\n }\n}\n\n/** Custom Property Editor registered for the \"number\" type name and the \"number-custom\" editor name.\n * It uses the [[CustomNumberEditor]] React component.\n * @alpha\n */\nexport class CustomNumberPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <CustomNumberEditor />;\n }\n public override get containerHandlesEscape(): boolean {\n return false;\n }\n}\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Number,\n CustomNumberPropertyEditor,\n StandardEditorNames.NumberCustom\n);\n"]}
@@ -140,7 +140,6 @@ export class DateTimeEditor extends React.PureComponent {
140
140
  }
141
141
  }
142
142
  async setStateFromProps() {
143
- var _a, _b;
144
143
  const record = this.props.propertyRecord;
145
144
  let initialValue;
146
145
  let typeConverter;
@@ -159,8 +158,8 @@ export class DateTimeEditor extends React.PureComponent {
159
158
  initialValue = new Date(record.value.value);
160
159
  else if (record.value.value === undefined)
161
160
  initialValue = new Date();
162
- typeConverter = TypeConverterManager.getConverter(record.property.typename, (_a = record.property.converter) === null || _a === void 0 ? void 0 : _a.name);
163
- const options = (_b = record.property.converter) === null || _b === void 0 ? void 0 : _b.options;
161
+ typeConverter = TypeConverterManager.getConverter(record.property.typename, record.property.converter?.name);
162
+ const options = record.property.converter?.options;
164
163
  if (options) {
165
164
  // istanbul ignore else
166
165
  if ("alternateDateFormat" in options) {