@opengeoweb/core 4.20.0 → 4.21.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.
Files changed (19) hide show
  1. package/index.esm.js +237 -124
  2. package/index.umd.js +279 -165
  3. package/lib/components/TimeSliderLite/TimeSliderLite.d.ts +1 -0
  4. package/lib/components/TimeSliderLite/TimeSliderLiteBackground/TimeSliderLiteBackgroundSvg.d.ts +1 -0
  5. package/lib/components/TimeSliderLite/TimeSliderLiteButtons/ControlButtonGroup/ControlButtonGroup.d.ts +2 -2
  6. package/lib/components/TimeSliderLite/TimeSliderLiteButtons/PlayButton/PlayButton.d.ts +1 -0
  7. package/lib/components/TimeSliderLite/TimeSliderLiteButtons/StepButton/StepButton.d.ts +1 -0
  8. package/lib/components/TimeSliderLite/TimeSliderLiteConnect.d.ts +10 -2
  9. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/SubmenuWrapper.d.ts +8 -0
  10. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/TimeRangeOptions/DayHourSelector.d.ts +21 -0
  11. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/TimeRangeOptions/DayHourSelector.spec.d.ts +1 -0
  12. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/TimeRangeOptions/TimeRangeOptions.d.ts +15 -0
  13. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/TimeSliderLiteOptionsMenu.d.ts +27 -0
  14. package/lib/components/TimeSliderLite/TimeSliderLiteOptionsMenu/TimeSliderLiteOptionsMenu.spec.d.ts +1 -0
  15. package/lib/components/TimeSliderLite/index.d.ts +2 -1
  16. package/lib/components/TimeSliderLite/timeSliderLiteUtils.d.ts +37 -1
  17. package/package.json +7 -7
  18. package/lib/components/LayerManager/LayerSelect/LayerList/SearchHighlight.d.ts +0 -7
  19. /package/lib/components/{LayerManager/LayerSelect/LayerList/SearchHighlight.spec.d.ts → TimeSliderLite/TimeSliderLiteOptionsMenu/SubmenuWrapper.spec.d.ts} +0 -0
package/index.umd.js CHANGED
@@ -15278,59 +15278,6 @@
15278
15278
  }, {});
15279
15279
  };
15280
15280
 
