@itwin/imodel-components-react 4.10.0 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +1 -1
- package/lib/cjs/imodel-components-react/UiIModelComponents.js +6 -6
- package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +2 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js +4 -2
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +5 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +5 -5
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.js +4 -3
- package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js +4 -3
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts +2 -0
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.js +2 -0
- package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/cjs/imodel-components-react/editors/ColorEditor.js +2 -1
- package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +5 -4
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +1 -2
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +6 -7
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +10 -10
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +13 -9
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +21 -28
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts +3 -15
- package/lib/cjs/imodel-components-react/timeline/PlayButton.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/PlayButton.js +12 -42
- package/lib/cjs/imodel-components-react/timeline/PlayButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +111 -202
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +25 -333
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +5 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +39 -30
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +2 -2
- package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
- package/lib/cjs/imodel-components-react/useTranslation.d.ts +10 -0
- package/lib/cjs/imodel-components-react/useTranslation.d.ts.map +1 -0
- package/lib/cjs/imodel-components-react/useTranslation.js +20 -0
- package/lib/cjs/imodel-components-react/useTranslation.js.map +1 -0
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +13 -8
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.js +6 -6
- package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +2 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.js +4 -2
- package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js +5 -2
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +5 -5
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.js +4 -3
- package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.js +4 -3
- package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.d.ts +2 -0
- package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.js +2 -0
- package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/esm/imodel-components-react/editors/ColorEditor.js +2 -1
- package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.js +5 -4
- package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -5
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +1 -2
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +5 -4
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +6 -7
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +10 -10
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +15 -14
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +13 -9
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +21 -28
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +18 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +7 -6
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +14 -13
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +7 -6
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +9 -8
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +23 -22
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +7 -6
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +15 -14
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +6 -6
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts +3 -15
- package/lib/esm/imodel-components-react/timeline/PlayButton.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/PlayButton.js +12 -39
- package/lib/esm/imodel-components-react/timeline/PlayButton.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +2 -20
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +112 -203
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +25 -333
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +5 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +40 -31
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +2 -2
- package/lib/esm/imodel-components-react/timeline/interfaces.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
- package/lib/esm/imodel-components-react/useTranslation.d.ts +10 -0
- package/lib/esm/imodel-components-react/useTranslation.d.ts.map +1 -0
- package/lib/esm/imodel-components-react/useTranslation.js +16 -0
- package/lib/esm/imodel-components-react/useTranslation.js.map +1 -0
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +13 -8
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/public/locales/en/UiIModelComponents.json +14 -3
- package/package.json +10 -10
- package/lib/cjs/imodel-components-react/timeline/PlayButton.scss +0 -28
- package/lib/esm/imodel-components-react/timeline/PlayButton.scss +0 -28
|
@@ -37,11 +37,11 @@ const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
|
37
37
|
const components_react_1 = require("@itwin/components-react");
|
|
38
38
|
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
|
|
39
39
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
40
|
-
const UiIModelComponents_1 = require("../UiIModelComponents");
|
|
41
40
|
const InlineEdit_1 = require("./InlineEdit");
|
|
42
41
|
const interfaces_1 = require("./interfaces");
|
|
43
42
|
const PlayButton_1 = require("./PlayButton");
|
|
44
43
|
const Scrubber_1 = require("./Scrubber");
|
|
44
|
+
const useTranslation_1 = require("../useTranslation");
|
|
45
45
|
const slowSpeed = 60 * 1000;
|
|
46
46
|
const mediumSpeed = 20 * 1000;
|
|
47
47
|
const fastSpeed = 10 * 1000;
|
|
@@ -49,11 +49,12 @@ const fastSpeed = 10 * 1000;
|
|
|
49
49
|
* @public
|
|
50
50
|
*/
|
|
51
51
|
function TimelineComponent(props) {
|
|
52
|
+
var _a, _b, _c, _d;
|
|
52
53
|
const { appMenuItemOption = "replace", startDate, endDate, showDuration, timeZoneOffset, dateFormatOptions, timeFormatOptions, includeRepeat = true, onSettingsChange, onChange, onPlayPause, } = props;
|
|
53
|
-
const [isPlaying, setIsPlaying] = React.useState(
|
|
54
|
-
const [currentDuration, setCurrentDuration] = React.useState(props.initialDuration
|
|
54
|
+
const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);
|
|
55
|
+
const [currentDuration, setCurrentDuration] = React.useState((_a = props.initialDuration) !== null && _a !== void 0 ? _a : 0);
|
|
55
56
|
const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);
|
|
56
|
-
const [repeat, setRepeat] = React.useState(props.repeat
|
|
57
|
+
const [repeat, setRepeat] = React.useState((_b = props.repeat) !== null && _b !== void 0 ? _b : false);
|
|
57
58
|
const playOrReplay = React.useCallback(() => {
|
|
58
59
|
if (isPlaying)
|
|
59
60
|
return;
|
|
@@ -61,13 +62,13 @@ function TimelineComponent(props) {
|
|
|
61
62
|
setCurrentDuration(0);
|
|
62
63
|
}
|
|
63
64
|
setIsPlaying(true);
|
|
64
|
-
onPlayPause
|
|
65
|
+
onPlayPause === null || onPlayPause === void 0 ? void 0 : onPlayPause(true);
|
|
65
66
|
}, [isPlaying, onPlayPause, currentDuration, totalDuration]);
|
|
66
67
|
const pause = React.useCallback(() => {
|
|
67
68
|
if (!isPlaying)
|
|
68
69
|
return;
|
|
69
70
|
setIsPlaying(false);
|
|
70
|
-
onPlayPause
|
|
71
|
+
onPlayPause === null || onPlayPause === void 0 ? void 0 : onPlayPause(false);
|
|
71
72
|
}, [isPlaying, onPlayPause]);
|
|
72
73
|
const updateTotalDuration = (newTotalDuration) => {
|
|
73
74
|
if (newTotalDuration === totalDuration)
|
|
@@ -76,7 +77,7 @@ function TimelineComponent(props) {
|
|
|
76
77
|
const newCurrentDuration = fraction * newTotalDuration;
|
|
77
78
|
setTotalDuration(newTotalDuration);
|
|
78
79
|
setCurrentDuration(newCurrentDuration);
|
|
79
|
-
onSettingsChange
|
|
80
|
+
onSettingsChange === null || onSettingsChange === void 0 ? void 0 : onSettingsChange({ duration: newTotalDuration });
|
|
80
81
|
};
|
|
81
82
|
const updateDuration = (newDuration, currentTotalDuration = totalDuration) => {
|
|
82
83
|
newDuration = Math.max(newDuration, 0);
|
|
@@ -85,13 +86,13 @@ function TimelineComponent(props) {
|
|
|
85
86
|
return;
|
|
86
87
|
setCurrentDuration(newDuration);
|
|
87
88
|
const fraction = newDuration / currentTotalDuration;
|
|
88
|
-
onChange
|
|
89
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(fraction);
|
|
89
90
|
};
|
|
90
91
|
const updateRepeat = (newRepeat) => {
|
|
91
92
|
if (newRepeat === repeat)
|
|
92
93
|
return;
|
|
93
94
|
setRepeat(newRepeat);
|
|
94
|
-
onSettingsChange
|
|
95
|
+
onSettingsChange === null || onSettingsChange === void 0 ? void 0 : onSettingsChange({ loop: newRepeat });
|
|
95
96
|
};
|
|
96
97
|
const [prevTotalDuration, setPrevTotalDuration] = React.useState(props.totalDuration);
|
|
97
98
|
if (prevTotalDuration !== props.totalDuration) {
|
|
@@ -101,19 +102,21 @@ function TimelineComponent(props) {
|
|
|
101
102
|
const [prevInitialDuration, setPrevInitialDuration] = React.useState(props.initialDuration);
|
|
102
103
|
if (prevInitialDuration !== props.initialDuration) {
|
|
103
104
|
setPrevInitialDuration(props.initialDuration);
|
|
104
|
-
updateDuration(props.initialDuration
|
|
105
|
+
updateDuration((_c = props.initialDuration) !== null && _c !== void 0 ? _c : 0, props.totalDuration);
|
|
105
106
|
}
|
|
106
107
|
const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);
|
|
107
108
|
if (prevRepeat !== props.repeat) {
|
|
108
109
|
setPrevRepeat(props.repeat);
|
|
109
|
-
updateRepeat(props.repeat
|
|
110
|
+
updateRepeat((_d = props.repeat) !== null && _d !== void 0 ? _d : repeat);
|
|
110
111
|
}
|
|
111
112
|
React.useEffect(() => {
|
|
113
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
112
114
|
if (!props.componentId)
|
|
113
115
|
return;
|
|
114
116
|
return appui_abstract_1.UiAdmin.onGenericUiEvent.addListener((args) => {
|
|
115
117
|
const timelineArgs = args;
|
|
116
118
|
if (!timelineArgs ||
|
|
119
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
117
120
|
props.componentId !== timelineArgs.uiComponentId ||
|
|
118
121
|
timelineArgs.timelineAction === undefined)
|
|
119
122
|
return;
|
|
@@ -134,6 +137,7 @@ function TimelineComponent(props) {
|
|
|
134
137
|
break;
|
|
135
138
|
}
|
|
136
139
|
});
|
|
140
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
137
141
|
}, [isPlaying, pause, playOrReplay, props.componentId]);
|
|
138
142
|
useAnimation(({ delta }) => {
|
|
139
143
|
const duration = currentDuration + delta;
|
|
@@ -146,6 +150,12 @@ function TimelineComponent(props) {
|
|
|
146
150
|
pause();
|
|
147
151
|
}
|
|
148
152
|
}, isPlaying);
|
|
153
|
+
React.useEffect(() => {
|
|
154
|
+
if (props.isPlaying)
|
|
155
|
+
playOrReplay();
|
|
156
|
+
if (props.isPlaying === false)
|
|
157
|
+
pause();
|
|
158
|
+
}, [props.isPlaying, playOrReplay, pause]);
|
|
149
159
|
const onTimelineChange = (values) => {
|
|
150
160
|
const newDuration = values[0];
|
|
151
161
|
updateDuration(newDuration);
|
|
@@ -175,23 +185,22 @@ function TimelineComponent(props) {
|
|
|
175
185
|
}
|
|
176
186
|
exports.TimelineComponent = TimelineComponent;
|
|
177
187
|
function SettingsMenu({ appMenuItems, appMenuItemOption, includeRepeat, repeat, totalDuration, onRepeatClick, onTotalDurationChange, }) {
|
|
178
|
-
const
|
|
179
|
-
const repeatLabel = React.useMemo(() => UiIModelComponents_1.UiIModelComponents.translate("timeline.repeat"), []);
|
|
180
|
-
const standardItems = React.useMemo(() => [
|
|
181
|
-
{
|
|
182
|
-
label: UiIModelComponents_1.UiIModelComponents.translate("timeline.slow"),
|
|
183
|
-
timelineDuration: slowSpeed,
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
label: UiIModelComponents_1.UiIModelComponents.translate("timeline.medium"),
|
|
187
|
-
timelineDuration: mediumSpeed,
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
label: UiIModelComponents_1.UiIModelComponents.translate("timeline.fast"),
|
|
191
|
-
timelineDuration: fastSpeed,
|
|
192
|
-
},
|
|
193
|
-
], []);
|
|
188
|
+
const { translate } = (0, useTranslation_1.useTranslation)();
|
|
194
189
|
const menuItems = React.useMemo(() => {
|
|
190
|
+
const standardItems = [
|
|
191
|
+
{
|
|
192
|
+
label: translate("timeline.slow"),
|
|
193
|
+
timelineDuration: slowSpeed,
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
label: translate("timeline.medium"),
|
|
197
|
+
timelineDuration: mediumSpeed,
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
label: translate("timeline.fast"),
|
|
201
|
+
timelineDuration: fastSpeed,
|
|
202
|
+
},
|
|
203
|
+
];
|
|
195
204
|
if (!appMenuItems) {
|
|
196
205
|
return standardItems;
|
|
197
206
|
}
|
|
@@ -203,7 +212,7 @@ function SettingsMenu({ appMenuItems, appMenuItemOption, includeRepeat, repeat,
|
|
|
203
212
|
}
|
|
204
213
|
// Replace
|
|
205
214
|
return appMenuItems;
|
|
206
|
-
}, [appMenuItemOption, appMenuItems,
|
|
215
|
+
}, [appMenuItemOption, appMenuItems, translate]);
|
|
207
216
|
return (React.createElement(itwinui_react_1.DropdownMenu, { menuItems: (close) => {
|
|
208
217
|
return [
|
|
209
218
|
...(includeRepeat
|
|
@@ -211,7 +220,7 @@ function SettingsMenu({ appMenuItems, appMenuItemOption, includeRepeat, repeat,
|
|
|
211
220
|
React.createElement(itwinui_react_1.MenuItem, { key: "repeat", onClick: () => {
|
|
212
221
|
onRepeatClick();
|
|
213
222
|
close();
|
|
214
|
-
}, startIcon: repeat ? React.createElement(itwinui_icons_react_1.SvgCheckmark, null) : React.createElement(React.Fragment, null) },
|
|
223
|
+
}, startIcon: repeat ? React.createElement(itwinui_icons_react_1.SvgCheckmark, null) : React.createElement(React.Fragment, null) }, translate("timeline.repeat")),
|
|
215
224
|
React.createElement(itwinui_react_1.MenuDivider, { key: "divider" }),
|
|
216
225
|
]
|
|
217
226
|
: []),
|
|
@@ -224,7 +233,7 @@ function SettingsMenu({ appMenuItems, appMenuItemOption, includeRepeat, repeat,
|
|
|
224
233
|
}),
|
|
225
234
|
];
|
|
226
235
|
}, placement: "top-start" },
|
|
227
|
-
React.createElement(itwinui_react_1.IconButton, { "data-testid": "timeline-settings",
|
|
236
|
+
React.createElement(itwinui_react_1.IconButton, { "data-testid": "timeline-settings", label: translate("button.label.settings"), styleType: "borderless" },
|
|
228
237
|
React.createElement(itwinui_icons_react_1.SvgMoreVertical, null))));
|
|
229
238
|
}
|
|
230
239
|
function useAnimation(onAnimate, playing = true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,oCAAkC;AAClC,6CAA+B;AAC/B,0DAAgD;AAEhD,8DAIiC;AACjC,oEAA2E;AAC3E,wDAK8B;AAC9B,8DAA2D;AAC3D,6CAA0C;AAE1C,6CAAuD;AACvD,6CAA0C;AAC1C,yCAAsC;AAEtC,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAwF5B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,iBAAiB,GAAG,SAAS,EAC7B,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GAAG,IAAI,EACpB,gBAAgB,EAChB,QAAQ,EACR,WAAW,GACZ,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAC1D,KAAK,CAAC,eAAe,IAAI,CAAC,CAC3B,CAAC;IACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAC9E,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;IAElE,MAAM,YAAY,GAAG,K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AAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport {\n toDateString,\n toTimeString,\n UiComponents,\n} from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton } from \"./PlayButton\";\nimport { Scrubber } from \"./Scrubber\";\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n\n/** [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n\n/** [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n\n/** [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.)\n * @deprecated in 4.10.x. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed.\n * @deprecated in 4.10.x. Has no effect.\n */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true)\n * @deprecated in 4.10.x. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `replace`. */\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const settingsLabel = React.useMemo(\n () => UiComponents.translate(\"button.label.settings\"),\n []\n );\n const repeatLabel = React.useMemo(\n () => UiIModelComponents.translate(\"timeline.repeat\"),\n []\n );\n const standardItems: TimelineMenuItemProps[] = React.useMemo(\n () => [\n {\n label: UiIModelComponents.translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: UiIModelComponents.translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ],\n []\n );\n\n const menuItems = React.useMemo(() => {\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, standardItems]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {repeatLabel}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n title={settingsLabel}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n}\n\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TimelineComponent.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/TimelineComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,oCAAkC;AAClC,6CAA+B;AAC/B,0DAAgD;AAEhD,8DAAqE;AACrE,oEAA2E;AAC3E,wDAK8B;AAC9B,6CAA0C;AAE1C,6CAAuD;AACvD,6CAA0C;AAC1C,yCAAsC;AACtC,sDAAmD;AAEnD,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AA4F5B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;;IAC7D,MAAM,EACJ,iBAAiB,GAAG,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,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC5B,OAAO,CACL,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CACtE,CAAC;KACH;SAAM;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KAC5B;AACH,CAAC;AAED,SAAS,aAAa,CAAC,EAAU;IAC/B,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1B,oCAAoC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;AACnD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\nimport \"./TimelineComponent.scss\";\nimport * as React from \"react\";\nimport { UiAdmin } from \"@itwin/appui-abstract\";\nimport type { DateFormatOptions } from \"@itwin/components-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport { SvgCheckmark, SvgMoreVertical } from \"@itwin/itwinui-icons-react\";\nimport {\n DropdownMenu,\n IconButton,\n MenuDivider,\n MenuItem,\n} from \"@itwin/itwinui-react\";\nimport { InlineEdit } from \"./InlineEdit\";\nimport type { PlaybackSettings, TimelinePausePlayArgs } from \"./interfaces\";\nimport { TimelinePausePlayAction } from \"./interfaces\";\nimport { PlayButton } from \"./PlayButton\";\nimport { Scrubber } from \"./Scrubber\";\nimport { useTranslation } from \"../useTranslation\";\n\nconst slowSpeed = 60 * 1000;\nconst mediumSpeed = 20 * 1000;\nconst fastSpeed = 10 * 1000;\n\n/** [[TimelineMenuItemOption]]: specifies how the app wants the timeline speeds to be installed on the TimelineComponent's ContextMenu\n * \"replace\" : use the app-supplied items in place of the standard items\n * \"append\" : add the app-supplied items following the standard items\n * \"prefix\" : add the app-supplied items before the standard items\n *\n * @public\n */\nexport type TimelineMenuItemOption = \"replace\" | \"append\" | \"prefix\";\n\n/** [[TimelineMenuItemProps]] specifies playback speed entries in the Timeline's ContextMenu\n * @public\n */\nexport interface TimelineMenuItemProps {\n /** localized label for menu item */\n label: string;\n\n /** duration for the entire timeline to play */\n timelineDuration: number;\n}\n\n/** TimelineDateMarkerProps: Mark a date on the timeline with an indicator\n * @public\n */\nexport interface TimelineDateMarkerProps {\n /** Date to mark. If undefined, today's date will be used. */\n date?: Date;\n /** ReactNode to use as the marker on the timeline. If undefined, a short vertical bar will mark the date. */\n dateMarker?: React.ReactNode;\n}\n\n/** [[TimelineComponentProps]] configure the timeline\n * @public\n */\nexport interface TimelineComponentProps {\n /** Start date: beginning of the date range of a date-based timeline. */\n startDate?: Date;\n /** End date: end of the date range of a date-based timeline. */\n endDate?: Date;\n /** Total duration: range of the timeline in milliseconds.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.appMenuItems}.\n */\n totalDuration: number;\n /** Initial value for the current duration (the location of the thumb) in milliseconds */\n initialDuration?: number;\n /** Show in minimized mode (For future use. This prop will always be treated as true.)\n * @deprecated in 4.10.x. Has no effect.\n */\n minimized?: boolean;\n /** When playing, repeat indefinitely. Defaults to `false`.\n * @note This can be changed by user interaction. See {@link TimelineComponentProps.includeRepeat}.\n */\n repeat?: boolean;\n /** Show duration instead of time */\n showDuration?: boolean;\n /** Callback with current duration value (as a fraction) */\n onChange?: (duration: number) => void;\n /** Callback triggered when play/pause button is pressed */\n onPlayPause?: (playing: boolean) => void;\n /** Callback triggered when backward/forward buttons are pressed.\n * @deprecated in 4.10.x. Has no effect.\n */\n onJump?: (forward: boolean) => void;\n /** Callback triggered when a setting is changed */\n onSettingsChange?: (arg: PlaybackSettings) => void;\n /** Always display in miniMode with no expand menu (For future use. This prop will always be treated as true)\n * @deprecated in 4.10.x. Has no effect.\n */\n alwaysMinimized?: boolean;\n /** ComponentId -- must be set to use TimelineComponentEvents\n * @deprecated in 4.11.x. Use the isPlaying prop instead.\n */\n componentId?: string;\n /** Include the repeat option on the Timeline Context Menu. Defaults to `true`. */\n includeRepeat?: boolean;\n /** App-supplied speed entries in the Timeline Context Menu. Defaults to `[Slow, Medium, Fast]` items. */\n appMenuItems?: TimelineMenuItemProps[];\n /** How to include the supplied app menu items in the Timeline Context Menu (prefix, append or replace). Defaults to `replace`. */\n appMenuItemOption?: TimelineMenuItemOption;\n /** Display date and time offset by the number of minutes specified. When undefined - local timezone will be used */\n timeZoneOffset?: number;\n /** Display a marker on the timeline rail to indicate current date - will only work if starDate and endDate are defined */\n markDate?: TimelineDateMarkerProps;\n /** Options used to format date string. If not defined it will user browser default locale settings. */\n dateFormatOptions?: DateFormatOptions;\n /** Options used to format time string. If not defined it will user browser default locale settings. */\n timeFormatOptions?: DateFormatOptions;\n /** Used to control the play/pause state of the Timeline.*/\n isPlaying?: boolean;\n}\n\n/** [[TimelineComponent]] is used to playback timeline data\n * @public\n */\nexport function TimelineComponent(props: TimelineComponentProps) {\n const {\n appMenuItemOption = \"replace\",\n startDate,\n endDate,\n showDuration,\n timeZoneOffset,\n dateFormatOptions,\n timeFormatOptions,\n includeRepeat = true,\n onSettingsChange,\n onChange,\n onPlayPause,\n } = props;\n const [isPlaying, setIsPlaying] = React.useState(!!props.isPlaying);\n const [currentDuration, setCurrentDuration] = React.useState(\n props.initialDuration ?? 0\n );\n const [totalDuration, setTotalDuration] = React.useState(props.totalDuration);\n const [repeat, setRepeat] = React.useState(props.repeat ?? false);\n\n const playOrReplay = React.useCallback(() => {\n if (isPlaying) return;\n\n if (currentDuration >= totalDuration) {\n setCurrentDuration(0);\n }\n\n setIsPlaying(true);\n onPlayPause?.(true);\n }, [isPlaying, onPlayPause, currentDuration, totalDuration]);\n const pause = React.useCallback(() => {\n if (!isPlaying) return;\n setIsPlaying(false);\n onPlayPause?.(false);\n }, [isPlaying, onPlayPause]);\n const updateTotalDuration = (newTotalDuration: number) => {\n if (newTotalDuration === totalDuration) return;\n\n const fraction = currentDuration / totalDuration;\n const newCurrentDuration = fraction * newTotalDuration;\n\n setTotalDuration(newTotalDuration);\n setCurrentDuration(newCurrentDuration);\n onSettingsChange?.({ duration: newTotalDuration });\n };\n const updateDuration = (\n newDuration: number,\n currentTotalDuration = totalDuration\n ) => {\n newDuration = Math.max(newDuration, 0);\n newDuration = Math.min(newDuration, currentTotalDuration);\n\n if (newDuration === currentDuration) return;\n setCurrentDuration(newDuration);\n\n const fraction = newDuration / currentTotalDuration;\n onChange?.(fraction);\n };\n const updateRepeat = (newRepeat: boolean) => {\n if (newRepeat === repeat) return;\n\n setRepeat(newRepeat);\n onSettingsChange?.({ loop: newRepeat });\n };\n\n const [prevTotalDuration, setPrevTotalDuration] = React.useState(\n props.totalDuration\n );\n if (prevTotalDuration !== props.totalDuration) {\n setPrevTotalDuration(props.totalDuration);\n updateTotalDuration(props.totalDuration);\n }\n\n const [prevInitialDuration, setPrevInitialDuration] = React.useState(\n props.initialDuration\n );\n if (prevInitialDuration !== props.initialDuration) {\n setPrevInitialDuration(props.initialDuration);\n updateDuration(props.initialDuration ?? 0, props.totalDuration);\n }\n\n const [prevRepeat, setPrevRepeat] = React.useState(props.repeat);\n if (prevRepeat !== props.repeat) {\n setPrevRepeat(props.repeat);\n updateRepeat(props.repeat ?? repeat);\n }\n\n React.useEffect(() => {\n // eslint-disable-next-line deprecation/deprecation\n if (!props.componentId) return;\n return UiAdmin.onGenericUiEvent.addListener((args) => {\n const timelineArgs = args as TimelinePausePlayArgs;\n if (\n !timelineArgs ||\n // eslint-disable-next-line deprecation/deprecation\n props.componentId !== timelineArgs.uiComponentId ||\n timelineArgs.timelineAction === undefined\n )\n return;\n\n switch (timelineArgs.timelineAction) {\n case TimelinePausePlayAction.Play:\n playOrReplay();\n break;\n case TimelinePausePlayAction.Pause:\n pause();\n break;\n case TimelinePausePlayAction.Toggle:\n if (isPlaying) {\n pause();\n } else {\n playOrReplay();\n }\n break;\n }\n });\n // eslint-disable-next-line deprecation/deprecation\n }, [isPlaying, pause, playOrReplay, props.componentId]);\n useAnimation(({ delta }) => {\n const duration = currentDuration + delta;\n updateDuration(duration);\n\n if (duration >= totalDuration) {\n if (repeat) {\n setCurrentDuration(0);\n return;\n }\n\n pause();\n }\n }, isPlaying);\n\n React.useEffect(() => {\n if (props.isPlaying) playOrReplay();\n\n if (props.isPlaying === false) pause();\n }, [props.isPlaying, playOrReplay, pause]);\n\n const onTimelineChange = (values: ReadonlyArray<number>) => {\n const newDuration = values[0];\n updateDuration(newDuration);\n };\n\n const currentDurationStr = toDisplayTime(currentDuration);\n const totalDurationStr = toDisplayTime(totalDuration);\n const hasDates = !!startDate && !!endDate;\n return (\n <div data-testid=\"timeline-component\" className=\"timeline-component\">\n <PlayButton isPlaying={isPlaying} onPlay={playOrReplay} onPause={pause} />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-start-date\" className=\"timeline-date\">\n {toDateString(startDate, timeZoneOffset, dateFormatOptions)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span data-testid=\"test-start-time\" className=\"timeline-time\">\n {toTimeString(startDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <span className=\"timeline-duration-time\">{currentDurationStr}</span>\n )}\n </div>\n <Scrubber\n className=\"slider\"\n currentDuration={currentDuration}\n totalDuration={totalDuration}\n startDate={startDate}\n endDate={endDate}\n isPlaying={isPlaying}\n showTime={!showDuration}\n onChange={onTimelineChange}\n onUpdate={onTimelineChange}\n timeZoneOffset={props.timeZoneOffset}\n markDate={props.markDate}\n />\n <div className=\"time-container\">\n {hasDates && (\n <span data-testid=\"test-end-date\" className=\"timeline-date\">\n {toDateString(endDate, timeZoneOffset)}\n </span>\n )}\n {hasDates && !showDuration && (\n <span className=\"timeline-time\">\n {toTimeString(endDate, timeZoneOffset, timeFormatOptions)}\n </span>\n )}\n {showDuration && (\n <InlineEdit\n className=\"timeline-duration-time\"\n defaultValue={totalDurationStr}\n onChange={(value) => {\n const newTotalDuration = timeToMs(value);\n updateTotalDuration(newTotalDuration);\n }}\n />\n )}\n </div>\n <SettingsMenu\n appMenuItems={props.appMenuItems}\n appMenuItemOption={appMenuItemOption}\n includeRepeat={includeRepeat}\n repeat={repeat}\n totalDuration={totalDuration}\n onRepeatClick={() => {\n updateRepeat(!repeat);\n }}\n onTotalDurationChange={(newTotalDuration) => {\n updateTotalDuration(newTotalDuration);\n }}\n />\n </div>\n );\n}\n\ntype SettingsMenuProps = Pick<\n TimelineComponentProps,\n \"appMenuItems\" | \"totalDuration\"\n> &\n Pick<\n Required<TimelineComponentProps>,\n \"appMenuItemOption\" | \"includeRepeat\" | \"repeat\"\n > & {\n onRepeatClick: () => void;\n onTotalDurationChange: (totalDuration: number) => void;\n };\n\nfunction SettingsMenu({\n appMenuItems,\n appMenuItemOption,\n includeRepeat,\n repeat,\n totalDuration,\n onRepeatClick,\n onTotalDurationChange,\n}: SettingsMenuProps) {\n const { translate } = useTranslation();\n\n const menuItems = React.useMemo(() => {\n const standardItems: TimelineMenuItemProps[] = [\n {\n label: translate(\"timeline.slow\"),\n timelineDuration: slowSpeed,\n },\n {\n label: translate(\"timeline.medium\"),\n timelineDuration: mediumSpeed,\n },\n {\n label: translate(\"timeline.fast\"),\n timelineDuration: fastSpeed,\n },\n ];\n\n if (!appMenuItems) {\n return standardItems;\n }\n\n if (appMenuItemOption === \"append\") {\n return [...standardItems, ...appMenuItems];\n }\n if (appMenuItemOption === \"prefix\") {\n return [...appMenuItems, ...standardItems];\n }\n // Replace\n return appMenuItems;\n }, [appMenuItemOption, appMenuItems, translate]);\n\n return (\n <DropdownMenu\n menuItems={(close) => {\n return [\n ...(includeRepeat\n ? [\n <MenuItem\n key=\"repeat\"\n onClick={() => {\n onRepeatClick();\n close();\n }}\n startIcon={repeat ? <SvgCheckmark /> : <></>}\n >\n {translate(\"timeline.repeat\")}\n </MenuItem>,\n <MenuDivider key=\"divider\" />,\n ]\n : []),\n ...menuItems.map((item, index) => {\n const checked = totalDuration === item.timelineDuration;\n return (\n <MenuItem\n key={index}\n startIcon={checked ? <SvgCheckmark /> : <></>}\n onClick={() => {\n onTotalDurationChange(item.timelineDuration);\n close();\n }}\n >\n {item.label}\n </MenuItem>\n );\n }),\n ];\n }}\n placement=\"top-start\"\n >\n <IconButton\n data-testid=\"timeline-settings\"\n label={translate(\"button.label.settings\")}\n styleType=\"borderless\"\n >\n <SvgMoreVertical />\n </IconButton>\n </DropdownMenu>\n );\n}\n\nfunction useAnimation(\n onAnimate: (args: { delta: number }) => void,\n playing = true\n) {\n const onAnimateRef = React.useRef(onAnimate);\n onAnimateRef.current = onAnimate;\n\n const lastTimeRef = React.useRef<number | undefined>();\n\n React.useEffect(() => {\n if (!playing) return;\n\n let handle = 0;\n let didCancel = false;\n\n const animate = (time: number) => {\n if (lastTimeRef.current === undefined) {\n lastTimeRef.current = time;\n }\n\n const delta = time - lastTimeRef.current;\n lastTimeRef.current = time;\n\n onAnimateRef.current({\n delta,\n });\n\n if (didCancel) return;\n\n handle = window.requestAnimationFrame(animate);\n };\n\n handle = window.requestAnimationFrame(animate);\n return () => {\n didCancel = true;\n lastTimeRef.current = undefined;\n window.cancelAnimationFrame(handle);\n };\n }, [playing]);\n}\n\nfunction timeToMs(time: string) {\n if (time.indexOf(\":\") !== -1) {\n return (\n (Number(time.split(\":\")[0]) * 60 + Number(time.split(\":\")[1])) * 1000\n );\n } else {\n return Number(time) * 1000;\n }\n}\n\nfunction toDisplayTime(ms: number) {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(ms);\n // const hours = date.getUTCHours();\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ColorDef } from "@itwin/core-common";
|
|
5
5
|
import type { ScreenViewport } from "@itwin/core-frontend";
|
|
6
|
-
import type { GenericUiEventArgs } from "@itwin/appui-abstract";
|
|
7
6
|
/** The timeline scale.
|
|
8
7
|
* @public
|
|
9
8
|
*/
|
|
@@ -70,7 +69,8 @@ export declare enum TimelinePausePlayAction {
|
|
|
70
69
|
/** Args for event to pause or play the timeline component
|
|
71
70
|
* @public
|
|
72
71
|
*/
|
|
73
|
-
export interface TimelinePausePlayArgs
|
|
72
|
+
export interface TimelinePausePlayArgs {
|
|
73
|
+
uiComponentId: string;
|
|
74
74
|
timelineAction: TimelinePausePlayAction;
|
|
75
75
|
}
|
|
76
76
|
/** Interface for a timeline data provider class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/interfaces.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/interfaces.ts"],"names":[],"mappings":"AAI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E,4BAA4B,CAAC;IAC7C,iCAAiC;IACjC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,mBAAmB;IACnB,WAAW,EAAE,QAAQ,CAAC;IACtB,6CAA6C;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;sGACkG;IAClG,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/interfaces.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/interfaces.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAKH;;GAEG;AACH,IAAY,aAWX;AAXD,WAAY,aAAa;IACvB,iBAAiB;IACjB,mDAAK,CAAA;IACL,oBAAoB;IACpB,yDAAQ,CAAA;IACR,kBAAkB;IAClB,qDAAM,CAAA;IACN,gBAAgB;IAChB,iDAAI,CAAA;IACJ,iBAAiB;IACjB,mDAAK,CAAA;AACP,CAAC,EAXW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAWxB;AAED;;GAEG;AACH,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,qDAAqD;IACrD,yEAAU,CAAA;IACV,sEAAsE;IACtE,2EAAW,CAAA;AACb,CAAC,EALW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAK9B;AAwCD;;GAEG;AACH,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,yEAAM,CAAA;IACN,uEAAK,CAAA;IACL,qEAAI,CAAA;AACN,CAAC,EAJW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAIlC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Timeline\n */\n\nimport type { ColorDef } from \"@itwin/core-common\";\nimport type { ScreenViewport } from \"@itwin/core-frontend\";\n\n/** The timeline scale.\n * @public\n */\nexport enum TimelineScale {\n /** Show years */\n Years,\n /** Show quarters */\n Quarters,\n /** Show months */\n Months,\n /** Show days */\n Days,\n /** Show hours */\n Hours,\n}\n\n/** Determines if data displayed to use is the actual date or the amount of time elapsed since project start.\n * @public\n */\nexport enum TimelineDateDisplay {\n /** Display time axis using actual start/end dates */\n ActualTime,\n /** Display time axis using time relative to actual start/end dates */\n ProjectTime,\n}\n\n/**\n * Playback Settings.\n * @public\n */\nexport interface PlaybackSettings {\n /** time in milliseconds to play animation from start date to end date */\n duration?: number;\n /** Set to True if animation to restart each time playbackEnd is reached. Defaults to false. */\n loop?: boolean;\n /** If true a minimal set of data is displayed. */\n minimized?: boolean;\n /** Playback start. If defined must be within start-end range. If not define 'start' is used. */\n playbackStart?: Date;\n /** Playback end. If defined must be within start-end range and later than playbackStart. If not define 'end' is used. */\n playbackEnd?: Date;\n /** Set to True if user should be allowed to insert milestone dates. Defaults to false */\n allowMilestoneEdits?: boolean;\n /** Define if actual date/times are used or date/times relative to project are used to draw timeline axis. */\n dateDisplay?: TimelineDateDisplay;\n}\n\n/**\n * An interface used to notify Handlers of the current pointer position in the timeline playback. Valid range is 0 to 1 and it determines percentage complete.\n * @public\n */\nexport type AnimationFractionChangeHandler = (\n animationFraction: number\n) => void;\n\n/**\n * An interface used to notify Handlers of Playback Settings changes.\n * Contains the settings to be used.\n * @public\n */\nexport type PlaybackSettingsChangeHandler = (\n settingsChange: PlaybackSettings\n) => void;\n\n/** Actions for Pause/Play event\n * @public\n */\nexport enum TimelinePausePlayAction {\n Toggle,\n Pause,\n Play,\n}\n/** Args for event to pause or play the timeline component\n * @public\n */\nexport interface TimelinePausePlayArgs {\n uiComponentId: string;\n timelineAction: TimelinePausePlayAction;\n}\n/** Interface for a timeline data provider class\n * @public\n */\nexport interface TimelineDataProvider {\n /** uniqueId of provider */\n id: string;\n /** view id when viewport is initially assigned */\n viewId: string;\n /** returns true if the provider has timeline animation data available */\n supportsTimelineAnimation: boolean;\n /** Starting date for entire timeline */\n start?: Date;\n /** End date for entire timeline */\n end?: Date;\n /** Current animation fraction from 0.0 to 1.0 */\n animationFraction?: number;\n getSettings(): PlaybackSettings;\n /** Called to get the initial scrubber location. This must be a value between 0 and the duration in PlaybackSettings. */\n initialDuration: number;\n /** Called to get the duration of the Playback. */\n duration: number;\n /** If true the playback will continuously loop. */\n loop: boolean;\n /** Called to save the playback settings */\n updateSettings(settings: PlaybackSettings): void;\n /** Async call to load milestone and settings data */\n loadTimelineData(): Promise<boolean>;\n /** Called when an internal process has defined the playback settings and the UI needs to be updated */\n onPlaybackSettingChanged?: PlaybackSettingsChangeHandler;\n /** Called when the an internal process has defined the playback settings and the UI needs to be updated */\n onAnimationFractionChanged?: AnimationFractionChangeHandler;\n /** viewport to show animation */\n viewport?: ScreenViewport;\n}\n\n/**\n * An interface used to notify Handlers of Playback progress.\n * Contains the settings to be used.\n * @alpha\n */\nexport type SolarPlaybackProgressHandler = (time: Date) => void;\n\n/** Data Provider interface for getting and setting solar position\n * @alpha\n */\nexport interface SolarDataProvider {\n // View Id used to determine sunrise and sunset\n viewId: string;\n /** returns true if the provider has timeline animation data available */\n supportsTimelineAnimation: boolean;\n // set to true is timeline should be shown - return false if view is not set to display shadow.\n readonly shouldShowTimeline: boolean;\n /** Starting date for entire timeline */\n day: Date;\n /** Starting time for day in milliseconds */\n readonly dayStartMs: number;\n /** Time of day for sun */\n readonly timeOfDay: Date;\n /** Called during playback to update animation */\n onTimeChanged?: SolarPlaybackProgressHandler;\n /** viewport to show animation */\n viewport?: ScreenViewport;\n /** Time of Sunrise to nearest minute */\n readonly sunrise: Date;\n /** time of Sunrise to nearest minute */\n readonly sunset: Date;\n /** shadow color */\n shadowColor: ColorDef;\n /** timezone offset for local project time */\n readonly timeZoneOffset: number;\n /** set date for shadow study. If isProjectDate is false the is assume to be in users\n * current time and the value is adjusted to be the same date and time at the project location. */\n setDateAndTime: (day: Date, isProjectDate?: boolean) => void;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface UseTranslationResult {
|
|
2
|
+
translate: (key: string) => string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Returns a translation function.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function useTranslation(): UseTranslationResult;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=useTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/useTranslation.ts"],"names":[],"mappings":"AAOA,UAAU,oBAAoB;IAC5B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAMrD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useTranslation = void 0;
|
|
8
|
+
const UiIModelComponents_1 = require("./UiIModelComponents");
|
|
9
|
+
/**
|
|
10
|
+
* Returns a translation function.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
function useTranslation() {
|
|
14
|
+
const translate = (key) => {
|
|
15
|
+
return UiIModelComponents_1.UiIModelComponents.translate(key);
|
|
16
|
+
};
|
|
17
|
+
return { translate };
|
|
18
|
+
}
|
|
19
|
+
exports.useTranslation = useTranslation;
|
|
20
|
+
//# sourceMappingURL=useTranslation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../../../src/imodel-components-react/useTranslation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,6DAA0D;AAM1D;;;GAGG;AACH,SAAgB,cAAc;IAC5B,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;QAChC,OAAO,uCAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC;AAND,wCAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { UiIModelComponents } from \"./UiIModelComponents\";\n\ninterface UseTranslationResult {\n translate: (key: string) => string;\n}\n\n/**\n * Returns a translation function.\n * @internal\n */\nexport function useTranslation(): UseTranslationResult {\n const translate = (key: string) => {\n return UiIModelComponents.translate(key);\n };\n\n return { translate };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewportComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EAEX,SAAS,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,gBAAgB;IAChB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/D,sCAAsC;IACtC,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,OAAO,cAAc,CAAC;IAC/C,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,cAAc,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"ViewportComponent.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/viewport/ViewportComponent.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,WAAW,EAEX,SAAS,EACV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,cAAc,EAGf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQrD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,wBAAwB;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,2CAA2C;IAC3C,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,wDAAwD;IACxD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB;IAChB,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC;IACjD,gBAAgB;IAChB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,KAAK,CAAC,SAAS,CAAC;IAC/D,sCAAsC;IACtC,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,OAAO,cAAc,CAAC;IAC/C,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,cAAc,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,qBA2UrD"}
|
|
@@ -44,7 +44,7 @@ const ViewportComponentEvents_1 = require("./ViewportComponentEvents");
|
|
|
44
44
|
function ViewportComponent(props) {
|
|
45
45
|
const { viewState, imodel, viewDefinitionId, getViewOverlay, viewManagerOverride, tentativePointOverride, onContextMenu, style, className, screenViewportOverride, controlId, viewportRef, } = props;
|
|
46
46
|
// istanbul ignore next
|
|
47
|
-
const viewManagerRef = React.useRef(viewManagerOverride
|
|
47
|
+
const viewManagerRef = React.useRef(viewManagerOverride !== null && viewManagerOverride !== void 0 ? viewManagerOverride : core_frontend_1.IModelApp.viewManager);
|
|
48
48
|
const tentativePointOverrideRef = React.useRef(tentativePointOverride);
|
|
49
49
|
const screenViewportCreated = React.useRef(false);
|
|
50
50
|
const viewportDiv = React.useRef(null);
|
|
@@ -102,9 +102,10 @@ function ViewportComponent(props) {
|
|
|
102
102
|
};
|
|
103
103
|
const targetPoint = React.useRef(null);
|
|
104
104
|
const getRotatePoint = (vp) => {
|
|
105
|
+
var _a, _b;
|
|
105
106
|
const lastTargetPoint = targetPoint.current;
|
|
106
107
|
// istanbul ignore next
|
|
107
|
-
const tentativePoint = tentativePointOverrideRef.current
|
|
108
|
+
const tentativePoint = (_a = tentativePointOverrideRef.current) !== null && _a !== void 0 ? _a : core_frontend_1.IModelApp.tentativePoint;
|
|
108
109
|
// istanbul ignore else
|
|
109
110
|
if (tentativePoint.isActive)
|
|
110
111
|
return tentativePoint.getPoint();
|
|
@@ -122,7 +123,7 @@ function ViewportComponent(props) {
|
|
|
122
123
|
targetPoint.current =
|
|
123
124
|
undefined !== visiblePoint ? visiblePoint : vp.view.getTargetPoint();
|
|
124
125
|
// istanbul ignore next
|
|
125
|
-
return targetPoint.current
|
|
126
|
+
return (_b = targetPoint.current) !== null && _b !== void 0 ? _b : vp.view.getCenter();
|
|
126
127
|
};
|
|
127
128
|
const handleCubeRotationChangeEvent = (args) => {
|
|
128
129
|
const viewManager = viewManagerRef.current;
|
|
@@ -173,7 +174,10 @@ function ViewportComponent(props) {
|
|
|
173
174
|
? screenViewportOverride
|
|
174
175
|
: core_frontend_1.ScreenViewport;
|
|
175
176
|
const parentWindow = parentDiv.ownerDocument.defaultView;
|
|
176
|
-
parentWindow.addEventListener("unload", handleWindowUnload,
|
|
177
|
+
parentWindow.addEventListener("unload", handleWindowUnload, {
|
|
178
|
+
once: true,
|
|
179
|
+
capture: true,
|
|
180
|
+
}); // by specifying 'once', listener clears after being called
|
|
177
181
|
ViewportComponentEvents_1.ViewportComponentEvents.initialize();
|
|
178
182
|
ViewportComponentEvents_1.ViewportComponentEvents.onDrawingViewportChangeEvent.addListener(handleDrawingViewportChangeEvent);
|
|
179
183
|
ViewportComponentEvents_1.ViewportComponentEvents.onCubeRotationChangeEvent.addListener(handleCubeRotationChangeEvent);
|
|
@@ -226,8 +230,8 @@ function ViewportComponent(props) {
|
|
|
226
230
|
}
|
|
227
231
|
// istanbul ignore next
|
|
228
232
|
if (isMounted.current &&
|
|
229
|
-
(currentViewState
|
|
230
|
-
setInitialViewState(currentViewState
|
|
233
|
+
((currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isOpen) || (currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.iModel.isBlank))) {
|
|
234
|
+
setInitialViewState(currentViewState === null || currentViewState === void 0 ? void 0 : currentViewState.clone());
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
237
|
if (undefined === initialViewState)
|
|
@@ -236,12 +240,13 @@ function ViewportComponent(props) {
|
|
|
236
240
|
const [viewOverlay, setViewOverlay] = React.useState(null);
|
|
237
241
|
// This useEffect connects to ViewManger as soon as initialViewState is available once component is mounted.
|
|
238
242
|
React.useEffect(() => {
|
|
243
|
+
var _a;
|
|
239
244
|
const parentDiv = viewportDiv.current;
|
|
240
245
|
const viewManager = viewManagerRef.current;
|
|
241
246
|
// istanbul ignore next
|
|
242
247
|
if (parentDiv &&
|
|
243
248
|
initialViewState &&
|
|
244
|
-
(initialViewState
|
|
249
|
+
((initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isOpen) || (initialViewState === null || initialViewState === void 0 ? void 0 : initialViewState.iModel.isBlank))) {
|
|
245
250
|
if (!screenViewportCreated.current) {
|
|
246
251
|
const screenViewport = getScreenViewport(parentDiv, initialViewState);
|
|
247
252
|
screenViewportRef.current = screenViewport;
|
|
@@ -254,7 +259,7 @@ function ViewportComponent(props) {
|
|
|
254
259
|
}
|
|
255
260
|
else {
|
|
256
261
|
// istanbul ignore next
|
|
257
|
-
screenViewportRef.current
|
|
262
|
+
(_a = screenViewportRef.current) === null || _a === void 0 ? void 0 : _a.changeView(initialViewState);
|
|
258
263
|
}
|
|
259
264
|
}
|
|
260
265
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|