@itwin/imodel-components-react 4.10.0 → 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 (233) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +1 -1
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js +6 -6
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +2 -1
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +4 -2
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +2 -0
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +5 -2
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +2 -0
  14. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +1 -1
  16. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  17. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +2 -0
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +5 -5
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  21. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +2 -0
  22. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  23. package/lib/cjs/imodel-components-react/color/HueSlider.js +4 -3
  24. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  25. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +2 -0
  26. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  27. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +4 -3
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +2 -0
  30. package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
  31. package/lib/cjs/imodel-components-react/color/Swatch.js +2 -0
  32. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  33. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +2 -1
  34. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  36. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +5 -4
  37. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
  39. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  40. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
  41. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  43. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +1 -2
  44. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -1
  46. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  47. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
  48. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  50. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +6 -7
  51. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  52. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +10 -10
  54. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  55. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  56. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
  57. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  59. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +13 -9
  60. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  61. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  62. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +21 -28
  63. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  64. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  65. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
  66. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  67. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  68. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
  69. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  70. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  71. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
  72. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  73. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  74. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
  75. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  76. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  77. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
  78. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  79. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  80. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
  81. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  82. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
  84. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  85. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
  87. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  88. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
  90. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  91. package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts +3 -15
  92. package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts.map +1 -1
  93. package/lib/cjs/imodel-components-react/timeline/PlayButton.js +12 -42
  94. package/lib/cjs/imodel-components-react/timeline/PlayButton.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +1 -1
  96. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  97. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
  98. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  99. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +111 -202
  100. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  101. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +25 -333
  102. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +5 -1
  103. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  104. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +39 -30
  105. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  106. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +2 -2
  107. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  108. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  109. package/lib/cjs/imodel-components-react/useTranslation.d.ts +10 -0
  110. package/lib/cjs/imodel-components-react/useTranslation.d.ts.map +1 -0
  111. package/lib/cjs/imodel-components-react/useTranslation.js +20 -0
  112. package/lib/cjs/imodel-components-react/useTranslation.js.map +1 -0
  113. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  114. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +13 -8
  115. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  116. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +1 -1
  117. package/lib/esm/imodel-components-react/UiIModelComponents.js +6 -6
  118. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  119. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +2 -1
  120. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  121. package/lib/esm/imodel-components-react/color/AlphaSlider.js +4 -2
  122. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  123. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +2 -0
  124. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  125. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +5 -2
  126. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  127. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +2 -0
  128. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  129. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +1 -1
  130. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  131. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +2 -0
  132. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  133. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +5 -5
  134. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  135. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +2 -0
  136. package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  137. package/lib/esm/imodel-components-react/color/HueSlider.js +4 -3
  138. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  139. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +2 -0
  140. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  141. package/lib/esm/imodel-components-react/color/SaturationPicker.js +4 -3
  142. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  143. package/lib/esm/imodel-components-react/color/Swatch.d.ts +2 -0
  144. package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
  145. package/lib/esm/imodel-components-react/color/Swatch.js +2 -0
  146. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  147. package/lib/esm/imodel-components-react/editors/ColorEditor.js +2 -1
  148. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  149. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  150. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +5 -4
  151. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  152. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
  153. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  154. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
  155. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  156. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  157. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +1 -2
  158. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  159. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -1
  160. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  161. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
  162. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  163. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  164. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +6 -7
  165. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  166. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  167. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +10 -10
  168. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  169. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  170. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
  171. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  172. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  173. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +13 -9
  174. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  175. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  176. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +21 -28
  177. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  178. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  179. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
  180. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  181. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  182. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
  183. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  184. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  185. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
  186. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  187. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  188. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
  189. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  190. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  191. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
  192. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  193. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  194. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
  195. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  196. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  197. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
  198. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  199. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  200. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
  201. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  202. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  203. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
  204. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  205. package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts +3 -15
  206. package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts.map +1 -1
  207. package/lib/esm/imodel-components-react/timeline/PlayButton.js +12 -39
  208. package/lib/esm/imodel-components-react/timeline/PlayButton.js.map +1 -1
  209. package/lib/esm/imodel-components-react/timeline/Scrubber.js +1 -1
  210. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  211. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
  212. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  213. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +112 -203
  214. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  215. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +25 -333
  216. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +5 -1
  217. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  218. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +40 -31
  219. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  220. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +2 -2
  221. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  222. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  223. package/lib/esm/imodel-components-react/useTranslation.d.ts +10 -0
  224. package/lib/esm/imodel-components-react/useTranslation.d.ts.map +1 -0
  225. package/lib/esm/imodel-components-react/useTranslation.js +16 -0
  226. package/lib/esm/imodel-components-react/useTranslation.js.map +1 -0
  227. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  228. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +13 -8
  229. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  230. package/lib/public/locales/en/UiIModelComponents.json +14 -3
  231. package/package.json +10 -10
  232. package/lib/cjs/imodel-components-react/timeline/PlayButton.scss +0 -28
  233. package/lib/esm/imodel-components-react/timeline/PlayButton.scss +0 -28
