@itwin/components-react 4.10.0-dev.1 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/lib/cjs/components-react/UiComponents.d.ts +1 -1
  3. package/lib/cjs/components-react/UiComponents.js +2 -4
  4. package/lib/cjs/components-react/UiComponents.js.map +1 -1
  5. package/lib/cjs/components-react/common/DelayedSpinner.js +3 -2
  6. package/lib/cjs/components-react/common/DelayedSpinner.js.map +1 -1
  7. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js +2 -1
  8. package/lib/cjs/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  9. package/lib/cjs/components-react/converters/DateTimeTypeConverter.js +1 -1
  10. package/lib/cjs/components-react/converters/DateTimeTypeConverter.js.map +1 -1
  11. package/lib/cjs/components-react/converters/NumericTypeConverter.js +4 -2
  12. package/lib/cjs/components-react/converters/NumericTypeConverter.js.map +1 -1
  13. package/lib/cjs/components-react/converters/PointTypeConverter.d.ts.map +1 -1
  14. package/lib/cjs/components-react/converters/PointTypeConverter.js +2 -0
  15. package/lib/cjs/components-react/converters/PointTypeConverter.js.map +1 -1
  16. package/lib/cjs/components-react/converters/TypeConverter.d.ts.map +1 -1
  17. package/lib/cjs/components-react/converters/TypeConverter.js +3 -1
  18. package/lib/cjs/components-react/converters/TypeConverter.js.map +1 -1
  19. package/lib/cjs/components-react/datepicker/DatePicker.d.ts +2 -0
  20. package/lib/cjs/components-react/datepicker/DatePicker.d.ts.map +1 -1
  21. package/lib/cjs/components-react/datepicker/DatePicker.js +48 -45
  22. package/lib/cjs/components-react/datepicker/DatePicker.js.map +1 -1
  23. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.d.ts +5 -2
  24. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.d.ts.map +1 -1
  25. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js +8 -7
  26. package/lib/cjs/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  27. package/lib/cjs/components-react/datepicker/IntlFormatter.d.ts +1 -0
  28. package/lib/cjs/components-react/datepicker/IntlFormatter.d.ts.map +1 -1
  29. package/lib/cjs/components-react/datepicker/IntlFormatter.js +1 -0
  30. package/lib/cjs/components-react/datepicker/IntlFormatter.js.map +1 -1
  31. package/lib/cjs/components-react/datepicker/TimeField.d.ts.map +1 -1
  32. package/lib/cjs/components-react/datepicker/TimeField.js +49 -48
  33. package/lib/cjs/components-react/datepicker/TimeField.js.map +1 -1
  34. package/lib/cjs/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  35. package/lib/cjs/components-react/editors/CustomNumberEditor.js +14 -11
  36. package/lib/cjs/components-react/editors/CustomNumberEditor.js.map +1 -1
  37. package/lib/cjs/components-react/editors/DateTimeEditor.js +5 -3
  38. package/lib/cjs/components-react/editors/DateTimeEditor.js.map +1 -1
  39. package/lib/cjs/components-react/editors/EditorContainer.js +3 -3
  40. package/lib/cjs/components-react/editors/EditorContainer.js.map +1 -1
  41. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js +1 -1
  42. package/lib/cjs/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  43. package/lib/cjs/components-react/editors/EnumEditor.d.ts +0 -1
  44. package/lib/cjs/components-react/editors/EnumEditor.d.ts.map +1 -1
  45. package/lib/cjs/components-react/editors/EnumEditor.js +2 -3
  46. package/lib/cjs/components-react/editors/EnumEditor.js.map +1 -1
  47. package/lib/cjs/components-react/editors/IconEditor.d.ts.map +1 -1
  48. package/lib/cjs/components-react/editors/IconEditor.js +1 -1
  49. package/lib/cjs/components-react/editors/IconEditor.js.map +1 -1
  50. package/lib/cjs/components-react/editors/ImageCheckBoxEditor.js +1 -1
  51. package/lib/cjs/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  52. package/lib/cjs/components-react/editors/NumericInputEditor.js +2 -2
  53. package/lib/cjs/components-react/editors/NumericInputEditor.js.map +1 -1
  54. package/lib/cjs/components-react/editors/PopupButton.d.ts.map +1 -1
  55. package/lib/cjs/components-react/editors/PopupButton.js +10 -7
  56. package/lib/cjs/components-react/editors/PopupButton.js.map +1 -1
  57. package/lib/cjs/components-react/editors/SliderEditor.js +1 -1
  58. package/lib/cjs/components-react/editors/SliderEditor.js.map +1 -1
  59. package/lib/cjs/components-react/editors/TextEditor.d.ts +0 -1
  60. package/lib/cjs/components-react/editors/TextEditor.d.ts.map +1 -1
  61. package/lib/cjs/components-react/editors/TextEditor.js +7 -6
  62. package/lib/cjs/components-react/editors/TextEditor.js.map +1 -1
  63. package/lib/cjs/components-react/editors/TextareaEditor.d.ts +0 -1
  64. package/lib/cjs/components-react/editors/TextareaEditor.d.ts.map +1 -1
  65. package/lib/cjs/components-react/editors/TextareaEditor.js +3 -4
  66. package/lib/cjs/components-react/editors/TextareaEditor.js.map +1 -1
  67. package/lib/cjs/components-react/favorite/FavoritePropertyList.js +3 -3
  68. package/lib/cjs/components-react/favorite/FavoritePropertyList.js.map +1 -1
  69. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.d.ts.map +1 -1
  70. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.js +4 -3
  71. package/lib/cjs/components-react/filter-builder/FilterBuilderLogicalOperator.js.map +1 -1
  72. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  73. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  74. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
  75. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js +6 -5
  76. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  77. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js +4 -3
  78. package/lib/cjs/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  79. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js +3 -3
  80. package/lib/cjs/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  81. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.d.ts.map +1 -1
  82. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.js +4 -3
  83. package/lib/cjs/components-react/filter-builder/FilterBuilderToolbar.js.map +1 -1
  84. package/lib/cjs/components-react/filter-builder/Operators.js +13 -13
  85. package/lib/cjs/components-react/filter-builder/Operators.js.map +1 -1
  86. package/lib/cjs/components-react/filtering/FilteringInput.d.ts +0 -3
  87. package/lib/cjs/components-react/filtering/FilteringInput.d.ts.map +1 -1
  88. package/lib/cjs/components-react/filtering/FilteringInput.js +6 -8
  89. package/lib/cjs/components-react/filtering/FilteringInput.js.map +1 -1
  90. package/lib/cjs/components-react/filtering/ResultSelector.d.ts +0 -1
  91. package/lib/cjs/components-react/filtering/ResultSelector.d.ts.map +1 -1
  92. package/lib/cjs/components-react/filtering/ResultSelector.js +2 -3
  93. package/lib/cjs/components-react/filtering/ResultSelector.js.map +1 -1
  94. package/lib/cjs/components-react/inputs/ParsedInput.js +2 -2
  95. package/lib/cjs/components-react/inputs/ParsedInput.js.map +1 -1
  96. package/lib/cjs/components-react/properties/ValueRendererManager.d.ts +3 -0
  97. package/lib/cjs/components-react/properties/ValueRendererManager.d.ts.map +1 -1
  98. package/lib/cjs/components-react/properties/ValueRendererManager.js +12 -1
  99. package/lib/cjs/components-react/properties/ValueRendererManager.js.map +1 -1
  100. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  101. package/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  102. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts +25 -0
  103. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts.map +1 -0
  104. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.js +62 -0
  105. package/lib/cjs/components-react/properties/renderers/CustomizablePropertyRenderer.js.map +1 -0
  106. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  107. package/lib/cjs/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  108. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts +3 -4
  109. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts.map +1 -1
  110. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js +6 -44
  111. package/lib/cjs/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  112. package/lib/cjs/components-react/properties/renderers/PropertyView.d.ts +1 -1
  113. package/lib/cjs/components-react/properties/renderers/PropertyView.d.ts.map +1 -1
  114. package/lib/cjs/components-react/properties/renderers/PropertyView.js +2 -3
  115. package/lib/cjs/components-react/properties/renderers/PropertyView.js.map +1 -1
  116. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  117. package/lib/cjs/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  118. package/lib/cjs/components-react/properties/renderers/value/Common.js +2 -1
  119. package/lib/cjs/components-react/properties/renderers/value/Common.js.map +1 -1
  120. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -1
  121. package/lib/cjs/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  122. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  123. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +8 -11
  124. package/lib/cjs/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  125. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -1
  126. package/lib/cjs/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  127. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  128. package/lib/cjs/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  129. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  130. package/lib/cjs/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  131. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  132. package/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  133. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  134. package/lib/cjs/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  135. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  136. package/lib/cjs/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  137. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map +1 -1
  138. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +1 -3
  139. package/lib/cjs/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  140. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +1 -3
  141. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  142. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js +90 -80
  143. package/lib/cjs/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  144. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  145. package/lib/cjs/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  146. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  147. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  148. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  149. package/lib/cjs/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  150. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  151. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  152. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  153. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  154. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  155. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  156. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  157. package/lib/cjs/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  158. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  159. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  160. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +1 -1
  161. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  162. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +22 -12
  163. package/lib/cjs/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  164. package/lib/cjs/components-react/selectable-content/SelectableContent.js +3 -2
  165. package/lib/cjs/components-react/selectable-content/SelectableContent.js.map +1 -1
  166. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -1
  167. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js +15 -14
  168. package/lib/cjs/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  169. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  170. package/lib/cjs/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  171. package/lib/cjs/components-react/tree/controlled/TreeModel.js +8 -7
  172. package/lib/cjs/components-react/tree/controlled/TreeModel.js.map +1 -1
  173. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  174. package/lib/cjs/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  175. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  176. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js +3 -2
  177. package/lib/cjs/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  178. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js +2 -1
  179. package/lib/cjs/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  180. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js +5 -3
  181. package/lib/cjs/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  182. package/lib/cjs/components-react/useTranslation.d.ts +10 -0
  183. package/lib/cjs/components-react/useTranslation.d.ts.map +1 -0
  184. package/lib/cjs/components-react/useTranslation.js +20 -0
  185. package/lib/cjs/components-react/useTranslation.js.map +1 -0
  186. package/lib/cjs/components-react.d.ts +1 -0
  187. package/lib/cjs/components-react.d.ts.map +1 -1
  188. package/lib/cjs/components-react.js +1 -0
  189. package/lib/cjs/components-react.js.map +1 -1
  190. package/lib/esm/components-react/UiComponents.d.ts +1 -1
  191. package/lib/esm/components-react/UiComponents.js +2 -4
  192. package/lib/esm/components-react/UiComponents.js.map +1 -1
  193. package/lib/esm/components-react/common/DelayedSpinner.js +3 -2
  194. package/lib/esm/components-react/common/DelayedSpinner.js.map +1 -1
  195. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js +2 -1
  196. package/lib/esm/components-react/common/UseDebouncedAsyncValue.js.map +1 -1
  197. package/lib/esm/components-react/converters/DateTimeTypeConverter.js +1 -1
  198. package/lib/esm/components-react/converters/DateTimeTypeConverter.js.map +1 -1
  199. package/lib/esm/components-react/converters/NumericTypeConverter.js +4 -2
  200. package/lib/esm/components-react/converters/NumericTypeConverter.js.map +1 -1
  201. package/lib/esm/components-react/converters/PointTypeConverter.d.ts.map +1 -1
  202. package/lib/esm/components-react/converters/PointTypeConverter.js +2 -0
  203. package/lib/esm/components-react/converters/PointTypeConverter.js.map +1 -1
  204. package/lib/esm/components-react/converters/TypeConverter.d.ts.map +1 -1
  205. package/lib/esm/components-react/converters/TypeConverter.js +3 -1
  206. package/lib/esm/components-react/converters/TypeConverter.js.map +1 -1
  207. package/lib/esm/components-react/datepicker/DatePicker.d.ts +2 -0
  208. package/lib/esm/components-react/datepicker/DatePicker.d.ts.map +1 -1
  209. package/lib/esm/components-react/datepicker/DatePicker.js +48 -45
  210. package/lib/esm/components-react/datepicker/DatePicker.js.map +1 -1
  211. package/lib/esm/components-react/datepicker/DatePickerPopupButton.d.ts +5 -2
  212. package/lib/esm/components-react/datepicker/DatePickerPopupButton.d.ts.map +1 -1
  213. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js +8 -7
  214. package/lib/esm/components-react/datepicker/DatePickerPopupButton.js.map +1 -1
  215. package/lib/esm/components-react/datepicker/IntlFormatter.d.ts +1 -0
  216. package/lib/esm/components-react/datepicker/IntlFormatter.d.ts.map +1 -1
  217. package/lib/esm/components-react/datepicker/IntlFormatter.js +1 -0
  218. package/lib/esm/components-react/datepicker/IntlFormatter.js.map +1 -1
  219. package/lib/esm/components-react/datepicker/TimeField.d.ts.map +1 -1
  220. package/lib/esm/components-react/datepicker/TimeField.js +49 -48
  221. package/lib/esm/components-react/datepicker/TimeField.js.map +1 -1
  222. package/lib/esm/components-react/editors/CustomNumberEditor.d.ts.map +1 -1
  223. package/lib/esm/components-react/editors/CustomNumberEditor.js +14 -11
  224. package/lib/esm/components-react/editors/CustomNumberEditor.js.map +1 -1
  225. package/lib/esm/components-react/editors/DateTimeEditor.js +5 -3
  226. package/lib/esm/components-react/editors/DateTimeEditor.js.map +1 -1
  227. package/lib/esm/components-react/editors/EditorContainer.js +3 -3
  228. package/lib/esm/components-react/editors/EditorContainer.js.map +1 -1
  229. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js +1 -1
  230. package/lib/esm/components-react/editors/EnumButtonGroupEditor.js.map +1 -1
  231. package/lib/esm/components-react/editors/EnumEditor.d.ts +0 -1
  232. package/lib/esm/components-react/editors/EnumEditor.d.ts.map +1 -1
  233. package/lib/esm/components-react/editors/EnumEditor.js +2 -3
  234. package/lib/esm/components-react/editors/EnumEditor.js.map +1 -1
  235. package/lib/esm/components-react/editors/IconEditor.d.ts.map +1 -1
  236. package/lib/esm/components-react/editors/IconEditor.js +1 -1
  237. package/lib/esm/components-react/editors/IconEditor.js.map +1 -1
  238. package/lib/esm/components-react/editors/ImageCheckBoxEditor.js +1 -1
  239. package/lib/esm/components-react/editors/ImageCheckBoxEditor.js.map +1 -1
  240. package/lib/esm/components-react/editors/NumericInputEditor.js +2 -2
  241. package/lib/esm/components-react/editors/NumericInputEditor.js.map +1 -1
  242. package/lib/esm/components-react/editors/PopupButton.d.ts.map +1 -1
  243. package/lib/esm/components-react/editors/PopupButton.js +11 -8
  244. package/lib/esm/components-react/editors/PopupButton.js.map +1 -1
  245. package/lib/esm/components-react/editors/SliderEditor.js +1 -1
  246. package/lib/esm/components-react/editors/SliderEditor.js.map +1 -1
  247. package/lib/esm/components-react/editors/TextEditor.d.ts +0 -1
  248. package/lib/esm/components-react/editors/TextEditor.d.ts.map +1 -1
  249. package/lib/esm/components-react/editors/TextEditor.js +7 -6
  250. package/lib/esm/components-react/editors/TextEditor.js.map +1 -1
  251. package/lib/esm/components-react/editors/TextareaEditor.d.ts +0 -1
  252. package/lib/esm/components-react/editors/TextareaEditor.d.ts.map +1 -1
  253. package/lib/esm/components-react/editors/TextareaEditor.js +3 -4
  254. package/lib/esm/components-react/editors/TextareaEditor.js.map +1 -1
  255. package/lib/esm/components-react/favorite/FavoritePropertyList.js +3 -3
  256. package/lib/esm/components-react/favorite/FavoritePropertyList.js.map +1 -1
  257. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.d.ts.map +1 -1
  258. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.js +4 -3
  259. package/lib/esm/components-react/filter-builder/FilterBuilderLogicalOperator.js.map +1 -1
  260. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js +2 -1
  261. package/lib/esm/components-react/filter-builder/FilterBuilderRuleOperator.js.map +1 -1
  262. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.d.ts.map +1 -1
  263. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js +6 -5
  264. package/lib/esm/components-react/filter-builder/FilterBuilderRuleProperty.js.map +1 -1
  265. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js +4 -3
  266. package/lib/esm/components-react/filter-builder/FilterBuilderRuleValue.js.map +1 -1
  267. package/lib/esm/components-react/filter-builder/FilterBuilderState.js +3 -3
  268. package/lib/esm/components-react/filter-builder/FilterBuilderState.js.map +1 -1
  269. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.d.ts.map +1 -1
  270. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.js +4 -3
  271. package/lib/esm/components-react/filter-builder/FilterBuilderToolbar.js.map +1 -1
  272. package/lib/esm/components-react/filter-builder/Operators.js +13 -13
  273. package/lib/esm/components-react/filter-builder/Operators.js.map +1 -1
  274. package/lib/esm/components-react/filtering/FilteringInput.d.ts +0 -3
  275. package/lib/esm/components-react/filtering/FilteringInput.d.ts.map +1 -1
  276. package/lib/esm/components-react/filtering/FilteringInput.js +7 -9
  277. package/lib/esm/components-react/filtering/FilteringInput.js.map +1 -1
  278. package/lib/esm/components-react/filtering/ResultSelector.d.ts +0 -1
  279. package/lib/esm/components-react/filtering/ResultSelector.d.ts.map +1 -1
  280. package/lib/esm/components-react/filtering/ResultSelector.js +2 -3
  281. package/lib/esm/components-react/filtering/ResultSelector.js.map +1 -1
  282. package/lib/esm/components-react/inputs/ParsedInput.js +2 -2
  283. package/lib/esm/components-react/inputs/ParsedInput.js.map +1 -1
  284. package/lib/esm/components-react/properties/ValueRendererManager.d.ts +3 -0
  285. package/lib/esm/components-react/properties/ValueRendererManager.d.ts.map +1 -1
  286. package/lib/esm/components-react/properties/ValueRendererManager.js +12 -1
  287. package/lib/esm/components-react/properties/ValueRendererManager.js.map +1 -1
  288. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js +4 -3
  289. package/lib/esm/components-react/properties/renderers/CommonPropertyRenderer.js.map +1 -1
  290. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts +25 -0
  291. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.d.ts.map +1 -0
  292. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.js +35 -0
  293. package/lib/esm/components-react/properties/renderers/CustomizablePropertyRenderer.js.map +1 -0
  294. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js +1 -1
  295. package/lib/esm/components-react/properties/renderers/NonPrimitivePropertyRenderer.js.map +1 -1
  296. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts +3 -4
  297. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.d.ts.map +1 -1
  298. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js +3 -21
  299. package/lib/esm/components-react/properties/renderers/PrimitivePropertyRenderer.js.map +1 -1
  300. package/lib/esm/components-react/properties/renderers/PropertyView.d.ts +1 -1
  301. package/lib/esm/components-react/properties/renderers/PropertyView.d.ts.map +1 -1
  302. package/lib/esm/components-react/properties/renderers/PropertyView.js +2 -3
  303. package/lib/esm/components-react/properties/renderers/PropertyView.js.map +1 -1
  304. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js +4 -4
  305. package/lib/esm/components-react/properties/renderers/label/PropertyLabelRenderer.js.map +1 -1
  306. package/lib/esm/components-react/properties/renderers/value/Common.js +2 -1
  307. package/lib/esm/components-react/properties/renderers/value/Common.js.map +1 -1
  308. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js +1 -1
  309. package/lib/esm/components-react/properties/renderers/value/DoublePropertyValueRenderer.js.map +1 -1
  310. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.d.ts.map +1 -1
  311. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js +8 -11
  312. package/lib/esm/components-react/properties/renderers/value/MultilineTextPropertyValueRenderer.js.map +1 -1
  313. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js +1 -1
  314. package/lib/esm/components-react/properties/renderers/value/NavigationPropertyValueRenderer.js.map +1 -1
  315. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js +6 -3
  316. package/lib/esm/components-react/properties/renderers/value/PrimitivePropertyValueRenderer.js.map +1 -1
  317. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js +2 -1
  318. package/lib/esm/components-react/propertygrid/PropertyCategoryRendererManager.js.map +1 -1
  319. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js +2 -1
  320. package/lib/esm/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier.js.map +1 -1
  321. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js +2 -1
  322. package/lib/esm/components-react/propertygrid/component/PropertyCategoryBlock.js.map +1 -1
  323. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js +2 -2
  324. package/lib/esm/components-react/propertygrid/component/PropertyGridCommons.js.map +1 -1
  325. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.d.ts.map +1 -1
  326. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js +1 -3
  327. package/lib/esm/components-react/propertygrid/component/PropertyGridEventsRelatedPropsSupplier.js.map +1 -1
  328. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts +1 -3
  329. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.d.ts.map +1 -1
  330. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js +90 -80
  331. package/lib/esm/components-react/propertygrid/component/VirtualizedPropertyGrid.js.map +1 -1
  332. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js +13 -11
  333. package/lib/esm/components-react/propertygrid/dataproviders/FilteringDataProvider.js.map +1 -1
  334. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js +2 -2
  335. package/lib/esm/components-react/propertygrid/dataproviders/filterers/CompositePropertyDataFilterer.js.map +1 -1
  336. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js +2 -1
  337. package/lib/esm/components-react/propertygrid/dataproviders/filterers/DisplayValuePropertyDataFilterer.js.map +1 -1
  338. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js +2 -1
  339. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableCustomGridCategory.js.map +1 -1
  340. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js +2 -2
  341. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableFlatGridItem.js.map +1 -1
  342. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js +3 -2
  343. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridCategory.js.map +1 -1
  344. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js +1 -1
  345. package/lib/esm/components-react/propertygrid/internal/flat-items/MutableGridItemFactory.js.map +1 -1
  346. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js +1 -1
  347. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatNonPrimitivePropertyRenderer.js.map +1 -1
  348. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts +1 -1
  349. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.d.ts.map +1 -1
  350. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js +22 -12
  351. package/lib/esm/components-react/propertygrid/internal/flat-properties/FlatPropertyRenderer.js.map +1 -1
  352. package/lib/esm/components-react/selectable-content/SelectableContent.js +3 -2
  353. package/lib/esm/components-react/selectable-content/SelectableContent.js.map +1 -1
  354. package/lib/esm/components-react/toolbar/InternalToolbarComponent.d.ts.map +1 -1
  355. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js +15 -14
  356. package/lib/esm/components-react/toolbar/InternalToolbarComponent.js.map +1 -1
  357. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js +6 -5
  358. package/lib/esm/components-react/toolbar/useConditionalSynchedItems.js.map +1 -1
  359. package/lib/esm/components-react/tree/controlled/TreeModel.js +8 -7
  360. package/lib/esm/components-react/tree/controlled/TreeModel.js.map +1 -1
  361. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js +8 -6
  362. package/lib/esm/components-react/tree/controlled/TreeNodeLoader.js.map +1 -1
  363. package/lib/esm/components-react/tree/controlled/component/ControlledTree.d.ts.map +1 -1
  364. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js +3 -2
  365. package/lib/esm/components-react/tree/controlled/component/ControlledTree.js.map +1 -1
  366. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js +2 -1
  367. package/lib/esm/components-react/tree/controlled/internal/SparseTree.js.map +1 -1
  368. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js +5 -3
  369. package/lib/esm/components-react/tree/controlled/internal/TreeSelectionManager.js.map +1 -1
  370. package/lib/esm/components-react/useTranslation.d.ts +10 -0
  371. package/lib/esm/components-react/useTranslation.d.ts.map +1 -0
  372. package/lib/esm/components-react/useTranslation.js +16 -0
  373. package/lib/esm/components-react/useTranslation.js.map +1 -0
  374. package/lib/esm/components-react.d.ts +1 -0
  375. package/lib/esm/components-react.d.ts.map +1 -1
  376. package/lib/esm/components-react.js +1 -0
  377. package/lib/esm/components-react.js.map +1 -1
  378. package/lib/public/locales/en/UiComponents.json +7 -1
  379. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iCAA+B;AAC/B,4DAAoC;AACpC,6CAA+B;AAE/B,0DAK+B;AAE/B,mEAGiC;AACjC,+CAAgF;AAEhF,uDAAoD;AAEpD,yDAAsD;AACtD,6EAA0E;AAC1E,+EAAgF;AAChF,wDAA4C;AAC5C,mDAA2D;AAmB3D;;GAEG;AACH,MAAa,cACX,SAAQ,KAAK,CAAC,aAAuD;IADvE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,cAAS,GAAG,KAAK,CAAC;QAClB,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAkC;YAC9D,KAAK,EAAE,IAAI,IAAI,EAAE;YACjB,SAAS,EAAE,KAAK;SACjB,CAAC;QA+CM,kBAAa,GAAG,CAAC,QAAc,EAAQ,EAAE;YAC/C,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;gBAC/C,uBAAuB;gBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;oBACxB,QAAQ,GAAG,IAAA,gCAAoB,EAC7B,QAAQ,EACR,QAAQ,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,CAClC,CAAC;iBACH;gBAED,KAAK,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;aACjE;QACH,CAAC,CAAC;QAEM,sBAAiB,GAAG,CAAC,IAAc,EAAQ,EAAE;YACnD,sCAAsC;YACtC,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;gBACxB,MAAM,cAAc,GAAG,IAAA,gCAAoB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C,iBAAiB,GACpC,CACE,CACP,CACG,CACL;oBACH,oBAAC,kCAAoB,IACnB,IAAI,EAAE,IAAI,CAAC,SAAS,EACpB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAC5B,CACW,CACH,CACV,CACP,CAAC;IACJ,CAAC;CACF;AAtTD,wCAsTC;AAED;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,0CAAkB;IACjE,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,KAAK,GAAI,CAAC;IAC7C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AARD,kEAQC;AAED;;;GAGG;AACH,MAAa,sBAAuB,SAAQ,0CAAkB;IAC5D,IAAW,SAAS;QAClB,OAAO,oBAAC,cAAc,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;IAC5C,CAAC;IACD,uBAAuB;IACvB,IAAoB,mBAAmB;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AARD,wDAQC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,SAAS,EAC3B,2BAA2B,CAC5B,CAAC;AACF,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,QAAQ,EAC1B,sBAAsB,CACvB,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\nimport \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport {\n AlternateDateFormats,\n PropertyValueFormat,\n StandardTypeNames,\n TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport type { TimeSpec } from \"../datepicker/TimeField\";\nimport { TimeField } from \"../datepicker/TimeField\";\nimport type { TypeConverter } from \"../converters/TypeConverter\";\nimport { DatePicker } from \"../datepicker/DatePicker\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\n\n// cSpell:ignore datepicker\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n isDisabled?: boolean;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor\n extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: this.state.displayValue,\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(\n typeConverter: TypeConverter,\n newValue: Date\n ): Promise<void> {\n // istanbul ignore else\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(\n this.props.propertyRecord.property,\n newValue\n );\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n // istanbul ignore else\n if (this._isMounted && this.state.typeConverter) {\n // istanbul ignore else\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(\n newValue,\n newValue.getTimezoneOffset() * -1\n );\n }\n\n void this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n }\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 async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n // istanbul ignore else\n if (this.props.showTime) timeDisplay = TimeDisplay.H12MC;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n // istanbul ignore else\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined) initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n );\n\n const options = record.property.converter?.options;\n if (options) {\n // istanbul ignore else\n if (\"alternateDateFormat\" in options) {\n // istanbul ignore else\n if (\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n // istanbul ignore next\n if (\n alternateDateFormat &&\n timeDisplay !== TimeDisplay.H24MS &&\n timeDisplay !== TimeDisplay.H24M\n )\n timeDisplay = TimeDisplay.H24MS;\n }\n\n // istanbul ignore else\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n // istanbul ignore next\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n // istanbul ignore next\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const isDisabled = record && !!record.isDisabled;\n const displayValue = await typeConverter.convertPropertyToString(\n record!.property,\n initialValue\n );\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: initialValue,\n isDisabled,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n // istanbul ignore next\n if (this.props.onCancel) this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const date = this.state.editInUtc\n ? adjustDateToTimezone(this.state.value, 0)\n : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-datetime-editor\",\n this.props.className\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.displayValue}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n >\n <PopupContent>\n <>\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker\n selected={date}\n onDateChange={this._handleChange}\n showFocusOutline={false}\n />\n {this.state.timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {\"Time\"}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={this.state.timeDisplay}\n onTimeChange={this._handleTimeChange}\n />\n </div>\n )}\n </div>\n </>\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.ShortDate,\n ShortDateTimePropertyEditor\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.DateTime,\n DateTimePropertyEditor\n);\n"]}
