@itwin/imodel-components-react 4.1.0 → 4.2.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 (353) hide show
  1. package/CHANGELOG.md +335 -327
  2. package/LICENSE.md +9 -9
  3. package/README.md +11 -11
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  5. package/lib/cjs/imodel-components-react/UiIModelComponents.js +13 -10
  6. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +23 -17
  9. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  10. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +71 -63
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  13. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +11 -9
  14. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  16. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +1 -1
  17. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +6 -8
  19. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +1 -1
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +11 -12
  23. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  24. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  25. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +1 -1
  26. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  27. package/lib/cjs/imodel-components-react/color/HueSlider.js +32 -15
  28. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/color/HueSlider.scss +78 -61
  30. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +1 -1
  31. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  32. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +14 -11
  33. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  34. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +36 -35
  35. package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
  36. package/lib/cjs/imodel-components-react/color/Swatch.js +5 -8
  37. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -22
  39. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts.map +1 -1
  40. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +3 -3
  41. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  43. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +17 -9
  44. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  46. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  47. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +8 -6
  48. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  50. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +1 -1
  51. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  52. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +18 -12
  53. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +1 -1
  55. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  56. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +36 -22
  57. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  59. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  60. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +12 -16
  61. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  63. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  64. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +14 -10
  65. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  66. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  67. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  68. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +31 -11
  69. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  70. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  71. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  72. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +103 -49
  73. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  75. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  76. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +171 -66
  77. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  78. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +20 -13
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +4 -7
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +14 -10
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +33 -11
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  93. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +16 -10
  94. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  96. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +32 -24
  97. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  99. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +58 -39
  100. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  101. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  102. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +8 -7
  103. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +55 -16
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +11 -5
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +39 -12
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +11 -5
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +19 -7
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +21 -8
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +11 -5
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +13 -6
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  128. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  129. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +22 -12
  130. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  131. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  132. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +30 -13
  133. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  134. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  135. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +15 -7
  136. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  137. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  138. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +11 -9
  139. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  140. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  141. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +7 -4
  142. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  143. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +27 -27
  144. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  145. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +3 -3
  146. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  147. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -28
  148. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +1 -1
  149. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  150. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +32 -17
  151. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  152. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -105
  153. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  154. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +61 -27
  155. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  156. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  157. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  158. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +4 -5
  159. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  160. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +40 -40
  161. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +165 -165
  162. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  163. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +56 -29
  164. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  165. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +178 -178
  166. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  167. package/lib/cjs/imodel-components-react/timeline/interfaces.js +3 -3
  168. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  169. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +2 -2
  170. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  171. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +45 -33
  172. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  173. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  174. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +5 -4
  175. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  176. package/lib/cjs/imodel-components-react.js +3 -3
  177. package/lib/cjs/imodel-components-react.js.map +1 -1
  178. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  179. package/lib/esm/imodel-components-react/UiIModelComponents.js +13 -10
  180. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  181. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  182. package/lib/esm/imodel-components-react/color/AlphaSlider.js +23 -17
  183. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  184. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +71 -63
  185. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +1 -1
  186. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  187. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +11 -9
  188. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  189. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  190. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +1 -1
  191. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  192. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +7 -9
  193. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  194. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +1 -1
  195. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  196. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +13 -14
  197. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  198. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  199. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +1 -1
  200. package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  201. package/lib/esm/imodel-components-react/color/HueSlider.js +32 -15
  202. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  203. package/lib/esm/imodel-components-react/color/HueSlider.scss +78 -61
  204. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +1 -1
  205. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  206. package/lib/esm/imodel-components-react/color/SaturationPicker.js +14 -11
  207. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  208. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +36 -35
  209. package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
  210. package/lib/esm/imodel-components-react/color/Swatch.js +5 -8
  211. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  212. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -22
  213. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts.map +1 -1
  214. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +3 -3
  215. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  216. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  217. package/lib/esm/imodel-components-react/editors/ColorEditor.js +18 -10
  218. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  219. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  220. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  221. package/lib/esm/imodel-components-react/editors/WeightEditor.js +10 -8
  222. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  223. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  224. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +1 -1
  225. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  226. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +18 -12
  227. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  228. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +1 -1
  229. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  230. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +38 -24
  231. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  232. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  233. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  234. package/lib/esm/imodel-components-react/lineweight/Swatch.js +12 -16
  235. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  236. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  237. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  238. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +14 -10
  239. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  240. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  241. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  242. package/lib/esm/imodel-components-react/navigationaids/Cube.js +31 -11
  243. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  244. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  245. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  246. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +105 -51
  247. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  248. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  249. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  250. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +173 -68
  251. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  252. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  253. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
  254. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +20 -13
  255. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  256. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  257. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
  258. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +4 -7
  259. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  260. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  261. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +14 -10
  262. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  263. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  264. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +33 -11
  265. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  266. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  267. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +16 -10
  268. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  269. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  270. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +32 -24
  271. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  272. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  273. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +58 -39
  274. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  275. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  276. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +8 -7
  277. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  278. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  279. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +55 -16
  280. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  281. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  282. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +11 -5
  283. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  284. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  285. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +39 -12
  286. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  287. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  288. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +11 -5
  289. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  290. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  291. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +19 -7
  292. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  293. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  294. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +21 -8
  295. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  296. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  297. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +11 -5
  298. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  299. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  300. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +13 -6
  301. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  302. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  303. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +22 -12
  304. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  305. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  306. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +30 -13
  307. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  308. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  309. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +16 -8
  310. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  311. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  312. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +11 -9
  313. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  314. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  315. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +7 -4
  316. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  317. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +27 -27
  318. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  319. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +3 -3
  320. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  321. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -28
  322. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +1 -1
  323. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  324. package/lib/esm/imodel-components-react/timeline/Scrubber.js +32 -17
  325. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  326. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -105
  327. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  328. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +63 -29
  329. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  330. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  331. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  332. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +4 -5
  333. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  334. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +40 -40
  335. package/lib/esm/imodel-components-react/timeline/Timeline.scss +165 -165
  336. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  337. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +58 -31
  338. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  339. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +178 -178
  340. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  341. package/lib/esm/imodel-components-react/timeline/interfaces.js +3 -3
  342. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  343. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +2 -2
  344. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  345. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +47 -35
  346. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  347. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  348. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +5 -4
  349. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  350. package/lib/esm/imodel-components-react.js +3 -3
  351. package/lib/esm/imodel-components-react.js.map +1 -1
  352. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  353. package/package.json +15 -24
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  /** @packageDocumentation
7
7
  * @module Inputs
8
8
  */
@@ -53,7 +53,9 @@ function adjustFormatterSpec(formatterSpec) {
53
53
  showOnlyPrimaryUnit: true,
54
54
  traits: formatterSpec.format.formatTraits & ~core_quantity_1.FormatTraits.ShowUnitLabel,
55
55
  type: core_quantity_1.FormatType.Decimal,
56
- precision: core_quantity_1.FormatType.Decimal !== formatterSpec.format.type ? core_quantity_1.DecimalPrecision.Four : formatterSpec.format.precision,
56
+ precision: core_quantity_1.FormatType.Decimal !== formatterSpec.format.type
57
+ ? core_quantity_1.DecimalPrecision.Four
58
+ : formatterSpec.format.precision,
57
59
  });
58
60
  return new core_quantity_1.FormatterSpec("single-value", newFormat, singleUnitConversion, formatterSpec.persistenceUnit);
59
61
  }