@@ -32,33 +32,34 @@ var __importStar = (this && this.__importStar) || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.ThousandsSelector = void 0;
34
34
  const React = __importStar(require("react"));
35
- const UiIModelComponents_1 = require("../../UiIModelComponents");
36
35
  const itwinui_react_1 = require("@itwin/itwinui-react");
36
+ const useTranslation_1 = require("../../useTranslation");
37
37
  /** Component use to set Quantity Format thousand group separator.
38
38
  * @internal
39
39
  */
40
40
  function ThousandsSelector(props) {
41
41
  const { separator, ...otherProps } = props;
42
- const uomDefaultEntries = React.useRef([
43
- {
44
- value: ",",
45
- label: UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.thousand_separator.comma"),
46
- },
47
- {
48
- value: ".",
49
- label: UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.thousand_separator.point"),
50
- },
51
- ]);
42
+ const { translate } = (0, useTranslation_1.useTranslation)();
52
43
  const separatorOptions = React.useMemo(() => {
44
+ const uomDefaultEntries = [
45
+ {
46
+ value: ",",
47
+ label: translate("QuantityFormat.thousand_separator.comma"),
48
+ },
49
+ {
50
+ value: ".",
51
+ label: translate("QuantityFormat.thousand_separator.point"),
52
+ },
53
+ ];
53
54
  const completeListOfEntries = [];
54
55
  // istanbul ignore next (only used if format already has a character that does not match standard options)
55
56
  if (undefined ===
56
- uomDefaultEntries.current.find((option) => option.value === separator)) {
57
+ uomDefaultEntries.find((option) => option.value === separator)) {
57
58
  completeListOfEntries.push({ value: separator, label: separator });
58
59
  }
59
- completeListOfEntries.push(...uomDefaultEntries.current);
60
+ completeListOfEntries.push(...uomDefaultEntries);
60
61
  return completeListOfEntries;
61
- }, [separator]);
62
+ }, [separator, translate]);
62
63
  return (React.createElement(itwinui_react_1.Select, { options: separatorOptions, value: separator, size: "small", ...otherProps }));
63
64
  }