1
+ {"version":3,"file":"DateTimeEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/DateTimeEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iCAA+B;AAC/B,4DAAoC;AACpC,6CAA+B;AAE/B,0DAK+B;AAE/B,mEAGiC;AACjC,+CAAgF;AAEhF,uDAAoD;AAEpD,yDAAsD;AACtD,6EAA0E;AAC1E,+EAAgF;AAChF,wDAA4C;AAC5C,mDAA2D;AAmB3D;;GAEG;AACH,MAAa,cACX,SAAQ,KAAK,CAAC,aAAuD;IADvE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,cAAS,GAAG,KAAK,CAAC;QAClB,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAkC;YAC9D,KAAK,EAAE,IAAI,IAAI,EAAE;YACjB,SAAS,EAAE,KAAK;SACjB,CAAC;QA+CM,kBAAa,GAAG,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ACF;AARD,wDAQC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,SAAS,EAC3B,2BAA2B,CAC5B,CAAC;AACF,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,QAAQ,EAC1B,sBAAsB,CACvB,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\nimport \"./DateTimeEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport {\n AlternateDateFormats,\n PropertyValueFormat,\n StandardTypeNames,\n TimeDisplay,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { PopupButton, PopupContent, PopupOkCancelButtons } from \"./PopupButton\";\nimport type { TimeSpec } from \"../datepicker/TimeField\";\nimport { TimeField } from \"../datepicker/TimeField\";\nimport type { TypeConverter } from \"../converters/TypeConverter\";\nimport { DatePicker } from \"../datepicker/DatePicker\";\nimport { TypeConverterManager } from \"../converters/TypeConverterManager\";\nimport { DateTimeTypeConverterBase } from \"../converters/DateTimeTypeConverter\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport { adjustDateToTimezone } from \"../common/DateUtils\";\n\n// cSpell:ignore datepicker\n\n/** @internal */\ninterface DateTimeEditorState {\n value: Date;\n displayValue?: string;\n timeDisplay?: TimeDisplay;\n isDisabled?: boolean;\n typeConverter?: TypeConverter;\n editInUtc: boolean;\n}\n\n/** @internal */\ninterface DateTimeEditorProps extends PropertyEditorProps {\n showTime?: boolean;\n}\n\n/** DateTimeEditor React component that is a property editor for selection of date and time.\n * @internal\n */\nexport class DateTimeEditor\n extends React.PureComponent<DateTimeEditorProps, DateTimeEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _enterKey = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<DateTimeEditorState> = {\n value: new Date(),\n editInUtc: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.value,\n displayValue: this.state.displayValue,\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this.htmlElement)\n containsFocus = this.htmlElement.contains(document.activeElement);\n return containsFocus;\n }\n\n public async processDateChange(\n typeConverter: TypeConverter,\n newValue: Date\n ): Promise<void> {\n // istanbul ignore else\n if (this.props.propertyRecord) {\n const displayValue = await typeConverter.convertPropertyToString(\n this.props.propertyRecord.property,\n newValue\n );\n this.setState({\n value: newValue,\n displayValue,\n });\n }\n }\n\n private _handleChange = (newValue: Date): void => {\n // istanbul ignore else\n if (this._isMounted && this.state.typeConverter) {\n // istanbul ignore else\n if (this.state.editInUtc) {\n newValue = adjustDateToTimezone(\n newValue,\n newValue.getTimezoneOffset() * -1\n );\n }\n\n void this.processDateChange(this.state.typeConverter, newValue);\n }\n };\n\n private _handleTimeChange = (time: TimeSpec): void => {\n // Combine new time into selected Date\n if (this.state.editInUtc) {\n const newWorkingDate = adjustDateToTimezone(this.state.value, 0);\n newWorkingDate.setUTCHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n } else {\n const newWorkingDate = new Date(this.state.value.getTime());\n newWorkingDate.setHours(time.hours, time.minutes, time.seconds);\n this._handleChange(newWorkingDate);\n }\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 async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue: Date | undefined;\n let typeConverter: TypeConverter | undefined;\n let timeDisplay: TimeDisplay | undefined;\n let alternateDateFormat = AlternateDateFormats.None;\n let editInUtc = false;\n\n // istanbul ignore else\n if (this.props.showTime) timeDisplay = TimeDisplay.H12MC;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n // istanbul ignore else\n if (record.value.value instanceof Date)\n initialValue = new Date(record.value.value);\n else if (typeof record.value.value === \"string\")\n initialValue = new Date(record.value.value);\n else if (record.value.value === undefined) initialValue = new Date();\n\n typeConverter = TypeConverterManager.getConverter(\n record.property.typename,\n record.property.converter?.name\n );\n\n const options = record.property.converter?.options;\n if (options) {\n // istanbul ignore else\n if (\"alternateDateFormat\" in options) {\n // istanbul ignore else\n if (\n DateTimeTypeConverterBase.isAlternateDateFormats(\n options.alternateDateFormat\n )\n ) {\n timeDisplay = TimeDisplay.H24MS;\n alternateDateFormat = options.alternateDateFormat;\n }\n }\n\n if (\"timeDisplay\" in options && this.props.showTime) {\n timeDisplay = options.timeDisplay;\n // use 24 hr time display if alternateDateFormat is defined\n // istanbul ignore next\n if (\n alternateDateFormat &&\n timeDisplay !== TimeDisplay.H24MS &&\n timeDisplay !== TimeDisplay.H24M\n )\n timeDisplay = TimeDisplay.H24MS;\n }\n\n // istanbul ignore else\n if (alternateDateFormat) {\n editInUtc = true;\n\n if (this.props.showTime) {\n if (alternateDateFormat === AlternateDateFormats.IsoShort) {\n alternateDateFormat = AlternateDateFormats.IsoDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShort) {\n alternateDateFormat = AlternateDateFormats.UtcDateTime;\n }\n if (alternateDateFormat === AlternateDateFormats.UtcShortWithDay) {\n alternateDateFormat = AlternateDateFormats.UtcDateTimeWithDay;\n }\n } else {\n timeDisplay = undefined;\n if (alternateDateFormat === AlternateDateFormats.IsoDateTime)\n alternateDateFormat = AlternateDateFormats.IsoShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTime)\n alternateDateFormat = AlternateDateFormats.UtcShort;\n if (alternateDateFormat === AlternateDateFormats.UtcDateTimeWithDay)\n alternateDateFormat = AlternateDateFormats.UtcShortWithDay;\n }\n }\n }\n }\n\n // istanbul ignore next\n if (!initialValue) {\n throw new Error(\"Bad Value\");\n }\n\n // istanbul ignore next\n if (!typeConverter) {\n throw new Error(\"Unable to determine TypeConverter\");\n }\n\n const isDisabled = record && !!record.isDisabled;\n const displayValue = await typeConverter.convertPropertyToString(\n record!.property,\n initialValue\n );\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n value: initialValue,\n isDisabled,\n timeDisplay,\n typeConverter,\n displayValue,\n editInUtc,\n });\n }\n\n private _handleEnter = async (): Promise<void> => {\n this._enterKey = true;\n await this._handleCommit();\n };\n\n private _handleClose = async (): Promise<void> => {\n if (this._enterKey) {\n this._enterKey = false;\n } else {\n // istanbul ignore next\n if (this.props.onCancel) this.props.onCancel();\n }\n };\n\n private _handleOk = async (_event: React.MouseEvent): Promise<void> => {\n await this._handleCommit();\n };\n\n private _handleCancel = (_event: React.MouseEvent): void => {\n // istanbul ignore else\n if (this.props.onCancel) {\n this.props.onCancel();\n }\n };\n\n private _handleCommit = async (): Promise<void> => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n };\n\n /** @internal */\n public override render(): React.ReactNode {\n const date = this.state.editInUtc\n ? adjustDateToTimezone(this.state.value, 0)\n : this.state.value;\n const timeSpec: TimeSpec = {\n hours: date.getHours(),\n minutes: date.getMinutes(),\n seconds: date.getSeconds(),\n };\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-datetime-editor\",\n this.props.className\n );\n\n return (\n <div className={className} ref={this._divElement}>\n <PopupButton\n label={this.state.displayValue}\n onClose={this._handleClose}\n onEnter={this._handleEnter}\n setFocus={this.props.setFocus}\n >\n <PopupContent>\n <>\n <div\n className=\"components-date-picker-calendar-popup-panel\"\n data-testid=\"components-date-picker-calendar-popup-panel\"\n >\n <DatePicker // eslint-disable-line deprecation/deprecation\n selected={date}\n onDateChange={this._handleChange}\n showFocusOutline={false}\n />\n {this.state.timeDisplay && (\n <div className=\"time-container\">\n <Text variant=\"body\" className=\"time-label\">\n {\"Time\"}\n </Text>\n <TimeField\n time={timeSpec}\n timeDisplay={this.state.timeDisplay}\n onTimeChange={this._handleTimeChange}\n />\n </div>\n )}\n </div>\n </>\n <PopupOkCancelButtons\n onOk={this._handleOk}\n onCancel={this._handleCancel}\n />\n </PopupContent>\n </PopupButton>\n </div>\n );\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class ShortDateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={false} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\n/** DateTime Property Editor registered for the \"number\" type name and \"DateTime\" editor name.\n * It uses the [[DateTimeEditor]] React component.\n * @internal\n */\nexport class DateTimePropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <DateTimeEditor showTime={true} />;\n }\n // istanbul ignore next\n public override get containerHandlesTab(): boolean {\n return false;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.ShortDate,\n ShortDateTimePropertyEditor\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.DateTime,\n DateTimePropertyEditor\n);\n"]}
@@ -58,13 +58,13 @@ class EditorContainer extends React.PureComponent {
58
58
  };
