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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/CHANGELOG.md +20 -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 +12 -8
  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 +12 -9
  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 +12 -11
  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 +3 -2
  34. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  36. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  37. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  38. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +5 -4
  39. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  40. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +5 -5
  41. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +3 -3
  43. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
  45. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  47. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +3 -3
  48. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -1
  50. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  51. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
  52. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  54. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +7 -8
  55. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  57. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +10 -10
  58. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  59. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  60. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
  61. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  63. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +13 -9
  64. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  65. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  66. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +22 -29
  67. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
  70. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  72. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
  73. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  75. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
  76. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  77. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  78. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
  79. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  80. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  81. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
  82. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  84. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
  85. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  87. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
  88. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  90. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
  91. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  93. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
  94. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +2 -2
  96. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  97. package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts +12 -0
  98. package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts.map +1 -0
  99. package/lib/cjs/imodel-components-react/timeline/PlayButton.js +50 -0
  100. package/lib/cjs/imodel-components-react/timeline/PlayButton.js.map +1 -0
  101. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +0 -1
  102. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  103. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +1 -1
  104. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  105. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
  106. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  107. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +111 -202
  108. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  109. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +25 -333
  110. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +33 -67
  111. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  112. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +226 -330
  113. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  114. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +27 -140
  115. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +2 -2
  116. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  117. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  118. package/lib/cjs/imodel-components-react/useTranslation.d.ts +10 -0
  119. package/lib/cjs/imodel-components-react/useTranslation.d.ts.map +1 -0
  120. package/lib/cjs/imodel-components-react/useTranslation.js +20 -0
  121. package/lib/cjs/imodel-components-react/useTranslation.js.map +1 -0
  122. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  123. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +13 -8
  124. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  125. package/lib/cjs/imodel-components-react.d.ts +0 -1
  126. package/lib/cjs/imodel-components-react.d.ts.map +1 -1
  127. package/lib/cjs/imodel-components-react.js +0 -1
  128. package/lib/cjs/imodel-components-react.js.map +1 -1
  129. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +1 -1
  130. package/lib/esm/imodel-components-react/UiIModelComponents.js +6 -6
  131. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  132. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +2 -1
  133. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  134. package/lib/esm/imodel-components-react/color/AlphaSlider.js +12 -8
  135. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  136. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +2 -0
  137. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  138. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +5 -2
  139. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  140. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +2 -0
  141. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  142. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +1 -1
  143. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  144. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +2 -0
  145. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  146. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +5 -5
  147. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  148. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +2 -0
  149. package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  150. package/lib/esm/imodel-components-react/color/HueSlider.js +12 -9
  151. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  152. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +2 -0
  153. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  154. package/lib/esm/imodel-components-react/color/SaturationPicker.js +12 -11
  155. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  156. package/lib/esm/imodel-components-react/color/Swatch.d.ts +2 -0
  157. package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
  158. package/lib/esm/imodel-components-react/color/Swatch.js +2 -0
  159. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  160. package/lib/esm/imodel-components-react/editors/ColorEditor.js +3 -2
  161. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  162. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  163. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  164. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  165. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +5 -4
  166. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  167. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +5 -5
  168. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  169. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +3 -3
  170. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  171. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
  172. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  173. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  174. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +3 -3
  175. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  176. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -1
  177. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  178. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
  179. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  180. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  181. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +7 -8
  182. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  183. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
  184. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +10 -10
  185. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  186. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  187. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
  188. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  189. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  190. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +13 -9
  191. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  192. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  193. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +22 -29
  194. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  195. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
  196. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
  197. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  198. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
  199. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
  200. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  201. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
  202. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
  203. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  204. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
  205. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
  206. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  207. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
  208. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
  209. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  210. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  211. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
  212. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  213. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
  214. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
  215. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  216. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  217. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
  218. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  219. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  220. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
  221. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  222. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +2 -2
  223. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  224. package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts +12 -0
  225. package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts.map +1 -0
  226. package/lib/esm/imodel-components-react/timeline/PlayButton.js +23 -0
  227. package/lib/esm/imodel-components-react/timeline/PlayButton.js.map +1 -0
  228. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +0 -1
  229. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  230. package/lib/esm/imodel-components-react/timeline/Scrubber.js +1 -1
  231. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  232. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
  233. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  234. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +112 -203
  235. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  236. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +25 -333
  237. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +33 -67
  238. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  239. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +228 -329
  240. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  241. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +27 -140
  242. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +2 -2
  243. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  244. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  245. package/lib/esm/imodel-components-react/useTranslation.d.ts +10 -0
  246. package/lib/esm/imodel-components-react/useTranslation.d.ts.map +1 -0
  247. package/lib/esm/imodel-components-react/useTranslation.js +16 -0
  248. package/lib/esm/imodel-components-react/useTranslation.js.map +1 -0
  249. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  250. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +13 -8
  251. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  252. package/lib/esm/imodel-components-react.d.ts +0 -1
  253. package/lib/esm/imodel-components-react.d.ts.map +1 -1
  254. package/lib/esm/imodel-components-react.js +0 -1
  255. package/lib/esm/imodel-components-react.js.map +1 -1
  256. package/lib/public/locales/en/UiIModelComponents.json +14 -3
  257. package/package.json +20 -20
  258. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +0 -34
  259. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts.map +0 -1
  260. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +0 -100
  261. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +0 -1
  262. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +0 -28
  263. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +0 -34
  264. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts.map +0 -1
  265. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +0 -69
  266. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +0 -1
  267. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +0 -28
