@itwin/imodel-components-react 4.0.0-dev.11 → 4.0.0-dev.13

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 (354) hide show
  1. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js +75 -79
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +190 -186
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +112 -108
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  14. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +78 -74
  15. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  16. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  17. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +149 -145
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +143 -139
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  23. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  24. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
  25. package/lib/cjs/imodel-components-react/color/HueSlider.js +203 -199
  26. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  27. package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
  28. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  29. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +217 -213
  30. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  31. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  32. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  33. package/lib/cjs/imodel-components-react/color/Swatch.js +64 -60
  34. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -22
  36. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  37. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  38. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  39. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  40. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +155 -151
  41. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  43. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  44. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +164 -160
  45. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  47. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  48. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +100 -96
  49. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  51. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  52. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +272 -268
  53. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  55. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  56. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +89 -85
  57. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  58. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  59. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  60. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +163 -159
  61. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +51 -52
  63. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  64. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +131 -127
  65. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  66. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  67. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +175 -174
  68. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +650 -638
  70. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  72. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  73. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +657 -653
  74. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  75. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  76. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  77. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +103 -99
  78. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +59 -63
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +56 -53
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +88 -84
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +89 -86
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +112 -109
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  93. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +133 -133
  94. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  96. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +187 -184
  97. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  99. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +149 -145
  100. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  101. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  102. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +63 -59
  103. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  104. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +51 -47
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +58 -54
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +52 -48
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +54 -50
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +62 -58
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +51 -47
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +60 -56
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +98 -95
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  128. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  129. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +123 -119
  130. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  131. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  132. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +143 -143
  133. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  134. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  135. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  136. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  137. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  138. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +85 -81
  139. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  140. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  141. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  142. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +99 -95
  143. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  144. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -28
  145. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  146. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +195 -191
  147. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  148. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -105
  149. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  150. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +432 -428
  151. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  152. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  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/SpeedTimeline.scss +39 -39
  157. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  158. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  159. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  160. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +398 -365
  161. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  162. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +178 -161
  163. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +174 -174
  164. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  165. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  166. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  167. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  168. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  169. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +276 -274
  170. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  171. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  172. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  173. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  174. package/lib/cjs/imodel-components-react.d.ts +82 -82
  175. package/lib/cjs/imodel-components-react.js +105 -101
  176. package/lib/cjs/imodel-components-react.js.map +1 -1
  177. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  178. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  179. package/lib/esm/imodel-components-react/UiIModelComponents.js +72 -75
  180. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  181. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  182. package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
  183. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  184. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
  185. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  186. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +83 -83
  187. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  188. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  189. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  190. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
  191. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  192. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  193. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +122 -122
  194. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  195. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  196. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  197. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +114 -114
  198. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  199. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  200. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  201. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  202. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  203. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  204. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  205. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  206. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  207. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  208. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  209. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  210. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  211. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -22
  212. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  213. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  214. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  215. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  216. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  217. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  218. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  219. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  220. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  221. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  222. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  223. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  224. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  225. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  226. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  227. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  228. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +243 -243
  229. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  230. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  231. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  232. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  233. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  234. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  235. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  236. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +134 -133
  237. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  238. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +51 -52
  239. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  240. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  241. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  242. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  243. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +175 -174
  244. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  245. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +620 -610
  246. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  247. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  248. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  249. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +627 -626
  250. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  251. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  252. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  253. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  254. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  255. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +59 -63
  256. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  257. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +29 -30
  258. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  259. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  260. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +61 -61
  261. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  262. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  263. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +62 -63
  264. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  265. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  266. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +82 -83
  267. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  268. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  269. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +106 -110
  270. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  271. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  272. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +157 -158
  273. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  274. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  275. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +122 -122
  276. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  277. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  278. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  279. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  280. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  281. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  282. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  283. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  284. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  285. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  286. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  287. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  288. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  289. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  290. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  291. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  292. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  293. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  294. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  295. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  296. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  297. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  298. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  299. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  300. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  301. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  302. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +68 -69
  303. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  304. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  305. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  306. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  307. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  308. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +139 -139
  309. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  310. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  311. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  312. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  313. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  314. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  315. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  316. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  317. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  318. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +68 -68
  319. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  320. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -28
  321. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  322. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  323. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  324. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -105
  325. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  326. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +402 -402
  327. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  328. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  329. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  330. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  331. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  332. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  333. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  334. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +130 -133
  335. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  336. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +368 -339
  337. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  338. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +178 -161
  339. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +174 -174
  340. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
  341. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  342. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  343. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  344. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  345. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +249 -251
  346. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  347. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  348. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +96 -95
  349. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  350. package/lib/esm/imodel-components-react.d.ts +82 -82
  351. package/lib/esm/imodel-components-react.js +87 -87
  352. package/lib/esm/imodel-components-react.js.map +1 -1
  353. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  354. package/package.json +24 -28
