@itwin/imodel-components-react 4.0.0-dev.8 → 4.0.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 (330) hide show
  1. package/CHANGELOG.md +66 -1
  2. package/README.md +2 -2
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  5. package/lib/cjs/imodel-components-react/UiIModelComponents.js +77 -79
  6. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +190 -186
  9. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +112 -107
  13. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +19 -21
  15. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  16. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +78 -74
  17. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +143 -137
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +15 -17
  23. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
  24. package/lib/cjs/imodel-components-react/color/HueSlider.js +203 -199
  25. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  27. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +217 -213
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  30. package/lib/cjs/imodel-components-react/color/Swatch.js +64 -60
  31. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  32. package/lib/cjs/imodel-components-react/color/Swatch.scss +5 -7
  33. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  34. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  35. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  36. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +155 -151
  37. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +4 -5
  39. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  40. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +164 -160
  41. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +4 -5
  43. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  44. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +100 -96
  45. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  47. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  48. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +272 -265
  49. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +6 -7
  51. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  52. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +89 -85
  53. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +7 -8
  55. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  56. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +163 -159
  57. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +13 -15
  59. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  60. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +131 -127
  61. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +154 -174
  63. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  64. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +631 -634
  65. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  66. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +18 -21
  67. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  68. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +657 -647
  70. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +9 -8
  72. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  73. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +103 -99
  74. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  75. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +10 -16
  76. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  77. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +57 -53
  78. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +88 -83
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +90 -86
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +113 -109
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +137 -133
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  93. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +188 -184
  94. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  96. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  97. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +149 -154
  98. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  99. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  100. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +63 -59
  101. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  102. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  103. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +51 -47
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +58 -54
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +52 -48
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +54 -50
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +62 -58
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +51 -47
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +60 -56
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +99 -95
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +123 -119
  128. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  129. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  130. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  131. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +142 -143
  132. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  133. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  134. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  135. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  136. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +85 -81
  137. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  138. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +2 -2
  139. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  140. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  141. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +99 -91
  142. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  143. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +11 -9
  144. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  145. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +195 -191
  146. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  147. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +13 -15
  148. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  149. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  150. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +432 -424
  151. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  152. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +49 -48
  153. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  154. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +58 -54
  155. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  156. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  157. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  158. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +398 -358
  159. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  160. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +39 -25
  161. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +145 -174
  162. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  163. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  164. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  165. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  166. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  167. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +278 -274
  168. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  169. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  170. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  171. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  172. package/lib/cjs/imodel-components-react.d.ts +81 -82
  173. package/lib/cjs/imodel-components-react.d.ts.map +1 -1
  174. package/lib/cjs/imodel-components-react.js +104 -101
  175. package/lib/cjs/imodel-components-react.js.map +1 -1
  176. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  177. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  178. package/lib/esm/imodel-components-react/UiIModelComponents.js +74 -75
  179. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  180. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  181. package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
  182. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  183. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  184. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  185. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +83 -82
  186. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  187. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +19 -21
  188. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  189. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
  190. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  191. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  192. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +114 -112
  193. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  194. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +15 -17
  195. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  196. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  197. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  198. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  199. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  200. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  201. package/lib/esm/imodel-components-react/color/Swatch.scss +5 -7
  202. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  203. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  204. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  205. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  206. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +4 -5
  207. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  208. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  209. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +4 -5
  210. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  211. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  212. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  213. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  214. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +243 -240
  215. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  216. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +6 -7
  217. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  218. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  219. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +7 -8
  220. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  221. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +134 -133
  222. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  223. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +13 -15
  224. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  225. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  226. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +154 -174
  227. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  228. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +601 -606
  229. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  230. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +18 -21
  231. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  232. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  233. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +627 -620
  234. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  235. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +9 -8
  236. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  237. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  238. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +10 -16
  239. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  240. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +30 -30
  241. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  242. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  243. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +61 -60
  244. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  245. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  246. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +63 -63
  247. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  248. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +83 -83
  249. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  250. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +110 -110
  251. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  252. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +158 -158
  253. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  254. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  255. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +122 -131
  256. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  257. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  258. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  259. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  260. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  261. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  262. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  263. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  264. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  265. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  266. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  267. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  268. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  269. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  270. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  271. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  272. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  273. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  274. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +69 -69
  275. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  276. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  277. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  278. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  279. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +138 -139
  280. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  281. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  282. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  283. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  284. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  285. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +2 -2
  286. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  287. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  288. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +68 -64
  289. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  290. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +11 -9
  291. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  292. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  293. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +13 -15
  294. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  295. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  296. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +402 -398
  297. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  298. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +49 -48
  299. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  300. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  301. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  302. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  303. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +368 -332
  304. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  305. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +39 -25
  306. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +145 -174
  307. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  308. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  309. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  310. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  311. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  312. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +251 -251
  313. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  314. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +96 -95
  315. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  316. package/lib/esm/imodel-components-react.d.ts +81 -82
  317. package/lib/esm/imodel-components-react.d.ts.map +1 -1
  318. package/lib/esm/imodel-components-react.js +86 -87
  319. package/lib/esm/imodel-components-react.js.map +1 -1
  320. package/package.json +38 -47
  321. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  322. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  323. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +0 -146
  324. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  325. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +0 -94
  326. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +0 -22
  327. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts.map +0 -1
  328. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +0 -123
  329. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +0 -1
  330. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +0 -94
