@opengeoweb/time-slider 19.6.0 → 19.6.1-nightly-20260913

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/dist/index.esm.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { Grid, useTheme, Box, Typography, Menu, MenuItem, CardHeader, FormControl, TextField, Select, Popper, Paper, Stack, InputAdornment, ClickAwayListener } from '@mui/material';
2
+ import { Grid, useTheme, Box, Typography, Menu, MenuItem, CardHeader, RadioGroup, FormControlLabel, Radio, Divider, FormHelperText, FormControl, TextField, Select, Popper, Paper, Stack, ClickAwayListener } from '@mui/material';
3
3
  import React, { useState, useRef, useEffect, useCallback, useContext, useMemo, createElement } from 'react';
4
- import { dateUtils, isTargetInteractiveInput, isDialogFocused, safelyInitI18nForTestsAndStories, CustomIconButton, CustomTooltip, CanvasComponent, renderCounter, CustomToggleButton } from '@opengeoweb/shared';
4
+ import { dateUtils, isTargetInteractiveInput, isDialogFocused, safelyInitI18nForTestsAndStories, CustomIconButton, CustomTooltip, CanvasComponent, NumberWithUnitField, DateTimePicker, renderCounter, pickerDateToUTC, CustomToggleButton } from '@opengeoweb/shared';
5
5
  import { debounce, throttle } from 'lodash';
6
- import { ChevronDown, ChevronUp, dragHandlePath, Edit, Animation, AutoUpdateActive, AutoUpdateInActive, StepForward, StepBackward, Now, Pause, Play, Speed, Clock, FastForward, Options, CalendarToday, ThemeWrapper, lightTheme, darkTheme } from '@opengeoweb/theme';
6
+ import { ChevronDown, ChevronUp, dragHandlePath, Edit, Animation, CalendarToday, AutoUpdateActive, AutoUpdateInActive, StepForward, StepBackward, Now, Pause, Play, Speed, Clock, FastForward, Options, ThemeWrapper, lightTheme, darkTheme } from '@opengeoweb/theme';
7
7
  import i18n from 'i18next';
8
8
  import { useTranslation, I18nextProvider } from 'react-i18next';
9
9
  import { Box as Box$1 } from '@mui/system';
10
- import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
11
- import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
12
- import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
13
10
  import { PickerDay } from '@mui/x-date-pickers/PickerDay';
14
11
 
