@opengeoweb/time-slider 19.5.1 → 19.6.1-nightly-20260912

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,
@@ -2059,6 +2158,7 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
2059
2158
  icon = _ref.icon,
2060
2159
  _ref$onChangeSliderVa = _ref.onChangeSliderValue,
2061
2160
  onChangeSliderValue = _ref$onChangeSliderVa === void 0 ? function () {} : _ref$onChangeSliderVa,
2161
+ onSelectSliderValue = _ref.onSelectSliderValue,
2062
2162
  displayCurrentLength = _ref.displayCurrentLength,
2063
2163
  _ref$disbleUserSetDur = _ref.disbleUserSetDuration,
2064
2164
  disbleUserSetDuration = _ref$disbleUserSetDur === void 0 ? true : _ref$disbleUserSetDur,
@@ -2188,6 +2288,7 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
2188
2288
  if (!isSelected) {
2189
2289
  onChangeSliderValue(mark.value);
2190
2290
  }
2291
+ onSelectSliderValue == null || onSelectSliderValue(mark.value);
2191
2292
  setOpen(false);
2192
2293
  },
2193
2294
  selected: !!isSelected && !displayLengthInputField,
@@ -2338,6 +2439,537 @@ var AnimationLengthButton = function AnimationLengthButton(_ref) {
2338
2439
  });
2339
2440
  };
2340
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
+
2341
2973
  var AutoUpdateButton = function AutoUpdateButton(_ref) {
2342
2974
  var _ref$toggleAutoUpdate = _ref.toggleAutoUpdate,
2343
2975
  toggleAutoUpdate = _ref$toggleAutoUpdate === void 0 ? function () {} : _ref$toggleAutoUpdate,
@@ -2715,6 +3347,16 @@ var getTimeStepShortcutDirection = function getTimeStepShortcutDirection(event)
2715
3347
  }
2716
3348
  return null;
2717
3349
  };