59
59
  this._handleKeyDown = (e) => {
60
60
  switch (e.key) {
61
- case ts_key_enum_1.Key.Escape:
61
+ case ts_key_enum_1.Key.Escape.valueOf():
62
62
  this.onPressEscape(e);
63
63
  break;
64
- case ts_key_enum_1.Key.Enter:
64
+ case ts_key_enum_1.Key.Enter.valueOf():
65
65
  this.onPressEnter(e);
66
66
  break;
67
- case ts_key_enum_1.Key.Tab:
67
+ case ts_key_enum_1.Key.Tab.valueOf():
68
68
  this.onPressTab(e);
69
69
  break;
70
70
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kCAAgC;AAChC,6CAA+B;AAC/B,6CAAkC;AAElC,0DAAgD;AAMhD,mEAAgE;AAuEhE;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAAmC;IAA9E;;QAyCU,sBAAiB,GAAG,CAAC,EAAoB,EAAE,EAAE;YACnD,uBAAuB;YACvB,IACE,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB;gBAC5B,IAAI,CAAC,eAAe;gBACpB,IAAI,CAAC,eAAe,CAAC,oBAAoB;gBAEzC,KAAK,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACvC,CAAC,CAAC;QAEM,yBAAoB,GAAG,CAAC,CAAmB,EAAE,EAAE;YACrD,CAAC,CAAC,eAAe,EAAE,CAAC;QACtB,CAAC,CAAC;QAEM,iBAAY,GAAG,CAAC,CAAmB,EAAE,EAAE;YAC7C,CAAC,CAAC,eAAe,EAAE,CAAC;QACtB,CAAC,CAAC;QAEM,mBAAc,GAAG,CAAC,CAAsB,EAAE,EAAE;YAClD,QAAQ,CAAC,CAAC,GAAG,EAAE;gBACb,KAAK,iBAAG,CAAC,MAAM;oBACb,IAAI,CAAC,aAAa,CA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,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF;AAtND,0CAsNC","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\nimport \"./EditorContainer.scss\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n AsyncErrorMessage,\n PropertyEditorBase,\n} from \"./PropertyEditorManager\";\nimport { PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** Arguments for the Property Updated event callback\n * @public\n */\nexport interface PropertyUpdatedArgs {\n /** The property being updated. */\n propertyRecord: PropertyRecord;\n /** The new value for the property. */\n newValue: PropertyValue;\n}\n\n/** Properties for a property editor component\n * @public\n */\nexport interface PropertyEditorProps extends CommonProps {\n /** The property being updated. */\n propertyRecord?: PropertyRecord;\n /** Handler for commit */\n onCommit?: (args: PropertyUpdatedArgs) => void;\n /** Handler for cancel */\n onCancel?: () => void;\n /** Handler for blur */\n onBlur?: (event: React.FocusEvent) => void;\n /** Indicates whether the Property Editor should set focus */\n setFocus?: boolean;\n /**\n * Indicates whether value change should call onCommit().\n * @internal\n */\n shouldCommitOnChange?: boolean;\n}\n\n/** [[EditorContainer]] React component properties\n * @public\n */\nexport interface EditorContainerProps extends CommonProps {\n /** The property being updated. */\n propertyRecord: PropertyRecord;\n /** Tooltip text */\n title?: string;\n /** Handler for commit */\n onCommit: (args: PropertyUpdatedArgs) => void;\n /** Handler for cancel */\n onCancel: () => void;\n /** Indicates whether the Property Editor should set focus */\n setFocus?: boolean;\n\n /** @internal */\n ignoreEditorBlur?: boolean;\n /**\n * Indicates whether value change should call onCommit().\n * @internal\n */\n shouldCommitOnChange?: boolean;\n}\n\n/** @internal */\ninterface CloneProps extends PropertyEditorProps {\n ref: (ref: any) => void;\n}\n\n/** Interface implemented by React based type editors\n * @public\n */\nexport interface TypeEditor {\n getPropertyValue: () => Promise<PropertyValue | undefined>;\n htmlElement: HTMLElement | null;\n hasFocus: boolean;\n}\n\n/**\n * EditorContainer React component used by the Tree and PropertyGrid for cell editing.\n * @public\n */\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\n private _editorRef: TypeEditor | undefined;\n private _propertyEditor: PropertyEditorBase | undefined;\n\n private createEditor(): React.ReactNode {\n const editorRef = (ref: TypeEditor | undefined) => (this._editorRef = ref);\n\n const editorProps: CloneProps = {\n ref: editorRef,\n onCommit: this._handleEditorCommit,\n onCancel: this._handleEditorCancel,\n onBlur: this._handleEditorBlur,\n propertyRecord: this.props.propertyRecord,\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\n className: this.props.className,\n style: this.props.style,\n shouldCommitOnChange: this.props.shouldCommitOnChange,\n };\n\n const propDescription = this.props.propertyRecord.property;\n\n const editorName =\n propDescription.editor !== undefined\n ? propDescription.editor.name\n : undefined;\n this._propertyEditor = PropertyEditorManager.createEditor(\n propDescription.typename,\n editorName,\n propDescription.dataController\n );\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\n\n let clonedNode: React.ReactNode = null;\n // istanbul ignore else\n if (React.isValidElement(editorNode)) {\n clonedNode = React.cloneElement(editorNode, editorProps);\n }\n\n return clonedNode;\n }\n\n private _handleEditorBlur = (_e: React.FocusEvent) => {\n // istanbul ignore else\n if (\n !this.props.ignoreEditorBlur &&\n this._propertyEditor &&\n this._propertyEditor.containerHandlesBlur\n )\n void this._handleContainerCommit();\n };\n\n private _handleContainerBlur = (e: React.FocusEvent) => {\n e.stopPropagation();\n };\n\n private _handleClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case Key.Escape:\n this.onPressEscape(e);\n break;\n case Key.Enter:\n this.onPressEnter(e);\n break;\n case Key.Tab:\n this.onPressTab(e);\n break;\n default:\n if (\n this._propertyEditor &&\n this._propertyEditor.containerStopsKeydownPropagation\n )\n e.stopPropagation();\n }\n };\n\n private _handleRightClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private onPressEscape(_e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\n this._commitCancel();\n }\n }\n\n private onPressEnter(e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\n // istanbul ignore else\n if (this._editorRef && this._editorRef.hasFocus) e.stopPropagation();\n void this._handleContainerCommit();\n }\n }\n\n private onPressTab(e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\n e.stopPropagation();\n void this._handleContainerCommit();\n }\n }\n\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\n // istanbul ignore else\n if (errorMessage && this._editorRef) {\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\n // istanbul ignore else\n if (htmlElement)\n UiAdmin.messagePresenter.displayInputFieldMessage(\n htmlElement,\n errorMessage.severity,\n errorMessage.briefMessage,\n errorMessage.detailedMessage\n );\n else\n UiAdmin.messagePresenter.displayMessage(\n errorMessage.severity,\n errorMessage.briefMessage,\n errorMessage.detailedMessage,\n errorMessage.messageType\n );\n }\n }\n\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\n let isValid = true;\n\n // istanbul ignore else\n if (this._propertyEditor && this.props.propertyRecord) {\n const validateResult = await this._propertyEditor.validateValue(\n value,\n this.props.propertyRecord\n );\n\n if (validateResult.encounteredError) {\n this.displayOutputMessage(validateResult.errorMessage);\n isValid = false;\n }\n } else {\n isValid = false;\n }\n\n return isValid;\n }\n\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\n void this._commit(args);\n };\n\n private _handleContainerCommit = async (): Promise<void> => {\n const newValue =\n this._editorRef && (await this._editorRef.getPropertyValue());\n // istanbul ignore else\n if (newValue !== undefined) {\n void this._commit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n };\n\n private _commit = async (args: PropertyUpdatedArgs) => {\n const newValue = args.newValue;\n const isValid = await this.isNewValueValid(newValue);\n if (isValid) {\n let doCommit = true;\n // istanbul ignore else\n if (this._propertyEditor && args.propertyRecord) {\n const commitResult = await this._propertyEditor.commitValue(\n newValue,\n args.propertyRecord\n );\n if (commitResult.encounteredError) {\n this.displayOutputMessage(commitResult.errorMessage);\n doCommit = false;\n }\n }\n\n if (doCommit) {\n this.props.onCommit(args);\n }\n }\n };\n\n private _handleEditorCancel = () => {\n this._commitCancel();\n };\n\n private _commitCancel = () => {\n this.props.onCancel();\n };\n\n /** @internal */\n public override render() {\n return (\n <span\n className=\"components-editor-container\"\n onBlur={this._handleContainerBlur}\n onKeyDown={this._handleKeyDown}\n onClick={this._handleClick}\n onContextMenu={this._handleRightClick}\n title={this.props.title}\n data-testid=\"editor-container\"\n role=\"presentation\"\n >\n {this.createEditor()}\n </span>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"EditorContainer.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EditorContainer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kCAAgC;AAChC,6CAA+B;AAC/B,6CAAkC;AAElC,0DAAgD;AAMhD,mEAAgE;AAuEhE;;;GAGG;AACH,MAAa,eAAgB,SAAQ,KAAK,CAAC,aAAmC;IAA9E;;QAyCU,sBAAiB,GAAG,CAAC,EAAoB,EAAE,EAAE;YACnD,uBAAuB;YACvB,IACE,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,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;YACrD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAC7D,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,cAAc,CAC1B,CAAC;YAEF,IAAI,cAAc,CAAC,gBAAgB,EAAE;gBACnC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;gBACvD,OAAO,GAAG,KAAK,CAAC;aACjB;SACF;aAAM;YACL,OAAO,GAAG,KAAK,CAAC;SACjB;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAiDD,gBAAgB;IACA,MAAM;QACpB,OAAO,CACL,8BACE,SAAS,EAAC,6BAA6B,EACvC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EACjC,SAAS,EAAE,IAAI,CAAC,cAAc,EAC9B,OAAO,EAAE,IAAI,CAAC,YAAY,EAC1B,aAAa,EAAE,IAAI,CAAC,iBAAiB,EACrC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,kBAAkB,EAC9B,IAAI,EAAC,cAAc,IAElB,IAAI,CAAC,YAAY,EAAE,CACf,CACR,CAAC;IACJ,CAAC;CACF;AAtND,0CAsNC","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\nimport \"./EditorContainer.scss\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n AsyncErrorMessage,\n PropertyEditorBase,\n} from \"./PropertyEditorManager\";\nimport { PropertyEditorManager } from \"./PropertyEditorManager\";\n\n/** Arguments for the Property Updated event callback\n * @public\n */\nexport interface PropertyUpdatedArgs {\n /** The property being updated. */\n propertyRecord: PropertyRecord;\n /** The new value for the property. */\n newValue: PropertyValue;\n}\n\n/** Properties for a property editor component\n * @public\n */\nexport interface PropertyEditorProps extends CommonProps {\n /** The property being updated. */\n propertyRecord?: PropertyRecord;\n /** Handler for commit */\n onCommit?: (args: PropertyUpdatedArgs) => void;\n /** Handler for cancel */\n onCancel?: () => void;\n /** Handler for blur */\n onBlur?: (event: React.FocusEvent) => void;\n /** Indicates whether the Property Editor should set focus */\n setFocus?: boolean;\n /**\n * Indicates whether value change should call onCommit().\n * @internal\n */\n shouldCommitOnChange?: boolean;\n}\n\n/** [[EditorContainer]] React component properties\n * @public\n */\nexport interface EditorContainerProps extends CommonProps {\n /** The property being updated. */\n propertyRecord: PropertyRecord;\n /** Tooltip text */\n title?: string;\n /** Handler for commit */\n onCommit: (args: PropertyUpdatedArgs) => void;\n /** Handler for cancel */\n onCancel: () => void;\n /** Indicates whether the Property Editor should set focus */\n setFocus?: boolean;\n\n /** @internal */\n ignoreEditorBlur?: boolean;\n /**\n * Indicates whether value change should call onCommit().\n * @internal\n */\n shouldCommitOnChange?: boolean;\n}\n\n/** @internal */\ninterface CloneProps extends PropertyEditorProps {\n ref: (ref: any) => void;\n}\n\n/** Interface implemented by React based type editors\n * @public\n */\nexport interface TypeEditor {\n getPropertyValue: () => Promise<PropertyValue | undefined>;\n htmlElement: HTMLElement | null;\n hasFocus: boolean;\n}\n\n/**\n * EditorContainer React component used by the Tree and PropertyGrid for cell editing.\n * @public\n */\nexport class EditorContainer extends React.PureComponent<EditorContainerProps> {\n private _editorRef: TypeEditor | undefined;\n private _propertyEditor: PropertyEditorBase | undefined;\n\n private createEditor(): React.ReactNode {\n const editorRef = (ref: TypeEditor | undefined) => (this._editorRef = ref);\n\n const editorProps: CloneProps = {\n ref: editorRef,\n onCommit: this._handleEditorCommit,\n onCancel: this._handleEditorCancel,\n onBlur: this._handleEditorBlur,\n propertyRecord: this.props.propertyRecord,\n setFocus: this.props.setFocus !== undefined ? this.props.setFocus : true,\n className: this.props.className,\n style: this.props.style,\n shouldCommitOnChange: this.props.shouldCommitOnChange,\n };\n\n const propDescription = this.props.propertyRecord.property;\n\n const editorName =\n propDescription.editor !== undefined\n ? propDescription.editor.name\n : undefined;\n this._propertyEditor = PropertyEditorManager.createEditor(\n propDescription.typename,\n editorName,\n propDescription.dataController\n );\n const editorNode: React.ReactNode = this._propertyEditor.reactNode;\n\n let clonedNode: React.ReactNode = null;\n // istanbul ignore else\n if (React.isValidElement(editorNode)) {\n clonedNode = React.cloneElement(editorNode, editorProps);\n }\n\n return clonedNode;\n }\n\n private _handleEditorBlur = (_e: React.FocusEvent) => {\n // istanbul ignore else\n if (\n !this.props.ignoreEditorBlur &&\n this._propertyEditor &&\n this._propertyEditor.containerHandlesBlur\n )\n void this._handleContainerCommit();\n };\n\n private _handleContainerBlur = (e: React.FocusEvent) => {\n e.stopPropagation();\n };\n\n private _handleClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case Key.Escape.valueOf():\n this.onPressEscape(e);\n break;\n case Key.Enter.valueOf():\n this.onPressEnter(e);\n break;\n case Key.Tab.valueOf():\n this.onPressTab(e);\n break;\n default:\n if (\n this._propertyEditor &&\n this._propertyEditor.containerStopsKeydownPropagation\n )\n e.stopPropagation();\n }\n };\n\n private _handleRightClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private onPressEscape(_e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesEscape) {\n this._commitCancel();\n }\n }\n\n private onPressEnter(e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesEnter) {\n // istanbul ignore else\n if (this._editorRef && this._editorRef.hasFocus) e.stopPropagation();\n void this._handleContainerCommit();\n }\n }\n\n private onPressTab(e: React.KeyboardEvent): void {\n // istanbul ignore else\n if (this._propertyEditor && this._propertyEditor.containerHandlesTab) {\n e.stopPropagation();\n void this._handleContainerCommit();\n }\n }\n\n private displayOutputMessage(errorMessage: AsyncErrorMessage | undefined) {\n // istanbul ignore else\n if (errorMessage && this._editorRef) {\n const htmlElement = this._editorRef && this._editorRef.htmlElement;\n // istanbul ignore else\n if (htmlElement)\n UiAdmin.messagePresenter.displayInputFieldMessage(\n htmlElement,\n errorMessage.severity,\n errorMessage.briefMessage,\n errorMessage.detailedMessage\n );\n else\n UiAdmin.messagePresenter.displayMessage(\n errorMessage.severity,\n errorMessage.briefMessage,\n errorMessage.detailedMessage,\n errorMessage.messageType\n );\n }\n }\n\n private async isNewValueValid(value: PropertyValue): Promise<boolean> {\n let isValid = true;\n\n // istanbul ignore else\n if (this._propertyEditor && this.props.propertyRecord) {\n const validateResult = await this._propertyEditor.validateValue(\n value,\n this.props.propertyRecord\n );\n\n if (validateResult.encounteredError) {\n this.displayOutputMessage(validateResult.errorMessage);\n isValid = false;\n }\n } else {\n isValid = false;\n }\n\n return isValid;\n }\n\n private _handleEditorCommit = (args: PropertyUpdatedArgs): void => {\n void this._commit(args);\n };\n\n private _handleContainerCommit = async (): Promise<void> => {\n const newValue =\n this._editorRef && (await this._editorRef.getPropertyValue());\n // istanbul ignore else\n if (newValue !== undefined) {\n void this._commit({\n propertyRecord: this.props.propertyRecord,\n newValue,\n });\n }\n };\n\n private _commit = async (args: PropertyUpdatedArgs) => {\n const newValue = args.newValue;\n const isValid = await this.isNewValueValid(newValue);\n if (isValid) {\n let doCommit = true;\n // istanbul ignore else\n if (this._propertyEditor && args.propertyRecord) {\n const commitResult = await this._propertyEditor.commitValue(\n newValue,\n args.propertyRecord\n );\n if (commitResult.encounteredError) {\n this.displayOutputMessage(commitResult.errorMessage);\n doCommit = false;\n }\n }\n\n if (doCommit) {\n this.props.onCommit(args);\n }\n }\n };\n\n private _handleEditorCancel = () => {\n this._commitCancel();\n };\n\n private _commitCancel = () => {\n this.props.onCancel();\n };\n\n /** @internal */\n public override render() {\n return (\n <span\n className=\"components-editor-container\"\n onBlur={this._handleContainerBlur}\n onKeyDown={this._handleKeyDown}\n onClick={this._handleClick}\n onContextMenu={this._handleRightClick}\n title={this.props.title}\n data-testid=\"editor-container\"\n role=\"presentation\"\n >\n {this.createEditor()}\n </span>\n );\n }\n}\n"]}
@@ -141,7 +141,7 @@ class EnumButtonGroupEditor extends React.Component {
141
141
  // istanbul ignore else
142
142
  if (propertyRecord.property.editor &&
143
143
  propertyRecord.property.editor.params) {
144
- const bgParams = propertyRecord.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.ButtonGroupData);
144
+ const bgParams = propertyRecord.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.ButtonGroupData.valueOf());
145
145
  // istanbul ignore else