@@ -65,7 +67,7 @@ function convertValueFromDisplayToPersistence(value, unitConversions, unit) {
65
67
  // istanbul ignore next
66
68
  if (!unitConversion)
67
69
  return value;
68
- const convertedValue = (value * unitConversion.conversion.factor) + unitConversion.conversion.offset;
70
+ const convertedValue = value * unitConversion.conversion.factor + unitConversion.conversion.offset;
69
71
  return convertedValue;
70
72
  }
71
73
  function getUnitLabel(parserSpec) {
@@ -77,7 +79,7 @@ function getUnitLabel(parserSpec) {
77
79
  return parserSpec.outUnit.label;
78
80
  const [unit, label] = format.units[0];
79
81
  // istanbul ignore next
80
- return label !== null && label !== void 0 ? label : unit.label;
82
+ return label ?? unit.label;
81
83
  }
82
84
  const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuantityNumberInput(props, ref) {
83
85
  const { containerClassName, persistenceValue, min, max, onChange, onBlur, onKeyDown, step, snap, showTouchButtons, quantityType, ...otherProps } = props;
@@ -97,24 +99,24 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
97
99
  const lastFormattedValueRef = React.useRef(formatValue(persistenceValue));
98
100
  const [formattedValue, setFormattedValue] = React.useState(() => lastFormattedValueRef.current);
99
101
  React.useEffect(() => {
100
- const handleUnitSystemChanged = (() => {
102
+ const handleUnitSystemChanged = () => {
101
103
  setFormatterSpec(adjustFormatterSpec(core_frontend_1.IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));
102
104
  setParserSpec(core_frontend_1.IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));
103
- });
105
+ };
104
106
  core_frontend_1.IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);
105
107
  return () => {
106
108
  core_frontend_1.IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);
107
109
  };
108
110
  }, [quantityType]);
109
111
  React.useEffect(() => {
110
- const handleUnitSystemChanged = ((args) => {
112
+ const handleUnitSystemChanged = (args) => {
111
113
  const quantityKey = core_frontend_1.IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);
112
114
  // istanbul ignore else
113
115
  if (args.quantityType === quantityKey) {
114
116
  setFormatterSpec(adjustFormatterSpec(core_frontend_1.IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));
115
117
  setParserSpec(core_frontend_1.IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));
116
118
  }
117
- });
119
+ };
118
120
  core_frontend_1.IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);
119
121
  return () => {
120
122
  core_frontend_1.IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);
@@ -136,7 +138,9 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
136
138
  // istanbul ignore else
137
139
  if (parserSpec) {
138
140
  // convert value from display unit to persistence unit
139
- const [unit] = parserSpec.format.units ? parserSpec.format.units[0] : /* istanbul ignore next */ [parserSpec.outUnit];
141
+ const [unit] = parserSpec.format.units
142
+ ? parserSpec.format.units[0]
143
+ : /* istanbul ignore next */ [parserSpec.outUnit];
140
144
  persistedValue = convertValueFromDisplayToPersistence(newValue, parserSpec.unitConversions, unit);
141
145
  rawValueRef.current = persistedValue;
142
146
  }
@@ -145,12 +149,12 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
145
149
  setFormattedValue(newFormattedVal);
146
150
  }, [formatValue, onChange, parserSpec]);