64
65
  exports.ThousandsSelector = ThousandsSelector;
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,iEAA8D;AAE9D,wDAA8C;AAW9C;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAyB;QAC7D;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,uCAAkB,CAAC,SAAS,CACjC,yCAAyC,CAC1C;SACF;QACD;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,uCAAkB,CAAC,SAAS,CACjC,yCAAyC,CAC1C;SACF;KACF,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EACtE;YACA,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;SACpE;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAtCD,8CAsCC","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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\n\n/** Properties of [[ThousandsSelector]] component.\n * @internal\n */\nexport interface ThousandsSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSelector(props: ThousandsSelectorProps) {\n const { separator, ...otherProps } = props;\n const uomDefaultEntries = React.useRef<SelectOption<string>[]>([\n {\n value: \",\",\n label: UiIModelComponents.translate(\n \"QuantityFormat.thousand_separator.comma\"\n ),\n },\n {\n value: \".\",\n label: UiIModelComponents.translate(\n \"QuantityFormat.thousand_separator.point\"\n ),\n },\n ]);\n\n const separatorOptions = React.useMemo(() => {\n const completeListOfEntries: SelectOption<string>[] = [];\n // istanbul ignore next (only used if format already has a character that does not match standard options)\n if (\n undefined ===\n uomDefaultEntries.current.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries.current);\n return completeListOfEntries;\n }, [separator]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA8C;AAC9C,yDAAsD;AAWtD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;SACF,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D;YACA,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;SACpE;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAnCD,8CAmCC","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 QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[ThousandsSelector]] component.\n * @internal\n */\nexport interface ThousandsSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSelector(props: ThousandsSelectorProps) {\n const { separator, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n {\n value: \",\",\n label: translate(\"QuantityFormat.thousand_separator.comma\"),\n },\n {\n value: \".\",\n label: translate(\"QuantityFormat.thousand_separator.point\"),\n },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n // istanbul ignore next (only used if format already has a character that does not match standard options)\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAgHhE"}
1
+ {"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAwGhE"}
@@ -39,12 +39,14 @@ const React = __importStar(require("react"));
39
39
  const core_quantity_1 = require("@itwin/core-quantity");
40
40
  const itwinui_react_1 = require("@itwin/itwinui-react");
41
41
  const ThousandsSelector_1 = require("./ThousandsSelector");
42
- const UiIModelComponents_1 = require("../../UiIModelComponents");
42
+ const useTranslation_1 = require("../../useTranslation");
43
43
  /** Component use to set Quantity Format thousand group separator.
44
44
  * @internal
45
45
  */
46
46
  function ThousandsSeparator(props) {
47
+ var _a;
47
48
  const { formatProps, onChange } = props;
49
+ const { translate } = (0, useTranslation_1.useTranslation)();
48
50
  const handleSetFormatProps = React.useCallback((newProps) => {
49
51
  onChange && onChange(newProps);
50
52
  }, [onChange]);
@@ -98,13 +100,11 @@ function ThousandsSeparator(props) {
98
100
  };
99
101
  handleSetFormatProps(newFormatProps);
100
102
  }, [formatProps, isFormatTraitSet, handleSetFormatProps]);
101
- const useThousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.useThousandSeparatorLabel"));
102
- const thousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.thousandSeparatorLabel"));
103
103
  return (React.createElement(React.Fragment, null,
104
- React.createElement("span", { className: "uicore-label" }, useThousandSeparatorLabel.current),
104
+ React.createElement("span", { className: "uicore-label" }, translate("QuantityFormat.labels.useThousandSeparatorLabel")),
105
105
  React.createElement(itwinui_react_1.Checkbox, { "data-testid": "use-thousands-separator", checked: isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleUseThousandsSeparatorChange }),
106
- React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator) && "uicore-disabled") }, thousandSeparatorLabel.current),
107
- React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: formatProps.thousandSeparator ?? ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
106
+ React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator) && "uicore-disabled") }, translate("QuantityFormat.labels.thousandSeparatorLabel")),
107
+ React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: (_a = formatProps.thousandSeparator) !== null && _a !== void 0 ? _a : ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
108
108
  }
109
109
  exports.ThousandsSeparator = ThousandsSeparator;