146
146
  if (bgParams) {
147
147
  bgParams.buttons.forEach((iconDef, index) => {
@@ -1 +1 @@
1
- {"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAS/B,0DAK+B;AAC/B,kDAAyC;AAEzC,mEAGiC;AACjC,mGAA0E;AAW1E;;GAEG;AACH,MAAa,qBACX,SAAQ,KAAK,CAAC,SAA0D;IAD1E;;QAIU,aAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;QACzD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAyC;YACrE,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;QA0GM,uBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YA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E,KAAa,EAAE,EAAE,CAClE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAC9B,CACC,CACP,CAAC;IACJ,CAAC;CACF;AApMD,sDAoMC;AAED;;;GAGG;AACH,MAAa,6BAA8B,SAAQ,0CAAkB;IACnE,uBAAuB;IACvB,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AALD,sEAKC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,6BAA6B,EAC7B,oCAAmB,CAAC,eAAe,CACpC,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\nimport \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ButtonGroupEditorParams,\n EnumerationChoice,\n IconDefinition,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport svgPlaceholder from \"@bentley/icons-generic/icons/placeholder.svg\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumButtonGroupEditor\n extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState>\n implements TypeEditor\n{\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n /** @internal */\n public override componentDidMount() {\n void this.setStateFromProps();\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 async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.property.enum &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: svgPlaceholder });\n\n // istanbul ignore else\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n // istanbul ignore else\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const bgParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ButtonGroupData\n ) as ButtonGroupEditorParams;\n // istanbul ignore else\n if (bgParams) {\n bgParams.buttons.forEach(\n (iconDef: IconDefinition, index: number) => {\n // istanbul ignore else\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n }\n );\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n // istanbul ignore else\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices\n ? this.state.choices[index].value\n : /* istanbul ignore next */ 0;\n const isActive = choiceValue === this.state.selectValue ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n // istanbul ignore else\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\"\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement | null) =>\n ref && this._btnRefs.set(choiceValue, ref)\n }\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\n </button>\n );\n }\n\n /** @internal */\n public override render() {\n return (\n <div\n className={classnames(\n \"components-enumbuttongroup-editor\",\n this.props.className\n )}\n style={this.props.style}\n ref={this._divElement}\n >\n {this.state.choices &&\n this.state.enumIcons.length &&\n this.state.choices.map((choice: EnumerationChoice, index: number) =>\n this.getButton(choice, index)\n )}\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @public\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase {\n // istanbul ignore next\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Enum,\n EnumPropertyButtonGroupEditor,\n StandardEditorNames.EnumButtonGroup\n);\n"]}
1
+ {"version":3,"file":"EnumButtonGroupEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumButtonGroupEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,wCAAsC;AACtC,4DAAoC;AACpC,6CAA+B;AAS/B,0DAK+B;AAC/B,kDAAyC;AAEzC,mEAGiC;AACjC,mGAA0E;AAW1E;;GAEG;AACH,MAAa,qBACX,SAAQ,KAAK,CAAC,SAA0D;IAD1E;;QAIU,aAAQ,GAAG,IAAI,GAAG,EAAsC,CAAC;QACzD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAAyC;YACrE,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;QA0GM,uBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC7C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YAEnE,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,EAAE;gBAC3D,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,C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a,6BAA8B,SAAQ,0CAAkB;IACnE,uBAAuB;IACvB,IAAW,SAAS;QAClB,OAAO,oBAAC,qBAAqB,OAAG,CAAC;IACnC,CAAC;CACF;AALD,sEAKC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,6BAA6B,EAC7B,oCAAmB,CAAC,eAAe,CACpC,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\nimport \"./EnumButtonGroupEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ButtonGroupEditorParams,\n EnumerationChoice,\n IconDefinition,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { Icon } from \"@itwin/core-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport svgPlaceholder from \"@bentley/icons-generic/icons/placeholder.svg\";\n\n// cspell:ignore buttongroup enumbuttongroup\n\n/** @internal */\ninterface EnumButtonGroupEditorState {\n selectValue: string | number;\n enumIcons: IconDefinition[];\n choices: EnumerationChoice[];\n}\n\n/** EnumButtonGroupEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumButtonGroupEditor\n extends React.Component<PropertyEditorProps, EnumButtonGroupEditorState>\n implements TypeEditor\n{\n private _btnRefs = new Map<string | number, HTMLButtonElement>();\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumButtonGroupEditorState> = {\n selectValue: \"\",\n enumIcons: [],\n choices: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n /** @internal */\n public override componentDidMount() {\n void this.setStateFromProps();\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 async setStateFromProps() {\n const { propertyRecord } = this.props;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.property.enum &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n let selectValue: string | number;\n\n if (typeof primitiveValue === \"string\") {\n selectValue = primitiveValue;\n } else {\n selectValue = primitiveValue as number;\n }\n\n let choices: EnumerationChoice[] = [];\n // istanbul ignore else\n if (propertyRecord && propertyRecord.property.enum) {\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const numChoices = choices.length;\n const enumIcons = new Array<IconDefinition>(numChoices);\n enumIcons.fill({ iconSpec: svgPlaceholder });\n\n // istanbul ignore else\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n // istanbul ignore else\n if (\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const bgParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ButtonGroupData.valueOf()\n ) as ButtonGroupEditorParams;\n // istanbul ignore else\n if (bgParams) {\n bgParams.buttons.forEach(\n (iconDef: IconDefinition, index: number) => {\n // istanbul ignore else\n if (index < numChoices) {\n enumIcons[index] = iconDef;\n }\n }\n );\n }\n }\n }\n\n this.setState({ selectValue, enumIcons, choices });\n }\n }\n\n private _handleButtonClick = (index: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n // istanbul ignore else\n if (this.state.choices && this.state.choices.length > index) {\n const selectValue = this.state.choices[index].value;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n }\n };\n\n private getButton(choice: EnumerationChoice, index: number) {\n const choiceValue = this.state.choices\n ? this.state.choices[index].value\n : /* istanbul ignore next */ 0;\n const isActive = choiceValue === this.state.selectValue ? true : false;\n let isDisabled = false;\n const isEnabledFunction = this.state.enumIcons[index].isEnabledFunction;\n // istanbul ignore else\n if (isEnabledFunction) {\n isDisabled = !isEnabledFunction();\n }\n\n const className = classnames(\n \"components-enumbuttongroup-button\",\n isDisabled && \"nz-is-disabled\",\n isActive && \"nz-is-active\"\n );\n\n return (\n <button\n ref={(ref: HTMLButtonElement | null) =>\n ref && this._btnRefs.set(choiceValue, ref)\n }\n data-testid={choice.label}\n className={className}\n title={choice.label}\n key={choice.label}\n onClick={() => this._handleButtonClick(index)}\n >\n <Icon iconSpec={this.state.enumIcons[index].iconSpec} />\n </button>\n );\n }\n\n /** @internal */\n public override render() {\n return (\n <div\n className={classnames(\n \"components-enumbuttongroup-editor\",\n this.props.className\n )}\n style={this.props.style}\n ref={this._divElement}\n >\n {this.state.choices &&\n this.state.enumIcons.length &&\n this.state.choices.map((choice: EnumerationChoice, index: number) =>\n this.getButton(choice, index)\n )}\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name and the \"enum-buttongroup\" editor name.\n * It uses the [[EnumButtonGroupEditor]] React component.\n * @public\n */\nexport class EnumPropertyButtonGroupEditor extends PropertyEditorBase {\n // istanbul ignore next\n public get reactNode(): React.ReactNode {\n return <EnumButtonGroupEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Enum,\n EnumPropertyButtonGroupEditor,\n StandardEditorNames.EnumButtonGroup\n);\n"]}
@@ -19,7 +19,6 @@ interface EnumEditorState {
19
19
  */
20
20
  export declare class EnumEditor extends React.PureComponent<PropertyEditorProps, EnumEditorState> implements TypeEditor {
21
21
  private _isMounted;
22
- private _ariaLabel;
23
22
  private _divElement;
24
23
  /** @internal */
25
24
  readonly state: Readonly<EnumEditorState>;
@@ -1 +1 @@
1
- {"version":3,"file":"EnumEditor.d.ts","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAqB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAGjC,gBAAgB;AAChB,UAAU,eAAe;IACvB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,UACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAChE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3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CAAC;IAChC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,qBAAa,UACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,eAAe,CAChE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAqC;IAExD,gBAAgB;IAChB,SAAyB,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,CAKvD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAiBnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAGD,IAAW,QAAQ,IAAI,OAAO,CAM7B;IAED,OAAO,CAAC,kBAAkB,CA4BxB;IAEF,gBAAgB;IACA,iBAAiB;IAKjC,gBAAgB;IACA,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAgD/B,gBAAgB;IACA,MAAM;CAwCvB;AAED;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IAExD,IAAoB,qBAAqB,IAAI,OAAO,CAEnD;IACD,IAAoB,gCAAgC,IAAI,OAAO,CAE9D;IAED,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
@@ -48,7 +48,6 @@ class EnumEditor extends React.PureComponent {
48
48
  constructor() {
49
49
  super(...arguments);
50
50
  this._isMounted = false;
51
- this._ariaLabel = UiComponents_1.UiComponents.translate("editor.enum");
52
51
  this._divElement = React.createRef();
53
52
  /** @internal */
54
53
  this.state = {
@@ -183,10 +182,10 @@ class EnumEditor extends React.PureComponent {
183
182
  ref: (el) => {
184
183
  if (!this.props.setFocus)
185
184
  return;
186
- el?.focus();
185
+ el === null || el === void 0 ? void 0 : el.focus();
187
186
  },
188
187
  className: "components-button",
189
- }, "aria-label": this._ariaLabel, size: "small" })));
188
+ }, "aria-label": UiComponents_1.UiComponents.translate("editor.enum"), size: "small" })));
190
189
  }