@@ -1,361 +1,260 @@
1
- import { UiAdmin } from "@itwin/appui-abstract";
2
- import { toDateString, toTimeString, UiComponents, } from "@itwin/components-react";
3
- import { Icon } from "@itwin/core-react";
4
- import { SvgCaretLeft, SvgCaretRight, SvgCheckmark, SvgMoreVertical, SvgPlayCircular, } from "@itwin/itwinui-icons-react";
5
- import { DropdownMenu, MenuDivider, MenuItem } from "@itwin/itwinui-react";
6
- import classnames from "classnames";
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Timeline
7
+ */
8
+ import "./TimelineComponent.scss";
7
9
  import * as React from "react";
8
- import { UiIModelComponents } from "../UiIModelComponents";
10
+ import { UiAdmin } from "@itwin/appui-abstract";
11
+ import { toDateString, toTimeString } from "@itwin/components-react";
12
+ import { SvgCheckmark, SvgMoreVertical } from "@itwin/itwinui-icons-react";
13
+ import { DropdownMenu, IconButton, MenuDivider, MenuItem, } from "@itwin/itwinui-react";
9
14
  import { InlineEdit } from "./InlineEdit";
10
15
  import { TimelinePausePlayAction } from "./interfaces";
11
- import { PlayButton, PlayerButton } from "./PlayerButton";
16
+ import { PlayButton } from "./PlayButton";
12
17
  import { Scrubber } from "./Scrubber";
13
- import "./TimelineComponent.scss";
14
- // cspell:ignore millisec
18
+ import { useTranslation } from "../useTranslation";
15
19
  const slowSpeed = 60 * 1000;
16
20
  const mediumSpeed = 20 * 1000;
17
21
  const fastSpeed = 10 * 1000;
18
- /**
19
- * [[TimelineComponent]] is used to playback timeline data
22
+ /** [[TimelineComponent]] is used to playback timeline data
20
23
  * @public
21
24
  */