147
151
  /**
148
- * Used internally to parse the argument x to it's numeric representation.
149
- * If the argument cannot be converted to finite number returns 0; If a
150
- * "precision" prop is specified uses it round the number with that
151
- * precision (no fixed precision here because the return value is float, not
152
- * string).
153
- */
152
+ * Used internally to parse the argument x to it's numeric representation.
153
+ * If the argument cannot be converted to finite number returns 0; If a
154
+ * "precision" prop is specified uses it round the number with that
155
+ * precision (no fixed precision here because the return value is float, not
156
+ * string).
157
+ */
154
158
  const parseInternal = React.useCallback((x) => {
155
159
  if (!x)
156
160
  return 0;
@@ -179,7 +183,8 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
179
183
  }
180
184
  else {
181
185
  // istanbul ignore else
182
- if (rawValueRef.current) { // restore last known good value
186
+ if (rawValueRef.current) {
187
+ // restore last known good value
183
188
  const lastKnownFormattedVal = formatValue(rawValueRef.current);
184
189
  setFormattedValue(lastKnownFormattedVal);
185
190
  return;
@@ -204,11 +209,12 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
204
209
  return !step ? 1 : step;
205
210
  }, [step]);
206
211
  /**
207
- * The internal method that actually sets the new value on the input
208
- */
212
+ * The internal method that actually sets the new value on the input
213
+ */
209
214
  const applyStep = React.useCallback((increment) => {
210
215
  const incrementValue = getIncrementValue(increment);
211
- let num = parseInternal(formattedValue) + (increment ? incrementValue : -incrementValue);
216
+ let num = parseInternal(formattedValue) +
217
+ (increment ? incrementValue : -incrementValue);
212
218
  if (snap) {
213
219
  num = Math.round(num / incrementValue) * incrementValue;
214
220
  }
@@ -216,7 +222,15 @@ const ForwardRefQuantityNumberInput = React.forwardRef(function ForwardRefQuanti
216
222
  const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;
217
223
  num = Math.min(Math.max(num, localMin), localMax);
218
224
  updateValue(num);
219
- }, [formattedValue, getIncrementValue, max, min, parseInternal, snap, updateValue]);
225
+ }, [
226
+ formattedValue,
227
+ getIncrementValue,
228
+ max,
229
+ min,
230
+ parseInternal,
231
+ snap,
232
+ updateValue,
233
+ ]);
220
234
  const handleKeyDown = React.useCallback((event) => {
221
235
  // istanbul ignore else
222
236
  if (event.key === appui_abstract_1.SpecialKey.Enter) {
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityNumberInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityNumberInput.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,kDAAyC;AACzC,0DAAmD;AAEnD,wDAAiD;AAEjD,wDAAyG;AAEzG,wDAA6C;AAC7C,oEAA0G;AAkC1G,wEAAwE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mDAAmD,EAAE,gBAAgB,IAAI,oCAAoC,CAAC;gBAEvI,6BAAK,SAAS,EAAC,kFAAkF,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa;oBACpI,oBAAC,iBAAI,IAAC,QAAQ,EAAE,OAAO,GAAI,CACvB;gBAEN,6BAAK,SAAS,EAAC,oFAAoF,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe;oBACxI,oBAAC,iBAAI,IAAC,QAAQ,EAAE,SAAS,GAAI,CACzB,CACF,CACF;QACN,8BAAM,SAAS,EAAC,wCAAwC,IAAE,SAAS,CAAQ,CACtE,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACU,QAAA,mBAAmB,GAA4D,6BAA6B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Inputs\r\n */\r\n\r\nimport \"./QuantityNumberInput.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { Icon } from \"@itwin/core-react\";\r\nimport { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport type { QuantityFormatsChangedArgs, QuantityTypeArg } from \"@itwin/core-frontend\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport type { ParserSpec, UnitConversionSpec, UnitProps } from \"@itwin/core-quantity\";\r\nimport { DecimalPrecision, FormatterSpec, FormatTraits, FormatType, Parser } from \"@itwin/core-quantity\";\r\nimport type { InputProps } from \"@itwin/itwinui-react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { SvgCaretDown, SvgCaretDownSmall, SvgCaretUp, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\r\n\r\n/** Step function prototype for [[QuantityNumberInput]] component\r\n * @beta\r\n */\r\nexport type StepFunctionProp = number | ((direction: string) => number | undefined);\r\n\r\n/** Properties for the [[QuantityNumberInput]] component\r\n * @beta\r\n */\r\nexport interface QuantityNumberInputProps extends Omit<InputProps, \"value\" | \"min\" | \"max\" | \"step\" | \"onFocus\" | \"onChange\"> {\r\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend).\r\n * Set to `undefined` to show placeholder text */\r\n persistenceValue?: number;\r\n /** CSS class name for the QuantityNumberInput component container div */\r\n containerClassName?: string;\r\n /** number or function\tNumber.MIN_SAFE_INTEGER */\r\n min?: number;\r\n /** number or function\tdefaults to Number.MAX_SAFE_INTEGER */\r\n max?: number;\r\n /** increment step value used while incrementing or decrementing (up/down buttons or arrow keys) defaults to 1. */\r\n step?: StepFunctionProp;\r\n /** Set to true to \"snap\" to the closest step value while incrementing or decrementing (up/down buttons or arrow keys). */\r\n snap?: boolean;\r\n /** Function to call when the quantity value is changed. The value returned will be in 'persistence' units. */\r\n onChange?: (value: number) => void;\r\n /** if true up/down buttons are shown larger and side by side */\r\n showTouchButtons?: boolean;\r\n /** Provides ability to return reference to HTMLInputElement */\r\n ref?: React.Ref<HTMLInputElement>;\r\n /** Type of quantity being input. */\r\n quantityType: QuantityTypeArg;\r\n}\r\n\r\n/** adjust formatter spec to show only primary unit without a label. */\r\nfunction adjustFormatterSpec(formatterSpec: FormatterSpec | undefined) {\r\n if (undefined === formatterSpec)\r\n return formatterSpec;\r\n const singleUnitConversion: UnitConversionSpec[] = [];\r\n singleUnitConversion.push(formatterSpec.unitConversions[0]);\r\n const newFormat = formatterSpec.format.clone({\r\n showOnlyPrimaryUnit: true,\r\n traits: formatterSpec.format.formatTraits & ~FormatTraits.ShowUnitLabel,\r\n type: FormatType.Decimal,\r\n precision: FormatType.Decimal !== formatterSpec.format.type ? DecimalPrecision.Four : formatterSpec.format.precision,\r\n });\r\n return new FormatterSpec(\"single-value\", newFormat, singleUnitConversion, formatterSpec.persistenceUnit);\r\n}\r\n\r\nfunction convertValueFromDisplayToPersistence(value: number, unitConversions: UnitConversionSpec[] | undefined, unit: UnitProps) {\r\n // istanbul ignore next\r\n if (!unitConversions || 0 === unitConversions.length)\r\n return value;\r\n\r\n const unitConversion = unitConversions.find((spec) => spec.name === unit.name);\r\n // istanbul ignore next\r\n if (!unitConversion)\r\n return value;\r\n\r\n const convertedValue = (value * unitConversion.conversion.factor) + unitConversion.conversion.offset;\r\n return convertedValue;\r\n}\r\n\r\nfunction getUnitLabel(parserSpec: ParserSpec | undefined) {\r\n if (undefined === parserSpec)\r\n return \"\";\r\n\r\n const format = parserSpec.format;\r\n // istanbul ignore else\r\n if (!format.units || !format.units[0])\r\n return parserSpec.outUnit.label;\r\n const [unit, label] = format.units[0];\r\n // istanbul ignore next\r\n return label ?? unit.label;\r\n}\r\n\r\nconst ForwardRefQuantityNumberInput = React.forwardRef<HTMLInputElement, QuantityNumberInputProps>(\r\n function ForwardRefQuantityNumberInput(props, ref) {\r\n\r\n const { containerClassName, persistenceValue, min, max,\r\n onChange, onBlur, onKeyDown, step, snap, showTouchButtons, quantityType, ...otherProps } = props;\r\n const rawValueRef = React.useRef(persistenceValue);\r\n\r\n const [formatterSpec, setFormatterSpec] = React.useState(() => adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n const [parserSpec, setParserSpec] = React.useState(() => IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n\r\n const formatValue = React.useCallback((value: number | undefined) => {\r\n if (undefined === value)\r\n return \"\";\r\n\r\n // istanbul ignore else\r\n if (formatterSpec) {\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n // istanbul ignore next\r\n return value.toFixed(2);\r\n }, [formatterSpec]);\r\n\r\n const lastFormattedValueRef = React.useRef(formatValue(persistenceValue));\r\n const [formattedValue, setFormattedValue] = React.useState(() => lastFormattedValueRef.current);\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((): void => {\r\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n });\r\n\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n React.useEffect(() => {\r\n const handleUnitSystemChanged = ((args: QuantityFormatsChangedArgs): void => {\r\n const quantityKey = IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\r\n // istanbul ignore else\r\n if (args.quantityType === quantityKey) {\r\n setFormatterSpec(adjustFormatterSpec(IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)));\r\n setParserSpec(IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType));\r\n }\r\n });\r\n\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(handleUnitSystemChanged);\r\n return () => {\r\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(handleUnitSystemChanged);\r\n };\r\n }, [quantityType]);\r\n\r\n const unitLabel = getUnitLabel(parserSpec);\r\n\r\n // See if new initialValue props have changed since component mounted\r\n React.useEffect(() => {\r\n rawValueRef.current = persistenceValue;\r\n const currentFormattedValue = formatValue(rawValueRef.current);\r\n setFormattedValue(currentFormattedValue);\r\n }, [formatValue, persistenceValue]);\r\n\r\n // this is the unprocessed input from user, it is not processed until blur or enter key press\r\n const handleDisplayValueChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormattedValue(event.currentTarget.value);\r\n }, []);\r\n\r\n const updateValue = React.useCallback((newValue: number) => {\r\n let persistedValue = newValue;\r\n // istanbul ignore else\r\n if (parserSpec) {\r\n // convert value from display unit to persistence unit\r\n const [unit] = parserSpec.format.units ? parserSpec.format.units[0] : /* istanbul ignore next */[parserSpec.outUnit];\r\n persistedValue = convertValueFromDisplayToPersistence(newValue, parserSpec.unitConversions, unit);\r\n rawValueRef.current = persistedValue;\r\n }\r\n const newFormattedVal = formatValue(persistedValue);\r\n onChange && onChange(persistedValue);\r\n setFormattedValue(newFormattedVal);\r\n\r\n }, [formatValue, onChange, parserSpec]);\r\n\r\n /**\r\n * Used internally to parse the argument x to it's numeric representation.\r\n * If the argument cannot be converted to finite number returns 0; If a\r\n * \"precision\" prop is specified uses it round the number with that\r\n * precision (no fixed precision here because the return value is float, not\r\n * string).\r\n */\r\n const parseInternal = React.useCallback((x: string | undefined) => {\r\n if (!x)\r\n return 0;\r\n\r\n let n = parseFloat(x);\r\n // istanbul ignore next\r\n if (isNaN(n) || !isFinite(n)) {\r\n n = 0;\r\n }\r\n\r\n const localPrecision = 6; // TODO get a reasonable value from format\r\n const q = Math.pow(10, localPrecision);\r\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\r\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\r\n n = Math.min(Math.max(n, localMin), localMax);\r\n n = Math.round(n * q) / q;\r\n\r\n return n;\r\n }, [min, max]);\r\n\r\n const updateValueFromString = React.useCallback((strValue: string) => {\r\n // istanbul ignore else\r\n if (parserSpec) {\r\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(strValue, parserSpec);\r\n // at this point we should have a string value in persistence units without a label\r\n if (Parser.isParsedQuantity(parseResult)) {\r\n const persistedValue = parseResult.value; // in persistence units\r\n // set strValue and let it go through parseInternal which will ensure min/max limits are observed\r\n strValue = formatValue(persistedValue)!;\r\n } else {\r\n // istanbul ignore else\r\n if (rawValueRef.current) { // restore last known good value\r\n const lastKnownFormattedVal = formatValue(rawValueRef.current);\r\n setFormattedValue(lastKnownFormattedVal);\r\n return;\r\n }\r\n }\r\n }\r\n const newValue = parseInternal(strValue);\r\n // istanbul ignore else\r\n if (undefined !== newValue)\r\n updateValue(newValue);\r\n }, [formatValue, parseInternal, parserSpec, updateValue]);\r\n\r\n const handleBlur = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n const newVal = parseInternal(event.target.value);\r\n onBlur && onBlur(event);\r\n updateValue(newVal);\r\n }, [parseInternal, updateValue, onBlur]);\r\n\r\n const getIncrementValue = React.useCallback((increment: boolean) => {\r\n if (typeof step === \"function\") {\r\n const stepVal = step(increment ? \"up\" : \"down\");\r\n return stepVal ? stepVal : 1;\r\n }\r\n\r\n return !step ? 1 : step;\r\n }, [step]);\r\n\r\n /**\r\n * The internal method that actually sets the new value on the input\r\n */\r\n const applyStep = React.useCallback((increment: boolean) => {\r\n const incrementValue = getIncrementValue(increment);\r\n\r\n let num = parseInternal(formattedValue) + (increment ? incrementValue : -incrementValue);\r\n if (snap) {\r\n num = Math.round(num / incrementValue) * incrementValue;\r\n }\r\n\r\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\r\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\r\n num = Math.min(Math.max(num, localMin), localMax);\r\n\r\n updateValue(num);\r\n }, [formattedValue, getIncrementValue, max, min, parseInternal, snap, updateValue]);\r\n\r\n const handleKeyDown = React.useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (event.key === SpecialKey.Enter) {\r\n updateValueFromString(event.currentTarget.value);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.Escape) {\r\n setFormattedValue(formatValue(rawValueRef.current));\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowDown) {\r\n applyStep(false);\r\n event.preventDefault();\r\n } else if (event.key === SpecialKey.ArrowUp) {\r\n applyStep(true);\r\n event.preventDefault();\r\n }\r\n onKeyDown && onKeyDown(event);\r\n }, [onKeyDown, updateValueFromString, formatValue, applyStep]);\r\n\r\n const handleDownClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\r\n applyStep(false);\r\n event.preventDefault();\r\n }, [applyStep]);\r\n\r\n const handleUpClick = React.useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\r\n applyStep(true);\r\n event.preventDefault();\r\n }, [applyStep]);\r\n\r\n // istanbul ignore next\r\n const handleFocus = React.useCallback((event: React.FocusEvent<HTMLInputElement>) => {\r\n event.currentTarget.select();\r\n }, []);\r\n\r\n const isDisabled = !!otherProps.disabled;\r\n const containerClasses = classnames(\"component-quantity-number-input-container\",\r\n containerClassName, showTouchButtons && \"component-number-buttons-for-touch\",\r\n isDisabled && \"component-quantity-number-input-disabled\",\r\n );\r\n\r\n const caretUp = showTouchButtons ? <SvgCaretUp /> : <SvgCaretUpSmall />;\r\n const caretDown = showTouchButtons ? <SvgCaretDown /> : <SvgCaretDownSmall />;\r\n\r\n return (\r\n <div className={containerClasses} >\r\n <div className=\"component-quantity-number-input-value-and-buttons-container\">\r\n <Input ref={ref} value={formattedValue} onChange={handleDisplayValueChange} onKeyDown={handleKeyDown}\r\n onBlur={handleBlur} onFocus={handleFocus} size=\"small\" {...otherProps} />\r\n <div className={classnames(\"component-quantity-number-input-buttons-container\", showTouchButtons && \"component-number-buttons-for-touch\")}>\r\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\r\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-up\" tabIndex={-1} onClick={handleUpClick}>\r\n <Icon iconSpec={caretUp} />\r\n </div>\r\n { /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\r\n <div className=\"component-quantity-number-input-button component-quantity-number-input-button-down\" tabIndex={-1} onClick={handleDownClick}>\r\n <Icon iconSpec={caretDown} />\r\n </div>\r\n </div>\r\n </div>\r\n <span className=\"component-quantity-number-input-suffix\">{unitLabel}</span>\r\n </div >\r\n );\r\n }\r\n);\r\n\r\n/** The QuantityNumberInput component accepts input for quantity values. The quantity value is shown as a single numeric value and the quantity's\r\n * \"display\" unit is shown next to the input control. The \"display\" unit is determined by the active unit system as defined by the [QuantityFormatter]($frontend).\r\n * The control also display buttons to increment and decrement the \"displayed\" value. The value reported by via the onChange function is in \"persistence\"\r\n * units that can be stored in the iModel.\r\n * @beta\r\n */\r\nexport const QuantityNumberInput: (props: QuantityNumberInputProps) => JSX.Element | null = ForwardRefQuantityNumberInput;\r\n"]}
1
+ {"version":3,"file":"QuantityNumberInput.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/QuantityNumberInput.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sCAAoC;AACpC,4DAAoC;AACpC,6CAA+B;AAC/B,kDAAyC;AACzC,0DAAmD;AAKnD,wDAAiD;AAMjD,wDAM8B;AAE9B,wDAA6C;AAC7C,oEAKoC;AAwCpC,wEAAwE;AACxE,SAAS,mBAAmB,CAAC,aAAwC;IACnE,IAAI,SAAS,KAAK,aAAa;QAAE,OAAO,aAAa,CAAC;IACtD,MAAM,oBAAoB,GAAyB,EAAE,CAAC;IACtD,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;QAC3C,mBAAmB,EAAE,IAAI;QACzB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,YAAY,GAAG,CAAC,4BAAY,CAAC,aAAa;QACvE,IAAI,EAAE,0BAAU,CAAC,OAAO;QACxB,SAAS,EACP,0BAAU,CAAC,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI;YAC9C,CAAC,CAAC,gCAAgB,CAAC,IAAI;YACvB,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS;KACrC,CAAC,CAAC;IACH,OAAO,IAAI,6BAAa,CACtB,cAAc,EACd,SAAS,EACT,oBAAoB,EACpB,aAAa,CAAC,eAAe,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,oCAAoC,CAC3C,KAAa,EACb,eAAiD,EACjD,IAAe;IAEf,uB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,OAAO,CACL,6BAAK,SAAS,EAAE,gBAAgB;QAC9B,6BAAK,SAAS,EAAC,6DAA6D;YAC1E,oBAAC,qBAAK,IACJ,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,wBAAwB,EAClC,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,EACpB,IAAI,EAAC,OAAO,KACR,UAAU,GACd;YACF,6BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,mDAAmD,EACnD,gBAAgB,IAAI,oCAAoC,CACzD;gBAGD,6BACE,SAAS,EAAC,kFAAkF,EAC5F,QAAQ,EAAE,CAAC,CAAC,EACZ,OAAO,EAAE,aAAa;oBAEtB,oBAAC,iBAAI,IAAC,QAAQ,EAAE,OAAO,GAAI,CACvB;gBAEN,6BACE,SAAS,EAAC,oFAAoF,EAC9F,QAAQ,EAAE,CAAC,CAAC,EACZ,OAAO,EAAE,eAAe;oBAExB,oBAAC,iBAAI,IAAC,QAAQ,EAAE,SAAS,GAAI,CACzB,CACF,CACF;QACN,8BAAM,SAAS,EAAC,wCAAwC,IACrD,SAAS,CACL,CACH,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,mBAAmB,GAEC,6BAA6B,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 Inputs\n */\n\nimport \"./QuantityNumberInput.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\nimport type {\n QuantityFormatsChangedArgs,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport type {\n ParserSpec,\n UnitConversionSpec,\n UnitProps,\n} from \"@itwin/core-quantity\";\nimport {\n DecimalPrecision,\n FormatterSpec,\n FormatTraits,\n FormatType,\n Parser,\n} from \"@itwin/core-quantity\";\nimport type { InputProps } from \"@itwin/itwinui-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport {\n SvgCaretDown,\n SvgCaretDownSmall,\n SvgCaretUp,\n SvgCaretUpSmall,\n} from \"@itwin/itwinui-icons-react\";\n\n/** Step function prototype for [[QuantityNumberInput]] component\n * @beta\n */\nexport type StepFunctionProp =\n | number\n | ((direction: string) => number | undefined);\n\n/** Properties for the [[QuantityNumberInput]] component\n * @beta\n */\nexport interface QuantityNumberInputProps\n extends Omit<\n InputProps,\n \"value\" | \"min\" | \"max\" | \"step\" | \"onFocus\" | \"onChange\"\n > {\n /** Initial magnitude in 'persistence' units. See `getPersistenceUnitByQuantityType` in [QuantityFormatter]($core-frontend).\n * Set to `undefined` to show placeholder text */\n persistenceValue?: number;\n /** CSS class name for the QuantityNumberInput component container div */\n containerClassName?: string;\n /** number or function\tNumber.MIN_SAFE_INTEGER */\n min?: number;\n /** number or function\tdefaults to Number.MAX_SAFE_INTEGER */\n max?: number;\n /** increment step value used while incrementing or decrementing (up/down buttons or arrow keys) defaults to 1. */\n step?: StepFunctionProp;\n /** Set to true to \"snap\" to the closest step value while incrementing or decrementing (up/down buttons or arrow keys). */\n snap?: boolean;\n /** Function to call when the quantity value is changed. The value returned will be in 'persistence' units. */\n onChange?: (value: number) => void;\n /** if true up/down buttons are shown larger and side by side */\n showTouchButtons?: boolean;\n /** Provides ability to return reference to HTMLInputElement */\n ref?: React.Ref<HTMLInputElement>;\n /** Type of quantity being input. */\n quantityType: QuantityTypeArg;\n}\n\n/** adjust formatter spec to show only primary unit without a label. */\nfunction adjustFormatterSpec(formatterSpec: FormatterSpec | undefined) {\n if (undefined === formatterSpec) return formatterSpec;\n const singleUnitConversion: UnitConversionSpec[] = [];\n singleUnitConversion.push(formatterSpec.unitConversions[0]);\n const newFormat = formatterSpec.format.clone({\n showOnlyPrimaryUnit: true,\n traits: formatterSpec.format.formatTraits & ~FormatTraits.ShowUnitLabel,\n type: FormatType.Decimal,\n precision:\n FormatType.Decimal !== formatterSpec.format.type\n ? DecimalPrecision.Four\n : formatterSpec.format.precision,\n });\n return new FormatterSpec(\n \"single-value\",\n newFormat,\n singleUnitConversion,\n formatterSpec.persistenceUnit\n );\n}\n\nfunction convertValueFromDisplayToPersistence(\n value: number,\n unitConversions: UnitConversionSpec[] | undefined,\n unit: UnitProps\n) {\n // istanbul ignore next\n if (!unitConversions || 0 === unitConversions.length) return value;\n\n const unitConversion = unitConversions.find(\n (spec) => spec.name === unit.name\n );\n // istanbul ignore next\n if (!unitConversion) return value;\n\n const convertedValue =\n value * unitConversion.conversion.factor + unitConversion.conversion.offset;\n return convertedValue;\n}\n\nfunction getUnitLabel(parserSpec: ParserSpec | undefined) {\n if (undefined === parserSpec) return \"\";\n\n const format = parserSpec.format;\n // istanbul ignore else\n if (!format.units || !format.units[0]) return parserSpec.outUnit.label;\n const [unit, label] = format.units[0];\n // istanbul ignore next\n return label ?? unit.label;\n}\n\nconst ForwardRefQuantityNumberInput = React.forwardRef<\n HTMLInputElement,\n QuantityNumberInputProps\n>(function ForwardRefQuantityNumberInput(props, ref) {\n const {\n containerClassName,\n persistenceValue,\n min,\n max,\n onChange,\n onBlur,\n onKeyDown,\n step,\n snap,\n showTouchButtons,\n quantityType,\n ...otherProps\n } = props;\n const rawValueRef = React.useRef(persistenceValue);\n\n const [formatterSpec, setFormatterSpec] = React.useState(() =>\n adjustFormatterSpec(\n IModelApp.quantityFormatter.findFormatterSpecByQuantityType(quantityType)\n )\n );\n const [parserSpec, setParserSpec] = React.useState(() =>\n IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType)\n );\n\n const formatValue = React.useCallback(\n (value: number | undefined) => {\n if (undefined === value) return \"\";\n\n // istanbul ignore else\n if (formatterSpec) {\n return formatterSpec.applyFormatting(value);\n }\n // istanbul ignore next\n return value.toFixed(2);\n },\n [formatterSpec]\n );\n\n const lastFormattedValueRef = React.useRef(formatValue(persistenceValue));\n const [formattedValue, setFormattedValue] = React.useState(\n () => lastFormattedValueRef.current\n );\n\n React.useEffect(() => {\n const handleUnitSystemChanged = (): void => {\n setFormatterSpec(\n adjustFormatterSpec(\n IModelApp.quantityFormatter.findFormatterSpecByQuantityType(\n quantityType\n )\n )\n );\n setParserSpec(\n IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType)\n );\n };\n\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(\n handleUnitSystemChanged\n );\n return () => {\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.removeListener(\n handleUnitSystemChanged\n );\n };\n }, [quantityType]);\n\n React.useEffect(() => {\n const handleUnitSystemChanged = (\n args: QuantityFormatsChangedArgs\n ): void => {\n const quantityKey =\n IModelApp.quantityFormatter.getQuantityTypeKey(quantityType);\n // istanbul ignore else\n if (args.quantityType === quantityKey) {\n setFormatterSpec(\n adjustFormatterSpec(\n IModelApp.quantityFormatter.findFormatterSpecByQuantityType(\n quantityType\n )\n )\n );\n setParserSpec(\n IModelApp.quantityFormatter.findParserSpecByQuantityType(quantityType)\n );\n }\n };\n\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(\n handleUnitSystemChanged\n );\n return () => {\n IModelApp.quantityFormatter.onQuantityFormatsChanged.removeListener(\n handleUnitSystemChanged\n );\n };\n }, [quantityType]);\n\n const unitLabel = getUnitLabel(parserSpec);\n\n // See if new initialValue props have changed since component mounted\n React.useEffect(() => {\n rawValueRef.current = persistenceValue;\n const currentFormattedValue = formatValue(rawValueRef.current);\n setFormattedValue(currentFormattedValue);\n }, [formatValue, persistenceValue]);\n\n // this is the unprocessed input from user, it is not processed until blur or enter key press\n const handleDisplayValueChange = React.useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setFormattedValue(event.currentTarget.value);\n },\n []\n );\n\n const updateValue = React.useCallback(\n (newValue: number) => {\n let persistedValue = newValue;\n // istanbul ignore else\n if (parserSpec) {\n // convert value from display unit to persistence unit\n const [unit] = parserSpec.format.units\n ? parserSpec.format.units[0]\n : /* istanbul ignore next */ [parserSpec.outUnit];\n persistedValue = convertValueFromDisplayToPersistence(\n newValue,\n parserSpec.unitConversions,\n unit\n );\n rawValueRef.current = persistedValue;\n }\n const newFormattedVal = formatValue(persistedValue);\n onChange && onChange(persistedValue);\n setFormattedValue(newFormattedVal);\n },\n [formatValue, onChange, parserSpec]\n );\n\n /**\n * Used internally to parse the argument x to it's numeric representation.\n * If the argument cannot be converted to finite number returns 0; If a\n * \"precision\" prop is specified uses it round the number with that\n * precision (no fixed precision here because the return value is float, not\n * string).\n */\n const parseInternal = React.useCallback(\n (x: string | undefined) => {\n if (!x) return 0;\n\n let n = parseFloat(x);\n // istanbul ignore next\n if (isNaN(n) || !isFinite(n)) {\n n = 0;\n }\n\n const localPrecision = 6; // TODO get a reasonable value from format\n const q = Math.pow(10, localPrecision);\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\n n = Math.min(Math.max(n, localMin), localMax);\n n = Math.round(n * q) / q;\n\n return n;\n },\n [min, max]\n );\n\n const updateValueFromString = React.useCallback(\n (strValue: string) => {\n // istanbul ignore else\n if (parserSpec) {\n const parseResult = IModelApp.quantityFormatter.parseToQuantityValue(\n strValue,\n parserSpec\n );\n // at this point we should have a string value in persistence units without a label\n if (Parser.isParsedQuantity(parseResult)) {\n const persistedValue = parseResult.value; // in persistence units\n // set strValue and let it go through parseInternal which will ensure min/max limits are observed\n strValue = formatValue(persistedValue)!;\n } else {\n // istanbul ignore else\n if (rawValueRef.current) {\n // restore last known good value\n const lastKnownFormattedVal = formatValue(rawValueRef.current);\n setFormattedValue(lastKnownFormattedVal);\n return;\n }\n }\n }\n const newValue = parseInternal(strValue);\n // istanbul ignore else\n if (undefined !== newValue) updateValue(newValue);\n },\n [formatValue, parseInternal, parserSpec, updateValue]\n );\n\n const handleBlur = React.useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n const newVal = parseInternal(event.target.value);\n onBlur && onBlur(event);\n updateValue(newVal);\n },\n [parseInternal, updateValue, onBlur]\n );\n\n const getIncrementValue = React.useCallback(\n (increment: boolean) => {\n if (typeof step === \"function\") {\n const stepVal = step(increment ? \"up\" : \"down\");\n return stepVal ? stepVal : 1;\n }\n\n return !step ? 1 : step;\n },\n [step]\n );\n\n /**\n * The internal method that actually sets the new value on the input\n */\n const applyStep = React.useCallback(\n (increment: boolean) => {\n const incrementValue = getIncrementValue(increment);\n\n let num =\n parseInternal(formattedValue) +\n (increment ? incrementValue : -incrementValue);\n if (snap) {\n num = Math.round(num / incrementValue) * incrementValue;\n }\n\n const localMin = undefined === min ? Number.MIN_SAFE_INTEGER : min;\n const localMax = undefined === max ? Number.MAX_SAFE_INTEGER : max;\n num = Math.min(Math.max(num, localMin), localMax);\n\n updateValue(num);\n },\n [\n formattedValue,\n getIncrementValue,\n max,\n min,\n parseInternal,\n snap,\n updateValue,\n ]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (event.key === SpecialKey.Enter) {\n updateValueFromString(event.currentTarget.value);\n event.preventDefault();\n } else if (event.key === SpecialKey.Escape) {\n setFormattedValue(formatValue(rawValueRef.current));\n event.preventDefault();\n } else if (event.key === SpecialKey.ArrowDown) {\n applyStep(false);\n event.preventDefault();\n } else if (event.key === SpecialKey.ArrowUp) {\n applyStep(true);\n event.preventDefault();\n }\n onKeyDown && onKeyDown(event);\n },\n [onKeyDown, updateValueFromString, formatValue, applyStep]\n );\n\n const handleDownClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n applyStep(false);\n event.preventDefault();\n },\n [applyStep]\n );\n\n const handleUpClick = React.useCallback(\n (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n applyStep(true);\n event.preventDefault();\n },\n [applyStep]\n );\n\n // istanbul ignore next\n const handleFocus = React.useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n event.currentTarget.select();\n },\n []\n );\n\n const isDisabled = !!otherProps.disabled;\n const containerClasses = classnames(\n \"component-quantity-number-input-container\",\n containerClassName,\n showTouchButtons && \"component-number-buttons-for-touch\",\n isDisabled && \"component-quantity-number-input-disabled\"\n );\n\n const caretUp = showTouchButtons ? <SvgCaretUp /> : <SvgCaretUpSmall />;\n const caretDown = showTouchButtons ? <SvgCaretDown /> : <SvgCaretDownSmall />;\n\n return (\n <div className={containerClasses}>\n <div className=\"component-quantity-number-input-value-and-buttons-container\">\n <Input\n ref={ref}\n value={formattedValue}\n onChange={handleDisplayValueChange}\n onKeyDown={handleKeyDown}\n onBlur={handleBlur}\n onFocus={handleFocus}\n size=\"small\"\n {...otherProps}\n />\n <div\n className={classnames(\n \"component-quantity-number-input-buttons-container\",\n showTouchButtons && \"component-number-buttons-for-touch\"\n )}\n >\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n className=\"component-quantity-number-input-button component-quantity-number-input-button-up\"\n tabIndex={-1}\n onClick={handleUpClick}\n >\n <Icon iconSpec={caretUp} />\n </div>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n className=\"component-quantity-number-input-button component-quantity-number-input-button-down\"\n tabIndex={-1}\n onClick={handleDownClick}\n >\n <Icon iconSpec={caretDown} />\n </div>\n </div>\n </div>\n <span className=\"component-quantity-number-input-suffix\">\n {unitLabel}\n </span>\n </div>\n );\n});\n\n/** The QuantityNumberInput component accepts input for quantity values. The quantity value is shown as a single numeric value and the quantity's\n * \"display\" unit is shown next to the input control. The \"display\" unit is determined by the active unit system as defined by the [QuantityFormatter]($frontend).\n * The control also display buttons to increment and decrement the \"displayed\" value. The value reported by via the onChange function is in \"persistence\"\n * units that can be stored in the iModel.\n * @beta\n */\nexport const QuantityNumberInput: (\n props: QuantityNumberInputProps\n) => React.ReactElement | null = ForwardRefQuantityNumberInput;\n"]}
@@ -1,106 +1,106 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/base/base";
6
-
7
- .component-quantity-number-input-container {
8
- display: flex;
9
- align-items: center;
10
- position: relative;
11
- padding: 0;
12
- margin: 0;
13
- box-sizing: border-box;
14
-
15
- .component-quantity-number-input-suffix {
16
- padding-left: 0.25em;
17
- }
18
-
19
- .component-quantity-number-input-value-and-buttons-container {
20
- position: relative;
21
- padding: 0;
22
- margin: 0;
23
- box-sizing: border-box;
24
-
25
- input {
26
- margin: 0;
27
- padding-right: 1.5em;
28
- }
29
-
30
- &.component-number-buttons-for-touch {
31
- input {
32
- padding-right: 3.5em;
33
- }
34
- }
35
-
36
- .component-quantity-number-input-buttons-container {
37
- position: absolute;
38
- top: 0;
39
- right: 0;
40
- width: 20px;
41
- height: 100%;
42
- @include uicore-centered;
43
- flex-direction: column;
44
-
45
- .component-quantity-number-input-button {
46
- font-size: 8px;
47
- outline: none;
48
- height: 100%;
49
- width: 100%;
50
- @include uicore-centered;
51
-
52
- &:hover {
53
- color: var(--iui-color-text-accent-hover);
54
- transition-duration: 150ms;
55
- }
56
-
57
- &.component-quantity-number-input-button-up {
58
- padding-top: 1px;
59
- }
60
-
61
- &.component-quantity-number-input-button-down {
62
- padding-top: 1px;
63
- }
64
- }
65
-
66
- &.component-number-buttons-for-touch {
67
- width: 3.5em;
68
- flex-direction: row-reverse;
69
-
70
- .component-quantity-number-input-button {
71
- font-size: 1em;
72
-
73
- &:hover {
74
- color: unset;
75
- transition-duration: unset;
76
- }
77
-
78
- &.component-quantity-number-input-button-up {
79
- padding-top: 2px;
80
- }
81
-
82
- &.component-quantity-number-input-button-down {
83
- padding-top: 2px;
84
- }
85
- }
86
- }
87
- }
88
- }
89
-
90
- &.component-quantity-number-input-disabled {
91
- .component-quantity-number-input-suffix {
92
- -webkit-user-select: none;
93
- user-select: none;
94
- color: var(--iui-color-text-disabled);
95
- }
96
- .component-quantity-number-input-button-up {
97
- pointer-events: none;
98
- color: var(--iui-color-text-disabled);
99
- }
100
-
101
- .component-quantity-number-input-button-down {
102
- pointer-events: none;
103
- color: var(--iui-color-text-disabled);
104
- }
105
- }
106
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/base/base";
6
+
7
+ .component-quantity-number-input-container {
8
+ display: flex;
9
+ align-items: center;
10
+ position: relative;
11
+ padding: 0;
12
+ margin: 0;
13
+ box-sizing: border-box;
14
+
15
+ .component-quantity-number-input-suffix {
16
+ padding-left: 0.25em;
17
+ }
18
+
19
+ .component-quantity-number-input-value-and-buttons-container {
20
+ position: relative;
21
+ padding: 0;
22
+ margin: 0;
23
+ box-sizing: border-box;
24
+
25
+ input {
26
+ margin: 0;
27
+ padding-right: 1.5em;
28
+ }
29
+
30
+ &.component-number-buttons-for-touch {
31
+ input {
32
+ padding-right: 3.5em;
33
+ }
34
+ }
35
+
36
+ .component-quantity-number-input-buttons-container {
37
+ position: absolute;
38
+ top: 0;
39
+ right: 0;
40
+ width: 20px;
41
+ height: 100%;
42
+ @include uicore-centered;
43
+ flex-direction: column;
44
+
45
+ .component-quantity-number-input-button {
46
+ font-size: 8px;
47
+ outline: none;
48
+ height: 100%;
49
+ width: 100%;
50
+ @include uicore-centered;
51
+
52
+ &:hover {
53
+ color: var(--iui-color-text-accent-hover);
54
+ transition-duration: 150ms;
55
+ }
56
+
57
+ &.component-quantity-number-input-button-up {
58
+ padding-top: 1px;
59
+ }
60
+
61
+ &.component-quantity-number-input-button-down {
62
+ padding-top: 1px;
63
+ }
64
+ }
65
+
66
+ &.component-number-buttons-for-touch {
67
+ width: 3.5em;
68
+ flex-direction: row-reverse;
69
+
70
+ .component-quantity-number-input-button {
71
+ font-size: 1em;
72
+
73
+ &:hover {
74
+ color: unset;
75
+ transition-duration: unset;
76
+ }
77
+
78
+ &.component-quantity-number-input-button-up {
79
+ padding-top: 2px;
80
+ }
81
+
82
+ &.component-quantity-number-input-button-down {
83
+ padding-top: 2px;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ &.component-quantity-number-input-disabled {
91
+ .component-quantity-number-input-suffix {
92
+ -webkit-user-select: none;
93
+ user-select: none;
94
+ color: var(--iui-color-text-disabled);
95
+ }
96
+ .component-quantity-number-input-button-up {
97
+ pointer-events: none;
98
+ color: var(--iui-color-text-disabled);
99
+ }
100
+
101
+ .component-quantity-number-input-button-down {
102
+ pointer-events: none;
103
+ color: var(--iui-color-text-disabled);
104
+ }
105
+ }
106
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"Swatch.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,WAAW;IACvG,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC;IAC9E,gBAAgB;gBACJ,KAAK,EAAE,qBAAqB;IAIxB,iBAAiB;IAKjB,MAAM;CAmDvB"}
1
+ {"version":3,"file":"Swatch.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,eAAe,CAAC;AAEvB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,WAAW;IACb,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC;IAC9E,gBAAgB;gBACJ,KAAK,EAAE,qBAAqB;IAIxB,iBAAiB;IAEjB,MAAM;CA6DvB"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
6
  /** @packageDocumentation
7
7
  * @module LineWeight
8
8
  */
@@ -46,33 +46,29 @@ class LineWeightSwatch extends React.PureComponent {
46
46
  constructor(props) {
47
47
  super(props);
48
48
  }
49
- componentDidMount() {
50
- // eslint-disable-next-line no-console
51
- // console.log(`LineWeightSwatchProps.componentDidMount setFocusRef=${this.props.setFocusRef} focusRef=${this.props.focusRef && this.props.focusRef.current ? "set" : "unset"}`);
52
- }
49
+ componentDidMount() { }
53
50
  render() {
54
51
  const { onClick, colorDef, weight, hideLabel, className, // do not pass on color swatch specific props
55
- // eslint-disable-next-line comma-dangle
56
52
  disabled, readonly, ...otherProps // pass-through props
57
53
  } = this.props;
58
54
  let rgbaString = "";
59
55
  if (colorDef) {
60
56
  rgbaString = (0, getCSSColorFromDef_1.getCSSColorFromDef)(colorDef);
61
57
  }
62
- const buttonStyle = colorDef ?
63
- {
58
+ const buttonStyle = colorDef
59
+ ? {
64
60
  ...this.props.style,
65
61
  color: rgbaString,
66
- } :
67
- {
62
+ }
63
+ : {
68
64
  ...this.props.style,
69
65
  };
70
- const svgStyle = colorDef ?
71
- {
66
+ const svgStyle = colorDef
67
+ ? {
72
68
  height: `${weight}px`,
73
69
  background: rgbaString,
74
- } :
75
- {
70
+ }
71
+ : {
76
72
  height: `${weight}px`,
77
73
  };
78
74
  const handleClick = (_e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Swatch.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yBAAuB;AACvB,4DAAoC;AACpC,6CAA+B;AAG/B,oEAAiE;AAoBjE;;GA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O,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ;YACrG,CAAC,SAAS,IAAI,kCAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ;YAC/C,6BAAK,KAAK,EAAE,QAAQ,GAAI,CACjB,CACV,CAAC;IACJ,CAAC;CACF;AA9DD,4CA8DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module LineWeight\r\n */\r\n\r\nimport \"./Swatch.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport type { ColorDef } from \"@itwin/core-common\";\r\nimport type { CommonProps } from \"@itwin/core-react\";\r\nimport { getCSSColorFromDef } from \"../color/getCSSColorFromDef\";\r\n\r\n/** Properties for the [[LineWeightSwatch]] React component\r\n * @public\r\n */\r\nexport interface LineWeightSwatchProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {\r\n /** color specification */\r\n weight: number;\r\n /** color specification */\r\n colorDef?: ColorDef;\r\n /** hide the weight label */\r\n hideLabel?: boolean;\r\n /** Disabled or not */\r\n disabled?: boolean;\r\n /** Readonly or not */\r\n readonly?: boolean;\r\n /** function to run when user selects a line weight swatch */\r\n onClick?: () => void;\r\n}\r\n\r\n/** LineWeightSwatch Functional component\r\n * @public\r\n */\r\nexport class LineWeightSwatch extends React.PureComponent<LineWeightSwatchProps> {\r\n /** @internal */\r\n constructor(props: LineWeightSwatchProps) {\r\n super(props);\r\n }\r\n\r\n public override componentDidMount() {\r\n // eslint-disable-next-line no-console\r\n // console.log(`LineWeightSwatchProps.componentDidMount setFocusRef=${this.props.setFocusRef} focusRef=${this.props.focusRef && this.props.focusRef.current ? \"set\" : \"unset\"}`);\r\n }\r\n\r\n public override render() {\r\n const {\r\n onClick, colorDef, weight, hideLabel, className, // do not pass on color swatch specific props\r\n // eslint-disable-next-line comma-dangle\r\n disabled, readonly, ...otherProps // pass-through props\r\n } = this.props;\r\n\r\n let rgbaString = \"\";\r\n\r\n if (colorDef) {\r\n rgbaString = getCSSColorFromDef(colorDef);\r\n }\r\n\r\n const buttonStyle: React.CSSProperties = colorDef ?\r\n {\r\n ...this.props.style,\r\n color: rgbaString,\r\n } :\r\n {\r\n ...this.props.style,\r\n };\r\n\r\n const svgStyle: React.CSSProperties = colorDef ?\r\n {\r\n height: `${weight}px`,\r\n background: rgbaString,\r\n } :\r\n {\r\n height: `${weight}px`,\r\n };\r\n\r\n const handleClick = (_e: React.MouseEvent) => {\r\n // istanbul ignore else\r\n if (onClick)\r\n onClick();\r\n };\r\n\r\n const classes = classnames(\r\n \"components-lineweight-swatch\",\r\n hideLabel && \"hide-label\",\r\n readonly && \"readonly\",\r\n className,\r\n );\r\n\r\n return (\r\n <button {...otherProps} style={buttonStyle} className={classes} onClick={handleClick} disabled={disabled}>\r\n {!hideLabel && <span>{weight.toFixed(0)}</span>}\r\n <div style={svgStyle} />\r\n </button>\r\n );\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Swatch.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/lineweight/Swatch.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yBAAuB;AACvB,4DAAoC;AACpC,6CAA+B;AAG/B,oEAAiE;AAsBjE;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK,CAAC,aAAoC;IAC9E,gBAAgB;IAChB,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,iBAAiB,KAAI,CAAC;IAEtB,MAAM;QACpB,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,EAAE,6CAA6C;QACxD,QAAQ,EACR,QAAQ,EACR,GAAG,UAAU,CAAC,qBAAqB;UACpC,GAAG,IAAI,CAAC,KAAK,CAAC;QAEf,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,IAAI,QAAQ,EAAE;YACZ,UAAU,GAAG,IAAA,uCAAkB,EAAC,QAAQ,CAAC,CAAC;SAC3C;QAED,MAAM,WAAW,GAAwB,QAAQ;YAC/C,CAAC,CAAC;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;gBACnB,KAAK,EAAE,UAAU;aAClB;YACH,CAAC,CAAC;gBACE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK;aACpB,CAAC;QAEN,MAAM,QAAQ,GAAwB,QAAQ;YAC5C,CAAC,CAAC;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;gBACrB,UAAU,EAAE,UAAU;aACvB;YACH,CAAC,CAAC;gBACE,MAAM,EAAE,GAAG,MAAM,IAAI;aACtB,CAAC;QAEN,MAAM,WAAW,GAAG,CAAC,EAAoB,EAAE,EAAE;YAC3C,uBAAuB;YACvB,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;QACzB,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,oBAAU,EACxB,8BAA8B,EAC9B,SAAS,IAAI,YAAY,EACzB,QAAQ,IAAI,UAAU,EACtB,SAAS,CACV,CAAC;QAEF,OAAO,CACL,mCACM,UAAU,EACd,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,OAAO,EAClB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,QAAQ;YAEjB,CAAC,SAAS,IAAI,kCAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ;YAC/C,6BAAK,KAAK,EAAE,QAAQ,GAAI,CACjB,CACV,CAAC;IACJ,CAAC;CACF;AArED,4CAqEC","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 LineWeight\n */\n\nimport \"./Swatch.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { ColorDef } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { getCSSColorFromDef } from \"../color/getCSSColorFromDef\";\n\n/** Properties for the [[LineWeightSwatch]] React component\n * @public\n */\nexport interface LineWeightSwatchProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** color specification */\n weight: number;\n /** color specification */\n colorDef?: ColorDef;\n /** hide the weight label */\n hideLabel?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** function to run when user selects a line weight swatch */\n onClick?: () => void;\n}\n\n/** LineWeightSwatch Functional component\n * @public\n */\nexport class LineWeightSwatch extends React.PureComponent<LineWeightSwatchProps> {\n /** @internal */\n constructor(props: LineWeightSwatchProps) {\n super(props);\n }\n\n public override componentDidMount() {}\n\n public override render() {\n const {\n onClick,\n colorDef,\n weight,\n hideLabel,\n className, // do not pass on color swatch specific props\n disabled,\n readonly,\n ...otherProps // pass-through props\n } = this.props;\n\n let rgbaString = \"\";\n\n if (colorDef) {\n rgbaString = getCSSColorFromDef(colorDef);\n }\n\n const buttonStyle: React.CSSProperties = colorDef\n ? {\n ...this.props.style,\n color: rgbaString,\n }\n : {\n ...this.props.style,\n };\n\n const svgStyle: React.CSSProperties = colorDef\n ? {\n height: `${weight}px`,\n background: rgbaString,\n }\n : {\n height: `${weight}px`,\n };\n\n const handleClick = (_e: React.MouseEvent) => {\n // istanbul ignore else\n if (onClick) onClick();\n };\n\n const classes = classnames(\n \"components-lineweight-swatch\",\n hideLabel && \"hide-label\",\n readonly && \"readonly\",\n className\n );\n\n return (\n <button\n {...otherProps}\n style={buttonStyle}\n className={classes}\n onClick={handleClick}\n disabled={disabled}\n >\n {!hideLabel && <span>{weight.toFixed(0)}</span>}\n <div style={svgStyle} />\n </button>\n );\n }\n}\n"]}