191
190
  }
192
191
  exports.EnumEditor = EnumEditor;
@@ -1 +1 @@
1
- {"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAE/B,0DAA+E;AAE/E,wDAA8C;AAE9C,mEAGiC;AACjC,kDAA+C;AAU/C;;GAEG;AACH,MAAa,UACX,SAAQ,KAAK,CAAC,aAAmD;IADnE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,eAAU,GAAG,2BAAY,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACnD,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAA8B;YAC1D,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QAgCM,uBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;YAChD,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,IAAI,WAA4B,CAAC;gBAEjC,qBAAqB;gBACrB,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa;oBAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;oBAC9D,WAAW,GAAG,QAAQ,CAAC;gBAE5B,IAAI,CAAC,QAAQ,CACX;oBACE,WAAW;iBACZ,EACD,KAAK,IAAI,EAAE;oBACT,uBAAuB;oBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;wBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACpD,uBAAuB;wBACvB,IAAI,aAAa,EAAE;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AC,UAAU,EAC3B,IAAI,EAAC,OAAO,GACZ,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAvLD,gCAuLC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,0CAAkB;IACxD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,gCAAgC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAZD,gDAYC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,kBAAkB,CACnB,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\nimport \"./EnumEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { EnumerationChoice, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface EnumEditorState {\n selectValue: string | number;\n valueIsNumber: boolean;\n options: SelectOption<string>[];\n parentDiv: HTMLDivElement | null;\n}\n\n/** EnumEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumEditor\n extends React.PureComponent<PropertyEditorProps, EnumEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _ariaLabel = UiComponents.translate(\"editor.enum\");\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumEditorState> = {\n selectValue: \"\",\n valueIsNumber: false,\n options: [],\n parentDiv: null,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateSelectValue = (newValue: string) => {\n // istanbul ignore else\n if (this._isMounted) {\n let selectValue: string | number;\n\n // istanbul ignore if\n if (this.state.valueIsNumber) selectValue = parseInt(newValue, 10);\n else selectValue = newValue;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n }\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 async setStateFromProps() {\n const { propertyRecord } = this.props;\n let initialValue: string | number = \"\";\n let valueIsNumber: boolean = false;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n if (typeof primitiveValue === \"string\") {\n initialValue = primitiveValue;\n valueIsNumber = false;\n } else {\n initialValue = primitiveValue as number;\n valueIsNumber = true;\n }\n }\n\n let choices: EnumerationChoice[] | undefined;\n\n if (propertyRecord && propertyRecord.property.enum) {\n // istanbul ignore else\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const options: SelectOption<string>[] = [];\n if (choices) {\n choices.forEach((choice: EnumerationChoice) => {\n options.push({ value: choice.value.toString(), label: choice.label });\n });\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n selectValue: initialValue,\n valueIsNumber,\n options,\n parentDiv: this._divElement.current,\n });\n }\n\n /** @internal */\n public override render() {\n const className = classnames(\n \"components-cell-editor\",\n \"components-enum-editor\",\n this.props.className\n );\n const selectValue =\n this.state.selectValue !== undefined\n ? this.state.selectValue.toString()\n : /* istanbul ignore next */ undefined;\n\n // set min-width to show about 4 characters + down arrow\n const minWidthStyle: React.CSSProperties = {\n minWidth: `6em`,\n };\n\n // The iTwinUI-react Select onBlur still does not work properly, so it cannot be used yet. NEEDSWORK\n // onBlur={this.props.onBlur}\n return (\n <div ref={this._divElement}>\n <Select\n className={className}\n style={this.props.style ? this.props.style : minWidthStyle}\n value={selectValue}\n onChange={this._updateSelectValue}\n data-testid=\"components-select-editor\"\n options={this.state.options}\n triggerProps={{\n ref: (el) => {\n if (!this.props.setFocus) return;\n el?.focus();\n },\n className: \"components-button\",\n }}\n aria-label={this._ariaLabel}\n size=\"small\"\n />\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name.\n * It uses the [[EnumEditor]] React component.\n * @public\n */\nexport class EnumPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerStopsKeydownPropagation(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <EnumEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Enum,\n EnumPropertyEditor\n);\n"]}
1
+ {"version":3,"file":"EnumEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/EnumEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAE/B,0DAA+E;AAE/E,wDAA8C;AAE9C,mEAGiC;AACjC,kDAA+C;AAU/C;;GAEG;AACH,MAAa,UACX,SAAQ,KAAK,CAAC,aAAmD;IADnE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAExD,gBAAgB;QACS,UAAK,GAA8B;YAC1D,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,KAAK;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QAgCM,uBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;YAChD,uBAAuB;YACvB,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,IAAI,WAA4B,CAAC;gBAEjC,qBAAqB;gBACrB,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa;oBAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;;oBAC9D,WAAW,GAAG,QAAQ,CAAC;gBAE5B,IAAI,CAAC,QAAQ,CACX;oBACE,WAAW;iBACZ,EACD,KAAK,IAAI,EAAE;oBACT,uBAAuB;oBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;wBACpD,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACpD,uBAAuB;wBACvB,IAAI,aAAa,EAAE;4BACjB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;gCAClB,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,c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CACP,CAAC;IACJ,CAAC;CACF;AAtLD,gCAsLC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,0CAAkB;IACxD,uBAAuB;IACvB,IAAoB,qBAAqB;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAoB,gCAAgC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAZD,gDAYC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,kBAAkB,CACnB,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\nimport \"./EnumEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { EnumerationChoice, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { UiComponents } from \"../UiComponents\";\n\n/** @internal */\ninterface EnumEditorState {\n selectValue: string | number;\n valueIsNumber: boolean;\n options: SelectOption<string>[];\n parentDiv: HTMLDivElement | null;\n}\n\n/** EnumEditor React component that is a property editor with select input\n * @public\n */\nexport class EnumEditor\n extends React.PureComponent<PropertyEditorProps, EnumEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n /** @internal */\n public override readonly state: Readonly<EnumEditorState> = {\n selectValue: \"\",\n valueIsNumber: false,\n options: [],\n parentDiv: null,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.selectValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n // istanbul ignore next\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n // istanbul ignore next\n public get hasFocus(): boolean {\n let containsFocus = false;\n // istanbul ignore else\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private _updateSelectValue = (newValue: string) => {\n // istanbul ignore else\n if (this._isMounted) {\n let selectValue: string | number;\n\n // istanbul ignore if\n if (this.state.valueIsNumber) selectValue = parseInt(newValue, 10);\n else selectValue = newValue;\n\n this.setState(\n {\n selectValue,\n },\n async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n }\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 async setStateFromProps() {\n const { propertyRecord } = this.props;\n let initialValue: string | number = \"\";\n let valueIsNumber: boolean = false;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n if (typeof primitiveValue === \"string\") {\n initialValue = primitiveValue;\n valueIsNumber = false;\n } else {\n initialValue = primitiveValue as number;\n valueIsNumber = true;\n }\n }\n\n let choices: EnumerationChoice[] | undefined;\n\n if (propertyRecord && propertyRecord.property.enum) {\n // istanbul ignore else\n if (propertyRecord.property.enum.choices instanceof Promise) {\n choices = await propertyRecord.property.enum.choices;\n } else {\n choices = propertyRecord.property.enum.choices;\n }\n }\n\n const options: SelectOption<string>[] = [];\n if (choices) {\n choices.forEach((choice: EnumerationChoice) => {\n options.push({ value: choice.value.toString(), label: choice.label });\n });\n }\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({\n selectValue: initialValue,\n valueIsNumber,\n options,\n parentDiv: this._divElement.current,\n });\n }\n\n /** @internal */\n public override render() {\n const className = classnames(\n \"components-cell-editor\",\n \"components-enum-editor\",\n this.props.className\n );\n const selectValue =\n this.state.selectValue !== undefined\n ? this.state.selectValue.toString()\n : /* istanbul ignore next */ undefined;\n\n // set min-width to show about 4 characters + down arrow\n const minWidthStyle: React.CSSProperties = {\n minWidth: `6em`,\n };\n\n // The iTwinUI-react Select onBlur still does not work properly, so it cannot be used yet. NEEDSWORK\n // onBlur={this.props.onBlur}\n return (\n <div ref={this._divElement}>\n <Select\n className={className}\n style={this.props.style ? this.props.style : minWidthStyle}\n value={selectValue}\n onChange={this._updateSelectValue}\n data-testid=\"components-select-editor\"\n options={this.state.options}\n triggerProps={{\n ref: (el) => {\n if (!this.props.setFocus) return;\n el?.focus();\n },\n className: \"components-button\",\n }}\n aria-label={UiComponents.translate(\"editor.enum\")}\n size=\"small\"\n />\n </div>\n );\n }\n}\n\n/** Enum Property Button Group Editor registered for the \"enum\" type name.\n * It uses the [[EnumEditor]] React component.\n * @public\n */\nexport class EnumPropertyEditor extends PropertyEditorBase {\n // istanbul ignore next\n public override get containerHandlesEnter(): boolean {\n return false;\n }\n public override get containerStopsKeydownPropagation(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <EnumEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Enum,\n EnumPropertyEditor\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":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SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
@@ -75,7 +75,7 @@ class IconEditor extends React.PureComponent {
75
75
  record.property &&
76
76
  record.property.editor &&
77
77
  record.property.editor.params) {
78
- const iconParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.IconListData);
78
+ const iconParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.IconListData.valueOf());
79
79
  // istanbul ignore else