110
110
  //# sourceMappingURL=ThousandsSeparator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAC5E,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B;IAC/D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAC5C,CAAC,QAAqB,EAAE,EAAE;QACxB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,KAAmB,EAAE,SAAkB,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE;YACb,gBAAgB;YAChB,uBAAuB;YACvB,IAAI,WAAW,CAAC,YAAY,EAAE;gBAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;oBACpD,CAAC,CAAC,WAAW,CAAC,YAAY;oBAC1B,CAAC,CAAC,0BAA0B,CAAC,WA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AuB;QACvB,IAAI,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAAE;YACnD,IAAI,iBAAiB,KAAK,GAAG;gBAAE,gBAAgB,GAAG,GAAG,CAAC;YACtD,4BAA4B;;gBACvB,gBAAgB,GAAG,GAAG,CAAC;SAC7B;QACD,MAAM,cAAc,GAAG;YACrB,GAAG,WAAW;YACd,iBAAiB;YACjB,gBAAgB;SACjB,CAAC;QACF,oBAAoB,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EACD,CAAC,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CACtD,CAAC;IAEF,MAAM,yBAAyB,GAAG,KAAK,CAAC,MAAM,CAC5C,uCAAkB,CAAC,SAAS,CAC1B,iDAAiD,CAClD,CACF,CAAC;IACF,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,CACzC,uCAAkB,CAAC,SAAS,CAAC,8CAA8C,CAAC,CAC7E,CAAC;IAEF,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAC5B,yBAAyB,CAAC,OAAO,CAC7B;QACP,oBAAC,wBAAQ,mBACK,yBAAyB,EACrC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EACxD,QAAQ,EAAE,iCAAiC,GAC3C;QACF,8BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,cAAc,EACd,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,IAAI,iBAAiB,CACtE,IAEA,sBAAsB,CAAC,OAAO,CAC1B;QACP,oBAAC,qCAAiB,mBACJ,8BAA8B,EAC1C,SAAS,EAAE,WAAW,CAAC,iBAAiB,IAAI,GAAG,EAC/C,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAC1D,QAAQ,EAAE,6BAA6B,GACvC,CACD,CACJ,CAAC;AACJ,CAAC;AAhHD,gDAgHC","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 QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { ThousandsSelector } from \"./ThousandsSelector\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\n\n/** Properties of [[ThousandsSeparator]] component.\n * @internal\n */\nexport interface ThousandsSeparatorProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSeparator(props: ThousandsSeparatorProps) {\n const { formatProps, onChange } = props;\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onChange && onChange(newProps);\n },\n [onChange]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = [...traits, traitStr];\n }\n } else {\n // clearing trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUseThousandsSeparatorChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleThousandSeparatorChange = React.useCallback(\n (thousandSeparator: string) => {\n let decimalSeparator = formatProps.decimalSeparator;\n // make sure 1000 and decimal separator do not match\n // istanbul ignore else\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n if (thousandSeparator === \".\") decimalSeparator = \",\";\n // thousandSeparator === \",\"\n else decimalSeparator = \".\";\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const useThousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\n \"QuantityFormat.labels.useThousandSeparatorLabel\"\n )\n );\n const thousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.thousandSeparatorLabel\")\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {useThousandSeparatorLabel.current}\n </span>\n <Checkbox\n data-testid=\"use-thousands-separator\"\n checked={isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleUseThousandsSeparatorChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.Use1000Separator) && \"uicore-disabled\"\n )}\n >\n {thousandSeparatorLabel.current}\n </span>\n <ThousandsSelector\n data-testid=\"thousands-separator-selector\"\n separator={formatProps.thousandSeparator ?? \",\"}\n disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleThousandSeparatorChange}\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AACh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AAC,EACD,CAAC,WAAW,EAAE,gBAAgB,EAAE,oBAAoB,CAAC,CACtD,CAAC;IAEF,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAC5B,SAAS,CAAC,iDAAiD,CAAC,CACxD;QACP,oBAAC,wBAAQ,mBACK,yBAAyB,EACrC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EACxD,QAAQ,EAAE,iCAAiC,GAC3C;QACF,8BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,cAAc,EACd,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,IAAI,iBAAiB,CACtE,IAEA,SAAS,CAAC,8CAA8C,CAAC,CACrD;QACP,oBAAC,qCAAiB,mBACJ,8BAA8B,EAC1C,SAAS,EAAE,MAAA,WAAW,CAAC,iBAAiB,mCAAI,GAAG,EAC/C,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAC1D,QAAQ,EAAE,6BAA6B,GACvC,CACD,CACJ,CAAC;AACJ,CAAC;AAxGD,gDAwGC","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 QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { ThousandsSelector } from \"./ThousandsSelector\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[ThousandsSeparator]] component.\n * @internal\n */\nexport interface ThousandsSeparatorProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSeparator(props: ThousandsSeparatorProps) {\n const { formatProps, onChange } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onChange && onChange(newProps);\n },\n [onChange]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = [...traits, traitStr];\n }\n } else {\n // clearing trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUseThousandsSeparatorChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleThousandSeparatorChange = React.useCallback(\n (thousandSeparator: string) => {\n let decimalSeparator = formatProps.decimalSeparator;\n // make sure 1000 and decimal separator do not match\n // istanbul ignore else\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n if (thousandSeparator === \".\") decimalSeparator = \",\";\n // thousandSeparator === \",\"\n else decimalSeparator = \".\";\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.useThousandSeparatorLabel\")}\n </span>\n <Checkbox\n data-testid=\"use-thousands-separator\"\n checked={isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleUseThousandsSeparatorChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.Use1000Separator) && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.thousandSeparatorLabel\")}\n </span>\n <ThousandsSelector\n data-testid=\"thousands-separator-selector\"\n separator={formatProps.thousandSeparator ?? \",\"}\n disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleThousandSeparatorChange}\n />\n </>\n );\n}\n"]}