15281
- /* *
15282
- * Licensed under the Apache License, Version 2.0 (the "License");
15283
- * you may not use this file except in compliance with the License.
15284
- * You may obtain a copy of the License at
15285
- *
15286
- * http://www.apache.org/licenses/LICENSE-2.0
15287
- *
15288
- * Unless required by applicable law or agreed to in writing, software
15289
- * distributed under the License is distributed on an "AS IS" BASIS,
15290
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15291
- * See the License for the specific language governing permissions and
15292
- * limitations under the License.
15293
- *
15294
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
15295
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
15296
- * */
15297
- var highlightStyle = {
15298
- background: '#ffeecc'
15299
- };
15300
-
15301
- var SearchHighlight = function SearchHighlight(_a) {
15302
- var text = _a.text,
15303
- search = _a.search;
15304
-
15305
- if (search === '') {
15306
- return /*#__PURE__*/React__default["default"].createElement("span", null, text);
15307
- }
15308
-
15309
- var searchWords = search.split(' ').reduce(function (words, word) {
15310
- return word ? __spreadArray(__spreadArray([], __read(words)), [word.toLocaleLowerCase()]) : words;
15311
- }, []);
15312
- var searchRegex = searchWords.map(function (word) {
15313
- return _.escapeRegExp(word);
15314
- }).join('|');
15315
- var textParts = text.split(new RegExp("(" + searchRegex + ")", 'gi'));
15316
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, textParts.map(function (part, index) {
15317
- var key = part + "-" + index;
15318
-
15319
- if (searchWords.some(function (search) {
15320
- return part.toLocaleLowerCase().includes(search);
15321
- })) {
15322
- return /*#__PURE__*/React__default["default"].createElement("mark", {
15323
- key: key,
15324
- style: highlightStyle
15325
- }, part);
15326
- }
15327
-
15328
- return /*#__PURE__*/React__default["default"].createElement("span", {
15329
- key: key
15330
- }, part);
15331
- }));
15332
- };
15333
-
15334
15281
  /* *
15335
15282
  * Licensed under the Apache License, Version 2.0 (the "License");
15336
15283
  * you may not use this file except in compliance with the License.
@@ -15399,7 +15346,7 @@
15399
15346
  textOverflow: 'ellipsis',
15400
15347
  overflow: 'hidden'
15401
15348
  }
15402
- }, /*#__PURE__*/React__default["default"].createElement(SearchHighlight, {
15349
+ }, /*#__PURE__*/React__default["default"].createElement(shared.SearchHighlight, {
15403
15350
  text: layer.title,
15404
15351
  search: searchFilter
15405
15352
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -15415,7 +15362,7 @@
15415
15362
  textOverflow: 'ellipsis',
15416
15363
  overflow: 'hidden'
15417
15364
  }
15418
- }, /*#__PURE__*/React__default["default"].createElement(SearchHighlight, {
15365
+ }, /*#__PURE__*/React__default["default"].createElement(shared.SearchHighlight, {
15419
15366
  text: service.name,
15420
15367
  search: searchFilter
15421
15368
  })), /*#__PURE__*/React__default["default"].createElement(LayerInfoButtonConnect, {
@@ -15431,7 +15378,7 @@
15431
15378
  }, layer["abstract"] && /*#__PURE__*/React__default["default"].createElement(material.Typography, {
15432
15379
  "data-testid": "layerAbstract",
15433
15380
  sx: layerInfoStyle
15434
- }, /*#__PURE__*/React__default["default"].createElement(SearchHighlight, {
15381
+ }, /*#__PURE__*/React__default["default"].createElement(shared.SearchHighlight, {
15435
15382
  text: layer["abstract"],
15436
15383
  search: searchFilter
15437
15384
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -15448,12 +15395,12 @@
15448
15395
  sx: columns.column6
15449
15396
  }, layer.path.length > 0 && /*#__PURE__*/React__default["default"].createElement(material.Typography, {
15450
15397
  sx: layerInfoStyle
15451
- }, "Groups:", ' ', /*#__PURE__*/React__default["default"].createElement(SearchHighlight, {
15398
+ }, "Groups:", ' ', /*#__PURE__*/React__default["default"].createElement(shared.SearchHighlight, {
15452
15399
  text: layer.path.join(' / '),
15453
15400
  search: searchFilter
15454
15401
  })), ((_b = layer.keywords) === null || _b === void 0 ? void 0 : _b.length) > 0 && /*#__PURE__*/React__default["default"].createElement(material.Typography, {
15455
15402
  sx: layerInfoStyle
15456
- }, "Keywords:", ' ', /*#__PURE__*/React__default["default"].createElement(SearchHighlight, {
15403
+ }, "Keywords:", ' ', /*#__PURE__*/React__default["default"].createElement(shared.SearchHighlight, {
15457
15404
  text: layer.keywords.slice().sort(function (a, b) {
15458
15405
  return a.localeCompare(b);
15459
15406
  }).join(', '),
@@ -27963,6 +27910,143 @@
27963
27910
  });
27964
27911
  };
27965
27912
 
27913
+ /* *
27914
+ * Licensed under the Apache License, Version 2.0 (the "License");
27915
+ * you may not use this file except in compliance with the License.
27916
+ * You may obtain a copy of the License at
27917
+ *
27918
+ * http://www.apache.org/licenses/LICENSE-2.0
27919
+ *
27920
+ * Unless required by applicable law or agreed to in writing, software
27921
+ * distributed under the License is distributed on an "AS IS" BASIS,
27922
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27923
+ * See the License for the specific language governing permissions and
27924
+ * limitations under the License.
27925
+ *
27926
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
27927
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
27928
+ * */
27929
+ var DAY_TO_MILLISECOND = 24 * 60 * 60 * 1000;
27930
+ var DAY_TO_SECOND = 86400;
27931
+ var MILLISECOND_TO_DAY = 1 / 86400000;
27932
+ var MILLISECOND_TO_SECOND = 1 / 1000;
27933
+ var MINUTE_TO_SECOND = 60;
27934
+ var SECOND_TO_MILLISECOND = 1000;
27935
+ var ONE_DAY_IN_SECONDS = DAY_TO_SECOND;
27936
+ /**
27937
+ * Reformats a date that has capitalized first letter and colon separator for time
27938
+ * @param dateString Date string from Date.toLocaleDateString
27939
+ * @returns Reformatted date string
27940
+ */
27941
+
27942
+ var reformatFinnishDateString = function reformatFinnishDateString(dateString) {
27943
+ var charPositionOfTimestamp = -4;
27944
+ return dateString.charAt(0).toUpperCase() + dateString.slice(1, charPositionOfTimestamp) + dateString.slice(charPositionOfTimestamp).replace('.', ':');
27945
+ };
27946
+ var getMonthChanges = function getMonthChanges(startDate, endDate) {
27947
+ var result = [];
27948
+ var currentDate = new Date(startDate.getTime());
27949
+ var lastDate = new Date(endDate.getTime());
27950
+ currentDate.setDate(1);
27951
+ currentDate.setHours(0, 0, 0, 0);
27952
+
27953
+ while (currentDate <= lastDate) {
27954
+ result.push(currentDate.getTime() * MILLISECOND_TO_SECOND);
27955
+ currentDate.setMonth(currentDate.getMonth() + 1);
27956
+ }
27957
+
27958
+ return result;
27959
+ };
27960
+ var getSelectedTimePx = function getSelectedTimePx(startTime, endTime, selectedTime, width) {
27961
+ var startDate = new Date(startTime * SECOND_TO_MILLISECOND);
27962
+ var startDateX = startDate.getTime() * MILLISECOND_TO_SECOND;
27963
+ var selectedTimeX = selectedTime - startDateX;
27964
+ var needleX = Math.floor(selectedTimeX / (endTime - startTime) * width);
27965
+ return needleX;
27966
+ };
27967
+ var boundedValue = function boundedValue(value, bounds) {
27968
+ var _a = __read(bounds, 2),
27969
+ min = _a[0],
27970
+ max = _a[1];
27971
+
27972
+ return Math.max(min, Math.min(max, value));
27973
+ };
27974
+ var getSelectedTimeFromPx = function getSelectedTimeFromPx(startTime, endTime, selectedTimePx, width) {
27975
+ var startDate = new Date(startTime * SECOND_TO_MILLISECOND);
27976
+ var startDateX = startDate.getTime() * MILLISECOND_TO_SECOND;
27977
+ var selectedTimeX = Math.floor(selectedTimePx / width * (endTime - startTime));
27978
+ var selectedTime = selectedTimeX + startDateX;
27979
+ return selectedTime;
27980
+ };
27981
+ var TickMode;
27982
+
27983
+ (function (TickMode) {
27984
+ TickMode[TickMode["DAY"] = 1] = "DAY";
27985
+ TickMode[TickMode["HALF_A_DAY"] = 2] = "HALF_A_DAY";
27986
+ TickMode[TickMode["SIX_HOURS"] = 4] = "SIX_HOURS";
27987
+ TickMode[TickMode["THREE_HOURS"] = 8] = "THREE_HOURS";
27988
+ TickMode[TickMode["ONE_HOUR"] = 24] = "ONE_HOUR";
27989
+ TickMode[TickMode["HALF_AN_HOUR"] = 48] = "HALF_AN_HOUR";
27990
+ TickMode[TickMode["FIFTEEN_MINUTES"] = 96] = "FIFTEEN_MINUTES";
27991
+ })(TickMode || (TickMode = {}));
27992
+
27993
+ var subTicksPerDay = function subTicksPerDay(dayWidthInPixels) {
27994
+ if (dayWidthInPixels < 40) {
27995
+ return TickMode.DAY;
27996
+ }
27997
+
27998
+ if (dayWidthInPixels < 75) {
27999
+ return TickMode.HALF_A_DAY;
28000
+ }
28001
+
28002
+ if (dayWidthInPixels < 400) {
28003
+ return TickMode.SIX_HOURS;
28004
+ }
28005
+
28006
+ if (dayWidthInPixels < 800) {
28007
+ return TickMode.THREE_HOURS;
28008
+ }
28009
+
28010
+ if (dayWidthInPixels < 1600) {
28011
+ return TickMode.ONE_HOUR;
28012
+ }
28013
+
28014
+ if (dayWidthInPixels < 3200) {
28015
+ return TickMode.HALF_AN_HOUR;
28016
+ }
28017
+
28018
+ return TickMode.FIFTEEN_MINUTES;
28019
+ };
28020
+ var maxSubTicksPerDay = function maxSubTicksPerDay(dayWidthInPixels, timeStep) {
28021
+ return Math.min(subTicksPerDay(dayWidthInPixels), Math.floor(ONE_DAY_IN_SECONDS / timeStep));
28022
+ };
28023
+
28024
+ /* *
28025
+ * Licensed under the Apache License, Version 2.0 (the "License");
28026
+ * you may not use this file except in compliance with the License.
28027
+ * You may obtain a copy of the License at
28028
+ *
28029
+ * http://www.apache.org/licenses/LICENSE-2.0
28030
+ *
28031
+ * Unless required by applicable law or agreed to in writing, software
28032
+ * distributed under the License is distributed on an "AS IS" BASIS,
28033
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28034
+ * See the License for the specific language governing permissions and
28035
+ * limitations under the License.
28036
+ *
28037
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
28038
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
28039
+ * */
28040
+
28041
+ var Submenu;
28042
+
28043
+ (function (Submenu) {
28044
+ Submenu["TIME_RANGE"] = "Time range";
28045
+ Submenu["TIME_STEP"] = "Time step";
28046
+ Submenu["SPEED"] = "Speed";
28047
+ Submenu["UPDATE_INTERVAL"] = "Update interval";
28048
+ })(Submenu || (Submenu = {}));
28049
+
27966
28050
  /* *
27967
28051
  * Licensed under the Apache License, Version 2.0 (the "License");
27968
28052
  * you may not use this file except in compliance with the License.
@@ -28045,11 +28129,14 @@
28045
28129
  var ControlButtonGroup = function ControlButtonGroup(_a) {
28046
28130
  var children = _a.children,
28047
28131
  right = _a.right,
28048
- left = _a.left;
28049
- return /*#__PURE__*/React__default["default"].createElement(material.ButtonGroup, {
28132
+ left = _a.left,
28133
+ props = __rest(_a, ["children", "right", "left"]);
28134
+
28135
+ return /*#__PURE__*/React__default["default"].createElement(material.ButtonGroup, __assign({
28050
28136
  orientation: "horizontal",
28051
- fullWidth: true,
28052
- sx: __assign(__assign(__assign({}, right && {
28137
+ fullWidth: true
28138
+ }, props, {
28139
+ sx: __assign(__assign(__assign(__assign({}, right && {
28053
28140
  borderTopLeftRadius: 0,
28054
28141
  borderBottomLeftRadius: 0
28055
28142
  }), left && {
@@ -28062,27 +28149,15 @@
28062
28149
  justifyContent: 'center',
28063
28150
  padding: '4px',
28064
28151
  gap: '2px'
28065
- })
28066
- }, children);
28152
+ }), props.sx)
28153
+ }), children);
28067
28154
  };
28068
28155
 
28069
- /* *
28070
- * Licensed under the Apache License, Version 2.0 (the "License");
28071
- * you may not use this file except in compliance with the License.
28072
- * You may obtain a copy of the License at
28073
- *
28074
- * http://www.apache.org/licenses/LICENSE-2.0
28075
- *
28076
- * Unless required by applicable law or agreed to in writing, software
28077
- * distributed under the License is distributed on an "AS IS" BASIS,
28078
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28079
- * See the License for the specific language governing permissions and
28080
- * limitations under the License.
28081
- *
28082
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
28083
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
28084
- * */
28085
- var TICK_HEIGHT = 8;
28156
+ var TICK_HEIGHT = 6;
28157
+ var HOUR_LABEL_OFFSET = 1.5;
28158
+ var MONTH_LABEL_BREAKPOINT = 65;
28159
+ var HOUR_LABEL_BREAKPOINT = 800;
28160
+ var HOUR_LABEL_EVERY_THIRD_HOUR_BREAKPOINT = 1600;
28086
28161
  var TIME_SLIDER_LITE_PADDING_RIGHT = 1;
28087
28162
 
28088
28163
  var TimeSliderLiteBackgroundSvg = function TimeSliderLiteBackgroundSvg(_a) {
@@ -28090,6 +28165,7 @@
28090
28165
  height = _a.height,
28091
28166
  startTime = _a.startTime,
28092
28167
  endTime = _a.endTime,
28168
+ timeStep = _a.timeStep,
28093
28169
  style = _a.style,
28094
28170
  locale = _a.locale;
28095
28171
  var timeSliderLite = material.useTheme().palette.geowebColors.timeSliderLite;
@@ -28102,15 +28178,23 @@
28102
28178
  } // Convert start and end time from Unix timestamp to JavaScript Date object
28103
28179
 
28104
28180
 
28105
- var startDate = new Date(startTime * 1000);
28106
- var endDate = new Date(endTime * 1000);
28107
- var totalDays = (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24);
28181
+ var startDate = new Date(startTime * SECOND_TO_MILLISECOND);
28182
+ var endDate = new Date(endTime * SECOND_TO_MILLISECOND);
28183
+ var totalDays = (endDate.getTime() - startDate.getTime()) * MILLISECOND_TO_DAY;
28108
28184
  var tickSpacing = width / totalDays;
28109
- var tickOffset = (startDate.getHours() + startDate.getMinutes() / 60) / 24 * tickSpacing; // Set up variables for date labels and background colors
28185
+
28186
+ if (tickSpacing === Infinity || tickSpacing === -Infinity || isNaN(tickSpacing)) {
28187
+ return null;
28188
+ }
28189
+
28190
+ var tickOffset = (startDate.getHours() + startDate.getMinutes() / 60) / 24 * tickSpacing;
28191
+ var showMonthLabel = tickSpacing < MONTH_LABEL_BREAKPOINT;
28192
+ var showHourLabel = tickSpacing > HOUR_LABEL_BREAKPOINT;
28193
+ var showHourLabelEveryThirdHour = tickSpacing < HOUR_LABEL_EVERY_THIRD_HOUR_BREAKPOINT; // Set up variables for date labels and background colors
28110
28194
 
28111
28195
  var dayLabels = [];
28112
28196
  var currentDate = startDate;
28113
- var lastDayLabelDate = new Date(endDate.getTime() + 2 * 24 * 60 * 60 * 1000); // Append two more days
28197
+ var lastDayLabelDate = new Date(endDate.getTime() + 2 * DAY_TO_MILLISECOND); // Append two more days
28114
28198
 
28115
28199
  while (currentDate < lastDayLabelDate) {
28116
28200
  var dateString = currentDate.toLocaleDateString(locale, {
@@ -28123,17 +28207,38 @@
28123
28207
  currentDate.setDate(currentDate.getDate() + 1);
28124
28208
  }
28125
28209
 
28210
+ var monthChanges = getMonthChanges(startDate, endDate);
28211
+ var monthLabels = showMonthLabel ? monthChanges.map(function (monthChange) {
28212
+ var x = getSelectedTimePx(startTime, endTime, monthChange, width) + 4;
28213
+ var dateString = new Date(monthChange * 1000).toLocaleDateString(locale, {
28214
+ weekday: 'short',
28215
+ month: 'numeric',
28216
+ day: 'numeric'
28217
+ });
28218
+ var label = dateString.charAt(0).toUpperCase() + dateString.slice(1);
28219
+ return /*#__PURE__*/React__default["default"].createElement("text", {
28220
+ x: x,
28221
+ y: 14,
28222
+ fill: timeSliderLite.timeline.fill,
28223
+ textAnchor: "left",
28224
+ fontSize: "12px",
28225
+ key: monthChange + "-month-change-text",
28226
+ style: {
28227
+ userSelect: 'none'
28228
+ }
28229
+ }, label);
28230
+ }) : null;
28126
28231
  var backgroundRectangles = dayLabels.map(function (label, index) {
28127
28232
  return /*#__PURE__*/React__default["default"].createElement("rect", {
28128
- x: index * tickSpacing - tickOffset,
28233
+ x: Math.floor(index * tickSpacing - tickOffset),
28129
28234
  y: 0,
28130
- width: tickSpacing,
28235
+ width: Math.ceil(tickSpacing),
28131
28236
  height: height,
28132
28237
  fill: index % 2 === 0 ? timeSliderLite.timelineBackground.fill : timeSliderLite.timelineBackgroundAlternative.fill,
28133
28238
  key: label + "-color"
28134
28239
  });
28135
28240
  });
28136
- var labels = dayLabels.map(function (label, index) {
28241
+ var dailyLabels = !showMonthLabel ? dayLabels.map(function (label, index) {
28137
28242
  return /*#__PURE__*/React__default["default"].createElement("text", {
28138
28243
  x: index * tickSpacing + 8 - tickOffset,
28139
28244
  y: 14,
@@ -28145,8 +28250,35 @@
28145
28250
  userSelect: 'none'
28146
28251
  }
28147
28252
  }, dayLabels[index]);
28148
- });
28149
- var ticksPerDay = 4;
28253
+ }) : null;
28254
+ var hourLabelsPerDay = 24;
28255
+ var hourLabels = showHourLabel ? dayLabels.map(function (label, index) {
28256
+ return Array.from({
28257
+ length: hourLabelsPerDay
28258
+ }, function (_, value) {
28259
+ var defaultProps = {
28260
+ x: index * tickSpacing + value * (tickSpacing / hourLabelsPerDay) - tickOffset - HOUR_LABEL_OFFSET,
28261
+ y: height - 10,
28262
+ visibility: showHourLabelEveryThirdHour && value % 3 !== 0 ? 'hidden' : 'visible',
28263
+ fill: timeSliderLite.timeline.fill,
28264
+ fontSize: '12px'
28265
+ };
28266
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("text", __assign({}, defaultProps, {
28267
+ textAnchor: "end",
28268
+ key: label + "-" + value + "-hour-label",
28269
+ style: {
28270
+ userSelect: 'none'
28271
+ }
28272
+ }), value), /*#__PURE__*/React__default["default"].createElement("text", __assign({}, defaultProps, {
28273
+ textAnchor: "start",
28274
+ key: label + "-" + value + "-00-label",
28275
+ style: {
28276
+ userSelect: 'none'
28277
+ }
28278
+ }), ":00"));
28279
+ });
28280
+ }).flat() : null;
28281
+ var ticksPerDay = timeStep ? maxSubTicksPerDay(tickSpacing, timeStep) : subTicksPerDay(tickSpacing);
28150
28282
  var tickMarks = dayLabels.map(function (label, index) {
28151
28283
  return Array.from({
28152
28284
  length: ticksPerDay + 1
@@ -28165,56 +28297,7 @@
28165
28297
  style: style,
28166
28298
  width: width + TIME_SLIDER_LITE_PADDING_RIGHT,
28167
28299
  height: height
28168
- }, backgroundRectangles, tickMarks, labels);
28169
- };
28170
-
28171
- /* *
28172
- * Licensed under the Apache License, Version 2.0 (the "License");
28173
- * you may not use this file except in compliance with the License.
28174
- * You may obtain a copy of the License at
28175
- *
28176
- * http://www.apache.org/licenses/LICENSE-2.0
28177
- *
28178
- * Unless required by applicable law or agreed to in writing, software
28179
- * distributed under the License is distributed on an "AS IS" BASIS,
28180
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28181
- * See the License for the specific language governing permissions and
28182
- * limitations under the License.
28183
- *
28184
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
28185
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
28186
- * */
28187
- var MILLISECOND_TO_SECOND = 1 / 1000;
28188
- /**
28189
- * Reformats a date that has capitalized first letter and colon separator for time
28190
- * @param dateString Date string from Date.toLocaleDateString
28191
- * @returns Reformatted date string
28192
- */
28193
-
28194
- var reformatFinnishDateString = function reformatFinnishDateString(dateString) {
28195
- var charPositionOfTimestamp = -4;
28196
- return dateString.charAt(0).toUpperCase() + dateString.slice(1, charPositionOfTimestamp) + dateString.slice(charPositionOfTimestamp).replace('.', ':');
28197
- };
28198
- var getSelectedTimePx = function getSelectedTimePx(startTime, endTime, selectedTime, width) {
28199
- var startDate = new Date(startTime * 1000);
28200
- var startDateX = startDate.getTime() * MILLISECOND_TO_SECOND;
28201
- var selectedTimeX = selectedTime - startDateX;
28202
- var needleX = Math.floor(selectedTimeX / (endTime - startTime) * width);
28203
- return needleX;
28204
- };
28205
- var boundedValue = function boundedValue(value, bounds) {
28206
- var _a = __read(bounds, 2),
28207
- min = _a[0],
28208
- max = _a[1];
28209
-
28210
- return Math.max(min, Math.min(max, value));
28211
- };
28212
- var getSelectedTimeFromPx = function getSelectedTimeFromPx(startTime, endTime, selectedTimePx, width) {
28213
- var startDate = new Date(startTime * 1000);
28214
- var startDateX = startDate.getTime() * MILLISECOND_TO_SECOND;
28215
- var selectedTimeX = Math.floor(selectedTimePx / width * (endTime - startTime));
28216
- var selectedTime = selectedTimeX + startDateX;
28217
- return selectedTime;
28300
+ }, backgroundRectangles, tickMarks, monthLabels, dailyLabels, hourLabels);
28218
28301
  };
28219
28302
 
28220
28303
  /* *
@@ -28417,7 +28500,7 @@
28417
28500
  areaWidth = _b[0],
28418
28501
  setAreaWidth = _b[1];
28419
28502
 
28420
- var drawNeedle = selectedTime && areaWidth;
28503
+ var drawNeedle = selectedTime && areaWidth && startTime < endTime;
28421
28504
  React.useLayoutEffect(function () {
28422
28505
  var sliderArea = sliderAreaRef.current;
28423
28506
  setAreaWidth(sliderArea.clientWidth - TIME_SLIDER_LITE_PADDING_RIGHT);
@@ -28443,6 +28526,7 @@
28443
28526
  position: 'absolute',
28444
28527
  top: 0
28445
28528
  },
28529
+ timeStep: timeStep,
28446
28530
  width: areaWidth,
28447
28531
  height: height,
28448
28532
  startTime: startTime,
@@ -28493,7 +28577,8 @@
28493
28577
  isDisabled = _a.isDisabled,
28494
28578
  _k = _a.onClick,
28495
28579
  onClick = _k === void 0 ? function () {} : _k,
28496
- settings = _a.settings;
28580
+ settings = _a.settings,
28581
+ tooltipDelay = _a.tooltipDelay;
28497
28582
  var forwardTitle = (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.label) === null || _b === void 0 ? void 0 : _b.forward) !== null && _c !== void 0 ? _c : 'Forward';
28498
28583
  var backwardTitle = (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.label) === null || _d === void 0 ? void 0 : _d.backward) !== null && _e !== void 0 ? _e : 'Backward';
28499
28584
  var forwardIcon = (_g = (_f = settings === null || settings === void 0 ? void 0 : settings.icon) === null || _f === void 0 ? void 0 : _f.forward) !== null && _g !== void 0 ? _g : /*#__PURE__*/React__namespace.createElement(theme.StepForward, {
@@ -28503,7 +28588,9 @@
28503
28588
  "data-testid": "step-backward-svg-path"
28504
28589
  });
28505
28590
  return /*#__PURE__*/React__namespace.createElement(material.Tooltip, __assign({}, timeSliderLiteTooltipDefaultProps, {
28506
- title: forward ? forwardTitle : backwardTitle
28591
+ title: forward ? forwardTitle : backwardTitle,
28592
+ enterDelay: tooltipDelay,
28593
+ enterNextDelay: tooltipDelay
28507
28594
  }), /*#__PURE__*/React__namespace.createElement(material.IconButton, __assign({}, timeSliderLiteButtonDefaultProps, {
28508
28595
  disabled: isDisabled,
28509
28596
  "aria-label": forward ? forwardTitle : backwardTitle,
@@ -28535,13 +28622,17 @@
28535
28622
  var isAnimating = _a.isAnimating,
28536
28623
  isDisabled = _a.isDisabled,
28537
28624
  onTogglePlayButton = _a.onTogglePlayButton,
28538
- settings = _a.settings;
28625
+ settings = _a.settings,
28626
+ tooltipDelay = _a.tooltipDelay;
28539
28627
  var pauseTitle = (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.label) === null || _b === void 0 ? void 0 : _b.pause) !== null && _c !== void 0 ? _c : 'Pause';
28540
28628
  var playTitle = (_e = (_d = settings === null || settings === void 0 ? void 0 : settings.label) === null || _d === void 0 ? void 0 : _d.play) !== null && _e !== void 0 ? _e : 'Play';
28541
28629
  var pauseIcon = (_g = (_f = settings === null || settings === void 0 ? void 0 : settings.icon) === null || _f === void 0 ? void 0 : _f.pause) !== null && _g !== void 0 ? _g : /*#__PURE__*/React__default["default"].createElement(theme.Pause, null);
28542
28630
  var playIcon = (_j = (_h = settings === null || settings === void 0 ? void 0 : settings.icon) === null || _h === void 0 ? void 0 : _h.play) !== null && _j !== void 0 ? _j : /*#__PURE__*/React__default["default"].createElement(theme.Play, null);
28543
28631
  return /*#__PURE__*/React__default["default"].createElement(material.Tooltip, __assign({}, timeSliderLiteTooltipDefaultProps, {
28544
- title: isAnimating ? pauseTitle : playTitle
28632
+ title: isAnimating ? pauseTitle : playTitle,
28633
+ placement: "top",
28634
+ enterDelay: tooltipDelay,
28635
+ enterNextDelay: tooltipDelay
28545
28636
  }), /*#__PURE__*/React__default["default"].createElement(material.IconButton, __assign({}, timeSliderLiteButtonDefaultProps, {
28546
28637
  sx: __assign(__assign({}, isAnimating && {
28547
28638
  backgroundColor: 'geowebColors.timeSliderLite.selected.backgroundColor'
@@ -28579,16 +28670,22 @@
28579
28670
  settings = _a.settings;
28580
28671
  var title = (_b = settings === null || settings === void 0 ? void 0 : settings.label) !== null && _b !== void 0 ? _b : 'Animation options';
28581
28672
  var icon = (_c = settings === null || settings === void 0 ? void 0 : settings.icon) !== null && _c !== void 0 ? _c : /*#__PURE__*/React__default["default"].createElement(theme.Options, null);
28582
- return /*#__PURE__*/React__default["default"].createElement(material.Tooltip, __assign({}, timeSliderLiteTooltipDefaultProps, {
28583
- title: title
28584
- }), /*#__PURE__*/React__default["default"].createElement(material.IconButton, __assign({}, timeSliderLiteButtonDefaultProps, {
28673
+ var Button = /*#__PURE__*/React__default["default"].createElement(material.IconButton, __assign({}, timeSliderLiteButtonDefaultProps, {
28585
28674
  sx: __assign(__assign({}, menuOpen && {
28586
28675
  backgroundColor: 'geowebColors.timeSliderLite.selected.backgroundColor'
28587
28676
  }), timeSliderLiteButtonDefaultProps.sx),
28588
28677
  "aria-selected": menuOpen,
28589
28678
  onClick: onClick,
28590
28679
  "data-testid": "TimeSliderLite-MenuButton"
28591
- }), icon));
28680
+ }), icon);
28681
+
28682
+ if (menuOpen) {
28683
+ return Button;
28684
+ }
28685
+
28686
+ return /*#__PURE__*/React__default["default"].createElement(material.Tooltip, __assign({}, timeSliderLiteTooltipDefaultProps, {
28687
+ title: title
28688
+ }), Button);
28592
28689
  };
28593
28690
 
28594
28691
  /* *
@@ -28610,6 +28707,7 @@
28610
28707
  var TIME_SLIDER_LITE_DEFAULT_HEIGHT = 40;
28611
28708
  var TIME_SLIDER_LITE_DEFAULT_LOCALE = 'en';
28612
28709
  var TIME_SLIDER_LITE_DEFAULT_TIME_STEP = 5;
28710
+ var TIME_SLIDER_LITE_TOOLTIP_DELAY = 3000;
28613
28711
  var styles$1 = {
28614
28712
  container: {
28615
28713
  display: 'grid',
@@ -28620,15 +28718,17 @@
28620
28718
  };
28621
28719
 
28622
28720
  var TimeSliderLite = function TimeSliderLite(_a) {
28721
+ var _b, _c;
28722
+
28623
28723
  var controlButtons = _a.controlButtons,
28624
28724
  endTime = _a.endTime,
28625
- _b = _a.height,
28626
- height = _b === void 0 ? TIME_SLIDER_LITE_DEFAULT_HEIGHT : _b,
28725
+ _d = _a.height,
28726
+ height = _d === void 0 ? TIME_SLIDER_LITE_DEFAULT_HEIGHT : _d,
28627
28727
  hideButton = _a.hideButton,
28628
28728
  isAnimating = _a.isAnimating,
28629
28729
  isVisible = _a.isVisible,
28630
- _c = _a.locale,
28631
- locale = _c === void 0 ? TIME_SLIDER_LITE_DEFAULT_LOCALE : _c,
28730
+ _e = _a.locale,
28731
+ locale = _e === void 0 ? TIME_SLIDER_LITE_DEFAULT_LOCALE : _e,
28632
28732
  mapId = _a.mapId,
28633
28733
  menuOpen = _a.menuOpen,
28634
28734
  overrideAnimation = _a.overrideAnimation,
@@ -28645,14 +28745,14 @@
28645
28745
  settings = _a.settings,
28646
28746
  startTime = _a.startTime,
28647
28747
  sx = _a.sx,
28648
- _d = _a.timeStep,
28649
- timeStep = _d === void 0 ? TIME_SLIDER_LITE_DEFAULT_TIME_STEP : _d;
28748
+ _f = _a.timeStep,
28749
+ timeStep = _f === void 0 ? TIME_SLIDER_LITE_DEFAULT_TIME_STEP : _f;
28650
28750
 
28651
- var _e = __read(React.useState(selectedTime), 2),
28652
- rawSelectedTime = _e[0],
28653
- setRawSelectedTime = _e[1];
28751
+ var _g = __read(React.useState(selectedTime), 2),
28752
+ rawSelectedTime = _g[0],
28753
+ setRawSelectedTime = _g[1];
28654
28754
 
28655
- var timeStepSeconds = timeStep * 60;
28755
+ var timeStepSeconds = timeStep * MINUTE_TO_SECOND;
28656
28756
  var roundedStartTime = Math.floor(startTime / timeStepSeconds) * timeStepSeconds;
28657
28757
  var roundedEndTime = Math.floor(endTime / timeStepSeconds) * timeStepSeconds;
28658
28758
  var runningExternalAnimation = overrideAnimation && isAnimating;
@@ -28701,12 +28801,19 @@
28701
28801
  if (isAnimating && onToggleAnimation) {
28702
28802
  onToggleAnimation();
28703
28803
  }
28704
- };
28804
+ }; // Handle time range selection
28805
+
28705
28806
 
28807
+ React.useEffect(function () {
28808
+ setRawSelectedTime(boundedValue(selectedTime, [roundedStartTime, roundedEndTime])); // eslint-disable-next-line react-hooks/exhaustive-deps
28809
+ }, [startTime, endTime]);
28810
+ var tooltipDelay = menuOpen ? TIME_SLIDER_LITE_TOOLTIP_DELAY : undefined;
28706
28811
  return /*#__PURE__*/React__default["default"].createElement(material.Grid, {
28707
28812
  container: true,
28708
28813
  sx: __assign(__assign(__assign({}, styles$1.container), sx), {
28709
- gridTemplateColumns: isVisible ? 'auto 1fr auto' : "1fr auto"
28814
+ gridTemplateColumns: isVisible ? 'auto 1fr auto' : "1fr auto",
28815
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28816
+ boxShadow: isVisible ? (_b = sx) === null || _b === void 0 ? void 0 : _b.boxShadow : undefined
28710
28817
  }),
28711
28818
  "data-testid": "timeSliderLite-" + mapId
28712
28819
  }, isVisible ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -28729,18 +28836,21 @@
28729
28836
  }), /*#__PURE__*/React__default["default"].createElement(PlayButton, {
28730
28837
  settings: settings === null || settings === void 0 ? void 0 : settings.playButton,
28731
28838
  isAnimating: isAnimating,
28732
- onTogglePlayButton: onToggleAnimation
28839
+ onTogglePlayButton: onToggleAnimation,
28840
+ tooltipDelay: tooltipDelay
28733
28841
  }), /*#__PURE__*/React__default["default"].createElement(StepButton, {
28734
28842
  settings: settings === null || settings === void 0 ? void 0 : settings.stepButton,
28735
28843
  onClick: function onClick() {
28736
28844
  return handleTimeStep(-timeStepSeconds);
28737
- }
28845
+ },
28846
+ tooltipDelay: tooltipDelay
28738
28847
  }), /*#__PURE__*/React__default["default"].createElement(StepButton, {
28739
28848
  forward: true,
28740
28849
  settings: settings === null || settings === void 0 ? void 0 : settings.stepButton,
28741
28850
  onClick: function onClick() {
28742
28851
  return handleTimeStep(timeStepSeconds);
28743
- }
28852
+ },
28853
+ tooltipDelay: tooltipDelay
28744
28854
  }))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
28745
28855
  item: true
28746
28856
  }, /*#__PURE__*/React__default["default"].createElement(TimeSliderLiteBackground, {
@@ -28761,9 +28871,13 @@
28761
28871
  }), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
28762
28872
  item: true,
28763
28873
  sx: {
28874
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28875
+ boxShadow: isVisible ? 'none' : (_c = sx) === null || _c === void 0 ? void 0 : _c.boxShadow,
28876
+ borderRadius: isVisible ? 'none' : '4px',
28764
28877
  height: height + "px"
28765
28878
  }
28766
28879
  }, hideButton || /*#__PURE__*/React__default["default"].createElement(ControlButtonGroup, {
28880
+ className: "timeSliderLite-hideButtonGroup-" + (isVisible ? 'hide' : 'show'),
28767
28881
  right: isVisible
28768
28882
  }, /*#__PURE__*/React__default["default"].createElement(HideButton, {
28769
28883
  settings: settings === null || settings === void 0 ? void 0 : settings.hideButton,
@@ -31,5 +31,6 @@ export interface TimeSliderLiteProps {
31
31
  export declare const TIME_SLIDER_LITE_DEFAULT_HEIGHT = 40;
32
32
  export declare const TIME_SLIDER_LITE_DEFAULT_LOCALE = "en";
33
33
  export declare const TIME_SLIDER_LITE_DEFAULT_TIME_STEP = 5;
34
+ export declare const TIME_SLIDER_LITE_TOOLTIP_DELAY = 3000;
34
35
  declare const TimeSliderLite: React.FC<TimeSliderLiteProps>;
35
36
  export default TimeSliderLite;