80
80
  if (iconParams) {
81
81
  if (iconParams.iconValue)
@@ -1 +1 @@
1
- {"version":3,"file":"IconEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/IconEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAO/B,0DAK+B;AAC/B,qEAAkE;AAElE,mEAGiC;AAajC;;GAEG;AACH,uBAAuB;AACvB,MAAa,UACX,SAAQ,KAAK,CAAC,aAAmD;IAOjE,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QALP,aAAQ,GAAe,IAAI,CAAC;QAC5B,eAAU,GAAG,KAAK,CAAC;QACnB,gBAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAoEhD,kBAAa,GAAG,CAAC,IAAY,EAAE,EAAE;YACvC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAgC,CAAC;YAEnE,IAAI,CAAC,QAAQ,CACX;gBACE,IAAI;aACL,EACD,KAAK,IAAI,EAAE;gBACT,uBAAuB;gBACvB,IAAI,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;oBACzC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACpD,uBAAuB;oBACvB,IAAI,aAAa,EAAE;wBACjB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,cA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E,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,YAAY,EAAE,IAAI,CAAC,aAAa,iBACpB,wBAAwB,GACpC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AA5JD,gCA4JC;AAED;;;GAGG;AACH,uBAAuB;AACvB,MAAa,kBAAmB,SAAQ,0CAAkB;IACxD,IAAW,SAAS;QAClB,OAAO,oBAAC,UAAU,OAAG,CAAC;IACxB,CAAC;CACF;AAJD,gDAIC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,kBAAkB,EAClB,oCAAmB,CAAC,UAAU,CAC/B,CAAC;AACF,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,MAAM,EACxB,kBAAkB,EAClB,oCAAmB,CAAC,UAAU,CAC/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 PropertyEditors\n */\n\nimport \"./IconEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconListEditorParams,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { IconPickerButton } from \"../iconpicker/IconPickerButton\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\n\n// cspell:ignore iconpicker\n\n/** @internal */\ninterface IconEditorState {\n icon: string;\n icons: string[];\n numColumns: number;\n readonly?: boolean;\n isDisabled?: boolean;\n}\n\n/** IconEditor React component that is a property editor with button and popup\n * @alpha\n */\n// istanbul ignore next\nexport class IconEditor\n extends React.PureComponent<PropertyEditorProps, IconEditorState>\n implements TypeEditor\n{\n private _control: any | null = null;\n private _isMounted = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n let icon = \"\";\n let numColumns = 4;\n const icons: string[] = [];\n const readonly = false;\n\n // TODO: add support for following if we need to specify set of weights to display\n const record = props.propertyRecord;\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.IconListData\n ) as IconListEditorParams;\n // istanbul ignore else\n if (iconParams) {\n if (iconParams.iconValue) icon = iconParams.iconValue;\n if (iconParams.numColumns) numColumns = iconParams.numColumns;\n if (iconParams.iconValues)\n iconParams.iconValues.forEach((i: string) => icons.push(i));\n }\n }\n\n this.state = { icon, icons, numColumns, readonly };\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.icon,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n // istanbul ignore else\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onIconChange = (icon: string) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n icon,\n },\n async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\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 async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as string;\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ icon: initialValue, readonly, isDisabled }, () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n });\n }\n\n /** @internal */\n public override render() {\n const { icon, icons, numColumns } = this.state;\n return (\n <div\n className={classnames(\"components-icon-editor\", this.props.className)}\n style={this.props.style}\n ref={this._divElement}\n >\n <IconPickerButton\n ref={(control) => (this._control = control)}\n icon={icon}\n icons={icons}\n numColumns={numColumns}\n disabled={this.state.isDisabled}\n readonly={this.state.readonly}\n onIconChange={this._onIconChange}\n data-testid=\"components-icon-editor\"\n />\n </div>\n );\n }\n}\n\n/** Icon Property Editor registered for the \"text\" and \"string\" type names and the \"icon-picker\" editor name.\n * It uses the [[IconEditor]] React component.\n * @alpha\n */\n// istanbul ignore next\nexport class IconPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <IconEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Text,\n IconPropertyEditor,\n StandardEditorNames.IconPicker\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.String,\n IconPropertyEditor,\n StandardEditorNames.IconPicker\n);\n"]}
1
+ {"version":3,"file":"IconEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/IconEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;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mB,CAAC,UAAU,CAC/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 PropertyEditors\n */\n\nimport \"./IconEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n IconListEditorParams,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport { IconPickerButton } from \"../iconpicker/IconPickerButton\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\n\n// cspell:ignore iconpicker\n\n/** @internal */\ninterface IconEditorState {\n icon: string;\n icons: string[];\n numColumns: number;\n readonly?: boolean;\n isDisabled?: boolean;\n}\n\n/** IconEditor React component that is a property editor with button and popup\n * @alpha\n */\n// istanbul ignore next\nexport class IconEditor\n extends React.PureComponent<PropertyEditorProps, IconEditorState>\n implements TypeEditor\n{\n private _control: any = null;\n private _isMounted = false;\n private _divElement = React.createRef<HTMLDivElement>();\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n let icon = \"\";\n let numColumns = 4;\n const icons: string[] = [];\n const readonly = false;\n\n // TODO: add support for following if we need to specify set of weights to display\n const record = props.propertyRecord;\n if (\n record &&\n record.property &&\n record.property.editor &&\n record.property.editor.params\n ) {\n const iconParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.IconListData.valueOf()\n ) as IconListEditorParams;\n // istanbul ignore else\n if (iconParams) {\n if (iconParams.iconValue) icon = iconParams.iconValue;\n if (iconParams.numColumns) numColumns = iconParams.numColumns;\n if (iconParams.iconValues)\n iconParams.iconValues.forEach((i: string) => icons.push(i));\n }\n }\n\n this.state = { icon, icons, numColumns, readonly };\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.icon,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n // istanbul ignore else\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onIconChange = (icon: string) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n icon,\n },\n async () => {\n // istanbul ignore else\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (propertyValue) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\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 async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = \"\";\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as string;\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n // istanbul ignore else\n if (this._isMounted)\n this.setState({ icon: initialValue, readonly, isDisabled }, () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n });\n }\n\n /** @internal */\n public override render() {\n const { icon, icons, numColumns } = this.state;\n return (\n <div\n className={classnames(\"components-icon-editor\", this.props.className)}\n style={this.props.style}\n ref={this._divElement}\n >\n <IconPickerButton\n ref={(control) => (this._control = control)}\n icon={icon}\n icons={icons}\n numColumns={numColumns}\n disabled={this.state.isDisabled}\n readonly={this.state.readonly}\n onIconChange={this._onIconChange}\n data-testid=\"components-icon-editor\"\n />\n </div>\n );\n }\n}\n\n/** Icon Property Editor registered for the \"text\" and \"string\" type names and the \"icon-picker\" editor name.\n * It uses the [[IconEditor]] React component.\n * @alpha\n */\n// istanbul ignore next\nexport class IconPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <IconEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Text,\n IconPropertyEditor,\n StandardEditorNames.IconPicker\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.String,\n IconPropertyEditor,\n StandardEditorNames.IconPicker\n);\n"]}
@@ -127,7 +127,7 @@ class ImageCheckBoxEditor extends React.PureComponent {
127
127
  propertyRecord.property &&
128
128
  propertyRecord.property.editor &&
129
129
  propertyRecord.property.editor.params) {
130
- const imageCheckBoxParams = propertyRecord.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.CheckBoxImages);
130
+ const imageCheckBoxParams = propertyRecord.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.CheckBoxImages.valueOf());
131
131
  // istanbul ignore else