@@ -1,24 +1,12 @@
1
- import "./PlayButton.scss";
2
1
  import * as React from "react";
3
- import type { CommonProps } from "@itwin/core-react";
4
- interface PlayButtonProps extends CommonProps {
2
+ interface PlayButtonProps {
5
3
  isPlaying: boolean;
6
4
  onPlay?: () => void;
7
5
  onPause?: () => void;
8
- tooltip?: string;
9
6
  }
10
- interface PlayButtonState {
11
- isPlaying: boolean;
12
- }
13
- /** Play/Pause button used on timeline control
7
+ /** Play/pause button used in timeline components.
14
8
  * @internal
15
9
  */
16
- export declare class PlayButton extends React.Component<PlayButtonProps, PlayButtonState> {
17
- constructor(props: PlayButtonProps, context?: any);
18
- /** @internal */
19
- componentDidUpdate(): void;
20
- private _onClick;
21
- render(): React.JSX.Element;
22
- }
10
+ export declare function PlayButton({ isPlaying, onPlay, onPause }: PlayButtonProps): React.JSX.Element;
23
11
  export {};
24
12
  //# sourceMappingURL=PlayButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlayButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/PlayButton.tsx"],"names":[],"mappings":"AAIA,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,UAAU,eAAgB,SAAQ,WAAW;IAC3C,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK,CAAC,SAAS,CAC7C,eAAe,EACf,eAAe,CAChB;gBACa,KAAK,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,GAAG;IAMjD,gBAAgB;IACA,kBAAkB;IAMlC,OAAO,CAAC,QAAQ,CAYd;IAEc,MAAM;CA6BvB"}
1
+ {"version":3,"file":"PlayButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/PlayButton.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,eAAe;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,eAAe,qBAoBzE"}
@@ -22,59 +22,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.PlayButton = void 0;
30
27
  /*---------------------------------------------------------------------------------------------
31
28
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
32
29
  * See LICENSE.md in the project root for license terms and full copyright notice.
33
30
  *--------------------------------------------------------------------------------------------*/
34
- require("./PlayButton.scss");
35
- const classnames_1 = __importDefault(require("classnames"));
36
31
  const React = __importStar(require("react"));
37
- const core_react_1 = require("@itwin/core-react");
38
32
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
39
- const UiIModelComponents_1 = require("../UiIModelComponents");
40
- /** Play/Pause button used on timeline control
33
+ const itwinui_react_1 = require("@itwin/itwinui-react");
34
+ const useTranslation_1 = require("../useTranslation");
35
+ /** Play/pause button used in timeline components.
41
36
  * @internal
42
37
  */
43
- class PlayButton extends React.Component {
44
- constructor(props, context) {
45
- super(props, context);
46
- this._onClick = () => {
47
- const _isPlaying = !this.state.isPlaying;
48
- this.setState({ isPlaying: _isPlaying });
49
- if (_isPlaying) {
50
- // istanbul ignore else
51
- if (this.props.onPlay)
52
- this.props.onPlay();
53
- }
54
- else {
55
- // istanbul ignore else
56
- if (this.props.onPause)
57
- this.props.onPause();
38
+ function PlayButton({ isPlaying, onPlay, onPause }) {
39
+ const { translate } = (0, useTranslation_1.useTranslation)();
40
+ const label = translate(isPlaying ? "timeline.pause" : "timeline.play");
41
+ return (React.createElement(itwinui_react_1.IconButton, { styleType: "borderless", label: label, onClick: () => {
42
+ if (isPlaying) {
43
+ onPause === null || onPause === void 0 ? void 0 : onPause();
44
+ return;
58
45
  }
59
- };
60
- this.state = { isPlaying: this.props.isPlaying };
61
- }
62
- /** @internal */
63
- componentDidUpdate() {
64
- if (this.props.isPlaying !== this.state.isPlaying) {
65
- this.setState((_, props) => ({ isPlaying: props.isPlaying }));
66
- }
67
- }
68
- render() {
69
- const { tooltip } = this.props;
70
- const iconSpec = this.state.isPlaying ? React.createElement(itwinui_icons_react_1.SvgPause, null) : React.createElement(itwinui_icons_react_1.SvgPlay, null);
71
- let title = tooltip;
72
- if (!title)
73
- title = UiIModelComponents_1.UiIModelComponents.translate(this.state.isPlaying ? "timeline.pause" : "timeline.play");
74
- return (React.createElement("button", { "data-testid": this.props.className, title: title, className: (0, classnames_1.default)("play-button", this.props.className), onClick: this._onClick },
75
- React.createElement("span", { className: "icon", "data-testid": this.state.isPlaying ? "pause" : "play" },
76
- React.createElement(core_react_1.Icon, { iconSpec: iconSpec, "data-testid": this.state.isPlaying ? "pause" : "play" }))));
77
- }
46
+ onPlay === null || onPlay === void 0 ? void 0 : onPlay();
47
+ } }, isPlaying ? React.createElement(itwinui_icons_react_1.SvgPause, null) : React.createElement(itwinui_icons_react_1.SvgPlay, null)));
78
48
  }
79
49
  exports.PlayButton = PlayButton;
80
50
  //# sourceMappingURL=PlayButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlayButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/PlayButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,6BAA2B;AAC3B,4DAAoC;AACpC,6CAA+B;AAE/B,kDAAyC;AACzC,oEAA+D;AAC/D,8DAA2D;AAa3D;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK,CAAC,SAGrC;IACC,YAAY,KAAsB,EAAE,OAAa;QAC/C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAYhB,aAAQ,GAAG,GAAG,EAAE;YACtB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;YAEzC,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;YAEzC,IAAI,UAAU,EAAE;gBACd,uBAAuB;gBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM;oBAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;aAC5C;iBAAM;gBACL,uBAAuB;gBACvB,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO;oBAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;aAC9C;QACH,CAAC,CAAC;QAtBA,IAAI,CAAC,KAAK,GAAG,EAAE,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AC;CACF;AA5DD,gCA4DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./PlayButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon } from \"@itwin/core-react\";\nimport { SvgPause, SvgPlay } from \"@itwin/itwinui-icons-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\ninterface PlayButtonProps extends CommonProps {\n isPlaying: boolean;\n onPlay?: () => void;\n onPause?: () => void;\n tooltip?: string;\n}\n\ninterface PlayButtonState {\n isPlaying: boolean;\n}\n\n/** Play/Pause button used on timeline control\n * @internal\n */\nexport class PlayButton extends React.Component<\n PlayButtonProps,\n PlayButtonState\n> {\n constructor(props: PlayButtonProps, context?: any) {\n super(props, context);\n\n this.state = { isPlaying: this.props.isPlaying };\n }\n\n /** @internal */\n public override componentDidUpdate() {\n if (this.props.isPlaying !== this.state.isPlaying) {\n this.setState((_, props) => ({ isPlaying: props.isPlaying }));\n }\n }\n\n private _onClick = () => {\n const _isPlaying = !this.state.isPlaying;\n\n this.setState({ isPlaying: _isPlaying });\n\n if (_isPlaying) {\n // istanbul ignore else\n if (this.props.onPlay) this.props.onPlay();\n } else {\n // istanbul ignore else\n if (this.props.onPause) this.props.onPause();\n }\n };\n\n public override render() {\n const { tooltip } = this.props;\n const iconSpec = this.state.isPlaying ? <SvgPause /> : <SvgPlay />;\n let title = tooltip;\n\n if (!title)\n title = UiIModelComponents.translate(\n this.state.isPlaying ? \"timeline.pause\" : \"timeline.play\"\n );\n\n return (\n <button\n data-testid={this.props.className}\n title={title}\n className={classnames(\"play-button\", this.props.className)}\n onClick={this._onClick}\n >\n <span\n className=\"icon\"\n data-testid={this.state.isPlaying ? \"pause\" : \"play\"}\n >\n <Icon\n iconSpec={iconSpec}\n data-testid={this.state.isPlaying ? \"pause\" : \"play\"}\n />\n </span>\n </button>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PlayButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/PlayButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,6CAA+B;AAC/B,oEAA+D;AAC/D,wDAAkD;AAClD,sDAAmD;AAQnD;;GAEG;AACH,SAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAmB;IACxE,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IACvC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;IAExE,OAAO,CACL,oBAAC,0BAAU,IACT,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,GAAG,EAAE;YACZ,IAAI,SAAS,EAAE;gBACb,OAAO,aAAP,OAAO,uBAAP,OAAO,EAAI,CAAC;gBACZ,OAAO;aACR;YAED,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;QACb,CAAC,IAEA,SAAS,CAAC,CAAC,CAAC,oBAAC,8BAAQ,OAAG,CAAC,CAAC,CAAC,oBAAC,6BAAO,OAAG,CAC5B,CACd,CAAC;AACJ,CAAC;AApBD,gCAoBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport { SvgPause, SvgPlay } from \"@itwin/itwinui-icons-react\";\nimport { IconButton } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../useTranslation\";\n\ninterface PlayButtonProps {\n isPlaying: boolean;\n onPlay?: () => void;\n onPause?: () => void;\n}\n\n/** Play/pause button used in timeline components.\n * @internal\n */\nexport function PlayButton({ isPlaying, onPlay, onPause }: PlayButtonProps) {\n const { translate } = useTranslation();\n const label = translate(isPlaying ? \"timeline.pause\" : \"timeline.play\");\n\n return (\n <IconButton\n styleType=\"borderless\"\n label={label}\n onClick={() => {\n if (isPlaying) {\n onPause?.();\n return;\n }\n\n onPlay?.();\n }}\n >\n {isPlaying ? <SvgPause /> : <SvgPlay />}\n </IconButton>\n );\n}\n"]}
@@ -157,7 +157,7 @@ function Scrubber(props) {
157
157
  sliderContainer &&
158
158
  setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
159
159
  }, [sliderContainer]);
160
- const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);
160
+ const thumbHasFocus = useFocusedThumb(sliderContainer !== null && sliderContainer !== void 0 ? sliderContainer : undefined);
161
161
  const tickLabel = React.useMemo(() => {
162
162
  const showTip = isPlaying || showRailTooltip || thumbHasFocus;
163
163
  const percent = isPlaying || thumbHasFocus
@@ -1 +1 @@
1
- {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,2BAAyB;AACzB,6CAA+B;AAC/B,wDAA8C;AAE9C,kDAAqD;AACrD,8DAAqE;AAGrE;;GAEG;AACH,SAAgB,wBAAwB,CAAC,IAAa,EAAE,OAAe;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;AAC7C,CAAC;AAHD,4DAGC;AAED,6BAA6B;AAC7B,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACvC,MAAM,OAAO,G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AAC;AAtHD,4BAsHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useEventListener } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent\";\n\n/**\n * @internal\n */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\n// istanbul ignore next - WIP\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\n// istanbul ignore next - WIP\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n // istanbul ignore else\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n // istanbul ignore else\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n const handleThumbFocus = React.useCallback(() => {\n setThumbHasFocus(true);\n }, []);\n\n const handleThumbBlur = React.useCallback(() => {\n setThumbHasFocus(false);\n }, []);\n\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n // istanbul ignore next\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n // istanbul ignore next\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,2BAAyB;AACzB,6CAA+B;AAC/B,wDAA8C;AAE9C,kDAAqD;AACrD,8DAAqE;AAGrE;;GAEG;AACH,SA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AAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,eAAe,CAAC,EACzB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,oBAAC,WAAW,OAAG;YACzB,SAAS,EAAE,2BAA2B;SACvC,CAAC,EACF,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,GAClC,CACH,CAAC;AACJ,CAAC;AAtHD,4BAsHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useEventListener } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent\";\n\n/**\n * @internal\n */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\n// istanbul ignore next - WIP\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\n// istanbul ignore next - WIP\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n // istanbul ignore else\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n // istanbul ignore else\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n const handleThumbFocus = React.useCallback(() => {\n setThumbHasFocus(true);\n }, []);\n\n const handleThumbBlur = React.useCallback(() => {\n setThumbHasFocus(false);\n }, []);\n\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n // istanbul ignore next\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n // istanbul ignore next\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n />\n );\n}\n"]}
@@ -30,23 +30,12 @@ interface SolarTimelineComponentState {
30
30
  * @alpha
31
31
  */
32
32
  export declare class SolarTimeline extends React.PureComponent<SolarTimelineComponentProps, SolarTimelineComponentState> {
33
- private _datePicker;
34
- private _settings;
35
33
  private _requestFrame;
36
34
  private _unmounted;
37
35
  private _timeLastCycle;
38
36
  private _totalPlayTime;
39
- private _settingsPopupTitle;
40
- private _playLabel;
41
- private _settingLabel;
42
- private _loopLabel;
43
- private _speedLabel;
44
- private _dateTimeLabel;
45
- private _months;
46
- private _timeLabel;
47
- private _amLabel;
48
- private _pmLabel;
49
37
  private readonly _presetColors;
38
+ private readonly _speeds;
50
39
  constructor(props: SolarTimelineComponentProps);
51
40
  componentWillUnmount(): void;
52
41
  private _updateAnimation;
@@ -54,12 +43,7 @@ export declare class SolarTimeline extends React.PureComponent<SolarTimelineComp
54
43
  private _onPause;
55
44
  private _onPlay;
56
45
  private setPlaybackTimeBySunTime;
57
- /** note the day passed in is in the time of the current user not in project time because the date picker works in
58
- * local time */
59
- private _onDayClick;
60
- private _onTimeChanged;
61
- private _onCloseDayPicker;
62
- private _onOpenDayPicker;
46
+ private _onDateChange;
63
47
  private _onCloseSettingsPopup;
64
48
  private _onOpenSettingsPopup;
65
49
  private ensureRange;
@@ -69,8 +53,6 @@ export declare class SolarTimeline extends React.PureComponent<SolarTimelineComp
69
53
  private _onSpeedChange;
70
54
  private _onToggleLoop;
71
55
  private _formatTime;
72
- private _onPresetColorPick;
73
- private _handleHueOrSaturationChange;
74
56
  getLocalTime(ticks: number): Date;
75
57
  render(): React.JSX.Element;
76
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SolarTimeline.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/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