@@ -1,55 +1,55 @@
1
- import "./Scrubber.scss";
2
- import * as React from "react";
3
- import { CommonProps } from "@itwin/core-react";
4
- import { TimelineDateMarkerProps } from "./TimelineComponent";
5
- /**
6
- * @internal
7
- */
8
- export declare function getPercentageOfRectangle(rect: DOMRect, pointer: number): number;
9
- /**
10
- * @internal
11
- */
12
- export declare function RailMarkers({ showToolTip, percent, tooltipText, markDate }: {
13
- showToolTip: boolean;
14
- percent: number;
15
- tooltipText: string;
16
- markDate?: DateMarkerProps;
17
- }): JSX.Element;
18
- /**
19
- * Custom Timeline Thumb
20
- * @internal
21
- */
22
- export declare function CustomThumb(): JSX.Element;
23
- /**
24
- * @internal
25
- */
26
- export declare function useFocusedThumb(sliderContainer: HTMLDivElement | undefined): boolean;
27
- /** Properties for Scrubber/Slider used on timeline control
28
- * @internal
29
- */
30
- export interface ScrubberProps extends CommonProps {
31
- currentDuration: number;
32
- totalDuration: number;
33
- isPlaying: boolean;
34
- inMiniMode: boolean;
35
- startDate?: Date;
36
- endDate?: Date;
37
- showTime?: boolean;
38
- onChange?: (values: ReadonlyArray<number>) => void;
39
- onUpdate?: (values: ReadonlyArray<number>) => void;
40
- timeZoneOffset?: number;
41
- markDate?: TimelineDateMarkerProps;
42
- }
43
- /** Properties for marking current date in RailMarkers
44
- * @internal
45
- */
46
- interface DateMarkerProps {
47
- datePercentage: number;
48
- dateMarker?: React.ReactNode;
49
- }
50
- /** Scrubber/Slider for timeline control
51
- * @internal
52
- */
53
- export declare function Scrubber(props: ScrubberProps): JSX.Element;
54
- export {};
1
+ import "./Scrubber.scss";
2
+ import * as React from "react";
3
+ import { CommonProps } from "@itwin/core-react";
4
+ import { TimelineDateMarkerProps } from "./TimelineComponent";
5
+ /**
6
+ * @internal
7
+ */
8
+ export declare function getPercentageOfRectangle(rect: DOMRect, pointer: number): number;
9
+ /**
10
+ * @internal
11
+ */
12
+ export declare function RailMarkers({ showToolTip, percent, tooltipText, markDate }: {
13
+ showToolTip: boolean;
14
+ percent: number;
15
+ tooltipText: string;
16
+ markDate?: DateMarkerProps;
17
+ }): JSX.Element;
18
+ /**
19
+ * Custom Timeline Thumb
20
+ * @internal
21
+ */
22
+ export declare function CustomThumb(): JSX.Element;
23
+ /**
24
+ * @internal
25
+ */
26
+ export declare function useFocusedThumb(sliderContainer: HTMLDivElement | undefined): boolean;
27
+ /** Properties for Scrubber/Slider used on timeline control
28
+ * @internal
29
+ */
30
+ export interface ScrubberProps extends CommonProps {
31
+ currentDuration: number;
32
+ totalDuration: number;
33
+ isPlaying: boolean;
34
+ inMiniMode: boolean;
35
+ startDate?: Date;
36
+ endDate?: Date;
37
+ showTime?: boolean;
38
+ onChange?: (values: ReadonlyArray<number>) => void;
39
+ onUpdate?: (values: ReadonlyArray<number>) => void;
40
+ timeZoneOffset?: number;
41
+ markDate?: TimelineDateMarkerProps;
42
+ }
43
+ /** Properties for marking current date in RailMarkers
44
+ * @internal
45
+ */
46
+ interface DateMarkerProps {
47
+ datePercentage: number;
48
+ dateMarker?: React.ReactNode;
49
+ }
50
+ /** Scrubber/Slider for timeline control
51
+ * @internal
52
+ */
53
+ export declare function Scrubber(props: ScrubberProps): JSX.Element;
54
+ export {};
55
55
  //# sourceMappingURL=Scrubber.d.ts.map