@@ -1,403 +1,403 @@
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
- // component is in alpha state - it may change after usability testing - test coverage not complete
9
- /* istanbul ignore file */
10
- import "./SolarTimeline.scss";
11
- import classnames from "classnames";
12
- import * as React from "react";
13
- import { Slider, Text, Tooltip } from "@itwin/itwinui-react";
14
- import { ColorByName, ColorDef } from "@itwin/core-common";
15
- import { RelativePosition, TimeDisplay } from "@itwin/appui-abstract";
16
- import { Icon, Popup } from "@itwin/core-react";
17
- import { adjustDateToTimezone, DatePicker, TimeField, UiComponents } from "@itwin/components-react";
18
- import { HueSlider } from "../color/HueSlider";
19
- import { SaturationPicker } from "../color/SaturationPicker";
20
- import { ColorSwatch } from "../color/Swatch";
21
- import { PlayButton } from "./PlayerButton";
22
- import { SpeedTimeline } from "./SpeedTimeline";
23
- import { CustomThumb, getPercentageOfRectangle, RailMarkers, useFocusedThumb } from "./Scrubber";
24
- import { UiIModelComponents } from "../UiIModelComponents";
25
- import { SvgCalendar, SvgLoop, SvgSettings } from "@itwin/itwinui-icons-react";
26
- // cSpell:ignore millisec solarsettings showticks shadowcolor solartimeline datepicker millisecs
27
- const millisecPerMinute = 1000 * 60;
28
- const millisecPerHour = millisecPerMinute * 60;
29
- // const millisecPerDay = millisecPerHour * 24;
30
- const defaultPlaybackDuration = 40 * 1000; // 40 seconds
31
- const addZero = (i) => {
32
- return (i < 10) ? `0${i}` : i;
33
- };
34
- function Timeline(props) {
35
- const sliderRef = React.useRef(null);
36
- const [sliderContainer, setSliderContainer] = React.useState();
37
- const [pointerPercent, setPointerPercent] = React.useState(0);
38
- React.useLayoutEffect(() => {
39
- // istanbul ignore else
40
- if (sliderRef.current) {
41
- const container = sliderRef.current.querySelector(".iui-slider-container");
42
- if (container && sliderContainer !== container) {
43
- setSliderContainer(container);
44
- }
45
- }
46
- }, [sliderContainer]);
47
- const thumbProps = () => {
48
- return {
49
- className: "components-timeline-thumb",
50
- children: React.createElement(CustomThumb, null),
51
- };
52
- };
53
- const tooltipProps = React.useCallback(() => {
54
- return { visible: false };
55
- }, []);
56
- const [showRailTooltip, setShowRailTooltip] = React.useState(false);
57
- const handlePointerEnter = React.useCallback(() => {
58
- setShowRailTooltip(true);
59
- }, []);
60
- const handlePointerLeave = React.useCallback(() => {
61
- setShowRailTooltip(false);
62
- }, []);
63
- const handlePointerMove = React.useCallback((event) => {
64
- sliderContainer &&
65
- setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
66
- }, [sliderContainer]);
67
- const { formatTick, formatTime, onChange, onUpdate, dayStartMs, sunSetOffsetMs, sunRiseOffsetMs, currentTimeOffsetMs, isPlaying } = props;
68
- const thumbHasFocus = useFocusedThumb(sliderContainer);
69
- const tickLabel = React.useMemo(() => {
70
- const showTip = isPlaying || showRailTooltip || thumbHasFocus;
71
- const totalDuration = sunSetOffsetMs - sunRiseOffsetMs;
72
- const percent = (isPlaying || thumbHasFocus) ? (currentTimeOffsetMs - sunRiseOffsetMs) / totalDuration : pointerPercent;
73
- const tooltipText = formatTime((isPlaying || thumbHasFocus) ? (dayStartMs + currentTimeOffsetMs) : (dayStartMs + (sunRiseOffsetMs + (pointerPercent * totalDuration))));
74
- return (React.createElement(RailMarkers, { showToolTip: showTip, percent: percent, tooltipText: tooltipText }));
75
- }, [isPlaying, showRailTooltip, thumbHasFocus, sunSetOffsetMs, sunRiseOffsetMs, currentTimeOffsetMs, pointerPercent, formatTime, dayStartMs]);
76
- const className = classnames("solar-slider", props.className, formatTick && "showticks");
77
- const sunRiseFormat = formatTime(dayStartMs + sunRiseOffsetMs);
78
- const sunSetFormat = formatTime(dayStartMs + sunSetOffsetMs);
79
- return (React.createElement("div", { className: className },
80
- React.createElement(Tooltip, { content: sunRiseFormat },
81
- React.createElement("span", { className: "sunrise" }, "\u2600")),
82
- React.createElement(Slider, { ref: sliderRef, className: className, step: millisecPerMinute, min: sunRiseOffsetMs, max: sunSetOffsetMs, minLabel: "", maxLabel: "", onUpdate: onUpdate, onChange: onChange, values: [currentTimeOffsetMs], tooltipProps: tooltipProps, thumbProps: thumbProps, tickLabels: tickLabel, railContainerProps: {
83
- onPointerEnter: handlePointerEnter,
84
- onPointerMove: handlePointerMove,
85
- onPointerLeave: handlePointerLeave,
86
- } }),
87
- React.createElement(Tooltip, { content: sunSetFormat },
88
- React.createElement("span", { className: "sunset" }, "\u263D"))));
89
- }
90
- /** Solar Timeline
91
- * @alpha
92
- */
93
- export class SolarTimeline extends React.PureComponent {
94
- constructor(props) {
95
- super(props);
96
- this._datePicker = null;
97
- this._settings = null;
98
- this._requestFrame = 0;
99
- this._unmounted = false;
100
- this._timeLastCycle = 0;
101
- this._totalPlayTime = 0;
102
- this._settingsPopupTitle = UiIModelComponents.translate("solarsettings.shadowcolor");
103
- this._playLabel = UiIModelComponents.translate("solartimeline.play");
104
- this._settingLabel = UiIModelComponents.translate("solartimeline.settings");
105
- this._loopLabel = UiIModelComponents.translate("timeline.repeat");
106
- this._speedLabel = UiIModelComponents.translate("solartimeline.speed");
107
- this._dateTimeLabel = UiIModelComponents.translate("solartimeline.dateTime");
108
- this._months = [
109
- UiComponents.translate("month.short.january"),
110
- UiComponents.translate("month.short.february"),
111
- UiComponents.translate("month.short.march"),
112
- UiComponents.translate("month.short.april"),
113
- UiComponents.translate("month.short.may"),
114
- UiComponents.translate("month.short.june"),
115
- UiComponents.translate("month.short.july"),
116
- UiComponents.translate("month.short.august"),
117
- UiComponents.translate("month.short.september"),
118
- UiComponents.translate("month.short.october"),
119
- UiComponents.translate("month.short.november"),
120
- UiComponents.translate("month.short.december"),
121
- ];
122
- this._timeLabel = UiComponents.translate("datepicker.time");
123
- this._amLabel = UiComponents.translate("time.am");
124
- this._pmLabel = UiComponents.translate("time.pm");
125
- this._presetColors = [
126
- ColorDef.create(ColorByName.grey),
127
- ColorDef.create(ColorByName.lightGrey),
128
- ColorDef.create(ColorByName.darkGrey),
129
- ColorDef.create(ColorByName.lightBlue),
130
- ColorDef.create(ColorByName.lightGreen),
131
- ColorDef.create(ColorByName.darkGreen),
132
- ColorDef.create(ColorByName.tan),
133
- ColorDef.create(ColorByName.darkBrown),
134
- ];
135
- // recursively update the animation until we hit the end or the pause button is clicked
136
- this._updateAnimation = (_timestamp) => {
137
- // istanbul ignore else
138
- if (!this.state.isPlaying || this._unmounted) {
139
- window.cancelAnimationFrame(this._requestFrame);
140
- return;
141
- }
142
- const currentTime = new Date().getTime();
143
- this._totalPlayTime += (currentTime - this._timeLastCycle);
144
- this._timeLastCycle = currentTime;
145
- let percentComplete = this._totalPlayTime / this.state.adjustedDuration;
146
- if (percentComplete > 1)
147
- percentComplete = 1;
148
- let newPlayingState = true;
149
- // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider
150
- let nextSunOffset = Math.floor(this.state.sunRiseOffsetMs + (percentComplete * this.state.sunDeltaMs));
151
- if (percentComplete > 0.99) {
152
- if (!this.state.loop) {
153
- newPlayingState = false;
154
- nextSunOffset = this.state.sunSetOffsetMs;
155
- window.cancelAnimationFrame(this._requestFrame);
156
- }
157
- else {
158
- nextSunOffset = this.state.sunRiseOffsetMs;
159
- this._totalPlayTime = 0;
160
- }
161
- }
162
- if (this.props.dataProvider.onTimeChanged) {
163
- const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);
164
- this.props.dataProvider.onTimeChanged(currentSunTime);
165
- }
166
- this.setState({ isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset }, () => {
167
- if (newPlayingState)
168
- this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
169
- });
170
- };
171
- // user clicked pause button
172
- this._onPause = () => {
173
- // istanbul ignore if
174
- if (!this.state.isPlaying)
175
- return;
176
- const currentTime = new Date().getTime();
177
- this._totalPlayTime += (currentTime - this._timeLastCycle);
178
- // stop requesting frames
179
- window.cancelAnimationFrame(this._requestFrame);
180
- // stop playing
181
- this.setState({ isPlaying: false });
182
- // istanbul ignore else
183
- if (this.props.onPlayPause)
184
- this.props.onPlayPause(false);
185
- };
186
- // user clicked play button
187
- this._onPlay = () => {
188
- // istanbul ignore if
189
- if (this.state.isPlaying)
190
- return;
191
- if (this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs || this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs) {
192
- this._totalPlayTime = 0;
193
- this._play(this.state.sunRiseOffsetMs);
194
- }
195
- else {
196
- this._play(this.state.currentTimeOffsetMs);
197
- }
198
- };
199
- /** note the day passed in is in the time of the current user not in project time because the date picker works in
200
- * local time */
201
- this._onDayClick = (day) => {
202
- const selectedDate = new Date(day.getTime() + this.state.currentTimeOffsetMs);
203
- this.props.dataProvider.setDateAndTime(selectedDate);
204
- const dayStartMs = this.props.dataProvider.dayStartMs;
205
- const sunRiseOffsetMs = this.props.dataProvider.sunrise.getTime() - dayStartMs;
206
- const sunSetOffsetMs = this.props.dataProvider.sunset.getTime() - dayStartMs;
207
- const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;
208
- const sunOffsetMs = this.ensureRange(this.state.currentTimeOffsetMs, sunRiseOffsetMs, sunSetOffsetMs);
209
- this.setPlaybackTimeBySunTime(sunOffsetMs, sunRiseOffsetMs, sunDeltaMs);
210
- /** call dataProvider to update display style */
211
- if (this.props.dataProvider.onTimeChanged)
212
- this.props.dataProvider.onTimeChanged(this.props.dataProvider.timeOfDay);
213
- this.setState({ dayStartMs, sunRiseOffsetMs, sunSetOffsetMs, currentTimeOffsetMs: sunOffsetMs, sunDeltaMs, isDateOpened: false }, () => {
214
- this._timeLastCycle = new Date().getTime();
215
- });
216
- };
217
- this._onTimeChanged = (time) => {
218
- // compute the current date (with time)
219
- const dayStartMs = this.props.dataProvider.dayStartMs;
220
- const sunTime = (time.hours * millisecPerHour) + (time.minutes * millisecPerMinute);
221
- const dateWithNewTime = new Date(dayStartMs + sunTime);
222
- this.props.dataProvider.setDateAndTime(dateWithNewTime, true);
223
- // notify the provider to update style
224
- if (this.props.dataProvider.onTimeChanged)
225
- this.props.dataProvider.onTimeChanged(dateWithNewTime);
226
- const currentTimeOffsetMs = this.ensureRange(sunTime, this.state.sunRiseOffsetMs, this.state.sunSetOffsetMs);
227
- this.setPlaybackTimeBySunTime(currentTimeOffsetMs, this.state.sunRiseOffsetMs, this.state.sunDeltaMs);
228
- this._timeLastCycle = new Date().getTime();
229
- // update the timeline
230
- this.setState({ currentTimeOffsetMs });
231
- };
232
- this._onCloseDayPicker = () => {
233
- this.setState({ isDateOpened: false });
234
- };
235
- this._onOpenDayPicker = () => {
236
- this.setState((prevState) => ({ isDateOpened: !prevState.isDateOpened }));
237
- };
238
- this._onCloseSettingsPopup = () => {
239
- this.setState({ isSettingsOpened: false });
240
- };
241
- this._onOpenSettingsPopup = () => {
242
- this.setState((prevState) => ({ isSettingsOpened: !prevState.isSettingsOpened }));
243
- };
244
- this._onUpdate = (values) => {
245
- if (!this.state.isPlaying)
246
- this.processSunTimeChange(values[0]);
247
- };
248
- this._onChange = (values) => {
249
- if (!this.state.isPlaying)
250
- this.processSunTimeChange(values[0]);
251
- };
252
- this._onSpeedChange = (value) => {
253
- const adjustedDuration = this.state.duration / value;
254
- this.setState({ speed: value, adjustedDuration });
255
- };
256
- this._onToggleLoop = () => {
257
- this.setState((prevState) => ({ loop: !prevState.loop }));
258
- };
259
- this._formatTime = (millisec) => {
260
- const date = new Date(millisec);
261
- // convert project date to browser locale date
262
- const localTime = adjustDateToTimezone(date, this.props.dataProvider.timeZoneOffset * 60);
263
- let hours = localTime.getHours();
264
- const minutes = addZero(date.getMinutes());
265
- const abbrev = (hours < 12) ? this._amLabel : (hours === 24) ? this._amLabel : this._pmLabel;
266
- hours = (hours > 12) ? hours - 12 : hours;
267
- return `${hours}:${minutes} ${abbrev}`;
268
- };
269
- this._onPresetColorPick = (shadowColor) => {
270
- this.setState({ shadowColor }, () => this.props.dataProvider.shadowColor = shadowColor);
271
- };
272
- this._handleHueOrSaturationChange = (hueOrSaturation) => {
273
- if (hueOrSaturation.s === 0) // for a ColorDef to be created from hsv s can't be 0
274
- hueOrSaturation = hueOrSaturation.clone(undefined, 0.5);
275
- const shadowColor = hueOrSaturation.toColorDef();
276
- this.setState({ shadowColor }, () => this.props.dataProvider.shadowColor = shadowColor);
277
- };
278
- const dayStartMs = this.props.dataProvider.dayStartMs;
279
- const sunRiseOffsetMs = this.props.dataProvider.sunrise.getTime() - dayStartMs;
280
- const sunSetOffsetMs = this.props.dataProvider.sunset.getTime() - dayStartMs;
281
- const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;
282
- const sunOffsetMs = this.props.dataProvider.timeOfDay.getTime() - dayStartMs;
283
- const currentTimeOffsetMs = this.ensureRange(sunOffsetMs, sunRiseOffsetMs, sunSetOffsetMs);
284
- const shadowColor = this.props.dataProvider.shadowColor;
285
- const duration = this.props.duration ? this.props.duration : defaultPlaybackDuration;
286
- const speed = this.props.speed ? this.props.speed : 2;
287
- const adjustedDuration = duration / speed;
288
- this.setPlaybackTimeBySunTime(currentTimeOffsetMs, sunRiseOffsetMs, sunDeltaMs, adjustedDuration);
289
- this.state = {
290
- isDateOpened: false,
291
- isSettingsOpened: false,
292
- isPlaying: false,
293
- dayStartMs,
294
- sunRiseOffsetMs,
295
- sunSetOffsetMs,
296
- sunDeltaMs,
297
- currentTimeOffsetMs,
298
- speed,
299
- loop: false,
300
- shadowColor,
301
- duration,
302
- adjustedDuration,
303
- };
304
- }
305
- componentWillUnmount() {
306
- window.cancelAnimationFrame(this._requestFrame);
307
- this._unmounted = true;
308
- }
309
- _play(sunTimeMs) {
310
- this._timeLastCycle = new Date().getTime();
311
- // start playing
312
- this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {
313
- this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
314
- // istanbul ignore else
315
- if (this.props.onPlayPause)
316
- this.props.onPlayPause(true);
317
- });
318
- }
319
- setPlaybackTimeBySunTime(sunOffsetMs, sunRiseOffsetMs, sunDeltaMs, adjustedDuration) {
320
- this._totalPlayTime = ((sunOffsetMs - sunRiseOffsetMs) / (sunDeltaMs)) * ((adjustedDuration) ? adjustedDuration : this.state.adjustedDuration);
321
- }
322
- ensureRange(value, min, max) {
323
- return Math.max(Math.min(value, max), min);
324
- }
325
- processSunTimeChange(sunTime) {
326
- if (sunTime === this.state.currentTimeOffsetMs)
327
- return;
328
- const currentTimeOffsetMs = this.ensureRange(sunTime, this.state.sunRiseOffsetMs, this.state.sunSetOffsetMs);
329
- if (this.props.dataProvider.onTimeChanged) {
330
- const currentSunTime = new Date(this.state.dayStartMs + currentTimeOffsetMs);
331
- this.props.dataProvider.onTimeChanged(currentSunTime);
332
- }
333
- this.setState({ currentTimeOffsetMs }, () => {
334
- const currentTime = new Date().getTime();
335
- this._timeLastCycle = currentTime;
336
- const percentComplete = (currentTimeOffsetMs - this.state.sunRiseOffsetMs) / this.state.sunDeltaMs;
337
- this._totalPlayTime = percentComplete * this.state.adjustedDuration;
338
- });
339
- }
340
- getLocalTime(ticks) {
341
- const projectTime = new Date(ticks);
342
- // convert project date to browser locale date
343
- return adjustDateToTimezone(projectTime, this.props.dataProvider.timeZoneOffset * 60);
344
- }
345
- render() {
346
- const { dataProvider } = this.props;
347
- const { speed, loop, currentTimeOffsetMs, sunRiseOffsetMs, sunSetOffsetMs } = this.state;
348
- const localTime = this.getLocalTime(this.state.dayStartMs + this.state.currentTimeOffsetMs);
349
- const formattedTime = this._formatTime(dataProvider.dayStartMs + currentTimeOffsetMs);
350
- const formattedDate = `${this._months[localTime.getMonth()]}, ${localTime.getDate()}`;
351
- const colorSwatchStyle = {
352
- width: `100%`,
353
- height: `100%`,
354
- };
355
- return (React.createElement("div", { className: "solar-timeline-wrapper" },
356
- React.createElement("div", { className: "header" },
357
- React.createElement(PlayButton, { tooltip: this._playLabel, className: "play-button", isPlaying: this.state.isPlaying, onPlay: this._onPlay, onPause: this._onPause }),
358
- React.createElement("button", { "data-testid": "solar-date-time-button", title: this._dateTimeLabel, className: "current-date", ref: (element) => this._datePicker = element, onClick: this._onOpenDayPicker },
359
- React.createElement("span", null, formattedDate),
360
- React.createElement("span", null, "/"),
361
- React.createElement("span", null, formattedTime),
362
- React.createElement("span", { className: "icon" },
363
- React.createElement(Icon, { iconSpec: React.createElement(SvgCalendar, null) }))),
364
- React.createElement(Popup, { style: { border: "none" }, offset: 11, target: this._datePicker, isOpen: this.state.isDateOpened, onClose: this._onCloseDayPicker, position: RelativePosition.Top },
365
- React.createElement("div", { className: "components-date-picker-calendar-popup-panel", "data-testid": "components-date-picker-calendar-popup-panel" },
366
- React.createElement(DatePicker, { selected: localTime, onDateChange: this._onDayClick, showFocusOutline: false }),
367
- React.createElement("div", { className: "time-container" },
368
- React.createElement(Text, { variant: "body", className: "time-label" }, this._timeLabel),
369
- React.createElement(TimeField, { time: { hours: localTime.getHours(), minutes: localTime.getMinutes(), seconds: 0 }, timeDisplay: TimeDisplay.H12MC, onTimeChange: this._onTimeChanged })))),
370
- React.createElement(Timeline, { className: "solar-timeline", dayStartMs: dataProvider.dayStartMs, sunSetOffsetMs: sunSetOffsetMs, sunRiseOffsetMs: sunRiseOffsetMs, currentTimeOffsetMs: currentTimeOffsetMs, onChange: this._onChange, onUpdate: this._onUpdate, formatTime: this._formatTime, isPlaying: this.state.isPlaying }),
371
- React.createElement("div", { className: "speed-container" },
372
- React.createElement("span", { title: this._speedLabel },
373
- speed,
374
- "x"),
375
- React.createElement(SpeedTimeline, { className: "speed", onChange: this._onSpeedChange, speed: this.state.speed })),
376
- React.createElement("span", { title: this._loopLabel, className: classnames("icon", !loop && "no-loop-playback", loop && "loop-playback"), onClick: this._onToggleLoop, role: "button", tabIndex: -1 },
377
- React.createElement(Icon, { iconSpec: React.createElement(SvgLoop, null) })),
378
- React.createElement("button", { "data-testid": "shadow-settings-button", title: this._settingLabel, className: "shadow-settings-button", ref: (element) => this._settings = element, onClick: this._onOpenSettingsPopup },
379
- React.createElement("span", { className: "icon" },
380
- React.createElement(Icon, { iconSpec: React.createElement(SvgSettings, null) }))),
381
- React.createElement(Popup, { className: "shadow-settings-popup", target: this._settings, offset: 11, isOpen: this.state.isSettingsOpened, onClose: this._onCloseSettingsPopup, position: RelativePosition.Top },
382
- React.createElement("div", { className: "shadow-settings-popup-container" },
383
- React.createElement("div", { className: "shadow-settings-header" }, this._settingsPopupTitle),
384
- React.createElement("div", { className: "shadow-settings-color" },
385
- React.createElement("div", { className: "shadow-settings-color-top" },
386
- React.createElement(SaturationPicker, { hsv: this.state.shadowColor.toHSV(), onSaturationChange: this._handleHueOrSaturationChange })),
387
- React.createElement("div", { className: "shadow-settings-color-bottom" },
388
- React.createElement("div", { className: "shadow-settings-color-bottom-left" },
389
- React.createElement(HueSlider, { hsv: this.state.shadowColor.toHSV(), onHueChange: this._handleHueOrSaturationChange, isHorizontal: true })),
390
- React.createElement("div", { className: "shadow-settings-color-bottom-right" },
391
- React.createElement(ColorSwatch, { style: colorSwatchStyle, colorDef: this.state.shadowColor, round: false })))),
392
- React.createElement("div", { className: "shadow-settings-color-presets" },
393
- React.createElement(ColorSwatch, { colorDef: this._presetColors[0], round: false, onColorPick: this._onPresetColorPick }),
394
- React.createElement(ColorSwatch, { colorDef: this._presetColors[1], round: false, onColorPick: this._onPresetColorPick }),
395
- React.createElement(ColorSwatch, { colorDef: this._presetColors[2], round: false, onColorPick: this._onPresetColorPick }),
396
- React.createElement(ColorSwatch, { colorDef: this._presetColors[3], round: false, onColorPick: this._onPresetColorPick }),
397
- React.createElement(ColorSwatch, { colorDef: this._presetColors[4], round: false, onColorPick: this._onPresetColorPick }),
398
- React.createElement(ColorSwatch, { colorDef: this._presetColors[5], round: false, onColorPick: this._onPresetColorPick }),
399
- React.createElement(ColorSwatch, { colorDef: this._presetColors[6], round: false, onColorPick: this._onPresetColorPick }),
400
- React.createElement(ColorSwatch, { colorDef: this._presetColors[7], round: false, onColorPick: this._onPresetColorPick })))))));
401
- }
402
- }
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
+ // component is in alpha state - it may change after usability testing - test coverage not complete
9
+ /* istanbul ignore file */
10
+ import "./SolarTimeline.scss";
11
+ import classnames from "classnames";
12
+ import * as React from "react";
13
+ import { Slider, Text, Tooltip } from "@itwin/itwinui-react";
14
+ import { ColorByName, ColorDef } from "@itwin/core-common";
15
+ import { RelativePosition, TimeDisplay } from "@itwin/appui-abstract";
16
+ import { Icon, Popup } from "@itwin/core-react";
17
+ import { adjustDateToTimezone, DatePicker, TimeField, UiComponents } from "@itwin/components-react";
18
+ import { HueSlider } from "../color/HueSlider";
19
+ import { SaturationPicker } from "../color/SaturationPicker";
20
+ import { ColorSwatch } from "../color/Swatch";
21
+ import { PlayButton } from "./PlayerButton";
22
+ import { SpeedTimeline } from "./SpeedTimeline";
23
+ import { CustomThumb, getPercentageOfRectangle, RailMarkers, useFocusedThumb } from "./Scrubber";
24
+ import { UiIModelComponents } from "../UiIModelComponents";
25
+ import { SvgCalendar, SvgLoop, SvgSettings } from "@itwin/itwinui-icons-react";
26
+ // cSpell:ignore millisec solarsettings showticks shadowcolor solartimeline datepicker millisecs
27
+ const millisecPerMinute = 1000 * 60;
28
+ const millisecPerHour = millisecPerMinute * 60;
29
+ // const millisecPerDay = millisecPerHour * 24;
30
+ const defaultPlaybackDuration = 40 * 1000; // 40 seconds
31
+ const addZero = (i) => {
32
+ return (i < 10) ? `0${i}` : i;
33
+ };
34
+ function Timeline(props) {
35
+ const sliderRef = React.useRef(null);
36
+ const [sliderContainer, setSliderContainer] = React.useState();
37
+ const [pointerPercent, setPointerPercent] = React.useState(0);
38
+ React.useLayoutEffect(() => {
39
+ // istanbul ignore else
40
+ if (sliderRef.current) {
41
+ const container = sliderRef.current.querySelector(".iui-slider-container");
42
+ if (container && sliderContainer !== container) {
43
+ setSliderContainer(container);
44
+ }
45
+ }
46
+ }, [sliderContainer]);
47
+ const thumbProps = () => {
48
+ return {
49
+ className: "components-timeline-thumb",
50
+ children: React.createElement(CustomThumb, null),
51
+ };
52
+ };
53
+ const tooltipProps = React.useCallback(() => {
54
+ return { visible: false };
55
+ }, []);
56
+ const [showRailTooltip, setShowRailTooltip] = React.useState(false);
57
+ const handlePointerEnter = React.useCallback(() => {
58
+ setShowRailTooltip(true);
59
+ }, []);
60
+ const handlePointerLeave = React.useCallback(() => {
61
+ setShowRailTooltip(false);
62
+ }, []);
63
+ const handlePointerMove = React.useCallback((event) => {
64
+ sliderContainer &&
65
+ setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
66
+ }, [sliderContainer]);
67
+ const { formatTick, formatTime, onChange, onUpdate, dayStartMs, sunSetOffsetMs, sunRiseOffsetMs, currentTimeOffsetMs, isPlaying } = props;
68
+ const thumbHasFocus = useFocusedThumb(sliderContainer);
69
+ const tickLabel = React.useMemo(() => {
70
+ const showTip = isPlaying || showRailTooltip || thumbHasFocus;
71
+ const totalDuration = sunSetOffsetMs - sunRiseOffsetMs;
72
+ const percent = (isPlaying || thumbHasFocus) ? (currentTimeOffsetMs - sunRiseOffsetMs) / totalDuration : pointerPercent;
73
+ const tooltipText = formatTime((isPlaying || thumbHasFocus) ? (dayStartMs + currentTimeOffsetMs) : (dayStartMs + (sunRiseOffsetMs + (pointerPercent * totalDuration))));
74
+ return (React.createElement(RailMarkers, { showToolTip: showTip, percent: percent, tooltipText: tooltipText }));
75
+ }, [isPlaying, showRailTooltip, thumbHasFocus, sunSetOffsetMs, sunRiseOffsetMs, currentTimeOffsetMs, pointerPercent, formatTime, dayStartMs]);
76
+ const className = classnames("solar-slider", props.className, formatTick && "showticks");
77
+ const sunRiseFormat = formatTime(dayStartMs + sunRiseOffsetMs);
78
+ const sunSetFormat = formatTime(dayStartMs + sunSetOffsetMs);
79
+ return (React.createElement("div", { className: className },
80
+ React.createElement(Tooltip, { content: sunRiseFormat },
81
+ React.createElement("span", { className: "sunrise" }, "\u2600")),
82
+ React.createElement(Slider, { ref: sliderRef, className: className, step: millisecPerMinute, min: sunRiseOffsetMs, max: sunSetOffsetMs, minLabel: "", maxLabel: "", onUpdate: onUpdate, onChange: onChange, values: [currentTimeOffsetMs], tooltipProps: tooltipProps, thumbProps: thumbProps, tickLabels: tickLabel, railContainerProps: {
83
+ onPointerEnter: handlePointerEnter,
84
+ onPointerMove: handlePointerMove,
85
+ onPointerLeave: handlePointerLeave,
86
+ } }),
87
+ React.createElement(Tooltip, { content: sunSetFormat },
88
+ React.createElement("span", { className: "sunset" }, "\u263D"))));
89
+ }
90
+ /** Solar Timeline
91
+ * @alpha
92
+ */
93
+ export class SolarTimeline extends React.PureComponent {
94
+ constructor(props) {
95
+ super(props);
96
+ this._datePicker = null;
97
+ this._settings = null;
98
+ this._requestFrame = 0;
99
+ this._unmounted = false;
100
+ this._timeLastCycle = 0;
101
+ this._totalPlayTime = 0;
102
+ this._settingsPopupTitle = UiIModelComponents.translate("solarsettings.shadowcolor");
103
+ this._playLabel = UiIModelComponents.translate("solartimeline.play");
104
+ this._settingLabel = UiIModelComponents.translate("solartimeline.settings");
105
+ this._loopLabel = UiIModelComponents.translate("timeline.repeat");
106
+ this._speedLabel = UiIModelComponents.translate("solartimeline.speed");
107
+ this._dateTimeLabel = UiIModelComponents.translate("solartimeline.dateTime");
108
+ this._months = [
109
+ UiComponents.translate("month.short.january"),
110
+ UiComponents.translate("month.short.february"),
111
+ UiComponents.translate("month.short.march"),
112
+ UiComponents.translate("month.short.april"),
113
+ UiComponents.translate("month.short.may"),
114
+ UiComponents.translate("month.short.june"),
115
+ UiComponents.translate("month.short.july"),
116
+ UiComponents.translate("month.short.august"),
117
+ UiComponents.translate("month.short.september"),
118
+ UiComponents.translate("month.short.october"),
119
+ UiComponents.translate("month.short.november"),
120
+ UiComponents.translate("month.short.december"),
121
+ ];
122
+ this._timeLabel = UiComponents.translate("datepicker.time");
123
+ this._amLabel = UiComponents.translate("time.am");
124
+ this._pmLabel = UiComponents.translate("time.pm");
125
+ this._presetColors = [
126
+ ColorDef.create(ColorByName.grey),
127
+ ColorDef.create(ColorByName.lightGrey),
128
+ ColorDef.create(ColorByName.darkGrey),
129
+ ColorDef.create(ColorByName.lightBlue),
130
+ ColorDef.create(ColorByName.lightGreen),
131
+ ColorDef.create(ColorByName.darkGreen),
132
+ ColorDef.create(ColorByName.tan),
133
+ ColorDef.create(ColorByName.darkBrown),
134
+ ];
135
+ // recursively update the animation until we hit the end or the pause button is clicked
136
+ this._updateAnimation = (_timestamp) => {
137
+ // istanbul ignore else
138
+ if (!this.state.isPlaying || this._unmounted) {
139
+ window.cancelAnimationFrame(this._requestFrame);
140
+ return;
141
+ }
142
+ const currentTime = new Date().getTime();
143
+ this._totalPlayTime += (currentTime - this._timeLastCycle);
144
+ this._timeLastCycle = currentTime;
145
+ let percentComplete = this._totalPlayTime / this.state.adjustedDuration;
146
+ if (percentComplete > 1)
147
+ percentComplete = 1;
148
+ let newPlayingState = true;
149
+ // calculate the next sun time base on the percentage playback complete - should be int value as that is step amount for slider
150
+ let nextSunOffset = Math.floor(this.state.sunRiseOffsetMs + (percentComplete * this.state.sunDeltaMs));
151
+ if (percentComplete > 0.99) {
152
+ if (!this.state.loop) {
153
+ newPlayingState = false;
154
+ nextSunOffset = this.state.sunSetOffsetMs;
155
+ window.cancelAnimationFrame(this._requestFrame);
156
+ }
157
+ else {
158
+ nextSunOffset = this.state.sunRiseOffsetMs;
159
+ this._totalPlayTime = 0;
160
+ }
161
+ }
162
+ if (this.props.dataProvider.onTimeChanged) {
163
+ const currentSunTime = new Date(this.state.dayStartMs + nextSunOffset);
164
+ this.props.dataProvider.onTimeChanged(currentSunTime);
165
+ }
166
+ this.setState({ isPlaying: newPlayingState, currentTimeOffsetMs: nextSunOffset }, () => {
167
+ if (newPlayingState)
168
+ this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
169
+ });
170
+ };
171
+ // user clicked pause button
172
+ this._onPause = () => {
173
+ // istanbul ignore if
174
+ if (!this.state.isPlaying)
175
+ return;
176
+ const currentTime = new Date().getTime();
177
+ this._totalPlayTime += (currentTime - this._timeLastCycle);
178
+ // stop requesting frames
179
+ window.cancelAnimationFrame(this._requestFrame);
180
+ // stop playing
181
+ this.setState({ isPlaying: false });
182
+ // istanbul ignore else
183
+ if (this.props.onPlayPause)
184
+ this.props.onPlayPause(false);
185
+ };
186
+ // user clicked play button
187
+ this._onPlay = () => {
188
+ // istanbul ignore if
189
+ if (this.state.isPlaying)
190
+ return;
191
+ if (this.state.currentTimeOffsetMs >= this.state.sunSetOffsetMs || this.state.currentTimeOffsetMs <= this.state.sunRiseOffsetMs) {
192
+ this._totalPlayTime = 0;
193
+ this._play(this.state.sunRiseOffsetMs);
194
+ }
195
+ else {
196
+ this._play(this.state.currentTimeOffsetMs);
197
+ }
198
+ };
199
+ /** note the day passed in is in the time of the current user not in project time because the date picker works in
200
+ * local time */
201
+ this._onDayClick = (day) => {
202
+ const selectedDate = new Date(day.getTime() + this.state.currentTimeOffsetMs);
203
+ this.props.dataProvider.setDateAndTime(selectedDate);
204
+ const dayStartMs = this.props.dataProvider.dayStartMs;
205
+ const sunRiseOffsetMs = this.props.dataProvider.sunrise.getTime() - dayStartMs;
206
+ const sunSetOffsetMs = this.props.dataProvider.sunset.getTime() - dayStartMs;
207
+ const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;
208
+ const sunOffsetMs = this.ensureRange(this.state.currentTimeOffsetMs, sunRiseOffsetMs, sunSetOffsetMs);
209
+ this.setPlaybackTimeBySunTime(sunOffsetMs, sunRiseOffsetMs, sunDeltaMs);
210
+ /** call dataProvider to update display style */
211
+ if (this.props.dataProvider.onTimeChanged)
212
+ this.props.dataProvider.onTimeChanged(this.props.dataProvider.timeOfDay);
213
+ this.setState({ dayStartMs, sunRiseOffsetMs, sunSetOffsetMs, currentTimeOffsetMs: sunOffsetMs, sunDeltaMs, isDateOpened: false }, () => {
214
+ this._timeLastCycle = new Date().getTime();
215
+ });
216
+ };
217
+ this._onTimeChanged = (time) => {
218
+ // compute the current date (with time)
219
+ const dayStartMs = this.props.dataProvider.dayStartMs;
220
+ const sunTime = (time.hours * millisecPerHour) + (time.minutes * millisecPerMinute);
221
+ const dateWithNewTime = new Date(dayStartMs + sunTime);
222
+ this.props.dataProvider.setDateAndTime(dateWithNewTime, true);
223
+ // notify the provider to update style
224
+ if (this.props.dataProvider.onTimeChanged)
225
+ this.props.dataProvider.onTimeChanged(dateWithNewTime);
226
+ const currentTimeOffsetMs = this.ensureRange(sunTime, this.state.sunRiseOffsetMs, this.state.sunSetOffsetMs);
227
+ this.setPlaybackTimeBySunTime(currentTimeOffsetMs, this.state.sunRiseOffsetMs, this.state.sunDeltaMs);
228
+ this._timeLastCycle = new Date().getTime();
229
+ // update the timeline
230
+ this.setState({ currentTimeOffsetMs });
231
+ };
232
+ this._onCloseDayPicker = () => {
233
+ this.setState({ isDateOpened: false });
234
+ };
235
+ this._onOpenDayPicker = () => {
236
+ this.setState((prevState) => ({ isDateOpened: !prevState.isDateOpened }));
237
+ };
238
+ this._onCloseSettingsPopup = () => {
239
+ this.setState({ isSettingsOpened: false });
240
+ };
241
+ this._onOpenSettingsPopup = () => {
242
+ this.setState((prevState) => ({ isSettingsOpened: !prevState.isSettingsOpened }));
243
+ };
244
+ this._onUpdate = (values) => {
245
+ if (!this.state.isPlaying)
246
+ this.processSunTimeChange(values[0]);
247
+ };
248
+ this._onChange = (values) => {
249
+ if (!this.state.isPlaying)
250
+ this.processSunTimeChange(values[0]);
251
+ };
252
+ this._onSpeedChange = (value) => {
253
+ const adjustedDuration = this.state.duration / value;
254
+ this.setState({ speed: value, adjustedDuration });
255
+ };
256
+ this._onToggleLoop = () => {
257
+ this.setState((prevState) => ({ loop: !prevState.loop }));
258
+ };
259
+ this._formatTime = (millisec) => {
260
+ const date = new Date(millisec);
261
+ // convert project date to browser locale date
262
+ const localTime = adjustDateToTimezone(date, this.props.dataProvider.timeZoneOffset * 60);
263
+ let hours = localTime.getHours();
264
+ const minutes = addZero(date.getMinutes());
265
+ const abbrev = (hours < 12) ? this._amLabel : (hours === 24) ? this._amLabel : this._pmLabel;
266
+ hours = (hours > 12) ? hours - 12 : hours;
267
+ return `${hours}:${minutes} ${abbrev}`;
268
+ };
269
+ this._onPresetColorPick = (shadowColor) => {
270
+ this.setState({ shadowColor }, () => this.props.dataProvider.shadowColor = shadowColor);
271
+ };
272
+ this._handleHueOrSaturationChange = (hueOrSaturation) => {
273
+ if (hueOrSaturation.s === 0) // for a ColorDef to be created from hsv s can't be 0
274
+ hueOrSaturation = hueOrSaturation.clone(undefined, 0.5);
275
+ const shadowColor = hueOrSaturation.toColorDef();
276
+ this.setState({ shadowColor }, () => this.props.dataProvider.shadowColor = shadowColor);
277
+ };
278
+ const dayStartMs = this.props.dataProvider.dayStartMs;
279
+ const sunRiseOffsetMs = this.props.dataProvider.sunrise.getTime() - dayStartMs;
280
+ const sunSetOffsetMs = this.props.dataProvider.sunset.getTime() - dayStartMs;
281
+ const sunDeltaMs = sunSetOffsetMs - sunRiseOffsetMs;
282
+ const sunOffsetMs = this.props.dataProvider.timeOfDay.getTime() - dayStartMs;
283
+ const currentTimeOffsetMs = this.ensureRange(sunOffsetMs, sunRiseOffsetMs, sunSetOffsetMs);
284
+ const shadowColor = this.props.dataProvider.shadowColor;
285
+ const duration = this.props.duration ? this.props.duration : defaultPlaybackDuration;
286
+ const speed = this.props.speed ? this.props.speed : 2;
287
+ const adjustedDuration = duration / speed;
288
+ this.setPlaybackTimeBySunTime(currentTimeOffsetMs, sunRiseOffsetMs, sunDeltaMs, adjustedDuration);
289
+ this.state = {
290
+ isDateOpened: false,
291
+ isSettingsOpened: false,
292
+ isPlaying: false,
293
+ dayStartMs,
294
+ sunRiseOffsetMs,
295
+ sunSetOffsetMs,
296
+ sunDeltaMs,
297
+ currentTimeOffsetMs,
298
+ speed,
299
+ loop: false,
300
+ shadowColor,
301
+ duration,
302
+ adjustedDuration,
303
+ };
304
+ }
305
+ componentWillUnmount() {
306
+ window.cancelAnimationFrame(this._requestFrame);
307
+ this._unmounted = true;
308
+ }
309
+ _play(sunTimeMs) {
310
+ this._timeLastCycle = new Date().getTime();
311
+ // start playing
312
+ this.setState({ isPlaying: true, currentTimeOffsetMs: sunTimeMs }, () => {
313
+ this._requestFrame = window.requestAnimationFrame(this._updateAnimation);
314
+ // istanbul ignore else
315
+ if (this.props.onPlayPause)
316
+ this.props.onPlayPause(true);
317
+ });
318
+ }
319
+ setPlaybackTimeBySunTime(sunOffsetMs, sunRiseOffsetMs, sunDeltaMs, adjustedDuration) {
320
+ this._totalPlayTime = ((sunOffsetMs - sunRiseOffsetMs) / (sunDeltaMs)) * ((adjustedDuration) ? adjustedDuration : this.state.adjustedDuration);
321
+ }
322
+ ensureRange(value, min, max) {
323
+ return Math.max(Math.min(value, max), min);
324
+ }
325
+ processSunTimeChange(sunTime) {
326
+ if (sunTime === this.state.currentTimeOffsetMs)
327
+ return;
328
+ const currentTimeOffsetMs = this.ensureRange(sunTime, this.state.sunRiseOffsetMs, this.state.sunSetOffsetMs);
329
+ if (this.props.dataProvider.onTimeChanged) {
330
+ const currentSunTime = new Date(this.state.dayStartMs + currentTimeOffsetMs);
331
+ this.props.dataProvider.onTimeChanged(currentSunTime);
332
+ }
333
+ this.setState({ currentTimeOffsetMs }, () => {
334
+ const currentTime = new Date().getTime();
335
+ this._timeLastCycle = currentTime;
336
+ const percentComplete = (currentTimeOffsetMs - this.state.sunRiseOffsetMs) / this.state.sunDeltaMs;
337
+ this._totalPlayTime = percentComplete * this.state.adjustedDuration;
338
+ });
339
+ }
340
+ getLocalTime(ticks) {
341
+ const projectTime = new Date(ticks);
342
+ // convert project date to browser locale date
343
+ return adjustDateToTimezone(projectTime, this.props.dataProvider.timeZoneOffset * 60);
344
+ }
345
+ render() {
346
+ const { dataProvider } = this.props;
347
+ const { speed, loop, currentTimeOffsetMs, sunRiseOffsetMs, sunSetOffsetMs } = this.state;
348
+ const localTime = this.getLocalTime(this.state.dayStartMs + this.state.currentTimeOffsetMs);
349
+ const formattedTime = this._formatTime(dataProvider.dayStartMs + currentTimeOffsetMs);
350
+ const formattedDate = `${this._months[localTime.getMonth()]}, ${localTime.getDate()}`;
351
+ const colorSwatchStyle = {
352
+ width: `100%`,
353
+ height: `100%`,
354
+ };
355
+ return (React.createElement("div", { className: "solar-timeline-wrapper" },
356
+ React.createElement("div", { className: "header" },
357
+ React.createElement(PlayButton, { tooltip: this._playLabel, className: "play-button", isPlaying: this.state.isPlaying, onPlay: this._onPlay, onPause: this._onPause }),
358
+ React.createElement("button", { "data-testid": "solar-date-time-button", title: this._dateTimeLabel, className: "current-date", ref: (element) => this._datePicker = element, onClick: this._onOpenDayPicker },
359
+ React.createElement("span", null, formattedDate),
360
+ React.createElement("span", null, "/"),
361
+ React.createElement("span", null, formattedTime),
362
+ React.createElement("span", { className: "icon" },
363
+ React.createElement(Icon, { iconSpec: React.createElement(SvgCalendar, null) }))),
364
+ React.createElement(Popup, { style: { border: "none" }, offset: 11, target: this._datePicker, isOpen: this.state.isDateOpened, onClose: this._onCloseDayPicker, position: RelativePosition.Top },
365
+ React.createElement("div", { className: "components-date-picker-calendar-popup-panel", "data-testid": "components-date-picker-calendar-popup-panel" },
366
+ React.createElement(DatePicker, { selected: localTime, onDateChange: this._onDayClick, showFocusOutline: false }),
367
+ React.createElement("div", { className: "time-container" },
368
+ React.createElement(Text, { variant: "body", className: "time-label" }, this._timeLabel),
369
+ React.createElement(TimeField, { time: { hours: localTime.getHours(), minutes: localTime.getMinutes(), seconds: 0 }, timeDisplay: TimeDisplay.H12MC, onTimeChange: this._onTimeChanged })))),
370
+ React.createElement(Timeline, { className: "solar-timeline", dayStartMs: dataProvider.dayStartMs, sunSetOffsetMs: sunSetOffsetMs, sunRiseOffsetMs: sunRiseOffsetMs, currentTimeOffsetMs: currentTimeOffsetMs, onChange: this._onChange, onUpdate: this._onUpdate, formatTime: this._formatTime, isPlaying: this.state.isPlaying }),
371
+ React.createElement("div", { className: "speed-container" },
372
+ React.createElement("span", { title: this._speedLabel },
373
+ speed,
374
+ "x"),
375
+ React.createElement(SpeedTimeline, { className: "speed", onChange: this._onSpeedChange, speed: this.state.speed })),
376
+ React.createElement("span", { title: this._loopLabel, className: classnames("icon", !loop && "no-loop-playback", loop && "loop-playback"), onClick: this._onToggleLoop, role: "button", tabIndex: -1 },
377
+ React.createElement(Icon, { iconSpec: React.createElement(SvgLoop, null) })),
378
+ React.createElement("button", { "data-testid": "shadow-settings-button", title: this._settingLabel, className: "shadow-settings-button", ref: (element) => this._settings = element, onClick: this._onOpenSettingsPopup },
379
+ React.createElement("span", { className: "icon" },
380
+ React.createElement(Icon, { iconSpec: React.createElement(SvgSettings, null) }))),
381
+ React.createElement(Popup, { className: "shadow-settings-popup", target: this._settings, offset: 11, isOpen: this.state.isSettingsOpened, onClose: this._onCloseSettingsPopup, position: RelativePosition.Top },
382
+ React.createElement("div", { className: "shadow-settings-popup-container" },
383
+ React.createElement("div", { className: "shadow-settings-header" }, this._settingsPopupTitle),
384
+ React.createElement("div", { className: "shadow-settings-color" },
385
+ React.createElement("div", { className: "shadow-settings-color-top" },
386
+ React.createElement(SaturationPicker, { hsv: this.state.shadowColor.toHSV(), onSaturationChange: this._handleHueOrSaturationChange })),
387
+ React.createElement("div", { className: "shadow-settings-color-bottom" },
388
+ React.createElement("div", { className: "shadow-settings-color-bottom-left" },
389
+ React.createElement(HueSlider, { hsv: this.state.shadowColor.toHSV(), onHueChange: this._handleHueOrSaturationChange, isHorizontal: true })),
390
+ React.createElement("div", { className: "shadow-settings-color-bottom-right" },
391
+ React.createElement(ColorSwatch, { style: colorSwatchStyle, colorDef: this.state.shadowColor, round: false })))),
392
+ React.createElement("div", { className: "shadow-settings-color-presets" },
393
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[0], round: false, onColorPick: this._onPresetColorPick }),
394
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[1], round: false, onColorPick: this._onPresetColorPick }),
395
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[2], round: false, onColorPick: this._onPresetColorPick }),
396
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[3], round: false, onColorPick: this._onPresetColorPick }),
397
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[4], round: false, onColorPick: this._onPresetColorPick }),
398
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[5], round: false, onColorPick: this._onPresetColorPick }),
399
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[6], round: false, onColorPick: this._onPresetColorPick }),
400
+ React.createElement(ColorSwatch, { colorDef: this._presetColors[7], round: false, onColorPick: this._onPresetColorPick })))))));
401
+ }
402
+ }
403
403
  //# sourceMappingURL=SolarTimeline.js.map