22
- export class TimelineComponent extends React.Component {
23
- constructor(props) {
24
- super(props);
25
- this._timeLastCycle = 0;
26
- this._requestFrame = 0;
27
- this._unmounted = false;
28
- this._standardTimelineMenuItems = [
29
- {
30
- label: UiIModelComponents.translate("timeline.slow"),
31
- timelineDuration: slowSpeed,
32
- },
33
- {
34
- label: UiIModelComponents.translate("timeline.medium"),
35
- timelineDuration: mediumSpeed,
36
- },
37
- {
38
- label: UiIModelComponents.translate("timeline.fast"),
39
- timelineDuration: fastSpeed,
40
- },
41
- ];
42
- this._handleTimelinePausePlayEvent = (args) => {
25
+ export function TimelineComponent(props) {
26
+ var _a, _b, _c, _d;
27
+ const { appMenuItemOption = "replace", startDate, endDate, showDuration, timeZoneOffset, dateFormatOptions, timeFormatOptions, includeRepeat = true, onSettingsChange, onChange, onPlayPause, } = props;
28
+ const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);
29
+ const [currentDuration, setCurrentDuration] = React.useState((_a = props.initialDuration) !== null && _a !== void 0 ? _a : 0);
30
+ const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);
31
+ const [repeat, setRepeat] = React.useState((_b = props.repeat) !== null && _b !== void 0 ? _b : false);
32
+ const playOrReplay = React.useCallback(() => {
33
+ if (isPlaying)
34
+ return;
35
+ if (currentDuration >= totalDuration) {
36
+ setCurrentDuration(0);
37
+ }
38
+ setIsPlaying(true);
39
+ onPlayPause === null || onPlayPause === void 0 ? void 0 : onPlayPause(true);
40
+ }, [isPlaying, onPlayPause, currentDuration, totalDuration]);
41
+ const pause = React.useCallback(() => {
42
+ if (!isPlaying)
43
+ return;
44
+ setIsPlaying(false);
45
+ onPlayPause === null || onPlayPause === void 0 ? void 0 : onPlayPause(false);
46
+ }, [isPlaying, onPlayPause]);
47
+ const updateTotalDuration = (newTotalDuration) => {
48
+ if (newTotalDuration === totalDuration)
49
+ return;
50
+ const fraction = currentDuration / totalDuration;
51
+ const newCurrentDuration = fraction * newTotalDuration;
52
+ setTotalDuration(newTotalDuration);
53
+ setCurrentDuration(newCurrentDuration);
54
+ onSettingsChange === null || onSettingsChange === void 0 ? void 0 : onSettingsChange({ duration: newTotalDuration });
55
+ };
56
+ const updateDuration = (newDuration, currentTotalDuration = totalDuration) => {
57
+ newDuration = Math.max(newDuration, 0);
58
+ newDuration = Math.min(newDuration, currentTotalDuration);
59
+ if (newDuration === currentDuration)
60
+ return;
61
+ setCurrentDuration(newDuration);
62
+ const fraction = newDuration / currentTotalDuration;
63
+ onChange === null || onChange === void 0 ? void 0 : onChange(fraction);
64
+ };
65
+ const updateRepeat = (newRepeat) => {
66
+ if (newRepeat === repeat)
67
+ return;
68
+ setRepeat(newRepeat);
69
+ onSettingsChange === null || onSettingsChange === void 0 ? void 0 : onSettingsChange({ loop: newRepeat });
70
+ };
71
+ const [prevTotalDuration, setPrevTotalDuration] = React.useState(props.totalDuration);
72
+ if (prevTotalDuration !== props.totalDuration) {
73
+ setPrevTotalDuration(props.totalDuration);
74
+ updateTotalDuration(props.totalDuration);
75
+ }
76
+ const [prevInitialDuration, setPrevInitialDuration] = React.useState(props.initialDuration);
77
+ if (prevInitialDuration !== props.initialDuration) {
78
+ setPrevInitialDuration(props.initialDuration);
79
+ updateDuration((_c = props.initialDuration) !== null && _c !== void 0 ? _c : 0, props.totalDuration);
80
+ }
81
+ const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);
82
+ if (prevRepeat !== props.repeat) {
83
+ setPrevRepeat(props.repeat);
84
+ updateRepeat((_d = props.repeat) !== null && _d !== void 0 ? _d : repeat);
85
+ }
86
+ React.useEffect(() => {
87
+ // eslint-disable-next-line deprecation/deprecation
88
+ if (!props.componentId)
89
+ return;
90
+ return UiAdmin.onGenericUiEvent.addListener((args) => {
43
91
  const timelineArgs = args;
44
- // istanbul ignore else
45
92
  if (!timelineArgs ||
46
- this.props.componentId !== timelineArgs.uiComponentId ||
93
+ // eslint-disable-next-line deprecation/deprecation
94
+ props.componentId !== timelineArgs.uiComponentId ||
47
95
  timelineArgs.timelineAction === undefined)
48
96
  return;
49
- let startPlaying;
50
97
  switch (timelineArgs.timelineAction) {
51
98
  case TimelinePausePlayAction.Play:
52
- startPlaying = true;
99
+ playOrReplay();
53
100
  break;
54
101
  case TimelinePausePlayAction.Pause:
55
- startPlaying = false;
102
+ pause();
56
103
  break;
57
104
  case TimelinePausePlayAction.Toggle:
58
- startPlaying = !this.state.isPlaying;
105
+ if (isPlaying) {
106
+ pause();
107
+ }
108
+ else {
109
+ playOrReplay();
110
+ }
59
111
  break;
60
- // istanbul ignore next
61
- default:
62
- return; // throw error?
63
- }
64
- if (startPlaying)
65
- this._onPlay();
66
- else
67
- this._onPause();
68
- };
69
- // user clicked backward button
70
- this._onBackward = () => {
71
- // istanbul ignore else
72
- if (this.props.onJump)
73
- this.props.onJump(false);
74
- };
75
- // user clicked forward button
76
- this._onForward = () => {
77
- // istanbul ignore else
78
- if (this.props.onJump)
79
- this.props.onJump(true);
80
- };
81
- // user clicked play button
82
- this._onPlay = () => {
83
- // istanbul ignore if
84
- if (this.state.isPlaying)
85
- return;
86
- // timeline was complete, restart from the beginning
87
- if (this.state.currentDuration >= this.state.totalDuration) {
88
- this._replay();
89
- }
90
- else
91
- this._play();
92
- // istanbul ignore else
93
- if (this.props.onPlayPause)
94
- this.props.onPlayPause(true);
95
- };
96
- // user clicked pause button
97
- this._onPause = () => {
98
- // istanbul ignore if
99
- if (!this.state.isPlaying)
100
- return;
101
- // stop requesting frames
102
- window.cancelAnimationFrame(this._requestFrame);
103
- // stop playing
104
- this.setState({ isPlaying: false });
105
- // istanbul ignore else
106
- if (this.props.onPlayPause)
107
- this.props.onPlayPause(false);
108
- };
109
- // user clicked on timeline rail or dragged scrubber handle
110
- this._onTimelineChange = (values) => {
111
- const currentDuration = values[0];
112
- this._setDuration(currentDuration);
113
- };
114
- // set the current duration, which will call the OnChange callback
115
- this._setDuration = (currentDuration, updatedTotal) => {
116
- const actualDuration = Math.min(updatedTotal ?? this.state.totalDuration, Math.max(currentDuration, 0));
117
- this._timeLastCycle = new Date().getTime();
118
- // istanbul ignore else
119
- if (!this._unmounted)
120
- this.setState({ currentDuration: actualDuration });
121
- // istanbul ignore else
122
- if (this.props.onChange) {
123
- const fraction = actualDuration / (updatedTotal ?? this.state.totalDuration);
124
- this.props.onChange(fraction);
125
112
  }
126
- };
127
- // recursively update the animation until we hit the end or the pause button is clicked
128
- this._updateAnimation = (_timestamp) => {
129
- // istanbul ignore else
130
- if (!this.state.isPlaying && !this._unmounted) {
131
- return;
132
- }
133
- // update duration
134
- const currentTime = new Date().getTime();
135
- const millisecondsElapsed = currentTime - this._timeLastCycle;
136
- const duration = this.state.currentDuration + millisecondsElapsed;
137
- this._setDuration(duration);
138
- // stop the animation!
139
- if (duration >= this.state.totalDuration) {
140
- window.cancelAnimationFrame(this._requestFrame);
141
- this.setState({ isPlaying: false });
142
- if (this.state.repeat)
143
- this._replay();
144
- else {
145
- // istanbul ignore else
146
- if (this.props.onPlayPause)
147
- this.props.onPlayPause(false);
148
- }
113
+ });
114
+ // eslint-disable-next-line deprecation/deprecation
115
+ }, [isPlaying, pause, playOrReplay, props.componentId]);
116
+ useAnimation(({ delta }) => {
117
+ const duration = currentDuration + delta;
118
+ updateDuration(duration);
119
+ if (duration >= totalDuration) {
120
+ if (repeat) {
121
+ setCurrentDuration(0);
149
122
  return;
150
123
  }
151
- // continue the animation - request the next frame
152
- this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
153
- };
154
- this._replay = () => {
155
- // timeline was complete, restart from the beginning
156
- this.setState({ currentDuration: 0 }, () => this._play());
157
- };
158
- // user changed the total duration
159
- this._onTotalDurationChange = (value) => {
160
- // NOTE: we should reset the current duration to 0
161
- const milliseconds = this._getMilliseconds(value);
162
- this._onSetTotalDuration(milliseconds);
163
- };
164
- this._changeRepeatSetting = (newValue) => {
165
- // istanbul ignore else
166
- if (newValue !== undefined) {
167
- this.setState(() => ({ repeat: newValue }), () => {
168
- // istanbul ignore else
169
- if (this.props.onSettingsChange) {
170
- this.props.onSettingsChange({ loop: this.state.repeat });
171
- }
172
- });
173
- }
174
- };
175
- this._onRepeatChanged = () => {
176
- this.setState((prevState) => ({ repeat: !prevState.repeat }), () => {
177
- // istanbul ignore else
178
- if (this.props.onSettingsChange) {
179
- this.props.onSettingsChange({ loop: this.state.repeat });
180
- }
181
- });
182
- };
183
- this._currentDate = () => {
184
- const fraction = this.state.currentDuration / this.state.totalDuration;
185
- if (this.props.endDate && this.props.startDate) {
186
- const timeElapsed = (this.props.endDate.getTime() - this.props.startDate.getTime()) *
187
- fraction;
188
- return new Date(this.props.startDate.getTime() + timeElapsed);
189
- }
190
- return new Date();
191
- };
192
- this._onSetTotalDuration = (milliseconds) => {
193
- this.setState({ totalDuration: milliseconds }, () => {
194
- // istanbul ignore else
195
- if (this.props.onSettingsChange) {
196
- this.props.onSettingsChange({ duration: milliseconds });
197
- }
198
- });
199
- };
200
- this._renderSettings = () => {
201
- const createMenuItemNodes = (close) => {
202
- const { totalDuration } = this.state;
203
- let contextMenuItems = [];
204
- if (!this.props.appMenuItems) {
205
- contextMenuItems = this._standardTimelineMenuItems;
206
- }
207
- else {
208
- if (this.props.appMenuItemOption === "append") {
209
- contextMenuItems = this._standardTimelineMenuItems.concat(this.props.appMenuItems);
210
- }
211
- else if (this.props.appMenuItemOption === "prefix") {
212
- contextMenuItems = this.props.appMenuItems.concat(this._standardTimelineMenuItems);
213
- }
214
- else {
215
- contextMenuItems = this.props.appMenuItems;
216
- }
217
- }
218
- const itemNodes = [];
219
- let keyIndex = 0;
220
- if (this.state.includeRepeat) {
221
- const checked = this.state.repeat;
222
- const icon = checked ? (React.createElement("span", { className: "icon" },
223
- React.createElement(Icon, { iconSpec: React.createElement(SvgCheckmark, null) }),
224
- " ")) : (React.createElement("span", null));
225
- itemNodes.push(React.createElement(MenuItem, { key: ++keyIndex, onClick: () => {
226
- this._onRepeatChanged();
227
- close();
228
- }, startIcon: icon }, this._repeatLabel));
229
- itemNodes.push(React.createElement(MenuDivider, { key: ++keyIndex }));
230
- }
231
- contextMenuItems.forEach((item, index) => {
232
- itemNodes.push(this._createMenuItemNode(item, index + keyIndex + 1, totalDuration, close));
233
- });
234
- return itemNodes;
235
- };
236
- return (React.createElement(DropdownMenu, { menuItems: createMenuItemNodes, placement: "top-start" },
237
- React.createElement("span", { "data-testid": "timeline-settings", className: "timeline-settings icon", role: "button", tabIndex: -1, title: UiComponents.translate("button.label.settings") },
238
- React.createElement(Icon, { iconSpec: React.createElement(SvgMoreVertical, null) }))));
239
- };
240
- this.state = {
241
- isPlaying: false,
242
- minimized: true,
243
- currentDuration: props.initialDuration
244
- ? props.initialDuration
245
- : /* istanbul ignore next */ 0,
246
- totalDuration: this.props.totalDuration,
247
- repeat: this.props.repeat ? true : false,
248
- includeRepeat: this.props.includeRepeat || this.props.includeRepeat === undefined
249
- ? true
250
- : false,
251
- };
252
- this._repeatLabel = UiIModelComponents.translate("timeline.repeat");
253
- // istanbul ignore else
254
- if (this.props.componentId) {
255
- // can't handle an event if we have no id
256
- this._removeListener = UiAdmin.onGenericUiEvent.addListener(this._handleTimelinePausePlayEvent);
124
+ pause();
257
125
  }
258
- }
259
- componentWillUnmount() {
260
- if (this._removeListener)
261
- this._removeListener();
262
- window.cancelAnimationFrame(this._requestFrame);
263
- this._unmounted = true;
264
- }
265
- shouldComponentUpdate(nextProps, nextState) {
266
- let result = false;
267
- // istanbul ignore next
268
- if (nextState !== this.state ||
269
- nextProps !== this.props ||
270
- nextProps.startDate !== this.props.startDate ||
271
- nextProps.endDate !== this.props.endDate ||
272
- nextProps.initialDuration !== this.props.initialDuration ||
273
- nextProps.repeat !== this.props.repeat)
274
- result = true;
275
- return result;
276
- }
277
- componentDidUpdate(prevProps) {
278
- // istanbul ignore else
279
- if (this.props.initialDuration !== prevProps.initialDuration) {
280
- this._setDuration(this.props.initialDuration
281
- ? this.props.initialDuration
282
- : /* istanbul ignore next */ 0, this.props.totalDuration !== prevProps.totalDuration
283
- ? this.props.totalDuration
284
- : undefined);
126
+ }, isPlaying);
127
+ React.useEffect(() => {
128
+ if (props.isPlaying)
129
+ playOrReplay();
130
+ if (props.isPlaying === false)
131
+ pause();
132
+ }, [props.isPlaying, playOrReplay, pause]);
133
+ const onTimelineChange = (values) => {
134
+ const newDuration = values[0];
135
+ updateDuration(newDuration);
136
+ };
137
+ const currentDurationStr = toDisplayTime(currentDuration);
138
+ const totalDurationStr = toDisplayTime(totalDuration);
139
+ const hasDates = !!startDate && !!endDate;
140
+ return (React.createElement("div", { "data-testid": "timeline-component", className: "timeline-component" },
141
+ React.createElement(PlayButton, { isPlaying: isPlaying, onPlay: playOrReplay, onPause: pause }),
142
+ React.createElement("div", { className: "time-container" },
143
+ hasDates && (React.createElement("span", { "data-testid": "test-start-date", className: "timeline-date" }, toDateString(startDate, timeZoneOffset, dateFormatOptions))),
144
+ hasDates && !showDuration && (React.createElement("span", { "data-testid": "test-start-time", className: "timeline-time" }, toTimeString(startDate, timeZoneOffset, timeFormatOptions))),
145
+ showDuration && (React.createElement("span", { className: "timeline-duration-time" }, currentDurationStr))),
146
+ React.createElement(Scrubber, { className: "slider", currentDuration: currentDuration, totalDuration: totalDuration, startDate: startDate, endDate: endDate, isPlaying: isPlaying, showTime: !showDuration, onChange: onTimelineChange, onUpdate: onTimelineChange, timeZoneOffset: props.timeZoneOffset, markDate: props.markDate }),
147
+ React.createElement("div", { className: "time-container" },
148
+ hasDates && (React.createElement("span", { "data-testid": "test-end-date", className: "timeline-date" }, toDateString(endDate, timeZoneOffset))),
149
+ hasDates && !showDuration && (React.createElement("span", { className: "timeline-time" }, toTimeString(endDate, timeZoneOffset, timeFormatOptions))),
150
+ showDuration && (React.createElement(InlineEdit, { className: "timeline-duration-time", defaultValue: totalDurationStr, onChange: (value) => {
151
+ const newTotalDuration = timeToMs(value);
152
+ updateTotalDuration(newTotalDuration);
153
+ } }))),
154
+ React.createElement(SettingsMenu, { appMenuItems: props.appMenuItems, appMenuItemOption: appMenuItemOption, includeRepeat: includeRepeat, repeat: repeat, totalDuration: totalDuration, onRepeatClick: () => {
155
+ updateRepeat(!repeat);
156
+ }, onTotalDurationChange: (newTotalDuration) => {
157
+ updateTotalDuration(newTotalDuration);
158
+ } })));
159
+ }
160
+ function SettingsMenu({ appMenuItems, appMenuItemOption, includeRepeat, repeat, totalDuration, onRepeatClick, onTotalDurationChange, }) {
161
+ const { translate } = useTranslation();
162
+ const menuItems = React.useMemo(() => {
163
+ const standardItems = [
164
+ {
165
+ label: translate("timeline.slow"),
166
+ timelineDuration: slowSpeed,
167
+ },
168
+ {
169
+ label: translate("timeline.medium"),
170
+ timelineDuration: mediumSpeed,
171
+ },
172
+ {
173
+ label: translate("timeline.fast"),
174
+ timelineDuration: fastSpeed,
175
+ },
176
+ ];
177
+ if (!appMenuItems) {
178
+ return standardItems;
285
179
  }
286
- // istanbul ignore else
287
- if (this.props.repeat !== prevProps.repeat) {
288
- this._changeRepeatSetting(this.props.repeat);
180
+ if (appMenuItemOption === "append") {
181
+ return [...standardItems, ...appMenuItems];
289
182
  }
290
- // istanbul ignore else
291
- if (this.props.totalDuration !== prevProps.totalDuration) {
292
- this._onSetTotalDuration(this.props.totalDuration);
183
+ if (appMenuItemOption === "prefix") {
184
+ return [...appMenuItems, ...standardItems];
293
185
  }
294
- }
295
- _play() {
296
- // start playing
297
- this.setState({ isPlaying: true }, () => {
298
- // request the next frame
299
- this._timeLastCycle = new Date().getTime();
300
- this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
301
- });
302
- }
303
- _displayTime(millisec) {
304
- const addZero = (i) => {
305
- return i < 10 ? `0${i}` : i;
186
+ // Replace
187
+ return appMenuItems;
188
+ }, [appMenuItemOption, appMenuItems, translate]);
189
+ return (React.createElement(DropdownMenu, { menuItems: (close) => {
190
+ return [
191
+ ...(includeRepeat
192
+ ? [
193
+ React.createElement(MenuItem, { key: "repeat", onClick: () => {
194
+ onRepeatClick();
195
+ close();
196
+ }, startIcon: repeat ? React.createElement(SvgCheckmark, null) : React.createElement(React.Fragment, null) }, translate("timeline.repeat")),
197
+ React.createElement(MenuDivider, { key: "divider" }),
198
+ ]
199
+ : []),
200
+ ...menuItems.map((item, index) => {
201
+ const checked = totalDuration === item.timelineDuration;
202
+ return (React.createElement(MenuItem, { key: index, startIcon: checked ? React.createElement(SvgCheckmark, null) : React.createElement(React.Fragment, null), onClick: () => {
203
+ onTotalDurationChange(item.timelineDuration);
204
+ close();
205
+ } }, item.label));
206
+ }),
207
+ ];
208
+ }, placement: "top-start" },
209
+ React.createElement(IconButton, { "data-testid": "timeline-settings", label: translate("button.label.settings"), styleType: "borderless" },
210
+ React.createElement(SvgMoreVertical, null))));
211
+ }
212
+ function useAnimation(onAnimate, playing = true) {
213
+ const onAnimateRef = React.useRef(onAnimate);
214
+ onAnimateRef.current = onAnimate;
215
+ const lastTimeRef = React.useRef();
216
+ React.useEffect(() => {
217
+ if (!playing)
218
+ return;
219
+ let handle = 0;
220
+ let didCancel = false;
221
+ const animate = (time) => {
222
+ if (lastTimeRef.current === undefined) {
223
+ lastTimeRef.current = time;
224
+ }
225
+ const delta = time - lastTimeRef.current;
226
+ lastTimeRef.current = time;
227
+ onAnimateRef.current({
228
+ delta,
229
+ });
230
+ if (didCancel)
231
+ return;
232
+ handle = window.requestAnimationFrame(animate);
306
233
  };
307
- const date = new Date(millisec);
308
- // const hours = date.getUTCHours();
309
- const minutes = date.getUTCMinutes();
310
- const seconds = date.getUTCSeconds();
311
- return `${addZero(minutes)}:${addZero(seconds)}`;
312
- }
313
- _getMilliseconds(time) {
314
- // istanbul ignore else - WIP
315
- if (time.indexOf(":") !== -1) {
316
- return ((Number(time.split(":")[0]) * 60 + Number(time.split(":")[1])) * 1000);
317
- }
318
- else {
319
- return Number(time) * 1000;
320
- }
321
- }
322
- _createMenuItemNode(item, index, currentTimelineDuration, close) {
323
- const label = item.label;
324
- const checked = currentTimelineDuration === item.timelineDuration;
325
- const icon = checked ? (React.createElement("span", { className: "icon" },
326
- React.createElement(Icon, { iconSpec: React.createElement(SvgCheckmark, null) }),
327
- " ")) : (React.createElement("span", null));
328
- return (React.createElement(MenuItem, { key: index, startIcon: icon, onClick: () => {
329
- this._onSetTotalDuration(item.timelineDuration);
330
- close();
331
- } }, label));
234
+ handle = window.requestAnimationFrame(animate);
235
+ return () => {
236
+ didCancel = true;
237
+ lastTimeRef.current = undefined;
238
+ window.cancelAnimationFrame(handle);
239
+ };
240
+ }, [playing]);
241
+ }
242
+ function timeToMs(time) {
243
+ if (time.indexOf(":") !== -1) {
244
+ return ((Number(time.split(":")[0]) * 60 + Number(time.split(":")[1])) * 1000);
332
245
  }
333
- render() {
334
- const { startDate, endDate, showDuration, timeZoneOffset, dateFormatOptions, timeFormatOptions, } = this.props;
335
- const { currentDuration, totalDuration, minimized } = this.state;
336
- const currentDate = this._currentDate();
337
- const durationString = this._displayTime(currentDuration);
338
- const totalDurationString = this._displayTime(totalDuration);
339
- const hasDates = !!startDate && !!endDate;
340
- return (React.createElement("div", { "data-testid": "timeline-component", className: classnames("timeline-component", !!minimized && "minimized", hasDates && "has-dates") },
341
- React.createElement("div", { className: "header" },
342
- React.createElement(PlayButton, { className: "play-button", isPlaying: this.state.isPlaying, onPlay: this._onPlay, onPause: this._onPause, "data-testid": "timeline-play" }),
343
- React.createElement(PlayerButton, { className: "play-backward", icon: React.createElement(SvgCaretLeft, null), onClick: this._onBackward, title: UiIModelComponents.translate("timeline.backward") }),
344
- React.createElement(PlayerButton, { className: "play-button-step", icon: React.createElement(SvgPlayCircular, null), isPlaying: this.state.isPlaying, onPlay: this._onPlay, onPause: this._onPause, title: UiIModelComponents.translate("timeline.step") }),
345
- React.createElement(PlayerButton, { className: "play-forward", icon: React.createElement(SvgCaretRight, null), onClick: this._onForward, title: UiIModelComponents.translate("timeline.backward") }),
346
- React.createElement("span", { className: "current-date" }, toDateString(currentDate, timeZoneOffset, dateFormatOptions))),
347
- React.createElement("div", { className: "scrubber" },
348
- React.createElement(PlayButton, { className: "play-button", isPlaying: this.state.isPlaying, onPlay: this._onPlay, onPause: this._onPause }),
349
- React.createElement("div", { className: "start-time-container" },
350
- hasDates && (React.createElement("span", { "data-testid": "test-start-date", className: "start-date" }, toDateString(startDate, timeZoneOffset, dateFormatOptions))),
351
- hasDates && !showDuration && (React.createElement("span", { "data-testid": "test-start-time", className: "start-time" }, toTimeString(startDate, timeZoneOffset, timeFormatOptions))),
352
- showDuration && (React.createElement("span", { className: "duration-start-time" }, durationString))),
353
- React.createElement(Scrubber, { className: "slider", currentDuration: this.state.currentDuration, totalDuration: totalDuration, startDate: startDate, endDate: endDate, isPlaying: this.state.isPlaying, inMiniMode: !!minimized, showTime: !showDuration, onChange: this._onTimelineChange, onUpdate: this._onTimelineChange, timeZoneOffset: this.props.timeZoneOffset, markDate: this.props.markDate }),
354
- React.createElement("div", { className: "end-time-container" },
355
- hasDates && (React.createElement("span", { className: "end-date" }, toDateString(endDate, timeZoneOffset))),
356
- hasDates && !showDuration && (React.createElement("span", { className: "end-time" }, toTimeString(endDate, timeZoneOffset, timeFormatOptions))),
357
- showDuration && (React.createElement(InlineEdit, { className: "duration-end-time", defaultValue: totalDurationString, onChange: this._onTotalDurationChange }))),
358
- minimized && this._renderSettings())));
246
+ else {
247
+ return Number(time) * 1000;
359
248
  }
360
249
  }
250
+ function toDisplayTime(ms) {
251
+ const addZero = (i) => {
252
+ return i < 10 ? `0${i}` : i;
253
+ };
254
+ const date = new Date(ms);
255
+ // const hours = date.getUTCHours();
256
+ const minutes = date.getUTCMinutes();
257
+ const seconds = date.getUTCSeconds();
258
+ return `${addZero(minutes)}:${addZero(seconds)}`;
259
+ }
361
260
  //# sourceMappingURL=TimelineComponent.js.map