@@ -1,192 +1,196 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.Scrubber = exports.useFocusedThumb = exports.CustomThumb = exports.RailMarkers = exports.getPercentageOfRectangle = void 0;
23
- /*---------------------------------------------------------------------------------------------
24
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
25
- * See LICENSE.md in the project root for license terms and full copyright notice.
26
- *--------------------------------------------------------------------------------------------*/
27
- require("./Scrubber.scss");
28
- const React = __importStar(require("react"));
29
- const itwinui_react_1 = require("@itwin/itwinui-react");
30
- const core_react_1 = require("@itwin/core-react");
31
- const components_react_1 = require("@itwin/components-react");
32
- /**
33
- * @internal
34
- */
35
- function getPercentageOfRectangle(rect, pointer) {
36
- const position = Math.min(rect.right, Math.max(rect.left, pointer));
37
- return (position - rect.left) / rect.width;
38
- }
39
- exports.getPercentageOfRectangle = getPercentageOfRectangle;
40
- // istanbul ignore next - WIP
41
- const formatDuration = (value) => {
42
- const addZero = (i) => {
43
- return (i < 10) ? `0${i}` : i;
44
- };
45
- const date = new Date(value);
46
- const minutes = date.getUTCMinutes();
47
- const seconds = date.getUTCSeconds();
48
- return `${addZero(minutes)}:${addZero(seconds)}`;
49
- };
50
- const formatDate = (startDate, endDate, fraction, timeZoneOffset) => {
51
- const delta = (endDate.getTime() - startDate.getTime()) * fraction;
52
- const date = new Date(startDate.getTime() + delta);
53
- return (0, components_react_1.toDateString)(date, timeZoneOffset);
54
- };
55
- // istanbul ignore next - WIP
56
- const formatTime = (startDate, endDate, fraction, timeZoneOffset) => {
57
- const delta = (endDate.getTime() - startDate.getTime()) * fraction;
58
- const date = new Date(startDate.getTime() + delta);
59
- return ` ${(0, components_react_1.toTimeString)(date, timeZoneOffset)}`;
60
- };
61
- function generateToolTipText(showTime, percent, min, max, startDate, endDate, timeZoneOffset = 0) {
62
- if (startDate && endDate)
63
- return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : ""} `;
64
- const val = Math.round(min + ((max - min) * percent));
65
- return formatDuration(val);
66
- }
67
- function getPercentageFromDate(startDate, endDate, date) {
68
- const newDate = date ? date : new Date();
69
- const startTime = startDate.getTime();
70
- const totalDuration = endDate.getTime() - startTime;
71
- return (newDate.getTime() - startTime) / totalDuration;
72
- }
73
- function getDateMarker(dateMarkerPropsIn, startDate, endDate) {
74
- const percentage = getPercentageFromDate(startDate, endDate, dateMarkerPropsIn.date);
75
- const marker = dateMarkerPropsIn.dateMarker ? dateMarkerPropsIn.dateMarker : React.createElement("span", { className: "date-marker-default" });
76
- return { datePercentage: percentage, dateMarker: marker };
77
- }
78
- function markDateInTimelineRange(dateMarkerProps, startDate, endDate) {
79
- // istanbul ignore else
80
- if (dateMarkerProps && startDate && endDate) {
81
- const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();
82
- // istanbul ignore else
83
- if (inDate.getTime() >= startDate.getTime() && inDate.getTime() <= endDate.getTime())
84
- return true;
85
- }
86
- return false;
87
- }
88
- /**
89
- * @internal
90
- */
91
- function RailMarkers({ showToolTip, percent, tooltipText, markDate }) {
92
- return (React.createElement("div", { className: "components-timeline-rail-marker-container" },
93
- showToolTip &&
94
- React.createElement("div", { className: "components-timeline-tooltip", style: { left: `${Math.round(percent * 100)}% ` } },
95
- React.createElement("span", { className: "tooltip-text" }, tooltipText)),
96
- markDate &&
97
- React.createElement("div", { className: "components-timeline-date-marker", "data-testid": "test-date-marker", style: { left: `${Math.round(markDate.datePercentage * 100)}% ` } }, markDate.dateMarker)));
98
- }
99
- exports.RailMarkers = RailMarkers;
100
- /**
101
- * Custom Timeline Thumb
102
- * @internal
103
- */
104
- function CustomThumb() {
105
- return (React.createElement("div", { className: "scrubber-handle" },
106
- React.createElement("div", null),
107
- React.createElement("div", null),
108
- React.createElement("div", null)));
109
- }
110
- exports.CustomThumb = CustomThumb;
111
- /**
112
- * @internal
113
- */
114
- function useFocusedThumb(sliderContainer) {
115
- const [thumbElement, setThumbElement] = React.useState();
116
- React.useLayoutEffect(() => {
117
- // istanbul ignore else
118
- if (sliderContainer) {
119
- const element = sliderContainer.querySelector(".iui-slider-thumb");
120
- if (element && thumbElement !== element) {
121
- setThumbElement(element);
122
- }
123
- }
124
- }, [sliderContainer, thumbElement]);
125
- const [thumbHasFocus, setThumbHasFocus] = React.useState(false);
126
- const handleThumbFocus = React.useCallback(() => {
127
- setThumbHasFocus(true);
128
- }, []);
129
- const handleThumbBlur = React.useCallback(() => {
130
- setThumbHasFocus(false);
131
- }, []);
132
- (0, core_react_1.useEventListener)("focus", handleThumbFocus, thumbElement);
133
- (0, core_react_1.useEventListener)("blur", handleThumbBlur, thumbElement);
134
- return thumbHasFocus;
135
- }
136
- exports.useFocusedThumb = useFocusedThumb;
137
- /** Scrubber/Slider for timeline control
138
- * @internal
139
- */
140
- function Scrubber(props) {
141
- const { startDate, endDate, showTime, isPlaying, totalDuration, timeZoneOffset, currentDuration, className, onChange, onUpdate } = props;
142
- const thumbProps = () => {
143
- return {
144
- className: "components-timeline-thumb",
145
- children: React.createElement(CustomThumb, null),
146
- };
147
- };
148
- const sliderRef = React.useRef(null);
149
- const [sliderContainer, setSliderContainer] = React.useState();
150
- const [pointerPercent, setPointerPercent] = React.useState(0);
151
- React.useLayoutEffect(() => {
152
- // istanbul ignore else
153
- if (sliderRef.current) {
154
- const container = sliderRef.current.querySelector(".iui-slider-container");
155
- if (container && sliderContainer !== container) {
156
- setSliderContainer(container);
157
- }
158
- }
159
- }, [sliderContainer]);
160
- const tooltipProps = React.useCallback(() => {
161
- return { visible: false };
162
- }, []);
163
- const [showRailTooltip, setShowRailTooltip] = React.useState(false);
164
- // istanbul ignore next
165
- const handlePointerEnter = React.useCallback(() => {
166
- setShowRailTooltip(true);
167
- }, []);
168
- // istanbul ignore next
169
- const handlePointerLeave = React.useCallback(() => {
170
- setShowRailTooltip(false);
171
- }, []);
172
- const handlePointerMove = React.useCallback((event) => {
173
- sliderContainer &&
174
- setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
175
- }, [sliderContainer]);
176
- const thumbHasFocus = useFocusedThumb(sliderContainer);
177
- const tickLabel = React.useMemo(() => {
178
- const showTip = isPlaying || showRailTooltip || thumbHasFocus;
179
- const percent = (isPlaying || thumbHasFocus) ? currentDuration / totalDuration : pointerPercent;
180
- const markDateInRange = markDateInTimelineRange(props.markDate, startDate, endDate);
181
- const currentDateMarker = props.markDate && markDateInRange && startDate && endDate ? getDateMarker(props.markDate, startDate, endDate) : undefined;
182
- const tooltipText = generateToolTipText(!!showTime, percent, 0, totalDuration, startDate, endDate, timeZoneOffset);
183
- return (React.createElement(RailMarkers, { showToolTip: showTip, percent: percent, tooltipText: tooltipText, markDate: currentDateMarker }));
184
- }, [isPlaying, showRailTooltip, currentDuration, totalDuration, pointerPercent, startDate, endDate, timeZoneOffset, showTime, thumbHasFocus, props.markDate]);
185
- return (React.createElement(itwinui_react_1.Slider, { ref: sliderRef, className: className, step: 1, min: 0, max: totalDuration, minLabel: "", maxLabel: "", onUpdate: onUpdate, onChange: onChange, values: [currentDuration], tooltipProps: tooltipProps, thumbProps: thumbProps, tickLabels: tickLabel, railContainerProps: {
186
- onPointerEnter: handlePointerEnter,
187
- onPointerMove: handlePointerMove,
188
- onPointerLeave: handlePointerLeave,
189
- } }));
190
- }
191
- exports.Scrubber = Scrubber;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Scrubber = exports.useFocusedThumb = exports.CustomThumb = exports.RailMarkers = exports.getPercentageOfRectangle = void 0;
27
+ /*---------------------------------------------------------------------------------------------
28
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
29
+ * See LICENSE.md in the project root for license terms and full copyright notice.
30
+ *--------------------------------------------------------------------------------------------*/
31
+ require("./Scrubber.scss");
32
+ const React = __importStar(require("react"));
33
+ const itwinui_react_1 = require("@itwin/itwinui-react");
34
+ const core_react_1 = require("@itwin/core-react");
35
+ const components_react_1 = require("@itwin/components-react");
36
+ /**
37
+ * @internal
38
+ */
39
+ function getPercentageOfRectangle(rect, pointer) {
40
+ const position = Math.min(rect.right, Math.max(rect.left, pointer));
41
+ return (position - rect.left) / rect.width;
42
+ }
43
+ exports.getPercentageOfRectangle = getPercentageOfRectangle;
44
+ // istanbul ignore next - WIP
45
+ const formatDuration = (value) => {
46
+ const addZero = (i) => {
47
+ return (i < 10) ? `0${i}` : i;
48
+ };
49
+ const date = new Date(value);
50
+ const minutes = date.getUTCMinutes();
51
+ const seconds = date.getUTCSeconds();
52
+ return `${addZero(minutes)}:${addZero(seconds)}`;
53
+ };
54
+ const formatDate = (startDate, endDate, fraction, timeZoneOffset) => {
55
+ const delta = (endDate.getTime() - startDate.getTime()) * fraction;
56
+ const date = new Date(startDate.getTime() + delta);
57
+ return (0, components_react_1.toDateString)(date, timeZoneOffset);
58
+ };
59
+ // istanbul ignore next - WIP
60
+ const formatTime = (startDate, endDate, fraction, timeZoneOffset) => {
61
+ const delta = (endDate.getTime() - startDate.getTime()) * fraction;
62
+ const date = new Date(startDate.getTime() + delta);
63
+ return ` ${(0, components_react_1.toTimeString)(date, timeZoneOffset)}`;
64
+ };
65
+ function generateToolTipText(showTime, percent, min, max, startDate, endDate, timeZoneOffset = 0) {
66
+ if (startDate && endDate)
67
+ return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : ""} `;
68
+ const val = Math.round(min + ((max - min) * percent));
69
+ return formatDuration(val);
70
+ }
71
+ function getPercentageFromDate(startDate, endDate, date) {
72
+ const newDate = date ? date : new Date();
73
+ const startTime = startDate.getTime();
74
+ const totalDuration = endDate.getTime() - startTime;
75
+ return (newDate.getTime() - startTime) / totalDuration;
76
+ }
77
+ function getDateMarker(dateMarkerPropsIn, startDate, endDate) {
78
+ const percentage = getPercentageFromDate(startDate, endDate, dateMarkerPropsIn.date);
79
+ const marker = dateMarkerPropsIn.dateMarker ? dateMarkerPropsIn.dateMarker : React.createElement("span", { className: "date-marker-default" });
80
+ return { datePercentage: percentage, dateMarker: marker };
81
+ }
82
+ function markDateInTimelineRange(dateMarkerProps, startDate, endDate) {
83
+ // istanbul ignore else
84
+ if (dateMarkerProps && startDate && endDate) {
85
+ const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();
86
+ // istanbul ignore else
87
+ if (inDate.getTime() >= startDate.getTime() && inDate.getTime() <= endDate.getTime())
88
+ return true;
89
+ }
90
+ return false;
91
+ }
92
+ /**
93
+ * @internal
94
+ */
95
+ function RailMarkers({ showToolTip, percent, tooltipText, markDate }) {
96
+ return (React.createElement("div", { className: "components-timeline-rail-marker-container" },
97
+ showToolTip &&
98
+ React.createElement("div", { className: "components-timeline-tooltip", style: { left: `${Math.round(percent * 100)}% ` } },
99
+ React.createElement("span", { className: "tooltip-text" }, tooltipText)),
100
+ markDate &&
101
+ React.createElement("div", { className: "components-timeline-date-marker", "data-testid": "test-date-marker", style: { left: `${Math.round(markDate.datePercentage * 100)}% ` } }, markDate.dateMarker)));
102
+ }
103
+ exports.RailMarkers = RailMarkers;
104
+ /**
105
+ * Custom Timeline Thumb
106
+ * @internal
107
+ */
108
+ function CustomThumb() {
109
+ return (React.createElement("div", { className: "scrubber-handle" },
110
+ React.createElement("div", null),
111
+ React.createElement("div", null),
112
+ React.createElement("div", null)));
113
+ }
114
+ exports.CustomThumb = CustomThumb;
115
+ /**
116
+ * @internal
117
+ */
118
+ function useFocusedThumb(sliderContainer) {
119
+ const [thumbElement, setThumbElement] = React.useState();
120
+ React.useLayoutEffect(() => {
121
+ // istanbul ignore else
122
+ if (sliderContainer) {
123
+ const element = sliderContainer.querySelector(".iui-slider-thumb");
124
+ if (element && thumbElement !== element) {
125
+ setThumbElement(element);
126
+ }
127
+ }
128
+ }, [sliderContainer, thumbElement]);
129
+ const [thumbHasFocus, setThumbHasFocus] = React.useState(false);
130
+ const handleThumbFocus = React.useCallback(() => {
131
+ setThumbHasFocus(true);
132
+ }, []);
133
+ const handleThumbBlur = React.useCallback(() => {
134
+ setThumbHasFocus(false);
135
+ }, []);
136
+ (0, core_react_1.useEventListener)("focus", handleThumbFocus, thumbElement);
137
+ (0, core_react_1.useEventListener)("blur", handleThumbBlur, thumbElement);
138
+ return thumbHasFocus;
139
+ }
140
+ exports.useFocusedThumb = useFocusedThumb;
141
+ /** Scrubber/Slider for timeline control
142
+ * @internal
143
+ */
144
+ function Scrubber(props) {
145
+ const { startDate, endDate, showTime, isPlaying, totalDuration, timeZoneOffset, currentDuration, className, onChange, onUpdate } = props;
146
+ const thumbProps = () => {
147
+ return {
148
+ className: "components-timeline-thumb",
149
+ children: React.createElement(CustomThumb, null),
150
+ };
151
+ };
152
+ const sliderRef = React.useRef(null);
153
+ const [sliderContainer, setSliderContainer] = React.useState();
154
+ const [pointerPercent, setPointerPercent] = React.useState(0);
155
+ React.useLayoutEffect(() => {
156
+ // istanbul ignore else
157
+ if (sliderRef.current) {
158
+ const container = sliderRef.current.querySelector(".iui-slider-container");
159
+ if (container && sliderContainer !== container) {
160
+ setSliderContainer(container);
161
+ }
162
+ }
163
+ }, [sliderContainer]);
164
+ const tooltipProps = React.useCallback(() => {
165
+ return { visible: false };
166
+ }, []);
167
+ const [showRailTooltip, setShowRailTooltip] = React.useState(false);
168
+ // istanbul ignore next
169
+ const handlePointerEnter = React.useCallback(() => {
170
+ setShowRailTooltip(true);
171
+ }, []);
172
+ // istanbul ignore next
173
+ const handlePointerLeave = React.useCallback(() => {
174
+ setShowRailTooltip(false);
175
+ }, []);
176
+ const handlePointerMove = React.useCallback((event) => {
177
+ sliderContainer &&
178
+ setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
179
+ }, [sliderContainer]);
180
+ const thumbHasFocus = useFocusedThumb(sliderContainer);
181
+ const tickLabel = React.useMemo(() => {
182
+ const showTip = isPlaying || showRailTooltip || thumbHasFocus;
183
+ const percent = (isPlaying || thumbHasFocus) ? currentDuration / totalDuration : pointerPercent;
184
+ const markDateInRange = markDateInTimelineRange(props.markDate, startDate, endDate);
185
+ const currentDateMarker = props.markDate && markDateInRange && startDate && endDate ? getDateMarker(props.markDate, startDate, endDate) : undefined;
186
+ const tooltipText = generateToolTipText(!!showTime, percent, 0, totalDuration, startDate, endDate, timeZoneOffset);
187
+ return (React.createElement(RailMarkers, { showToolTip: showTip, percent: percent, tooltipText: tooltipText, markDate: currentDateMarker }));
188
+ }, [isPlaying, showRailTooltip, currentDuration, totalDuration, pointerPercent, startDate, endDate, timeZoneOffset, showTime, thumbHasFocus, props.markDate]);
189
+ return (React.createElement(itwinui_react_1.Slider, { ref: sliderRef, className: className, step: 1, min: 0, max: totalDuration, minLabel: "", maxLabel: "", onUpdate: onUpdate, onChange: onChange, values: [currentDuration], tooltipProps: tooltipProps, thumbProps: thumbProps, tickLabels: tickLabel, railContainerProps: {
190
+ onPointerEnter: handlePointerEnter,
191
+ onPointerMove: handlePointerMove,
192
+ onPointerLeave: handlePointerLeave,
193
+ } }));
194
+ }
195
+ exports.Scrubber = Scrubber;
192
196
  //# sourceMappingURL=Scrubber.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,2BAAyB;AACzB,6CAA+B;AAC/B,wDAA8C;AAC9C,kDAAkE;AAClE,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,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,C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,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,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,UAAU,EACtB,UAAU,EAAE,SAAS,EACrB,kBAAkB,EAAE;YAClB,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,iBAAiB;YAChC,cAAc,EAAE,kBAAkB;SACnC,GACD,CACH,CAAC;AACJ,CAAC;AA9ED,4BA8EC","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\nimport \"./Scrubber.scss\";\r\nimport * as React from \"react\";\r\nimport { Slider } from \"@itwin/itwinui-react\";\r\nimport { CommonProps, useEventListener } from \"@itwin/core-react\";\r\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\r\nimport { TimelineDateMarkerProps } from \"./TimelineComponent\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\r\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\r\n return (position - rect.left) / rect.width;\r\n}\r\n\r\n// istanbul ignore next - WIP\r\nconst formatDuration = (value: number) => {\r\n const addZero = (i: number) => {\r\n return (i < 10) ? `0${i}` : i;\r\n };\r\n\r\n const date = new Date(value);\r\n const minutes = date.getUTCMinutes();\r\n const seconds = date.getUTCSeconds();\r\n return `${addZero(minutes)}:${addZero(seconds)}`;\r\n};\r\n\r\nconst formatDate = (startDate: Date, endDate: Date, fraction: number, timeZoneOffset?: number) => {\r\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\r\n const date = new Date(startDate.getTime() + delta);\r\n return toDateString(date, timeZoneOffset);\r\n};\r\n\r\n// istanbul ignore next - WIP\r\nconst formatTime = (startDate: Date, endDate: Date, fraction: number, timeZoneOffset?: number) => {\r\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\r\n const date = new Date(startDate.getTime() + delta);\r\n return ` ${toTimeString(date, timeZoneOffset)}`;\r\n};\r\n\r\nfunction generateToolTipText(showTime: boolean, percent: number, min: number, max: number, startDate?: Date, endDate?: Date, timeZoneOffset = 0) {\r\n if (startDate && endDate)\r\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"} `;\r\n\r\n const val = Math.round(min + ((max - min) * percent));\r\n return formatDuration(val);\r\n}\r\n\r\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\r\n const newDate = date ? date : new Date();\r\n const startTime = startDate.getTime();\r\n const totalDuration = endDate.getTime() - startTime;\r\n return (newDate.getTime() - startTime) / totalDuration;\r\n}\r\n\r\nfunction getDateMarker(dateMarkerPropsIn: TimelineDateMarkerProps, startDate: Date, endDate: Date): DateMarkerProps {\r\n const percentage = getPercentageFromDate(startDate, endDate, dateMarkerPropsIn.date);\r\n const marker = dateMarkerPropsIn.dateMarker ? dateMarkerPropsIn.dateMarker : <span className=\"date-marker-default\"></span>;\r\n return { datePercentage: percentage, dateMarker: marker };\r\n}\r\n\r\nfunction markDateInTimelineRange(dateMarkerProps?: TimelineDateMarkerProps, startDate?: Date, endDate?: Date): boolean {\r\n // istanbul ignore else\r\n if (dateMarkerProps && startDate && endDate) {\r\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\r\n // istanbul ignore else\r\n if (inDate.getTime() >= startDate.getTime() && inDate.getTime() <= endDate.getTime())\r\n return true;\r\n }\r\n return false;\r\n}\r\n/**\r\n * @internal\r\n */\r\nexport function RailMarkers({ showToolTip, percent, tooltipText, markDate }: {\r\n showToolTip: boolean;\r\n percent: number;\r\n tooltipText: string;\r\n markDate?: DateMarkerProps;\r\n}) {\r\n\r\n return (\r\n <div className=\"components-timeline-rail-marker-container\">\r\n {showToolTip &&\r\n <div className=\"components-timeline-tooltip\" style={{ left: `${Math.round(percent * 100)}% ` }}>\r\n <span className=\"tooltip-text\">{tooltipText}</span>\r\n </div>}\r\n {markDate &&\r\n <div className=\"components-timeline-date-marker\" data-testid=\"test-date-marker\" style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}>\r\n {markDate.dateMarker}\r\n </div>}\r\n </div>\r\n );\r\n}\r\n\r\n/**\r\n * Custom Timeline Thumb\r\n * @internal\r\n */\r\nexport function CustomThumb() {\r\n return (\r\n <div className=\"scrubber-handle\">\r\n <div /><div /><div />\r\n </div>\r\n );\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\r\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\r\n\r\n React.useLayoutEffect(() => {\r\n // istanbul ignore else\r\n if (sliderContainer) {\r\n const element = sliderContainer.querySelector(\".iui-slider-thumb\");\r\n if (element && thumbElement !== element) {\r\n setThumbElement(element as HTMLDivElement);\r\n }\r\n }\r\n }, [sliderContainer, thumbElement]);\r\n\r\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\r\n\r\n const handleThumbFocus = React.useCallback(() => {\r\n setThumbHasFocus(true);\r\n }, []);\r\n\r\n const handleThumbBlur = React.useCallback(() => {\r\n setThumbHasFocus(false);\r\n }, []);\r\n\r\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\r\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\r\n return thumbHasFocus;\r\n}\r\n\r\n/** Properties for Scrubber/Slider used on timeline control\r\n * @internal\r\n */\r\nexport interface ScrubberProps extends CommonProps {\r\n currentDuration: number;\r\n totalDuration: number;\r\n isPlaying: boolean;\r\n inMiniMode: boolean;\r\n startDate?: Date;\r\n endDate?: Date;\r\n showTime?: boolean;\r\n onChange?: (values: ReadonlyArray<number>) => void;\r\n onUpdate?: (values: ReadonlyArray<number>) => void;\r\n timeZoneOffset?: number;\r\n markDate?: TimelineDateMarkerProps;\r\n}\r\n\r\n/** Properties for marking current date in RailMarkers\r\n * @internal\r\n */\r\ninterface DateMarkerProps {\r\n datePercentage: number;\r\n dateMarker?: React.ReactNode;\r\n}\r\n/** Scrubber/Slider for timeline control\r\n * @internal\r\n */\r\nexport function Scrubber(props: ScrubberProps) {\r\n const { startDate, endDate, showTime, isPlaying, totalDuration, timeZoneOffset,\r\n currentDuration, className, onChange, onUpdate } = props;\r\n\r\n const thumbProps = () => {\r\n return {\r\n className: \"components-timeline-thumb\",\r\n children: <CustomThumb />,\r\n };\r\n };\r\n\r\n const sliderRef = React.useRef<HTMLDivElement>(null);\r\n const [sliderContainer, setSliderContainer] = React.useState<HTMLDivElement>();\r\n const [pointerPercent, setPointerPercent] = React.useState(0);\r\n\r\n React.useLayoutEffect(() => {\r\n // istanbul ignore else\r\n if (sliderRef.current) {\r\n const container = sliderRef.current.querySelector(\".iui-slider-container\");\r\n if (container && sliderContainer !== container) {\r\n setSliderContainer(container as HTMLDivElement);\r\n }\r\n }\r\n }, [sliderContainer]);\r\n\r\n const tooltipProps = React.useCallback(() => {\r\n return { visible: false };\r\n }, []);\r\n\r\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\r\n\r\n // istanbul ignore next\r\n const handlePointerEnter = React.useCallback(() => {\r\n setShowRailTooltip(true);\r\n }, []);\r\n\r\n // istanbul ignore next\r\n const handlePointerLeave = React.useCallback(() => {\r\n setShowRailTooltip(false);\r\n }, []);\r\n\r\n const handlePointerMove = React.useCallback((event: React.PointerEvent) => {\r\n sliderContainer &&\r\n setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));\r\n }, [sliderContainer]);\r\n\r\n const thumbHasFocus = useFocusedThumb(sliderContainer);\r\n\r\n const tickLabel = React.useMemo(() => {\r\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\r\n const percent = (isPlaying || thumbHasFocus) ? currentDuration / totalDuration : pointerPercent;\r\n const markDateInRange = markDateInTimelineRange(props.markDate, startDate, endDate);\r\n const currentDateMarker = props.markDate && markDateInRange && startDate && endDate ? getDateMarker(props.markDate, startDate, endDate) : undefined;\r\n const tooltipText = generateToolTipText(!!showTime, percent, 0, totalDuration, startDate, endDate, timeZoneOffset);\r\n return (<RailMarkers showToolTip={showTip} percent={percent} tooltipText={tooltipText} markDate={currentDateMarker} />);\r\n }, [isPlaying, showRailTooltip, currentDuration, totalDuration, pointerPercent, startDate, endDate, timeZoneOffset, showTime, thumbHasFocus, props.markDate]);\r\n\r\n return (\r\n <Slider ref={sliderRef}\r\n className={className}\r\n step={1}\r\n min={0}\r\n max={totalDuration}\r\n minLabel=\"\"\r\n maxLabel=\"\"\r\n onUpdate={onUpdate}\r\n onChange={onChange}\r\n values={[currentDuration]}\r\n tooltipProps={tooltipProps}\r\n thumbProps={thumbProps}\r\n tickLabels={tickLabel}\r\n railContainerProps={{\r\n onPointerEnter: handlePointerEnter,\r\n onPointerMove: handlePointerMove,\r\n onPointerLeave: handlePointerLeave,\r\n }}\r\n />\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,2BAAyB;AACzB,6CAA+B;AAC/B,wDAA8C;AAC9C,kDAAkE;AAClE,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,K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E,CAAC,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE9J,OAAO,CACL,oBAAC,sBAAM,IAAC,GAAG,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,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,UAAU,EACtB,UAAU,EAAE,SAAS,EACrB,kBAAkB,EAAE;YAClB,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,iBAAiB;YAChC,cAAc,EAAE,kBAAkB;SACnC,GACD,CACH,CAAC;AACJ,CAAC;AA9ED,4BA8EC","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\nimport \"./Scrubber.scss\";\r\nimport * as React from \"react\";\r\nimport { Slider } from \"@itwin/itwinui-react\";\r\nimport { CommonProps, useEventListener } from \"@itwin/core-react\";\r\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\r\nimport { TimelineDateMarkerProps } from \"./TimelineComponent\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\r\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\r\n return (position - rect.left) / rect.width;\r\n}\r\n\r\n// istanbul ignore next - WIP\r\nconst formatDuration = (value: number) => {\r\n const addZero = (i: number) => {\r\n return (i < 10) ? `0${i}` : i;\r\n };\r\n\r\n const date = new Date(value);\r\n const minutes = date.getUTCMinutes();\r\n const seconds = date.getUTCSeconds();\r\n return `${addZero(minutes)}:${addZero(seconds)}`;\r\n};\r\n\r\nconst formatDate = (startDate: Date, endDate: Date, fraction: number, timeZoneOffset?: number) => {\r\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\r\n const date = new Date(startDate.getTime() + delta);\r\n return toDateString(date, timeZoneOffset);\r\n};\r\n\r\n// istanbul ignore next - WIP\r\nconst formatTime = (startDate: Date, endDate: Date, fraction: number, timeZoneOffset?: number) => {\r\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\r\n const date = new Date(startDate.getTime() + delta);\r\n return ` ${toTimeString(date, timeZoneOffset)}`;\r\n};\r\n\r\nfunction generateToolTipText(showTime: boolean, percent: number, min: number, max: number, startDate?: Date, endDate?: Date, timeZoneOffset = 0) {\r\n if (startDate && endDate)\r\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"} `;\r\n\r\n const val = Math.round(min + ((max - min) * percent));\r\n return formatDuration(val);\r\n}\r\n\r\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\r\n const newDate = date ? date : new Date();\r\n const startTime = startDate.getTime();\r\n const totalDuration = endDate.getTime() - startTime;\r\n return (newDate.getTime() - startTime) / totalDuration;\r\n}\r\n\r\nfunction getDateMarker(dateMarkerPropsIn: TimelineDateMarkerProps, startDate: Date, endDate: Date): DateMarkerProps {\r\n const percentage = getPercentageFromDate(startDate, endDate, dateMarkerPropsIn.date);\r\n const marker = dateMarkerPropsIn.dateMarker ? dateMarkerPropsIn.dateMarker : <span className=\"date-marker-default\"></span>;\r\n return { datePercentage: percentage, dateMarker: marker };\r\n}\r\n\r\nfunction markDateInTimelineRange(dateMarkerProps?: TimelineDateMarkerProps, startDate?: Date, endDate?: Date): boolean {\r\n // istanbul ignore else\r\n if (dateMarkerProps && startDate && endDate) {\r\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\r\n // istanbul ignore else\r\n if (inDate.getTime() >= startDate.getTime() && inDate.getTime() <= endDate.getTime())\r\n return true;\r\n }\r\n return false;\r\n}\r\n/**\r\n * @internal\r\n */\r\nexport function RailMarkers({ showToolTip, percent, tooltipText, markDate }: {\r\n showToolTip: boolean;\r\n percent: number;\r\n tooltipText: string;\r\n markDate?: DateMarkerProps;\r\n}) {\r\n\r\n return (\r\n <div className=\"components-timeline-rail-marker-container\">\r\n {showToolTip &&\r\n <div className=\"components-timeline-tooltip\" style={{ left: `${Math.round(percent * 100)}% ` }}>\r\n <span className=\"tooltip-text\">{tooltipText}</span>\r\n </div>}\r\n {markDate &&\r\n <div className=\"components-timeline-date-marker\" data-testid=\"test-date-marker\" style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}>\r\n {markDate.dateMarker}\r\n </div>}\r\n </div>\r\n );\r\n}\r\n\r\n/**\r\n * Custom Timeline Thumb\r\n * @internal\r\n */\r\nexport function CustomThumb() {\r\n return (\r\n <div className=\"scrubber-handle\">\r\n <div /><div /><div />\r\n </div>\r\n );\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\r\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\r\n\r\n React.useLayoutEffect(() => {\r\n // istanbul ignore else\r\n if (sliderContainer) {\r\n const element = sliderContainer.querySelector(\".iui-slider-thumb\");\r\n if (element && thumbElement !== element) {\r\n setThumbElement(element as HTMLDivElement);\r\n }\r\n }\r\n }, [sliderContainer, thumbElement]);\r\n\r\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\r\n\r\n const handleThumbFocus = React.useCallback(() => {\r\n setThumbHasFocus(true);\r\n }, []);\r\n\r\n const handleThumbBlur = React.useCallback(() => {\r\n setThumbHasFocus(false);\r\n }, []);\r\n\r\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\r\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\r\n return thumbHasFocus;\r\n}\r\n\r\n/** Properties for Scrubber/Slider used on timeline control\r\n * @internal\r\n */\r\nexport interface ScrubberProps extends CommonProps {\r\n currentDuration: number;\r\n totalDuration: number;\r\n isPlaying: boolean;\r\n inMiniMode: boolean;\r\n startDate?: Date;\r\n endDate?: Date;\r\n showTime?: boolean;\r\n onChange?: (values: ReadonlyArray<number>) => void;\r\n onUpdate?: (values: ReadonlyArray<number>) => void;\r\n timeZoneOffset?: number;\r\n markDate?: TimelineDateMarkerProps;\r\n}\r\n\r\n/** Properties for marking current date in RailMarkers\r\n * @internal\r\n */\r\ninterface DateMarkerProps {\r\n datePercentage: number;\r\n dateMarker?: React.ReactNode;\r\n}\r\n/** Scrubber/Slider for timeline control\r\n * @internal\r\n */\r\nexport function Scrubber(props: ScrubberProps) {\r\n const { startDate, endDate, showTime, isPlaying, totalDuration, timeZoneOffset,\r\n currentDuration, className, onChange, onUpdate } = props;\r\n\r\n const thumbProps = () => {\r\n return {\r\n className: \"components-timeline-thumb\",\r\n children: <CustomThumb />,\r\n };\r\n };\r\n\r\n const sliderRef = React.useRef<HTMLDivElement>(null);\r\n const [sliderContainer, setSliderContainer] = React.useState<HTMLDivElement>();\r\n const [pointerPercent, setPointerPercent] = React.useState(0);\r\n\r\n React.useLayoutEffect(() => {\r\n // istanbul ignore else\r\n if (sliderRef.current) {\r\n const container = sliderRef.current.querySelector(\".iui-slider-container\");\r\n if (container && sliderContainer !== container) {\r\n setSliderContainer(container as HTMLDivElement);\r\n }\r\n }\r\n }, [sliderContainer]);\r\n\r\n const tooltipProps = React.useCallback(() => {\r\n return { visible: false };\r\n }, []);\r\n\r\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\r\n\r\n // istanbul ignore next\r\n const handlePointerEnter = React.useCallback(() => {\r\n setShowRailTooltip(true);\r\n }, []);\r\n\r\n // istanbul ignore next\r\n const handlePointerLeave = React.useCallback(() => {\r\n setShowRailTooltip(false);\r\n }, []);\r\n\r\n const handlePointerMove = React.useCallback((event: React.PointerEvent) => {\r\n sliderContainer &&\r\n setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));\r\n }, [sliderContainer]);\r\n\r\n const thumbHasFocus = useFocusedThumb(sliderContainer);\r\n\r\n const tickLabel = React.useMemo(() => {\r\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\r\n const percent = (isPlaying || thumbHasFocus) ? currentDuration / totalDuration : pointerPercent;\r\n const markDateInRange = markDateInTimelineRange(props.markDate, startDate, endDate);\r\n const currentDateMarker = props.markDate && markDateInRange && startDate && endDate ? getDateMarker(props.markDate, startDate, endDate) : undefined;\r\n const tooltipText = generateToolTipText(!!showTime, percent, 0, totalDuration, startDate, endDate, timeZoneOffset);\r\n return (<RailMarkers showToolTip={showTip} percent={percent} tooltipText={tooltipText} markDate={currentDateMarker} />);\r\n }, [isPlaying, showRailTooltip, currentDuration, totalDuration, pointerPercent, startDate, endDate, timeZoneOffset, showTime, thumbHasFocus, props.markDate]);\r\n\r\n return (\r\n <Slider ref={sliderRef}\r\n className={className}\r\n step={1}\r\n min={0}\r\n max={totalDuration}\r\n minLabel=\"\"\r\n maxLabel=\"\"\r\n onUpdate={onUpdate}\r\n onChange={onChange}\r\n values={[currentDuration]}\r\n tooltipProps={tooltipProps}\r\n thumbProps={thumbProps}\r\n tickLabels={tickLabel}\r\n railContainerProps={{\r\n onPointerEnter: handlePointerEnter,\r\n onPointerMove: handlePointerMove,\r\n onPointerLeave: handlePointerLeave,\r\n }}\r\n />\r\n );\r\n}\r\n"]}