@opengeoweb/time-slider 19.3.0 → 19.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +28 -12
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { Grid, useTheme, Box, Typography, Menu, MenuItem, CardHeader, FormControl, TextField, Select, Popper, Paper, Stack, InputAdornment, ClickAwayListener } from '@mui/material';
|
|
3
3
|
import React, { useState, useRef, useEffect, useCallback, useContext, useMemo, createElement } from 'react';
|
|
4
|
-
import { dateUtils, safelyInitI18nForTestsAndStories, CustomIconButton, CustomTooltip, CanvasComponent, renderCounter, CustomToggleButton } from '@opengeoweb/shared';
|
|
4
|
+
import { dateUtils, isTargetInteractiveInput, isDialogFocused, safelyInitI18nForTestsAndStories, CustomIconButton, CustomTooltip, CanvasComponent, renderCounter, CustomToggleButton } from '@opengeoweb/shared';
|
|
5
5
|
import { debounce, throttle } from 'lodash';
|
|
6
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';
|
|
7
7
|
import i18n from 'i18next';
|
|
@@ -702,7 +702,7 @@ var useToggleTimesliderVisibility = function useToggleTimesliderVisibility(mapIs
|
|
|
702
702
|
React.useEffect(function () {
|
|
703
703
|
var handleKeyDown = function handleKeyDown(event) {
|
|
704
704
|
var target = event.target;
|
|
705
|
-
if (target
|
|
705
|
+
if (!isTargetInteractiveInput(target) && !isDialogFocused() && (event.key === 't' || event.key === 'T') && mapIsActive) {
|
|
706
706
|
onToggleTimeSlider(!isVisible);
|
|
707
707
|
}
|
|
708
708
|
};
|
|
@@ -715,6 +715,10 @@ var useToggleTimesliderVisibility = function useToggleTimesliderVisibility(mapIs
|
|
|
715
715
|
var useMoveTimeWithKeyboard = function useMoveTimeWithKeyboard(mapIsActive, timeStep, dataStartTime, dataEndTime, onSetNewDate, onSetCenterTime, selectedTime) {
|
|
716
716
|
React.useEffect(function () {
|
|
717
717
|
var handleKeyDown = function handleKeyDown(event) {
|
|
718
|
+
var target = event.target;
|
|
719
|
+
if (isTargetInteractiveInput(target) || isDialogFocused()) {
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
718
722
|
if (event.key === 'Home' && mapIsActive) {
|
|
719
723
|
handleSetNowEvent(timeStep, dataStartTime, dataEndTime, dateUtils.unix(dateUtils.utc()), onSetNewDate, onSetCenterTime);
|
|
720
724
|
}
|
|
@@ -2081,16 +2085,25 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
|
|
|
2081
2085
|
setDisplayLengthInputField(false);
|
|
2082
2086
|
}
|
|
2083
2087
|
}, [displayLengthInputField, open]);
|
|
2088
|
+
var getDisplayTextFromMark = function getDisplayTextFromMark(mark) {
|
|
2089
|
+
if (!(mark != null && mark.label)) {
|
|
2090
|
+
return '';
|
|
2091
|
+
}
|
|
2092
|
+
var parts = t(mark.label).split(' ');
|
|
2093
|
+
if (parts.length > 1) {
|
|
2094
|
+
return parts[0] + parts.slice(1).join(' ');
|
|
2095
|
+
}
|
|
2096
|
+
return parts.join('');
|
|
2097
|
+
};
|
|
2084
2098
|
var buttonText = function buttonText(value, displayCurrentLength, currentMark) {
|
|
2085
2099
|
if (displayCurrentLength) {
|
|
2100
|
+
if (!Number.isInteger(value)) {
|
|
2101
|
+
return value + "m";
|
|
2102
|
+
}
|
|
2086
2103
|
return minutesToDescribedDuration(value);
|
|
2087
2104
|
}
|
|
2088
|
-
if (currentMark) {
|
|
2089
|
-
|
|
2090
|
-
if (parts.length > 1) {
|
|
2091
|
-
return parts[0] + parts.slice(1).join(' ');
|
|
2092
|
-
}
|
|
2093
|
-
return parts.join('');
|
|
2105
|
+
if (currentMark != null && currentMark.label) {
|
|
2106
|
+
return getDisplayTextFromMark(currentMark);
|
|
2094
2107
|
}
|
|
2095
2108
|
return '';
|
|
2096
2109
|
};
|
|
@@ -2103,6 +2116,9 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
|
|
|
2103
2116
|
var newValue = marks[Math.min(Math.max(currentMarkIndex - direction, 0), marks.length - 1)];
|
|
2104
2117
|
throttledScroll(newValue.value);
|
|
2105
2118
|
}, [currentMarkIndex, marks, throttledScroll]);
|
|
2119
|
+
var buttonDisplayText = buttonText(value, displayCurrentLength, currentMark);
|
|
2120
|
+
var menuDisplayValue = !Number.isInteger(value) ? value + "m" : minutesToDescribedDuration(value);
|
|
2121
|
+
var displayValue = isAutoSelected ? "A: " + buttonDisplayText : buttonDisplayText;
|
|
2106
2122
|
return jsxs(Box, {
|
|
2107
2123
|
onKeyDown: function onKeyDown(event) {
|
|
2108
2124
|
event.stopPropagation();
|
|
@@ -2129,7 +2145,7 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
|
|
|
2129
2145
|
fontWeight: 400,
|
|
2130
2146
|
textTransform: 'none'
|
|
2131
2147
|
},
|
|
2132
|
-
children:
|
|
2148
|
+
children: displayValue
|
|
2133
2149
|
})]
|
|
2134
2150
|
}), !!anchorRef && jsxs(Menu, {
|
|
2135
2151
|
anchorEl: anchorRef,
|
|
@@ -2165,7 +2181,7 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
|
|
|
2165
2181
|
},
|
|
2166
2182
|
children: title
|
|
2167
2183
|
}), marks.map(function (mark) {
|
|
2168
|
-
var isSelected = (currentMark == null ? void 0 : currentMark.value) === mark.value
|
|
2184
|
+
var isSelected = (currentMark == null ? void 0 : currentMark.value) === mark.value;
|
|
2169
2185
|
return jsx(MenuItem, {
|
|
2170
2186
|
disabled: allOptionsDisabled,
|
|
2171
2187
|
onClick: function onClick() {
|
|
@@ -2227,7 +2243,7 @@ var TimeSliderMenu = function TimeSliderMenu(_ref) {
|
|
|
2227
2243
|
textTransform: 'none',
|
|
2228
2244
|
lineHeight: 2
|
|
2229
2245
|
},
|
|
2230
|
-
children:
|
|
2246
|
+
children: menuDisplayValue
|
|
2231
2247
|
}), jsx(CustomTooltip, {
|
|
2232
2248
|
title: t('timeslider-edit'),
|
|
2233
2249
|
children: jsx("span", {
|
|
@@ -2714,7 +2730,7 @@ var useTimeStepShortcutListener = function useTimeStepShortcutListener(enabled,
|
|
|
2714
2730
|
}
|
|
2715
2731
|
var handleKeyDown = function handleKeyDown(event) {
|
|
2716
2732
|
var target = event.target;
|
|
2717
|
-
if ((target
|
|
2733
|
+
if (isTargetInteractiveInput(target) || isDialogFocused()) {
|
|
2718
2734
|
return;
|
|
2719
2735
|
}
|
|
2720
2736
|
var direction = getTimeStepShortcutDirection(event);
|