132
132
  if (imageCheckBoxParams) {
133
133
  imageOn = imageCheckBoxParams.imageOn;
@@ -1 +1 @@
1
- {"version":3,"file":"ImageCheckBoxEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/ImageCheckBoxEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAM/B,0DAK+B;AAE/B,mE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BAAmB,OAAG,CAAC;IACjC,CAAC;CACF;AAJD,kEAIC;AAED,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,OAAO,EACzB,2BAA2B,EAC3B,oCAAmB,CAAC,aAAa,CAClC,CAAC;AACF,6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,2BAA2B,EAC3B,oCAAmB,CAAC,aAAa,CAClC,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\nimport \"./ImageCheckBoxEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ImageCheckBoxParams,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { ImageCheckBox } from \"@itwin/core-react\";\n\n// cSpell:ignore imagecheckbox\n\n/** @internal */\ninterface ImageCheckBoxEditorState {\n /** Image for the \"checked\" state */\n imageOn: string;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string;\n checkboxValue: boolean;\n isDisabled?: boolean;\n}\n/** [[ImageCheckBoxEditor]]\n * Boolean editor that renders with an image instead of checkbox\n * @public\n */\nexport class ImageCheckBoxEditor\n extends React.PureComponent<PropertyEditorProps, ImageCheckBoxEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement> = React.createRef();\n\n /** @internal */\n public override readonly state: Readonly<ImageCheckBoxEditorState> = {\n imageOff: \"\",\n imageOn: \"\",\n checkboxValue: false,\n isDisabled: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.checkboxValue,\n displayValue: \"\",\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 /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n 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 this.setStateFromProps();\n }\n }\n\n private setStateFromProps() {\n const { propertyRecord } = this.props;\n let checkboxValue = false;\n let imageOn = \"\";\n let imageOff = \"\";\n let isDisabled = false;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n checkboxValue = primitiveValue as boolean;\n }\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.isDisabled)\n isDisabled = propertyRecord.isDisabled;\n\n if (\n propertyRecord &&\n propertyRecord.property &&\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const imageCheckBoxParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.CheckBoxImages\n ) as ImageCheckBoxParams;\n // istanbul ignore else\n if (imageCheckBoxParams) {\n imageOn = imageCheckBoxParams.imageOn;\n imageOff = imageCheckBoxParams.imageOff;\n }\n }\n this.setState({ imageOn, imageOff, checkboxValue, isDisabled });\n }\n\n private _handleClick = (checked: boolean) => {\n this.setState(\n {\n checkboxValue: checked,\n },\n async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (this._isMounted && propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n };\n\n public override render() {\n const className = classnames(\n \"components-cell-editor\",\n \"components-imagecheckbox-editor\",\n this.props.className\n );\n const checked = this.state.checkboxValue;\n const isDisabled = !!this.state.isDisabled;\n\n return (\n <ImageCheckBox\n inputRef={this._inputElement}\n imageOff={this.state.imageOff}\n imageOn={this.state.imageOn}\n className={className}\n border={true}\n style={this.props.style}\n checked={checked}\n disabled={isDisabled}\n onClick={this._handleClick}\n data-testid=\"components-imagecheckbox-editor\"\n />\n );\n }\n}\n\n/** ImageCheckBox Property Editor registered for the \"bool\" and \"boolean\" type names.\n * It uses the [[ImageCheckBoxEditor]] React component.\n * @public\n */\nexport class ImageCheckBoxPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ImageCheckBoxEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Boolean,\n ImageCheckBoxPropertyEditor,\n StandardEditorNames.ImageCheckBox\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Bool,\n ImageCheckBoxPropertyEditor,\n StandardEditorNames.ImageCheckBox\n);\n"]}
1
+ {"version":3,"file":"ImageCheckBoxEditor.js","sourceRoot":"","sources":["../../../../src/components-react/editors/ImageCheckBoxEditor.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAM/B,0DAK+B;AAE/B,mEAGiC;AACjC,kDAAkD;AAalD;;;GAGG;AACH,MAAa,mBACX,SAAQ,KAAK,CAAC,aAA4D;IAD5E;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAsC,KAAK,CAAC,SAAS,EAAE,CAAC;QAE7E,gBAA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6CAAqB,CAAC,cAAc,CAClC,kCAAiB,CAAC,IAAI,EACtB,2BAA2B,EAC3B,oCAAmB,CAAC,aAAa,CAClC,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\nimport \"./ImageCheckBoxEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type {\n ImageCheckBoxParams,\n PropertyEditorParams,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n StandardEditorNames,\n StandardTypeNames,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer\";\nimport {\n PropertyEditorBase,\n PropertyEditorManager,\n} from \"./PropertyEditorManager\";\nimport { ImageCheckBox } from \"@itwin/core-react\";\n\n// cSpell:ignore imagecheckbox\n\n/** @internal */\ninterface ImageCheckBoxEditorState {\n /** Image for the \"checked\" state */\n imageOn: string;\n /** Image for the \"unchecked\" (default) state */\n imageOff: string;\n checkboxValue: boolean;\n isDisabled?: boolean;\n}\n/** [[ImageCheckBoxEditor]]\n * Boolean editor that renders with an image instead of checkbox\n * @public\n */\nexport class ImageCheckBoxEditor\n extends React.PureComponent<PropertyEditorProps, ImageCheckBoxEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement: React.RefObject<HTMLInputElement> = React.createRef();\n\n /** @internal */\n public override readonly state: Readonly<ImageCheckBoxEditorState> = {\n imageOff: \"\",\n imageOn: \"\",\n checkboxValue: false,\n isDisabled: false,\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n // istanbul ignore else\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.checkboxValue,\n displayValue: \"\",\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 /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n 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 this.setStateFromProps();\n }\n }\n\n private setStateFromProps() {\n const { propertyRecord } = this.props;\n let checkboxValue = false;\n let imageOn = \"\";\n let imageOff = \"\";\n let isDisabled = false;\n\n // istanbul ignore else\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n checkboxValue = primitiveValue as boolean;\n }\n\n // istanbul ignore else\n if (propertyRecord && propertyRecord.isDisabled)\n isDisabled = propertyRecord.isDisabled;\n\n if (\n propertyRecord &&\n propertyRecord.property &&\n propertyRecord.property.editor &&\n propertyRecord.property.editor.params\n ) {\n const imageCheckBoxParams = propertyRecord.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.CheckBoxImages.valueOf()\n ) as ImageCheckBoxParams;\n // istanbul ignore else\n if (imageCheckBoxParams) {\n imageOn = imageCheckBoxParams.imageOn;\n imageOff = imageCheckBoxParams.imageOff;\n }\n }\n this.setState({ imageOn, imageOff, checkboxValue, isDisabled });\n }\n\n private _handleClick = (checked: boolean) => {\n this.setState(\n {\n checkboxValue: checked,\n },\n async () => {\n // istanbul ignore else\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n // istanbul ignore else\n if (this._isMounted && propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\n }\n );\n };\n\n public override render() {\n const className = classnames(\n \"components-cell-editor\",\n \"components-imagecheckbox-editor\",\n this.props.className\n );\n const checked = this.state.checkboxValue;\n const isDisabled = !!this.state.isDisabled;\n\n return (\n <ImageCheckBox\n inputRef={this._inputElement}\n imageOff={this.state.imageOff}\n imageOn={this.state.imageOn}\n className={className}\n border={true}\n style={this.props.style}\n checked={checked}\n disabled={isDisabled}\n onClick={this._handleClick}\n data-testid=\"components-imagecheckbox-editor\"\n />\n );\n }\n}\n\n/** ImageCheckBox Property Editor registered for the \"bool\" and \"boolean\" type names.\n * It uses the [[ImageCheckBoxEditor]] React component.\n * @public\n */\nexport class ImageCheckBoxPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ImageCheckBoxEditor />;\n }\n}\n\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Boolean,\n ImageCheckBoxPropertyEditor,\n StandardEditorNames.ImageCheckBox\n);\nPropertyEditorManager.registerEditor(\n StandardTypeNames.Bool,\n ImageCheckBoxPropertyEditor,\n StandardEditorNames.ImageCheckBox\n);\n"]}
@@ -128,7 +128,7 @@ class NumericInputEditor extends React.PureComponent {
128
128
  record.property &&
129
129
  record.property.editor &&
130
130
  record.property.editor.params) {
131
- const editorSizeParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.InputEditorSize);
131
+ const editorSizeParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.InputEditorSize.valueOf());
132
132
  if (editorSizeParams) {
133
133
  // istanbul ignore else
134
134
  if (editorSizeParams.size)
@@ -137,7 +137,7 @@ class NumericInputEditor extends React.PureComponent {
137
137
  if (editorSizeParams.maxLength)
138
138
  maxLength = editorSizeParams.maxLength;
139
139
  }
140
- const rangeParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.Range);
140
+ const rangeParams = record.property.editor.params.find((param) => param.type === appui_abstract_1.PropertyEditorParamTypes.Range.valueOf());
141
141
  if (rangeParams) {
142
142
  min = rangeParams.minimum;
143
143
  max = rangeParams.maximum;