15
12
  var en = {
@@ -61,7 +58,33 @@ var en = {
61
58
  "timeslider-span": "Span",
62
59
  "timeslider-marker": "Marker",
63
60
  "timeslider-marker-placement": "Marker placement",
64
- "timeslider-marker-label": "Select date and time"
61
+ "timeslider-marker-label": "Select date and time",
62
+ "timeslider-animation-length": "Animation length",
63
+ "timeslider-animation-length-auto": "Auto",
64
+ "timeslider-animation-length-now": "Now −/+",
65
+ "timeslider-animation-length-recurring-period": "Recurring period −/+",
66
+ "timeslider-animation-length-reference-time": "Reference time −/+",
67
+ "timeslider-animation-length-exact": "Exact",
68
+ "timeslider-anchor-time": "Anchor Time",
69
+ "timeslider-auto-animation-length": "Auto animation length",
70
+ "timeslider-date": "Date",
71
+ "timeslider-start-time": "Start time",
72
+ "timeslider-end-time": "End time",
73
+ "timeslider-unit-years": "years",
74
+ "timeslider-unit-months": "months",
75
+ "timeslider-unit-weeks": "weeks",
76
+ "timeslider-unit-days": "days",
77
+ "timeslider-unit-hours": "hours",
78
+ "timeslider-unit-minutes": "minutes",
79
+ "timeslider-unit-short-years": "yr",
80
+ "timeslider-unit-short-months": "mo",
81
+ "timeslider-unit-short-weeks": "w",
82
+ "timeslider-unit-short-days": "d",
83
+ "timeslider-unit-short-hours": "h",
84
+ "timeslider-unit-short-minutes": "m",
85
+ "timeslider-start-before-end": "Start time must be before end time",
86
+ "timeslider-animation-too-many-steps": "Reduce the animation length or increase the time step",
87
+ "timeslider-start-and-end-time": "Start and end time"
65
88
  };
66
89
  var fi = {
67
90
  "timeslider-auto": "Auto",
@@ -111,7 +134,32 @@ var fi = {
111
134
  "timeslider-span": "missing-translation",
112
135
  "timeslider-marker": "Aikamerkki",
113
136
  "timeslider-marker-placement": "Aikamerkin siirto",
114
- "timeslider-marker-label": "Valitse päivämäärä ja kellonaika"
137
+ "timeslider-marker-label": "Valitse päivämäärä ja kellonaika",
138
+ "timeslider-animation-length": "Animaation pituus",
139
+ "timeslider-animation-length-auto": "Auto",
140
+ "timeslider-animation-length-now": "Nyt −/+",
141
+ "timeslider-animation-length-recurring-period": "Toistuva jakso −/+",
142
+ "timeslider-animation-length-reference-time": "Referenssiaika −/+",
143
+ "timeslider-animation-length-exact": "Tarkka",
144
+ "timeslider-anchor-time": "Ankkuriaika",
145
+ "timeslider-auto-animation-length": "Automaattinen animaation pituus",
146
+ "timeslider-date": "Päivämäärä",
147
+ "timeslider-start-time": "Alkuaika",
148
+ "timeslider-end-time": "Loppuaika",
149
+ "timeslider-unit-years": "vuotta",
150
+ "timeslider-unit-months": "kuukautta",
151
+ "timeslider-unit-weeks": "viikkoa",
152
+ "timeslider-unit-days": "päivää",
153
+ "timeslider-unit-hours": "tuntia",
154
+ "timeslider-unit-minutes": "minuuttia",
155
+ "timeslider-unit-short-years": "v",
156
+ "timeslider-unit-short-months": "kk",
157
+ "timeslider-unit-short-weeks": "vk",
158
+ "timeslider-unit-short-days": "pv",
159
+ "timeslider-unit-short-hours": "t",
160
+ "timeslider-unit-short-minutes": "min",
161
+ "timeslider-start-before-end": "Alkuajan on oltava ennen loppuaikaa",
162
+ "timeslider-animation-too-many-steps": "Pienennä animaation pituutta tai kasvata aika-askelta"
115
163
  };
116
164
  var no = {
117
165
  "timeslider-auto": "Auto",
@@ -161,7 +209,32 @@ var no = {
161
209
  "timeslider-span": "Periode",
162
210
  "timeslider-marker": "missing translation",
163
211
  "timeslider-marker-placement": "missing translation",
164
- "timeslider-marker-label": "missing translation"
212
+ "timeslider-marker-label": "missing translation",
213
+ "timeslider-animation-length": "Animasjonslengde",
214
+ "timeslider-animation-length-auto": "Auto",
215
+ "timeslider-animation-length-now": "Nå −/+",
216
+ "timeslider-animation-length-recurring-period": "Gjentakende periode −/+",
217
+ "timeslider-animation-length-reference-time": "Referansetid −/+",
218
+ "timeslider-animation-length-exact": "Eksakt",
219
+ "timeslider-anchor-time": "Ankertid",
220
+ "timeslider-auto-animation-length": "Automatisk animasjonslengde",
221
+ "timeslider-date": "Dato",
222
+ "timeslider-start-time": "Starttid",
223
+ "timeslider-end-time": "Slutttid",
224
+ "timeslider-unit-years": "år",
225
+ "timeslider-unit-months": "måneder",
226
+ "timeslider-unit-weeks": "uker",
227
+ "timeslider-unit-days": "dager",
228
+ "timeslider-unit-hours": "timer",
229
+ "timeslider-unit-minutes": "minutter",
230
+ "timeslider-unit-short-years": "år",
231
+ "timeslider-unit-short-months": "mnd",
232
+ "timeslider-unit-short-weeks": "u",
233
+ "timeslider-unit-short-days": "d",
234
+ "timeslider-unit-short-hours": "t",
235
+ "timeslider-unit-short-minutes": "m",
236
+ "timeslider-start-before-end": "Starttid må være før slutttid",
237
+ "timeslider-animation-too-many-steps": "Reduser animasjonslengden eller øk tidssteget"
165
238
  };
166
239
  var nl = {
167
240
  "timeslider-auto": "Auto",
@@ -211,7 +284,33 @@ var nl = {
211
284
  "timeslider-span": "Tijdsperiode",
212
285
  "timeslider-marker": "Kies tijdstip",
213
286
  "timeslider-marker-placement": "Tijd kiezen",
214
- "timeslider-marker-label": "Selecteer datum en tijd"
287
+ "timeslider-marker-label": "Selecteer datum en tijd",
288
+ "timeslider-animation-length": "Animatielengte",
289
+ "timeslider-animation-length-auto": "Auto",
290
+ "timeslider-animation-length-now": "Nu −/+",
291
+ "timeslider-animation-length-recurring-period": "Terugkerende periode −/+",
292
+ "timeslider-animation-length-reference-time": "Referentietijd −/+",
293
+ "timeslider-animation-length-exact": "Exact",
294
+ "timeslider-anchor-time": "Ankertijd",
295
+ "timeslider-auto-animation-length": "Automatische animatielengte",
296
+ "timeslider-date": "Datum",
297
+ "timeslider-start-time": "Starttijd",
298
+ "timeslider-end-time": "Eindtijd",
299
+ "timeslider-unit-years": "jaren",
300
+ "timeslider-unit-months": "maanden",
301
+ "timeslider-unit-weeks": "weken",
302
+ "timeslider-unit-days": "dagen",
303
+ "timeslider-unit-hours": "uren",
304
+ "timeslider-unit-minutes": "minuten",
305
+ "timeslider-unit-short-years": "jr",
306
+ "timeslider-unit-short-months": "mnd",
307
+ "timeslider-unit-short-weeks": "w",
308
+ "timeslider-unit-short-days": "d",
309
+ "timeslider-unit-short-hours": "u",
310
+ "timeslider-unit-short-minutes": "m",
311
+ "timeslider-start-before-end": "Starttijd moet voor eindtijd liggen",
312
+ "timeslider-animation-too-many-steps": "Verklein de animatielengte of vergroot de tijdstap",
313
+ "timeslider-start-and-end-time": "Start- en eindtijd"
215
314
  };
216
315
  var timesliderTranslations = {
217
316
  en: en,
@@ -2340,6 +2439,537 @@ var AnimationLengthButton = function AnimationLengthButton(_ref) {
2340
2439
  });
2341
2440
  };
2342
2441
 
2442
+ var _modeTranslationKey;
2443
+ var AnimationLengthMode;
2444
+ (function (AnimationLengthMode) {
2445
+ AnimationLengthMode["Auto"] = "auto";
2446
+ AnimationLengthMode["Now"] = "now";
2447
+ AnimationLengthMode["RecurringPeriod"] = "recurringPeriod";
2448
+ AnimationLengthMode["ReferenceTime"] = "referenceTime";
2449
+ AnimationLengthMode["Exact"] = "exact";
2450
+ })(AnimationLengthMode || (AnimationLengthMode = {}));
2451
+ var timeUnits = ['years', 'months', 'weeks', 'days', 'hours', 'minutes'];
2452
+ var defaultStartOffset = {
2453
+ value: 0,
2454
+ unit: 'hours'
2455
+ };
2456
+ var defaultEndOffset = {
2457
+ value: 2,
2458
+ unit: 'hours'
2459
+ };
2460
+ var defaultNowAnimationLength = {
2461
+ mode: AnimationLengthMode.Now,
2462
+ startOffset: defaultStartOffset,
2463
+ endOffset: defaultEndOffset
2464
+ };
2465
+ var unitTranslationKey = {
2466
+ years: 'timeslider-unit-years',
2467
+ months: 'timeslider-unit-months',
2468
+ weeks: 'timeslider-unit-weeks',
2469
+ days: 'timeslider-unit-days',
2470
+ hours: 'timeslider-unit-hours',
2471
+ minutes: 'timeslider-unit-minutes'
2472
+ };
2473
+ var shortUnitTranslationKey = {
2474
+ years: 'timeslider-unit-short-years',
2475
+ months: 'timeslider-unit-short-months',
2476
+ weeks: 'timeslider-unit-short-weeks',
2477
+ days: 'timeslider-unit-short-days',
2478
+ hours: 'timeslider-unit-short-hours',
2479
+ minutes: 'timeslider-unit-short-minutes'
2480
+ };
2481
+ var modeTranslationKey = (_modeTranslationKey = {}, _modeTranslationKey[AnimationLengthMode.Auto] = 'timeslider-animation-length-auto', _modeTranslationKey[AnimationLengthMode.Now] = 'timeslider-animation-length-now', _modeTranslationKey[AnimationLengthMode.RecurringPeriod] = 'timeslider-animation-length-recurring-period', _modeTranslationKey[AnimationLengthMode.ReferenceTime] = 'timeslider-animation-length-reference-time', _modeTranslationKey[AnimationLengthMode.Exact] = 'timeslider-animation-length-exact', _modeTranslationKey);
2482
+ var offsetToDuration = function offsetToDuration(_ref) {
2483
+ var _ref2;
2484
+ var value = _ref.value,
2485
+ unit = _ref.unit;
2486
+ return _ref2 = {}, _ref2[unit] = value, _ref2;
2487
+ };
2488
+ var toAnimationTime = function toAnimationTime(date) {
2489
+ return dateUtils.dateToString(date, dateUtils.DATE_FORMAT_UTC);
2490
+ };
2491
+ /**
2492
+ * Offsets are signed: negative lands before now, positive after. They are applied
2493
+ * as calendar durations, so "+ 1 month" lands on the same day of the next month
2494
+ * rather than a fixed number of days later.
2495
+ */
2496
+ var resolveNowAnimationRange = function resolveNowAnimationRange(_ref3, now) {
2497
+ var _ref3$startOffset = _ref3.startOffset,
2498
+ startOffset = _ref3$startOffset === void 0 ? defaultStartOffset : _ref3$startOffset,
2499
+ _ref3$endOffset = _ref3.endOffset,
2500
+ endOffset = _ref3$endOffset === void 0 ? defaultEndOffset : _ref3$endOffset;
2501
+ if (now === void 0) {
2502
+ now = dateUtils.utc();
2503
+ }
2504
+ return {
2505
+ animationStartTime: toAnimationTime(dateUtils.add(now, offsetToDuration(startOffset))),
2506
+ animationEndTime: toAnimationTime(dateUtils.add(now, offsetToDuration(endOffset)))
2507
+ };
2508
+ };
2509
+ /** Offsets can use different units, so validity is decided on the resolved instants. */
2510
+ var isValidAnimationLength = function isValidAnimationLength(setting, now) {
2511
+ if (now === void 0) {
2512
+ now = dateUtils.utc();
2513
+ }
2514
+ if (setting.mode === AnimationLengthMode.Now) {
2515
+ var _resolveNowAnimationR = resolveNowAnimationRange(setting, now),
2516
+ animationStartTime = _resolveNowAnimationR.animationStartTime,
2517
+ animationEndTime = _resolveNowAnimationR.animationEndTime;
2518
+ return dateUtils.isBefore(dateUtils.utc(animationStartTime), dateUtils.utc(animationEndTime));
2519
+ }
2520
+ if (setting.animationStartTime && setting.animationEndTime) {
2521
+ return dateUtils.isBefore(dateUtils.utc(setting.animationStartTime).setSeconds(0, 0), dateUtils.utc(setting.animationEndTime).setSeconds(0, 0));
2522
+ }
2523
+ return true;
2524
+ };
2525
+ /** Frames the animation may hold; the range is expanded one entry per time step. */
2526
+ var MAX_ANIMATION_STEPS = 10000;
2527
+ /**
2528
+ * The cost of an animation is its span divided by the time step, so a wide range
2529
+ * is affordable with a coarse step and unaffordable with a fine one.
2530
+ */
2531
+ var isWithinAnimationStepLimit = function isWithinAnimationStepLimit(setting, timeStepInMinutes, now) {
2532
+ if (now === void 0) {
2533
+ now = dateUtils.utc();
2534
+ }
2535
+ if (!timeStepInMinutes) {
2536
+ return true;
2537
+ }
2538
+ var _resolveNowAnimationR2 = resolveNowAnimationRange(setting, now),
2539
+ animationStartTime = _resolveNowAnimationR2.animationStartTime,
2540
+ animationEndTime = _resolveNowAnimationR2.animationEndTime;
2541
+ var spanInMinutes = dateUtils.differenceInMinutes(dateUtils.utc(animationEndTime), dateUtils.utc(animationStartTime));
2542
+ return Math.abs(spanInMinutes) / timeStepInMinutes <= MAX_ANIMATION_STEPS;
2543
+ };
2544
+ var exactAnimationLength = {
2545
+ mode: AnimationLengthMode.Exact
2546
+ };
2547
+ var toExactAnimationTime = function toExactAnimationTime(date) {
2548
+ return dateUtils.dateToIsoString(date);
2549
+ };
2550
+
2551
+ var selectableModes = [AnimationLengthMode.Auto, AnimationLengthMode.Now, AnimationLengthMode.Exact];
2552
+ var OFFSET_MAX_DIGITS = 3;
2553
+ var maxOffsetByUnit = {
2554
+ minutes: 999,
2555
+ hours: 999,
2556
+ days: 365,
2557
+ weeks: 99,
2558
+ months: 99,
2559
+ years: 99
2560
+ };
2561
+ /* One line of MuiFormHelperText: 20px line box plus its 3px top margin. */
2562
+ var RESERVED_ERROR_HEIGHT = '23px';
2563
+ var styles$1 = {
2564
+ menu: {
2565
+ display: 'flex',
2566
+ flexDirection: 'column',
2567
+ minWidth: '260px',
2568
+ padding: '8px 12px'
2569
+ },
2570
+ sectionTitle: {
2571
+ fontSize: 12,
2572
+ fontWeight: 700
2573
+ },
2574
+ caption: {
2575
+ color: 'geowebColors.greys.accessible',
2576
+ fontSize: 11
2577
+ },
2578
+ radioLabel: {
2579
+ '& .MuiFormControlLabel-label': {
2580
+ fontSize: 14
2581
+ }
2582
+ },
2583
+ anchorRow: {
2584
+ alignItems: 'center',
2585
+ display: 'flex',
2586
+ gap: 1,
2587
+ paddingY: 0.5
2588
+ },
2589
+ anchorValue: {
2590
+ flexGrow: 1,
2591
+ fontSize: 14,
2592
+ fontWeight: 700
2593
+ },
2594
+ /* Matches the reserved error line below, so the fields sit between equal gaps. */
2595
+ offsets: {
2596
+ display: 'flex',
2597
+ gap: 1,
2598
+ paddingTop: RESERVED_ERROR_HEIGHT
2599
+ },
2600
+ reservedError: {
2601
+ visibility: 'hidden'
2602
+ },
2603
+ readOnlyValue: {
2604
+ fontSize: 14
2605
+ },
2606
+ exact: {
2607
+ display: 'flex',
2608
+ flexDirection: 'column'
2609
+ },
2610
+ dateTimePicker: {
2611
+ paddingBottom: 2
2612
+ }
2613
+ };
2614
+ var AnimationLengthMenu = function AnimationLengthMenu(_ref) {
2615
+ var _setting$startOffset2, _setting$endOffset2;
2616
+ var setting = _ref.setting,
2617
+ onChange = _ref.onChange,
2618
+ animationStartTime = _ref.animationStartTime,
2619
+ animationEndTime = _ref.animationEndTime,
2620
+ autoTimeStepLayerName = _ref.autoTimeStepLayerName,
2621
+ timeStep = _ref.timeStep,
2622
+ _ref$isAutoDisabled = _ref.isAutoDisabled,
2623
+ isAutoDisabled = _ref$isAutoDisabled === void 0 ? false : _ref$isAutoDisabled,
2624
+ _ref$disabled = _ref.disabled,
2625
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
2626
+ var _useTimesliderTransla = useTimesliderTranslation(),
2627
+ t = _useTimesliderTransla.t;
2628
+ var changeMode = function changeMode(mode) {
2629
+ if (mode === AnimationLengthMode.Now) {
2630
+ var _setting$startOffset, _setting$endOffset;
2631
+ onChange({
2632
+ mode: mode,
2633
+ startOffset: (_setting$startOffset = setting.startOffset) != null ? _setting$startOffset : defaultStartOffset,
2634
+ endOffset: (_setting$endOffset = setting.endOffset) != null ? _setting$endOffset : defaultEndOffset
2635
+ });
2636
+ return;
2637
+ }
2638
+ onChange(Object.assign({}, setting, {
2639
+ mode: mode
2640
+ }));
2641
+ };
2642
+ var startOffset = (_setting$startOffset2 = setting.startOffset) != null ? _setting$startOffset2 : defaultStartOffset;
2643
+ var endOffset = (_setting$endOffset2 = setting.endOffset) != null ? _setting$endOffset2 : defaultEndOffset;
2644
+ var unitOptions = timeUnits.map(function (unit) {
2645
+ return {
2646
+ value: unit,
2647
+ label: t(unitTranslationKey[unit])
2648
+ };
2649
+ });
2650
+ var asTimeOffset = function asTimeOffset(_ref2) {
2651
+ var value = _ref2.value,
2652
+ unit = _ref2.unit;
2653
+ var maxOffset = maxOffsetByUnit[unit];
2654
+ return {
2655
+ value: Math.max(-maxOffset, Math.min(maxOffset, value)),
2656
+ unit: unit
2657
+ };
2658
+ };
2659
+ /* One unit spans the whole window, so picking it on either field moves both. */
2660
+ var changeStartOffset = function changeStartOffset(offset) {
2661
+ var changed = asTimeOffset(offset);
2662
+ onChange(Object.assign({}, setting, {
2663
+ startOffset: changed,
2664
+ endOffset: asTimeOffset(Object.assign({}, endOffset, {
2665
+ unit: changed.unit
2666
+ }))
2667
+ }));
2668
+ };
2669
+ var changeEndOffset = function changeEndOffset(offset) {
2670
+ var changed = asTimeOffset(offset);
2671
+ onChange(Object.assign({}, setting, {
2672
+ startOffset: asTimeOffset(Object.assign({}, startOffset, {
2673
+ unit: changed.unit
2674
+ })),
2675
+ endOffset: changed
2676
+ }));
2677
+ };
2678
+ var followsClock = setting.mode === AnimationLengthMode.Now;
2679
+ var hasInvertedRange = !isValidAnimationLength(setting);
2680
+ var hasTooManySteps = followsClock && !hasInvertedRange && !isWithinAnimationStepLimit(setting, timeStep);
2681
+ var hasRangeError = hasInvertedRange || hasTooManySteps;
2682
+ var rangeError = function () {
2683
+ if (hasInvertedRange) {
2684
+ return t('timeslider-start-before-end');
2685
+ }
2686
+ if (hasTooManySteps) {
2687
+ return t('timeslider-animation-too-many-steps');
2688
+ }
2689
+ return ' ';
2690
+ }();
2691
+ var isModeDisabled = function isModeDisabled(mode) {
2692
+ return disabled || mode === AnimationLengthMode.Auto && isAutoDisabled;
2693
+ };
2694
+ var describedAnimationLength = animationStartTime && animationEndTime ? minutesToDescribedDuration(dateUtils.differenceInMinutes(dateUtils.utc(animationEndTime), dateUtils.utc(animationStartTime))) : '';
2695
+ var asDisplayTime = function asDisplayTime(time) {
2696
+ return time ? dateUtils.dateToString(dateUtils.utc(time), dateUtils.DATE_FORMAT_DATEPICKER, true) + " UTC" : '';
2697
+ };
2698
+ /* The surrounding Menu dismisses itself on Tab; keep it open so focus can reach the next field. */
2699
+ var keepMenuOpenOnTab = function keepMenuOpenOnTab(event) {
2700
+ if (event.key === 'Tab') {
2701
+ event.stopPropagation();
2702
+ }
2703
+ };
2704
+ var handleChangeStartTime = function handleChangeStartTime(date) {
2705
+ return onChange(Object.assign({}, setting, {
2706
+ animationStartTime: date ? toExactAnimationTime(date) : undefined,
2707
+ animationEndTime: animationEndTime
2708
+ }));
2709
+ };
2710
+ var handleChangeEndTime = function handleChangeEndTime(date) {
2711
+ return onChange(Object.assign({}, setting, {
2712
+ animationStartTime: animationStartTime,
2713
+ animationEndTime: date ? toExactAnimationTime(date) : undefined
2714
+ }));
2715
+ };
2716
+ return jsxs(Box, {
2717
+ onKeyDown: keepMenuOpenOnTab,
2718
+ sx: styles$1.menu,
2719
+ children: [jsx(Typography, {
2720
+ sx: styles$1.sectionTitle,
2721
+ children: t('timeslider-animation-length')
2722
+ }), jsx(RadioGroup, {
2723
+ onChange: function onChange(event) {
2724
+ return changeMode(event.target.value);
2725
+ },
2726
+ value: setting.mode,
2727
+ children: selectableModes.map(function (mode) {
2728
+ return jsx(FormControlLabel, {
2729
+ control: jsx(Radio, {
2730
+ size: "small"
2731
+ }),
2732
+ disabled: isModeDisabled(mode),
2733
+ label: t(modeTranslationKey[mode]),
2734
+ sx: styles$1.radioLabel,
2735
+ value: mode
2736
+ }, mode);
2737
+ })
2738
+ }), jsx(Divider, {
2739
+ sx: {
2740
+ marginY: 1
2741
+ }
2742
+ }), setting.mode === AnimationLengthMode.Exact ? jsx(Typography, {
2743
+ sx: styles$1.sectionTitle,
2744
+ children: t('timeslider-start-and-end-time')
2745
+ }) : jsx(Typography, {
2746
+ sx: styles$1.sectionTitle,
2747
+ children: t('timeslider-anchor-time')
2748
+ }), setting.mode === AnimationLengthMode.Auto && jsxs(Box, {
2749
+ children: [jsx(Typography, {
2750
+ sx: styles$1.readOnlyValue,
2751
+ children: autoTimeStepLayerName
2752
+ }), jsx(Typography, {
2753
+ sx: styles$1.caption,
2754
+ children: t('timeslider-auto-animation-length')
2755
+ }), jsx(Typography, {
2756
+ sx: styles$1.readOnlyValue,
2757
+ children: describedAnimationLength
2758
+ })]
2759
+ }), setting.mode === AnimationLengthMode.Now && jsxs(Box, {
2760
+ children: [jsx(Typography, {
2761
+ sx: styles$1.caption,
2762
+ children: t('timeslider-date')
2763
+ }), jsxs(Box, {
2764
+ sx: styles$1.anchorRow,
2765
+ children: [jsx(CalendarToday, {}), jsx(Typography, {
2766
+ sx: styles$1.anchorValue,
2767
+ children: t('timeslider-now')
2768
+ }), jsx(Typography, {
2769
+ sx: styles$1.caption,
2770
+ children: "UTC"
2771
+ })]
2772
+ }), jsxs(Box, {
2773
+ sx: styles$1.offsets,
2774
+ children: [jsx(NumberWithUnitField, {
2775
+ disabled: disabled,
2776
+ error: hasRangeError,
2777
+ label: t('timeslider-start-time'),
2778
+ maxDigits: OFFSET_MAX_DIGITS,
2779
+ maxMagnitude: maxOffsetByUnit[startOffset.unit],
2780
+ onChange: changeStartOffset,
2781
+ unit: startOffset.unit,
2782
+ unitOptions: unitOptions,
2783
+ value: startOffset.value
2784
+ }), jsx(NumberWithUnitField, {
2785
+ disabled: disabled,
2786
+ error: hasRangeError,
2787
+ label: t('timeslider-end-time'),
2788
+ maxDigits: OFFSET_MAX_DIGITS,
2789
+ maxMagnitude: maxOffsetByUnit[endOffset.unit],
2790
+ onChange: changeEndOffset,
2791
+ unit: endOffset.unit,
2792
+ unitOptions: unitOptions,
2793
+ value: endOffset.value
2794
+ })]
2795
+ }), jsx(FormHelperText, {
2796
+ "data-testid": "animationLengthRangeError",
2797
+ error: true,
2798
+ sx: hasRangeError ? undefined : styles$1.reservedError,
2799
+ children: rangeError
2800
+ })]
2801
+ }), setting.mode === AnimationLengthMode.Exact && jsxs(Box, {
2802
+ sx: styles$1.exact,
2803
+ children: [jsx(DateTimePicker, {
2804
+ label: t('timeslider-start-time'),
2805
+ onChange: handleChangeStartTime,
2806
+ slotProps: {
2807
+ textField: {
2808
+ error: hasRangeError
2809
+ }
2810
+ },
2811
+ sx: styles$1.dateTimePicker,
2812
+ value: animationStartTime ? new Date(animationStartTime) : undefined
2813
+ }), jsx(DateTimePicker, {
2814
+ label: t('timeslider-end-time'),
2815
+ onChange: handleChangeEndTime,
2816
+ slotProps: {
2817
+ textField: {
2818
+ error: hasRangeError
2819
+ }
2820
+ },
2821
+ value: animationEndTime ? new Date(animationEndTime) : undefined
2822
+ }), jsx(FormHelperText, {
2823
+ "data-testid": "animationLengthRangeError",
2824
+ error: true,
2825
+ sx: hasRangeError ? undefined : styles$1.reservedError,
2826
+ children: rangeError
2827
+ })]
2828
+ }), !selectableModes.includes(setting.mode) && jsxs(Box, {
2829
+ children: [jsx(Typography, {
2830
+ sx: styles$1.caption,
2831
+ children: t('timeslider-start-time')
2832
+ }), jsx(Typography, {
2833
+ sx: styles$1.readOnlyValue,
2834
+ children: asDisplayTime(animationStartTime)
2835
+ }), jsx(Typography, {
2836
+ sx: styles$1.caption,
2837
+ children: t('timeslider-end-time')
2838
+ }), jsx(Typography, {
2839
+ sx: styles$1.readOnlyValue,
2840
+ children: asDisplayTime(animationEndTime)
2841
+ })]
2842
+ })]
2843
+ });
2844
+ };
2845
+
2846
+ var styles = {
2847
+ button: {
2848
+ padding: '0px',
2849
+ paddingRight: '12px',
2850
+ width: '100%!important',
2851
+ minWidth: '64px',
2852
+ justifyContent: 'space-between'
2853
+ },
2854
+ buttonLabel: {
2855
+ fontSize: 12,
2856
+ fontWeight: 400,
2857
+ textTransform: 'none'
2858
+ }
2859
+ };
2860
+ var AnimationLengthPanel = function AnimationLengthPanel(_ref) {
2861
+ var setting = _ref.setting,
2862
+ onChange = _ref.onChange,
2863
+ animationStartTime = _ref.animationStartTime,
2864
+ animationEndTime = _ref.animationEndTime,
2865
+ autoTimeStepLayerName = _ref.autoTimeStepLayerName,
2866
+ timeStep = _ref.timeStep,
2867
+ _ref$isAutoDisabled = _ref.isAutoDisabled,
2868
+ isAutoDisabled = _ref$isAutoDisabled === void 0 ? false : _ref$isAutoDisabled,
2869
+ _ref$disabled = _ref.disabled,
2870
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
2871
+ var _useTimesliderTransla = useTimesliderTranslation(),
2872
+ t = _useTimesliderTransla.t;
2873
+ var _React$useState = React.useState(null),
2874
+ anchorRef = _React$useState[0],
2875
+ setAnchorRef = _React$useState[1];
2876
+ var _React$useState2 = React.useState(false),
2877
+ open = _React$useState2[0],
2878
+ setOpen = _React$useState2[1];
2879
+ var describedAnimationLength = animationStartTime && animationEndTime ? minutesToDescribedDuration(dateUtils.differenceInMinutes(dateUtils.utc(animationEndTime), dateUtils.utc(animationStartTime))) : '';
2880
+ var asDisplayTime = function asDisplayTime(time) {
2881
+ return time ? dateUtils.dateToString(dateUtils.utc(time), dateUtils.DATE_FORMAT_DATEPICKER) + " UTC" : '';
2882
+ };
2883
+ /* Zero has no direction, so it carries no sign. */
2884
+ var asSignedOffsetLabel = function asSignedOffsetLabel(_ref2) {
2885
+ var value = _ref2.value,
2886
+ unit = _ref2.unit;
2887
+ var sign = value === 0 ? '' : (value < 0 ? '−' : '+') + " ";
2888
+ return "" + sign + Math.abs(value) + " " + t(shortUnitTranslationKey[unit]);
2889
+ };
2890
+ var buttonLabel = function (_setting$startOffset, _setting$endOffset) {
2891
+ switch (setting.mode) {
2892
+ case AnimationLengthMode.Auto:
2893
+ return t('timeslider-auto') + " " + describedAnimationLength;
2894
+ case AnimationLengthMode.Now:
2895
+ return t('timeslider-now') + " " + asSignedOffsetLabel((_setting$startOffset = setting.startOffset) != null ? _setting$startOffset : defaultStartOffset) + " / " + asSignedOffsetLabel((_setting$endOffset = setting.endOffset) != null ? _setting$endOffset : defaultEndOffset);
2896
+ case AnimationLengthMode.Exact:
2897
+ return "" + t('timeslider-animation-length-exact');
2898
+ default:
2899
+ return describedAnimationLength;
2900
+ }
2901
+ }();
2902
+ /* Following the clock, so the heading names the anchor the offsets are counted from. */
2903
+ var tooltipHeading = setting.mode === AnimationLengthMode.Now ? t('timeslider-now') + " - " + dateUtils.dateToString(dateUtils.utc(), dateUtils.DATE_FORMAT_HOURS) : t(modeTranslationKey[setting.mode]);
2904
+ var tooltipTitle = jsxs(Box, {
2905
+ children: [jsx(Typography, {
2906
+ variant: "body2",
2907
+ children: tooltipHeading
2908
+ }), jsx(Typography, {
2909
+ variant: "body2",
2910
+ children: t('timeslider-start-time') + " " + asDisplayTime(animationStartTime)
2911
+ }), jsx(Typography, {
2912
+ variant: "body2",
2913
+ children: t('timeslider-end-time') + " " + asDisplayTime(animationEndTime)
2914
+ })]
2915
+ });
2916
+ return jsxs(Box, {
2917
+ onKeyDown: function onKeyDown(event) {
2918
+ event.stopPropagation();
2919
+ },
2920
+ children: [jsxs(CustomIconButton, {
2921
+ "aria-label": t('timeslider-animation-length'),
2922
+ "data-testid": "animationLengthPanelButton",
2923
+ isSelected: true,
2924
+ onClick: function onClick() {
2925
+ return setOpen(true);
2926
+ },
2927
+ ref: setAnchorRef,
2928
+ sx: styles.button,
2929
+ tooltipProps: {
2930
+ title: tooltipTitle,
2931
+ placement: 'top'
2932
+ },
2933
+ variant: "tool",
2934
+ children: [jsx(Animation, {}), jsx(Typography, {
2935
+ sx: styles.buttonLabel,
2936
+ children: buttonLabel
2937
+ })]
2938
+ }), !!anchorRef && jsx(Menu, {
2939
+ anchorEl: anchorRef,
2940
+ anchorOrigin: {
2941
+ vertical: -15,
2942
+ horizontal: 'center'
2943
+ },
2944
+ onClose: function onClose() {
2945
+ return setOpen(false);
2946
+ },
2947
+ open: open,
2948
+ slotProps: {
2949
+ backdrop: {
2950
+ sx: {
2951
+ backgroundColor: 'transparent'
2952
+ }
2953
+ }
2954
+ },
2955
+ transformOrigin: {
2956
+ vertical: 'bottom',
2957
+ horizontal: 'center'
2958
+ },
2959
+ children: jsx(AnimationLengthMenu, {
2960
+ animationEndTime: animationEndTime,
2961
+ animationStartTime: animationStartTime,
2962
+ autoTimeStepLayerName: autoTimeStepLayerName,
2963
+ disabled: disabled,
2964
+ isAutoDisabled: isAutoDisabled,
2965
+ onChange: onChange,
2966
+ setting: setting,
2967
+ timeStep: timeStep
2968
+ })
2969
+ })]
2970
+ });
2971
+ };
2972
+
2343
2973
  var AutoUpdateButton = function AutoUpdateButton(_ref) {
2344
2974
  var _ref$toggleAutoUpdate = _ref.toggleAutoUpdate,
2345
2975
  toggleAutoUpdate = _ref$toggleAutoUpdate === void 0 ? function () {} : _ref$toggleAutoUpdate,
@@ -2928,6 +3558,14 @@ var OptionsMenu = function OptionsMenu(_ref) {
2928
3558
  animationLengthBtn = _ref.animationLengthBtn;
2929
3559
  return jsxs(Fragment, {
2930
3560
  children: [jsx(Grid, {
3561
+ size: {
3562
+ xs: 'auto'
3563
+ },
3564
+ children: animationLengthBtn || jsx(AnimationLengthButton, {
3565
+ onChangeAnimationLength: function onChangeAnimationLength() {},
3566
+ toggleAnimationLengthAuto: function toggleAnimationLengthAuto() {}
3567
+ })
3568
+ }), jsx(Grid, {
2931
3569
  size: {
2932
3570
  xs: 'auto'
2933
3571
  },
@@ -2939,14 +3577,6 @@ var OptionsMenu = function OptionsMenu(_ref) {
2939
3577
  onToggleTimeSpan: function onToggleTimeSpan() {},
2940
3578
  timeSliderSpan: 0
2941
3579
  })
2942
- }), jsx(Grid, {
2943
- size: {
2944
- xs: 'auto'
2945
- },
2946
- children: animationLengthBtn || jsx(AnimationLengthButton, {
2947
- onChangeAnimationLength: function onChangeAnimationLength() {},
2948
- toggleAnimationLengthAuto: function toggleAnimationLengthAuto() {}
2949
- })
2950
3580
  }), jsx(Grid, {
2951
3581
  size: {
2952
3582
  xs: 'auto'
@@ -3238,18 +3868,6 @@ var renderTimeSliderCurrentTimeBox = function renderTimeSliderCurrentTimeBox(ctx
3238
3868
  };
3239
3869
 
3240
3870
  var _excluded = ["day", "today", "outsideCurrentMonth"];
3241
- var getTimezoneOffsetS = function getTimezoneOffsetS(value) {
3242
- return value.getTimezoneOffset() * 60;
3243
- };
3244
- var toLocalTime = function toLocalTime(dateTime) {
3245
- return dateUtils.fromUnix(dateTime + getTimezoneOffsetS(dateUtils.fromUnix(dateTime)));
3246
- };
3247
- var toUTCTime = function toUTCTime(dateTime) {
3248
- return dateUtils.unix(dateTime) - getTimezoneOffsetS(dateTime);
3249
- };
3250
- var OpenPicker = function OpenPicker() {
3251
- return jsx(CalendarToday, {});
3252
- };
3253
3871
  var enabledAndSelectedButtonStyle = {
3254
3872
  borderWidth: '6px',
3255
3873
  borderBottomStyle: 'solid',
@@ -3301,28 +3919,30 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3301
3919
  onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
3302
3920
  var _useTimesliderTransla = useTimesliderTranslation(),
3303
3921
  t = _useTimesliderTransla.t;
3304
- var _React$useState2 = React.useState(value ? toLocalTime(value) : null),
3305
- localTimeValue = _React$useState2[0],
3306
- setLocalTimeValue = _React$useState2[1];
3922
+ var _React$useState2 = React.useState(value ? dateUtils.fromUnix(value) : null),
3923
+ utcTimeValue = _React$useState2[0],
3924
+ setUtcTimeValue = _React$useState2[1];
3307
3925
  var _React$useState3 = React.useState(!dataStartTime || !dataEndTime || dataStartTime > dataEndTime),
3308
3926
  isUndefinedDateRange = _React$useState3[0],
3309
3927
  setIsUndefinedDateRange = _React$useState3[1];
3310
3928
  var isDateRangeDisabled = React.useCallback(function (date) {
3311
- if (dataStartTime === undefined || dataEndTime === undefined || dataStartTime > dataEndTime) {
3929
+ if (!date || dataStartTime === undefined || dataEndTime === undefined || dataStartTime > dataEndTime) {
3312
3930
  return true;
3313
3931
  }
3314
- var startOfFirstDay = dateUtils.fromUnix(dataStartTime);
3315
- startOfFirstDay.setHours(0, 0, 0);
3316
- var endOfLastDay = dateUtils.fromUnix(dataEndTime);
3317
- var day = dateUtils.unix(date);
3318
- return day < dateUtils.unix(startOfFirstDay) || day > dateUtils.unix(endOfLastDay);
3932
+ var asUtcDay = function asUtcDay(value) {
3933
+ return Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate());
3934
+ };
3935
+ var firstDay = asUtcDay(dateUtils.fromUnix(dataStartTime));
3936
+ var lastDay = asUtcDay(dateUtils.fromUnix(dataEndTime));
3937
+ var day = asUtcDay(date);
3938
+ return day < firstDay || day > lastDay;
3319
3939
  }, [dataStartTime, dataEndTime]);
3320
- var _React$useState4 = React.useState(isDateRangeDisabled(localTimeValue)),
3940
+ var _React$useState4 = React.useState(isDateRangeDisabled(utcTimeValue)),
3321
3941
  isDisabledRange = _React$useState4[0],
3322
3942
  setIsDisabledRange = _React$useState4[1];
3323
3943
  var handleSelect = function handleSelect() {
3324
- if (localTimeValue) {
3325
- onSelect(toUTCTime(localTimeValue));
3944
+ if (utcTimeValue) {
3945
+ onSelect(dateUtils.unix(utcTimeValue));
3326
3946
  }
3327
3947
  };
3328
3948
  var handleKeyDown = function handleKeyDown(event) {
@@ -3337,16 +3957,16 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3337
3957
  };
3338
3958
  var handleDateChange = function handleDateChange(value) {
3339
3959
  if (value instanceof Date || value === null || isDisabledDateWithSomeAvailableData()) {
3340
- setLocalTimeValue(value);
3960
+ setUtcTimeValue(value);
3341
3961
  }
3342
3962
  };
3343
3963
  var AvailableDay = function AvailableDay(props) {
3344
- return AvailableDayByTimeRange(props, isDateRangeDisabled(props.day));
3964
+ return AvailableDayByTimeRange(props, isDateRangeDisabled(pickerDateToUTC(props.day)));
3345
3965
  };
3346
3966
  React.useEffect(function () {
3347
3967
  setIsUndefinedDateRange(!dataStartTime || !dataEndTime || dataStartTime > dataEndTime);
3348
- setIsDisabledRange(isDateRangeDisabled(localTimeValue));
3349
- }, [dataStartTime, dataEndTime, localTimeValue, isDateRangeDisabled]);
3968
+ setIsDisabledRange(isDateRangeDisabled(utcTimeValue));
3969
+ }, [dataStartTime, dataEndTime, utcTimeValue, isDateRangeDisabled]);
3350
3970
  return jsx(Paper, {
3351
3971
  sx: {
3352
3972
  borderRadius: '0px',
@@ -3380,59 +4000,33 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3380
4000
  },
3381
4001
  children: t('timeslider-marker')
3382
4002
  })
3383
- }), jsx(LocalizationProvider, {
3384
- dateAdapter: AdapterDateFns,
3385
- children: jsx(DateTimePicker, {
3386
- ampm: false,
3387
- autoFocus: true,
3388
- closeOnSelect: false,
3389
- desktopModeMediaQuery: "@media (min-width: 720px)",
3390
- disableIgnoringDatePartForTimeValidation: true,
3391
- format: format,
3392
- label: t('timeslider-marker-label'),
3393
- maxDateTime: isUndefinedDateRange ? undefined : toLocalTime(dataEndTime),
3394
- minDateTime: isUndefinedDateRange ? undefined : toLocalTime(dataStartTime),
3395
- onChange: handleDateChange,
3396
- onClose: handleSelect,
3397
- shouldDisableDate: isDisabledDateWithSomeAvailableData,
3398
- slotProps: {
3399
- textField: {
3400
- variant: 'filled',
3401
- endAdornment: jsx(InputAdornment, {
3402
- position: "end",
3403
- sx: {
3404
- paddingTop: '16px'
3405
- },
3406
- children: "UTC"
3407
- })
3408
- },
3409
- field: {
3410
- onKeyDownCapture: handleKeyDown,
3411
- openPickerButtonPosition: 'start'
3412
- },
3413
- openPickerButton: {
3414
- size: 'small',
3415
- sx: {
3416
- padding: 0
3417
- }
3418
- }
3419
- },
3420
- slots: {
3421
- openPickerIcon: OpenPicker,
3422
- day: AvailableDay
3423
- },
3424
- sx: {
3425
- marginTop: '8px',
3426
- marginBottom: '8px',
3427
- marginLeft: '8px',
3428
- marginRight: '8px',
3429
- borderRadius: '0px'
3430
- },
3431
- timeSteps: {
3432
- minutes: 1
3433
- },
3434
- value: localTimeValue
3435
- })
4003
+ }), jsx(DateTimePicker, {
4004
+ autoFocus: true,
4005
+ closeOnSelect: false,
4006
+ disableIgnoringDatePartForTimeValidation: true,
4007
+ format: format,
4008
+ label: t('timeslider-marker-label'),
4009
+ maxDateTime: isUndefinedDateRange ? undefined : dateUtils.fromUnix(dataEndTime),
4010
+ minDateTime: isUndefinedDateRange ? undefined : dateUtils.fromUnix(dataStartTime),
4011
+ onChange: handleDateChange,
4012
+ onClose: handleSelect,
4013
+ shouldDisableDate: isDisabledDateWithSomeAvailableData,
4014
+ slotProps: {
4015
+ field: {
4016
+ onKeyDownCapture: handleKeyDown
4017
+ }
4018
+ },
4019
+ slots: {
4020
+ day: AvailableDay
4021
+ },
4022
+ sx: {
4023
+ marginTop: '8px',
4024
+ marginBottom: '8px',
4025
+ marginLeft: '8px',
4026
+ marginRight: '8px',
4027
+ borderRadius: '0px'
4028
+ },
4029
+ value: utcTimeValue
3436
4030
  })]
3437
4031
  })
3438
4032
  });
@@ -3688,4 +4282,4 @@ var DemoWrapper = function DemoWrapper(_ref2) {
3688
4282
  });
3689
4283
  };
3690
4284
 
3691
- export { AUTO_MOVE_AREA_PADDING, AnimationLength, AnimationLengthButton, AutoUpdateButton, _BackwardForwardStepButton as BackwardForwardStepButton, ControlButtons, DRAG_AREA_WIDTH, DemoWrapper, HideSliderButton, NowButton, OptionsMenu, OptionsMenuButton, PlayButton, Scale, SpeedButton, TIME_SLIDER_LEGEND_HEIGHT, TIME_SLIDER_NAMESPACE, TimeInMinutes, TimeSlider, TimeSliderButtons, TimeSliderCurrentTimeBox, TimeSliderLegend, TimeSliderMenu, TimeSpanButton, _TimeStepButton as TimeStepButton, calculateMouseTimeAndCheckBounds, convertStringTimeToUnix, defaultAnimationDelayAtStart, defaultDelay, defaultSecondsPerPx, defaultTimeSpan, defaultTimeStep, getAutoMoveAreaWidth, getFilteredTime, getFundamentalScale, getLargestTimeUnit, getNewCenterOfFixedPointZoom, getPixelsBetweenViewportAndTimesliderOnLeft, getPositions, getScaleFromSpan, getSpeedDelay, getTimeBoxWidth, getTimeSliderLegendElement, getTimeSliderLegendId, handleSetNowEvent, isDraggingEndWithinBounds, isDraggingStartWithinBounds, isInsideAnimationArea, isLeftAnimationIconArea, isRightAnimationIconArea, isSelectedTimeIconArea, marks$1 as marks, minutesToDescribedDuration, moveRelativeToTimePoint, moveSelectedTimePx, onsetNewDateDebounced, pixelToTimestamp, roundWithTimeStep, scaleToSecondsPerPx, scalingCoefficient, secondsPerPxFromCanvasWidth, secondsPerPxToScale, secondsPerPxValues, setNextTimeStep, setPreviousTimeStep, spanToScale, speedFactors, timeBoxGeom, timeSliderLegendDefaultProps, timeSliderUtils, timeValues, timesliderTranslations, timestampToPixel, timestampToPixelEdges, useCanvasTarget };
4285
+ export { AUTO_MOVE_AREA_PADDING, AnimationLength, AnimationLengthButton, AnimationLengthMenu, AnimationLengthMode, AnimationLengthPanel, AutoUpdateButton, _BackwardForwardStepButton as BackwardForwardStepButton, ControlButtons, DRAG_AREA_WIDTH, DemoWrapper, HideSliderButton, MAX_ANIMATION_STEPS, NowButton, OptionsMenu, OptionsMenuButton, PlayButton, Scale, SpeedButton, TIME_SLIDER_LEGEND_HEIGHT, TIME_SLIDER_NAMESPACE, TimeInMinutes, TimeSlider, TimeSliderButtons, TimeSliderCurrentTimeBox, TimeSliderLegend, TimeSliderMenu, TimeSpanButton, _TimeStepButton as TimeStepButton, calculateMouseTimeAndCheckBounds, convertStringTimeToUnix, defaultAnimationDelayAtStart, defaultDelay, defaultEndOffset, defaultNowAnimationLength, defaultSecondsPerPx, defaultStartOffset, defaultTimeSpan, defaultTimeStep, exactAnimationLength, getAutoMoveAreaWidth, getFilteredTime, getFundamentalScale, getLargestTimeUnit, getNewCenterOfFixedPointZoom, getPixelsBetweenViewportAndTimesliderOnLeft, getPositions, getScaleFromSpan, getSpeedDelay, getTimeBoxWidth, getTimeSliderLegendElement, getTimeSliderLegendId, handleSetNowEvent, isDraggingEndWithinBounds, isDraggingStartWithinBounds, isInsideAnimationArea, isLeftAnimationIconArea, isRightAnimationIconArea, isSelectedTimeIconArea, isValidAnimationLength, isWithinAnimationStepLimit, marks$1 as marks, minutesToDescribedDuration, modeTranslationKey, moveRelativeToTimePoint, moveSelectedTimePx, onsetNewDateDebounced, pixelToTimestamp, resolveNowAnimationRange, roundWithTimeStep, scaleToSecondsPerPx, scalingCoefficient, secondsPerPxFromCanvasWidth, secondsPerPxToScale, secondsPerPxValues, setNextTimeStep, setPreviousTimeStep, shortUnitTranslationKey, spanToScale, speedFactors, timeBoxGeom, timeSliderLegendDefaultProps, timeSliderUtils, timeUnits, timeValues, timesliderTranslations, timestampToPixel, timestampToPixelEdges, toExactAnimationTime, unitTranslationKey, useCanvasTarget };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { AnimationLengthSetting } from './animationLengthUtils';
3
+ export interface AnimationLengthMenuProps {
4
+ setting: AnimationLengthSetting;
5
+ onChange: (setting: AnimationLengthSetting) => void;
6
+ animationStartTime?: string;
7
+ animationEndTime?: string;
8
+ autoTimeStepLayerName?: string;
9
+ timeStep?: number;
10
+ isAutoDisabled?: boolean;
11
+ disabled?: boolean;
12
+ }
13
+ export declare const AnimationLengthMenu: React.FC<AnimationLengthMenuProps>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { AnimationLengthSetting } from './animationLengthUtils';
3
+ export interface AnimationLengthPanelProps {
4
+ setting: AnimationLengthSetting;
5
+ onChange: (setting: AnimationLengthSetting) => void;
6
+ animationStartTime?: string;
7
+ animationEndTime?: string;
8
+ autoTimeStepLayerName?: string;
9
+ timeStep?: number;
10
+ isAutoDisabled?: boolean;
11
+ disabled?: boolean;
12
+ }
13
+ export declare const AnimationLengthPanel: React.FC<AnimationLengthPanelProps>;
@@ -0,0 +1,47 @@
1
+ export declare enum AnimationLengthMode {
2
+ Auto = "auto",
3
+ Now = "now",
4
+ RecurringPeriod = "recurringPeriod",
5
+ ReferenceTime = "referenceTime",
6
+ Exact = "exact"
7
+ }
8
+ export type TimeUnit = 'years' | 'months' | 'weeks' | 'days' | 'hours' | 'minutes';
9
+ export declare const timeUnits: TimeUnit[];
10
+ export interface RelativeTimeOffset {
11
+ value: number;
12
+ unit: TimeUnit;
13
+ }
14
+ export interface AnimationLengthSetting {
15
+ mode: AnimationLengthMode;
16
+ startOffset?: RelativeTimeOffset;
17
+ endOffset?: RelativeTimeOffset;
18
+ animationStartTime?: string;
19
+ animationEndTime?: string;
20
+ }
21
+ export interface AnimationRange {
22
+ animationStartTime: string;
23
+ animationEndTime: string;
24
+ }
25
+ export declare const defaultStartOffset: RelativeTimeOffset;
26
+ export declare const defaultEndOffset: RelativeTimeOffset;
27
+ export declare const defaultNowAnimationLength: AnimationLengthSetting;
28
+ export declare const unitTranslationKey: Record<TimeUnit, string>;
29
+ export declare const shortUnitTranslationKey: Record<TimeUnit, string>;
30
+ export declare const modeTranslationKey: Record<AnimationLengthMode, string>;
31
+ /**
32
+ * Offsets are signed: negative lands before now, positive after. They are applied
33
+ * as calendar durations, so "+ 1 month" lands on the same day of the next month
34
+ * rather than a fixed number of days later.
35
+ */
36
+ export declare const resolveNowAnimationRange: ({ startOffset, endOffset, }: AnimationLengthSetting, now?: Date) => AnimationRange;
37
+ /** Offsets can use different units, so validity is decided on the resolved instants. */
38
+ export declare const isValidAnimationLength: (setting: AnimationLengthSetting, now?: Date) => boolean;
39
+ /** Frames the animation may hold; the range is expanded one entry per time step. */
40
+ export declare const MAX_ANIMATION_STEPS = 10000;
41
+ /**
42
+ * The cost of an animation is its span divided by the time step, so a wide range
43
+ * is affordable with a coarse step and unaffordable with a fine one.
44
+ */
45
+ export declare const isWithinAnimationStepLimit: (setting: AnimationLengthSetting, timeStepInMinutes: number | undefined, now?: Date) => boolean;
46
+ export declare const exactAnimationLength: AnimationLengthSetting;
47
+ export declare const toExactAnimationTime: (date: Date) => string;
@@ -0,0 +1,3 @@
1
+ export * from './animationLengthUtils';
2
+ export * from './AnimationLengthMenu';
3
+ export * from './AnimationLengthPanel';
@@ -1,4 +1,5 @@
1
1
  export * from './AnimationLengthButton/AnimationLengthButton';
2
+ export * from './AnimationLengthPanel';
2
3
  export * from './AutoUpdateButton/AutoUpdateButton';
3
4
  export * from './BackwardForwardStepButton/BackwardForwardStepButton';
4
5
  export * from './ControlButtons/ControlButtons';
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
1
  {
2
- "name": "@opengeoweb/time-slider",
3
- "version": "19.6.0",
4
- "description": "GeoWeb time-slider library for the opengeoweb project",
5
- "license": "Apache-2.0",
6
- "repository": {
7
- "type": "git",
8
- "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
- },
10
- "main": "./dist/index.esm.js",
11
- "module": "./dist/index.esm.js",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- "./package.json": "./package.json",
15
- ".": {
16
- "@opengeoweb/source": "./src/index.ts",
17
- "types": "./dist/index.d.ts",
18
- "import": "./dist/index.esm.js",
19
- "default": "./dist/index.esm.js"
20
- }
21
- },
22
- "dependencies": {
23
- "@opengeoweb/shared": "*",
24
- "lodash": "^4.18.1",
25
- "@opengeoweb/theme": "*",
26
- "@mui/x-date-pickers": "^9.3.0",
27
- "@mui/system": "^9.0.1",
28
- "i18next": "^25.0.1",
29
- "@mui/material": "^9.0.1",
30
- "react-i18next": "^15.1.1"
31
- },
32
- "peerDependencies": {
33
- "react": "19",
34
- "@emotion/react": "*",
35
- "@emotion/styled": "*"
36
- },
37
- "devDependencies": {
38
- "eslint-plugin-storybook": "10.3.3"
39
- },
40
- "files": [
41
- "dist",
42
- "!dist/package.json",
43
- "README.md",
44
- "package.json"
45
- ]
46
- }
2
+ "name": "@opengeoweb/time-slider",
3
+ "version": "19.6.1-nightly-20260913",
4
+ "description": "GeoWeb time-slider library for the opengeoweb project",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
+ },
10
+ "main": "./dist/index.esm.js",
11
+ "module": "./dist/index.esm.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "@opengeoweb/source": "./src/index.ts",
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.esm.js",
19
+ "default": "./dist/index.esm.js"
20
+ }
21
+ },
22
+ "dependencies": {
23
+ "@opengeoweb/shared": "19.6.1-nightly-20260913",
24
+ "lodash": "^4.18.1",
25
+ "@opengeoweb/theme": "19.6.1-nightly-20260913",
26
+ "@mui/x-date-pickers": "^9.3.0",
27
+ "@mui/system": "^9.0.1",
28
+ "i18next": "^25.0.1",
29
+ "@mui/material": "^9.0.1",
30
+ "react-i18next": "^15.1.1"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "19",
34
+ "@emotion/react": "*",
35
+ "@emotion/styled": "*"
36
+ },
37
+ "devDependencies": {
38
+ "eslint-plugin-storybook": "10.3.3"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "!dist/package.json",
43
+ "README.md",
44
+ "package.json"
45
+ ]
46
+ }