3350
+ var focusAdjacentMenuItem = function focusAdjacentMenuItem(target, direction) {
3351
+ var _target$parentElement, _target$parentElement2, _menuItems$nextIndex;
3352
+ if (!(target instanceof HTMLElement) || target.getAttribute('role') !== 'menuitem') {
3353
+ return;
3354
+ }
3355
+ var menuItems = Array.from((_target$parentElement = (_target$parentElement2 = target.parentElement) == null ? void 0 : _target$parentElement2.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')) != null ? _target$parentElement : []);
3356
+ var currentIndex = menuItems.indexOf(target);
3357
+ var nextIndex = currentIndex + (direction === 'up' ? -1 : 1);
3358
+ (_menuItems$nextIndex = menuItems[nextIndex]) == null || _menuItems$nextIndex.focus();
3359
+ };
2718
3360
  var TimeStepShortcutContext = /*#__PURE__*/React.createContext(null);
2719
3361
  // Listens for the time-step keyboard shortcut on document (capture phase, so it
2720
3362
  // runs before any element-level handlers that may stopPropagation). Ignores
@@ -2738,7 +3380,9 @@ var useTimeStepShortcutListener = function useTimeStepShortcutListener(enabled,
2738
3380
  return;
2739
3381
  }
2740
3382
  event.preventDefault();
3383
+ event.stopPropagation();
2741
3384
  onShortcutRef.current(direction);
3385
+ focusAdjacentMenuItem(target, direction);
2742
3386
  };
2743
3387
  document.addEventListener('keydown', handleKeyDown, {
2744
3388
  capture: true
@@ -2880,30 +3524,14 @@ var _TimeStepButton = function TimeStepButton(_ref) {
2880
3524
  var _useState = useState(isOpenByDefault),
2881
3525
  open = _useState[0],
2882
3526
  setOpen = _useState[1];
2883
- var stepToAdjacentMark = useCallback(function (direction) {
2884
- var _marks$nextIndex;
2885
- var currentIndex = marks.findIndex(function (mark) {
2886
- return mark.value === timeStep;
2887
- });
2888
- if (currentIndex === -1) {
2889
- return;
2890
- }
2891
- var indexDelta = direction === 'up' ? -1 : 1;
2892
- var nextIndex = Math.min(Math.max(currentIndex + indexDelta, 0), marks.length - 1);
2893
- var nextValue = (_marks$nextIndex = marks[nextIndex]) == null ? void 0 : _marks$nextIndex.value;
2894
- if (nextValue !== undefined && nextValue !== timeStep) {
2895
- onMenuItemClick(nextValue);
2896
- }
2897
- }, [timeStep, onMenuItemClick]);
2898
3527
  var shortcutContext = useContext(TimeStepShortcutContext);
2899
3528
  useEffect(function () {
2900
3529
  if (!(shortcutContext != null && shortcutContext.pendingDirection)) {
2901
3530
  return;
2902
3531
  }
2903
3532
  setOpen(true);
2904
- stepToAdjacentMark(shortcutContext.pendingDirection);
2905
3533
  shortcutContext.consume();
2906
- }, [shortcutContext, stepToAdjacentMark]);
3534
+ }, [shortcutContext]);
2907
3535
  return jsx(TimeSliderMenu, {
2908
3536
  allOptionsDisabled: disabled,
2909
3537
  displayCurrentLength: true,
@@ -2915,6 +3543,7 @@ var _TimeStepButton = function TimeStepButton(_ref) {
2915
3543
  isAutoSelected: isTimestepAuto,
2916
3544
  marks: translatedMarks,
2917
3545
  onChangeSliderValue: onMenuItemClick,
3546
+ onSelectSliderValue: shortcutContext == null ? void 0 : shortcutContext.closeOptionsMenu,
2918
3547
  open: open,
2919
3548
  setOpen: setOpen,
2920
3549
  title: t('timeslider-time-step'),
@@ -2929,6 +3558,14 @@ var OptionsMenu = function OptionsMenu(_ref) {
2929
3558
  animationLengthBtn = _ref.animationLengthBtn;
2930
3559
  return jsxs(Fragment, {
2931
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, {
2932
3569
  size: {
2933
3570
  xs: 'auto'
2934
3571
  },
@@ -2940,14 +3577,6 @@ var OptionsMenu = function OptionsMenu(_ref) {
2940
3577
  onToggleTimeSpan: function onToggleTimeSpan() {},
2941
3578
  timeSliderSpan: 0
2942
3579
  })
2943
- }), jsx(Grid, {
2944
- size: {
2945
- xs: 'auto'
2946
- },
2947
- children: animationLengthBtn || jsx(AnimationLengthButton, {
2948
- onChangeAnimationLength: function onChangeAnimationLength() {},
2949
- toggleAnimationLengthAuto: function toggleAnimationLengthAuto() {}
2950
- })
2951
3580
  }), jsx(Grid, {
2952
3581
  size: {
2953
3582
  xs: 'auto'
@@ -2986,6 +3615,7 @@ var OptionsMenuButton = function OptionsMenuButton(_ref) {
2986
3615
  var _useState3 = useState(null),
2987
3616
  pendingDirection = _useState3[0],
2988
3617
  setPendingDirection = _useState3[1];
3618
+ var openedByShortcutRef = useRef(false);
2989
3619
  var _useTimesliderTransla = useTimesliderTranslation(),
2990
3620
  t = _useTimesliderTransla.t;
2991
3621
  useEffect(function () {
@@ -2994,12 +3624,24 @@ var OptionsMenuButton = function OptionsMenuButton(_ref) {
2994
3624
  }
2995
3625
  }, [anchorEl, isOpenByDefault]);
2996
3626
  useTimeStepShortcutListener(enableKeyboardShortcut, function (direction) {
2997
- setOpen(true);
3627
+ setOpen(function (wasOpen) {
3628
+ if (!wasOpen) {
3629
+ openedByShortcutRef.current = true;
3630
+ }
3631
+ return true;
3632
+ });
2998
3633
  setPendingDirection(direction);
2999
3634
  });
3000
3635
  var shortcutContextValue = useMemo(function () {
3001
3636
  return {
3002
3637
  pendingDirection: pendingDirection,
3638
+ closeOptionsMenu: function closeOptionsMenu() {
3639
+ if (openedByShortcutRef.current) {
3640
+ setOpen(false);
3641
+ }
3642
+ openedByShortcutRef.current = false;
3643
+ setPendingDirection(null);
3644
+ },
3003
3645
  consume: function consume() {
3004
3646
  return setPendingDirection(null);
3005
3647
  }
@@ -3011,6 +3653,7 @@ var OptionsMenuButton = function OptionsMenuButton(_ref) {
3011
3653
  "data-testid": "optionsMenuButton",
3012
3654
  isSelected: open,
3013
3655
  onClick: function onClick() {
3656
+ openedByShortcutRef.current = false;
3014
3657
  setOpen(!open);
3015
3658
  },
3016
3659
  ref: function ref(_ref2) {
@@ -3225,18 +3868,6 @@ var renderTimeSliderCurrentTimeBox = function renderTimeSliderCurrentTimeBox(ctx
3225
3868
  };
3226
3869
 
3227
3870
  var _excluded = ["day", "today", "outsideCurrentMonth"];
3228
- var getTimezoneOffsetS = function getTimezoneOffsetS(value) {
3229
- return value.getTimezoneOffset() * 60;
3230
- };
3231
- var toLocalTime = function toLocalTime(dateTime) {
3232
- return dateUtils.fromUnix(dateTime + getTimezoneOffsetS(dateUtils.fromUnix(dateTime)));
3233
- };
3234
- var toUTCTime = function toUTCTime(dateTime) {
3235
- return dateUtils.unix(dateTime) - getTimezoneOffsetS(dateTime);
3236
- };
3237
- var OpenPicker = function OpenPicker() {
3238
- return jsx(CalendarToday, {});
3239
- };
3240
3871
  var enabledAndSelectedButtonStyle = {
3241
3872
  borderWidth: '6px',
3242
3873
  borderBottomStyle: 'solid',
@@ -3288,28 +3919,30 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3288
3919
  onCancel = _ref$onCancel === void 0 ? function () {} : _ref$onCancel;
3289
3920
  var _useTimesliderTransla = useTimesliderTranslation(),
3290
3921
  t = _useTimesliderTransla.t;
3291
- var _React$useState2 = React.useState(value ? toLocalTime(value) : null),
3292
- localTimeValue = _React$useState2[0],
3293
- 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];
3294
3925
  var _React$useState3 = React.useState(!dataStartTime || !dataEndTime || dataStartTime > dataEndTime),
3295
3926
  isUndefinedDateRange = _React$useState3[0],
3296
3927
  setIsUndefinedDateRange = _React$useState3[1];
3297
3928
  var isDateRangeDisabled = React.useCallback(function (date) {
3298
- if (dataStartTime === undefined || dataEndTime === undefined || dataStartTime > dataEndTime) {
3929
+ if (!date || dataStartTime === undefined || dataEndTime === undefined || dataStartTime > dataEndTime) {
3299
3930
  return true;
3300
3931
  }
3301
- var startOfFirstDay = dateUtils.fromUnix(dataStartTime);
3302
- startOfFirstDay.setHours(0, 0, 0);
3303
- var endOfLastDay = dateUtils.fromUnix(dataEndTime);
3304
- var day = dateUtils.unix(date);
3305
- 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;
3306
3939
  }, [dataStartTime, dataEndTime]);
3307
- var _React$useState4 = React.useState(isDateRangeDisabled(localTimeValue)),
3940
+ var _React$useState4 = React.useState(isDateRangeDisabled(utcTimeValue)),
3308
3941
  isDisabledRange = _React$useState4[0],
3309
3942
  setIsDisabledRange = _React$useState4[1];
3310
3943
  var handleSelect = function handleSelect() {
3311
- if (localTimeValue) {
3312
- onSelect(toUTCTime(localTimeValue));
3944
+ if (utcTimeValue) {
3945
+ onSelect(dateUtils.unix(utcTimeValue));
3313
3946
  }
3314
3947
  };
3315
3948
  var handleKeyDown = function handleKeyDown(event) {
@@ -3324,16 +3957,16 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3324
3957
  };
3325
3958
  var handleDateChange = function handleDateChange(value) {
3326
3959
  if (value instanceof Date || value === null || isDisabledDateWithSomeAvailableData()) {
3327
- setLocalTimeValue(value);
3960
+ setUtcTimeValue(value);
3328
3961
  }
3329
3962
  };
3330
3963
  var AvailableDay = function AvailableDay(props) {
3331
- return AvailableDayByTimeRange(props, isDateRangeDisabled(props.day));
3964
+ return AvailableDayByTimeRange(props, isDateRangeDisabled(pickerDateToUTC(props.day)));
3332
3965
  };
3333
3966
  React.useEffect(function () {
3334
3967
  setIsUndefinedDateRange(!dataStartTime || !dataEndTime || dataStartTime > dataEndTime);
3335
- setIsDisabledRange(isDateRangeDisabled(localTimeValue));
3336
- }, [dataStartTime, dataEndTime, localTimeValue, isDateRangeDisabled]);
3968
+ setIsDisabledRange(isDateRangeDisabled(utcTimeValue));
3969
+ }, [dataStartTime, dataEndTime, utcTimeValue, isDateRangeDisabled]);
3337
3970
  return jsx(Paper, {
3338
3971
  sx: {
3339
3972
  borderRadius: '0px',
@@ -3367,59 +4000,33 @@ var MarkerTimeSelector = function MarkerTimeSelector(_ref) {
3367
4000
  },
3368
4001
  children: t('timeslider-marker')
3369
4002
  })
3370
- }), jsx(LocalizationProvider, {
3371
- dateAdapter: AdapterDateFns,
3372
- children: jsx(DateTimePicker, {
3373
- ampm: false,
3374
- autoFocus: true,
3375
- closeOnSelect: false,
3376
- desktopModeMediaQuery: "@media (min-width: 720px)",
3377
- disableIgnoringDatePartForTimeValidation: true,
3378
- format: format,
3379
- label: t('timeslider-marker-label'),
3380
- maxDateTime: isUndefinedDateRange ? undefined : toLocalTime(dataEndTime),
3381
- minDateTime: isUndefinedDateRange ? undefined : toLocalTime(dataStartTime),
3382
- onChange: handleDateChange,
3383
- onClose: handleSelect,
3384
- shouldDisableDate: isDisabledDateWithSomeAvailableData,
3385
- slotProps: {
3386
- textField: {
3387
- variant: 'filled',
3388
- endAdornment: jsx(InputAdornment, {
3389
- position: "end",
3390
- sx: {
3391
- paddingTop: '16px'
3392
- },
3393
- children: "UTC"
3394
- })
3395
- },
3396
- field: {
3397
- onKeyDownCapture: handleKeyDown,
3398
- openPickerButtonPosition: 'start'
3399
- },
3400
- openPickerButton: {
3401
- size: 'small',
3402
- sx: {
3403
- padding: 0
3404
- }
3405
- }
3406
- },
3407
- slots: {
3408
- openPickerIcon: OpenPicker,
3409
- day: AvailableDay
3410
- },
3411
- sx: {
3412
- marginTop: '8px',
3413
- marginBottom: '8px',
3414
- marginLeft: '8px',
3415
- marginRight: '8px',
3416
- borderRadius: '0px'
3417
- },
3418
- timeSteps: {
3419
- minutes: 1
3420
- },
3421
- value: localTimeValue
3422
- })
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
3423
4030
  })]
3424
4031
  })
3425
4032
  });
@@ -3675,4 +4282,4 @@ var DemoWrapper = function DemoWrapper(_ref2) {
3675
4282
  });
3676
4283
  };
3677
4284
 
3678
- 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';
@@ -3,6 +3,7 @@ export type TimeStepDirection = 'up' | 'down';
3
3
  export declare const getTimeStepShortcutDirection: (event: KeyboardEvent | React.KeyboardEvent) => TimeStepDirection | null;
4
4
  export interface TimeStepShortcutContextValue {
5
5
  pendingDirection: TimeStepDirection | null;
6
+ closeOptionsMenu: () => void;
6
7
  consume: () => void;
7
8
  }
8
9
  export declare const TimeStepShortcutContext: React.Context<TimeStepShortcutContextValue | null>;
@@ -14,6 +14,7 @@ export interface TimeSliderMenuProps {
14
14
  handleAutoClick?: () => void;
15
15
  isAutoSelected?: boolean;
16
16
  onChangeSliderValue?: (markValue: number) => void;
17
+ onSelectSliderValue?: (markValue: number) => void;
17
18
  setOpen: (display: boolean) => void;
18
19
  open: boolean;
19
20
  displayCurrentLength?: boolean;
@@ -21,4 +22,4 @@ export interface TimeSliderMenuProps {
21
22
  customLengthSelector?: React.ReactNode;
22
23
  customFieldHeader?: string;
23
24
  }
24
- export declare const TimeSliderMenu: ({ marks, value, allOptionsDisabled, isAutoDisabled, handleAutoClick, isAutoSelected, title, icon, onChangeSliderValue, displayCurrentLength, disbleUserSetDuration, customLengthSelector, setOpen, customFieldHeader, open, }: TimeSliderMenuProps) => React.ReactElement;
25
+ export declare const TimeSliderMenu: ({ marks, value, allOptionsDisabled, isAutoDisabled, handleAutoClick, isAutoSelected, title, icon, onChangeSliderValue, onSelectSliderValue, displayCurrentLength, disbleUserSetDuration, customLengthSelector, setOpen, customFieldHeader, open, }: TimeSliderMenuProps) => React.ReactElement;
@@ -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.5.1",
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-20260912",
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-20260912",
24
+ "lodash": "^4.18.1",
25
+ "@opengeoweb/theme": "19.6.1-nightly-20260912",
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
+ }