@opengeoweb/core 10.1.0 → 11.0.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 (25) hide show
  1. package/README.md +3 -16
  2. package/index.esm.js +572 -227
  3. package/package.json +6 -2
  4. package/src/lib/components/Providers/Providers.d.ts +0 -2
  5. package/src/lib/components/Search/MyMapLocation.d.ts +5 -6
  6. package/src/lib/components/Search/SearchDialog.d.ts +4 -1
  7. package/src/lib/components/Search/{SearchControl.stories.d.ts → SearchDialog.stories.d.ts} +4 -4
  8. package/src/lib/components/Search/SearchDialogConnect.d.ts +5 -0
  9. package/src/lib/components/Search/SearchDialogConnect.spec.d.ts +1 -0
  10. package/src/lib/components/Search/SearchDialogConnect.stories.d.ts +7 -0
  11. package/src/lib/components/Search/index.d.ts +1 -1
  12. package/src/lib/components/Search/types.d.ts +13 -0
  13. package/src/lib/components/Search/utils.d.ts +8 -0
  14. package/src/lib/components/SyncGroups/SimpleTimeSliderConnect.d.ts +2 -2
  15. package/src/lib/components/SyncGroups/SyncGroupViewer.d.ts +1 -1
  16. package/src/lib/components/TimeSliderConnect/TimeSliderConnect.d.ts +1 -1
  17. package/src/lib/components/TimeSliderConnect/TimeSliderLegendConnect.d.ts +4 -0
  18. package/src/lib/store/index.d.ts +1 -0
  19. package/src/lib/store/store.d.ts +13 -0
  20. package/src/lib/utils/location-api/api.d.ts +3 -0
  21. package/src/lib/utils/location-api/fakeApi.d.ts +70 -0
  22. package/src/lib/utils/location-api/hooks.d.ts +4 -0
  23. package/src/lib/utils/testUtils.d.ts +1 -4
  24. package/src/lib/components/Search/SearchControlConnect.d.ts +0 -5
  25. /package/src/lib/components/{Search/SearchControlConnect.spec.d.ts → MultiMapViewConnect/HarmoniePresets/HarmonieTempAndPrecipPreset.spec.d.ts} +0 -0
package/index.esm.js CHANGED
@@ -1,21 +1,24 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useState, useCallback, useRef, useMemo } from 'react';
4
- import { Grid2, Box, MenuItem, Typography, useTheme, Popper, Fade, Tooltip, styled, LinearProgress, FormControl, InputLabel, Paper, List, ListItemButton, ListItemText, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, InputAdornment, DialogActions, Button, circularProgressClasses, ListItemIcon, Checkbox, Switch, Select } from '@mui/material';
3
+ import React__default, { useState, useCallback, useEffect, useMemo } from 'react';
4
+ import { Grid2, Box, MenuItem, Typography, useTheme, Popper, Fade, Tooltip, styled, LinearProgress, FormControl, InputLabel, Paper, List, ListItemButton, ListItemText, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, InputAdornment, DialogActions, Button, Autocomplete, ListItemIcon, Checkbox, Switch, Select } from '@mui/material';
5
5
  import { SHARED_NAMESPACE, sharedTranslations, CustomIconButton, CustomTooltip, TooltipSelect, AlertIcon, sliderHeaderStyle, CustomSlider, ToggleMenu, tooltipContainerStyles, renderCounter, AlertBanner, CustomAccordion, PROJECTION, calculateStartSize, useWheelStopPropagation, ToolContainerDraggable, useDebounce, dateUtils, ErrorBoundary } from '@opengeoweb/shared';
6
6
  import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, LayersAdd, CloudLoading, ColumnCollapsed, ColumnCollapse, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Add, MapAdd, WorldMapProjection, Layers, Search, Exclamation, MyLocation, Close, ExitDomain, Info, ThemeWrapper, lightTheme, FlagBritain, FlagNetherlands, FlagFinland, FlagNorway } from '@opengeoweb/theme';
7
7
  import i18n from 'i18next';
8
8
  import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
9
- import { TIMESLIDER_NAMESPACE, timesliderTranslations, defaultTimeSpan, TIME_SLIDER_LEGEND_HEIGHT, SpeedButton, TimeStepButton, AnimationLengthButton, AnimationLength, TimeSpanButton, secondsPerPxFromCanvasWidth, getNewCenterOfFixedPointZoom, OptionsMenuButton, PlayButton, defaultTimeStep, BackwardForwardStepButton, AutoUpdateButton, NowButton, handleSetNowEvent, TimeSliderButtons, TimeSliderCurrentTimeBox, TimeSliderLegend, TimeSlider, onsetNewDateDebounced, getFilteredTime, ControlButtons, OptionsMenu, TimeSliderClock } from '@opengeoweb/timeslider';
10
- import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations, WEBMAP_NAMESPACE, webmapTranslations, LayerInfoButton, LayerInfoDialog, MapControlButton, MapDimensionSelect, dimensionConfig, DimensionSelectDialog, DimensionSelectButton, registerDrawFunction, ZoomControls, LegendDialog, LegendButton, MapView, MapViewLayer, MapControls, emptyGeoJSON, publicLayers } from '@opengeoweb/webmap-react';
9
+ import { TIMESLIDER_NAMESPACE, timesliderTranslations, defaultTimeSpan, TIME_SLIDER_LEGEND_HEIGHT, SpeedButton, TimeStepButton, AnimationLengthButton, AnimationLength, TimeSpanButton, secondsPerPxFromCanvasWidth, getNewCenterOfFixedPointZoom, OptionsMenuButton, PlayButton, defaultTimeStep, BackwardForwardStepButton, AutoUpdateButton, NowButton, handleSetNowEvent, TimeSliderButtons, TimeSliderCurrentTimeBox, TimeSliderLegend, onsetNewDateDebounced, defaultSecondsPerPx, moveSelectedTimePx, TimeSlider, getFilteredTime, ControlButtons, OptionsMenu, TimeSliderClock } from '@opengeoweb/timeslider';
10
+ import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations, WEBMAP_NAMESPACE, webmapTranslations, LayerInfoButton, LayerInfoDialog, MapControlButton, MapDimensionSelect, dimensionConfig, DimensionSelectDialog, DimensionSelectButton, emptyGeoJSON, registerDrawFunction, ZoomControls, LegendDialog, LegendButton, MapView, MapViewLayer, MapControls, publicLayers } from '@opengeoweb/webmap-react';
11
11
  import { useDispatch, useSelector, connect, useStore, Provider } from 'react-redux';
12
12
  import { ReactSortable } from 'react-sortablejs';
13
13
  import Sortable from 'sortablejs';
14
- import { layerTypes, layerUtils, mapSelectors, layerActions, layerSelectors, serviceSelectors, serviceActions, mapActions, mapEnums, uiSelectors, uiTypes, useSetupDialog, filterLayers, getUserAddedServices, uiActions, genericSelectors, genericActions, drawtoolSelectors, syncConstants, loadingIndicatorActions, syncGroupsSelectors, defaultLayers, getSingularDrawtoolDrawLayerId, syncGroupsSelector, syncGroupsActions, routerUtils } from '@opengeoweb/store';
14
+ import { layerTypes, layerUtils, mapSelectors, layerActions, layerSelectors, serviceSelectors, serviceActions, mapActions, mapEnums, uiSelectors, uiTypes, useSetupDialog, filterLayers, getUserAddedServices, uiActions, genericSelectors, genericActions, drawingToolSelectors, syncConstants, loadingIndicatorActions, syncGroupsSelectors, defaultLayers, getSingularDrawtoolDrawLayerId, syncGroupsSelector, syncGroupsActions, routerUtils } from '@opengeoweb/store';
15
15
  import _, { isArray, isEqual, debounce, range } from 'lodash';
16
- import { webmapUtils, queryWMSServiceInfo, queryWMSLayers, queryWMSLayersTree, invalidateWMSGetCapabilities, LayerType, getWMSServiceId, getWMSGetFeatureInfoRequestURL, handleDateUtilsISOString, wmServiceListener, EVENT_GETCAPABILITIES_START, EVENT_GETCAPABILITIES_READY, WMLayer } from '@opengeoweb/webmap';
16
+ import { webmapUtils, queryWMSServiceInfo, queryWMSLayers, queryWMSLayersTree, invalidateWMSGetCapabilities, LayerType, getWMSServiceId, generateLayerId, getWMJSMapById, getWMSGetFeatureInfoRequestURL, handleDateUtilsISOString, wmServiceListener, EVENT_GETCAPABILITIES_START, EVENT_GETCAPABILITIES_READY, WMLayer } from '@opengeoweb/webmap';
17
17
  import { Box as Box$1, styled as styled$1 } from '@mui/system';
18
18
  import { LayerSelectButtonConnect, LayerSelectConnect } from '@opengeoweb/layer-select';
19
+ import { useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
20
+ import { getConfig } from '@opengeoweb/authentication';
21
+ import { handleResponse } from '@opengeoweb/api';
19
22
  import axios from 'axios';
20
23
  import DOMPurify from 'dompurify';
21
24
  import { snackbarTypes, snackbarActions, SnackbarWrapperConnect } from '@opengeoweb/snackbar';
@@ -65,10 +68,13 @@ var en = {
65
68
  "wms-loader-error-http": "Use https or allow Mixed Content in your browser to use this WMS service",
66
69
  "wms-loader-error-valid-service": "Please enter a valid WMS service",
67
70
  "wms-loader-error-valid-url": "Please enter a valid URL",
68
- "search-title": "Search",
69
- "search-title-aria": "Map search",
70
- "search-find-location": "Find my location",
71
- "search-error": "Geolocation error: {{error}}",
71
+ "search-title": "Find location",
72
+ "search-title-aria": "Find location on the map",
73
+ "search-my-location": "Find my location",
74
+ "search-title-long": "Find location, area, postal code, GPS, ...",
75
+ "search-no-results": "No results",
76
+ "my-location": "My location",
77
+ "search-clear": "Clear",
72
78
  "syncgroups-title": "Sync",
73
79
  "syncgroups-zoom": "ZoomPane",
74
80
  "syncgroups-timeslider": "Timeslider",
@@ -140,8 +146,11 @@ var fi = {
140
146
  "wms-loader-error-valid-url": "Lisää toimiva URL",
141
147
  "search-title": "Etsi",
142
148
  "search-title-aria": "Karttahaku",
143
- "search-find-location": "Etsi sijaintini",
144
- "search-error": "Maantieteellisen sijainnin virhe: {{error}}",
149
+ "search-my-location": "Etsi sijaintini",
150
+ "search-title-long": "Find location, area, postal code, GPS, ...",
151
+ "search-no-results": "No results",
152
+ "my-location": "My location",
153
+ "search-clear": "Clear",
145
154
  "syncgroups-title": "Sync",
146
155
  "syncgroups-zoom": "ZoomPane",
147
156
  "syncgroups-timeslider": "TimeSlider",
@@ -213,8 +222,11 @@ var no = {
213
222
  "wms-loader-error-valid-url": "Vennligst skriv inn en gyldig URL",
214
223
  "search-title": "Søk",
215
224
  "search-title-aria": "Kart søk",
216
- "search-find-location": "Finn min lokasjon",
217
- "search-error": "Geolocation error: {{error}}",
225
+ "search-my-location": "Finn min lokasjon",
226
+ "search-title-long": "Find location, area, postal code, GPS, ...",
227
+ "search-no-results": "No results",
228
+ "my-location": "Min lokasjon",
229
+ "search-clear": "Clear",
218
230
  "syncgroups-title": "Synkroniser",
219
231
  "syncgroups-zoom": "Zoom/Paner",
220
232
  "syncgroups-timeslider": "Timeslider",
@@ -286,8 +298,11 @@ var nl = {
286
298
  "wms-loader-error-valid-url": "Voer een geldige URL in",
287
299
  "search-title": "Zoeken",
288
300
  "search-title-aria": "Zoeken op de kaart",
289
- "search-find-location": "Vind mijn locatie",
290
- "search-error": "Geolocatie fout: {{error}}",
301
+ "search-my-location": "Vind mijn locatie",
302
+ "search-title-long": "Vind locatie, gebied, postcode, GPS, ...",
303
+ "search-no-results": "Geen resultaten",
304
+ "my-location": "Mijn locatie",
305
+ "search-clear": "Wissen",
291
306
  "syncgroups-title": "Synchroniseren",
292
307
  "syncgroups-zoom": "Zoomvenster",
293
308
  "syncgroups-timeslider": "Timeslider",
@@ -5627,230 +5642,508 @@ var SearchControlButtonConnect = function SearchControlButtonConnect(_ref) {
5627
5642
  });
5628
5643
  };
5629
5644
 
5630
- var MY_LOCATION = 'MyLocation';
5645
+ var MY_LOCATION = 'My location';
5631
5646
  var locationOptions = {
5632
5647
  enableHighAccuracy: false,
5633
- timeout: 5000,
5648
+ timeout: 10000,
5634
5649
  maximumAge: 0
5635
5650
  };
5636
- var circleDrawFunction = function circleDrawFunction(args, fillColor, radius) {
5637
- if (fillColor === void 0) {
5638
- fillColor = '#88F';
5639
- }
5640
- if (radius === void 0) {
5641
- radius = 12;
5642
- }
5643
- var ctx = args.context,
5644
- coord = args.coord;
5645
- ctx.strokeStyle = '#000';
5646
- ctx.fillStyle = fillColor || '#88F';
5647
- ctx.lineWidth = 1;
5648
- ctx.beginPath();
5649
- ctx.arc(coord.x, coord.y, radius || 10, 0, 2 * Math.PI);
5650
- ctx.fill();
5651
- ctx.stroke();
5652
- ctx.fillStyle = '#000';
5653
- ctx.beginPath();
5654
- ctx.arc(coord.x, coord.y, 2, 0, 2 * Math.PI);
5655
- ctx.fill();
5656
- };
5657
5651
  var MyMapLocation = function MyMapLocation(_ref) {
5658
- var _sx;
5659
- var mapId = _ref.mapId,
5660
- isLoading = _ref.isLoading,
5661
- hasFailed = _ref.hasFailed,
5662
- setIsLoading = _ref.setIsLoading,
5663
- setHasFailed = _ref.setHasFailed;
5652
+ var _ref$mapId = _ref.mapId,
5653
+ mapId = _ref$mapId === void 0 ? '' : _ref$mapId,
5654
+ _ref$isSelected = _ref.isSelected,
5655
+ isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
5656
+ _ref$onUpdateMyLocati = _ref.onUpdateMyLocation,
5657
+ onUpdateMyLocation = _ref$onUpdateMyLocati === void 0 ? function () {} : _ref$onUpdateMyLocati;
5658
+ var theme = useTheme();
5659
+ var _useState = useState(false),
5660
+ isLoading = _useState[0],
5661
+ setIsLoading = _useState[1];
5662
+ var _useState2 = useState(false),
5663
+ hasFailed = _useState2[0],
5664
+ setHasFailed = _useState2[1];
5664
5665
  var _useCoreTranslation = useCoreTranslation(),
5665
5666
  t = _useCoreTranslation.t;
5666
- var dispatch = useDispatch();
5667
- var layersBelongsToCurrentMapId = useSelector(function (store) {
5668
- return layerSelectors.getLayersByMapId(store, mapId || '');
5669
- });
5670
- var layerLocation = layersBelongsToCurrentMapId.find(function (layer) {
5671
- var _layer$geojson$featur;
5672
- if (layer.geojson && layer.geojson.features[0] && layer.geojson.features[0].properties && (_layer$geojson$featur = layer.geojson.features[0].properties) != null && _layer$geojson$featur.name) {
5673
- if (layer.geojson.features[0].properties.name === MY_LOCATION) {
5674
- return layer;
5675
- }
5676
- }
5677
- return undefined;
5678
- });
5679
- var layerLocationId = (layerLocation == null ? void 0 : layerLocation.id) || '';
5680
- var circleDrawFunctionId = useRef(registerDrawFunction(circleDrawFunction));
5681
5667
  var handleLocationClick = function handleLocationClick() {
5682
- setIsLoading(true);
5683
- if (mapId && layerLocationId !== '') {
5684
- dispatch(layerActions.layerDelete({
5685
- mapId: mapId,
5686
- layerId: layerLocationId
5687
- }));
5688
- setIsLoading(false);
5689
- } else if (navigator.geolocation && mapId && layerLocationId === '' && circleDrawFunctionId) {
5668
+ if (mapId && isSelected) {
5669
+ onUpdateMyLocation(undefined);
5670
+ } else if (navigator.geolocation && mapId && !isSelected) {
5671
+ setIsLoading(true);
5672
+ setHasFailed(false);
5690
5673
  navigator.geolocation.getCurrentPosition(function (success) {
5691
5674
  setIsLoading(false);
5692
- setHasFailed(false);
5693
5675
  var _success$coords = success.coords,
5694
5676
  latitude = _success$coords.latitude,
5695
5677
  longitude = _success$coords.longitude;
5696
- var geojson = {
5697
- type: 'FeatureCollection',
5698
- features: [{
5699
- type: 'Feature',
5700
- properties: {
5701
- name: MY_LOCATION,
5702
- drawFunctionId: circleDrawFunctionId.current
5703
- },
5704
- geometry: {
5705
- type: 'Point',
5706
- coordinates: [longitude, latitude]
5707
- }
5708
- }]
5678
+ var location = {
5679
+ lat: latitude,
5680
+ lon: longitude,
5681
+ name: MY_LOCATION,
5682
+ source: 'MyMapLocation',
5683
+ id: MY_LOCATION
5709
5684
  };
5710
- var layerId = webmapUtils.generateLayerId();
5711
- dispatch(layerActions.addLayer({
5712
- mapId: mapId,
5713
- layer: {
5714
- geojson: geojson,
5715
- layerType: LayerType.featureLayer
5716
- },
5717
- layerId: layerId,
5718
- origin: MY_LOCATION
5719
- }));
5720
- var wmjsMap = webmapUtils.getWMJSMapById(mapId);
5721
- if (!wmjsMap) {
5722
- return;
5723
- }
5724
- wmjsMap.calculateBoundingBoxAndZoom(latitude, longitude);
5725
- }, function (error) {
5685
+ onUpdateMyLocation(location);
5686
+ }, function () {
5726
5687
  setIsLoading(false);
5727
5688
  setHasFailed(true);
5728
- console.warn(t('search-error', {
5729
- error: error.message
5730
- }));
5689
+ onUpdateMyLocation(undefined);
5731
5690
  }, locationOptions);
5732
5691
  }
5733
5692
  };
5734
5693
  var chooseIcon = function chooseIcon() {
5735
5694
  return hasFailed ? jsx(Exclamation, {
5736
5695
  style: {
5737
- color: 'red'
5696
+ color: theme.palette.geowebColors.functional.error
5738
5697
  },
5739
5698
  "aria-label": "location error"
5740
5699
  }) : jsx(MyLocation, {
5741
5700
  "aria-label": "location default"
5742
5701
  });
5743
5702
  };
5744
- return jsx("div", {
5745
- children: isLoading ? jsxs(Fragment, {
5746
- children: [jsx(CircularProgress, {
5747
- value: 100,
5748
- variant: "determinate",
5749
- sx: {
5750
- height: '100%',
5751
- width: '100%',
5752
- color: function color(theme) {
5753
- return theme.palette.mode === 'light' ? '#1a90ff' : '#bad4ff';
5754
- },
5755
- padding: '8px'
5756
- },
5757
- thickness: 6,
5758
- "aria-label": "location loading"
5759
- }), jsx(CircularProgress, {
5760
- variant: "indeterminate",
5761
- disableShrink: true,
5762
- sx: (_sx = {
5763
- height: '100%',
5764
- width: '100%',
5765
- color: function color(theme) {
5766
- return theme.palette.mode === 'light' ? '#bad4ff' : '#45556F';
5767
- },
5768
- animationDuration: '1000ms',
5769
- position: 'absolute',
5770
- left: 0
5771
- }, _sx["& ." + circularProgressClasses.circle] = {
5772
- strokeLinecap: 'round'
5773
- }, _sx.padding = '8px', _sx),
5774
- thickness: 6
5775
- })]
5703
+ return jsx(Box, {
5704
+ sx: {
5705
+ height: 40,
5706
+ padding: 1
5707
+ },
5708
+ children: isLoading ? jsx(CircularProgress, {
5709
+ size: 24,
5710
+ "aria-label": "Location loading",
5711
+ color: "secondary"
5776
5712
  }) : jsx(CustomIconButton, {
5777
- title: t('search-find-location'),
5778
- "aria-label": MY_LOCATION,
5713
+ tooltipTitle: t('search-my-location'),
5714
+ "aria-label": t('search-my-location'),
5779
5715
  onClick: handleLocationClick,
5780
- isSelected: layerLocationId !== '',
5781
- size: "large",
5716
+ isSelected: isSelected,
5717
+ variant: "tool",
5718
+ size: "small",
5782
5719
  children: chooseIcon()
5783
5720
  })
5784
5721
  });
5785
5722
  };
5786
5723
 
5724
+ /* *
5725
+ * Licensed under the Apache License, Version 2.0 (the "License");
5726
+ * you may not use this file except in compliance with the License.
5727
+ * You may obtain a copy of the License at
5728
+ *
5729
+ * http://www.apache.org/licenses/LICENSE-2.0
5730
+ *
5731
+ * Unless required by applicable law or agreed to in writing, software
5732
+ * distributed under the License is distributed on an "AS IS" BASIS,
5733
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5734
+ * See the License for the specific language governing permissions and
5735
+ * limitations under the License.
5736
+ *
5737
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5738
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
5739
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
5740
+ * */
5741
+ var config = getConfig();
5742
+ var locationBaseUrl = config.GW_LOCATION_BASE_URL || '';
5743
+ var getLocationList = function getLocationList(search) {
5744
+ return fetch(locationBaseUrl + "/locations?search=" + search).then(handleResponse);
5745
+ };
5746
+ var getLocationDetail = function getLocationDetail(id, source) {
5747
+ return fetch(locationBaseUrl + "/locationdetail?id=" + id + "&source=" + source).then(handleResponse);
5748
+ };
5749
+
5750
+ var useLocationList = function useLocationList(search) {
5751
+ return useQuery({
5752
+ queryKey: ['location-list', search],
5753
+ queryFn: function () {
5754
+ var _queryFn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5755
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5756
+ while (1) switch (_context.prev = _context.next) {
5757
+ case 0:
5758
+ if (!(search.length > 0)) {
5759
+ _context.next = 2;
5760
+ break;
5761
+ }
5762
+ return _context.abrupt("return", getLocationList(search));
5763
+ case 2:
5764
+ return _context.abrupt("return", []);
5765
+ case 3:
5766
+ case "end":
5767
+ return _context.stop();
5768
+ }
5769
+ }, _callee);
5770
+ }));
5771
+ function queryFn() {
5772
+ return _queryFn.apply(this, arguments);
5773
+ }
5774
+ return queryFn;
5775
+ }()
5776
+ });
5777
+ };
5778
+ var useLocationDetail = function useLocationDetail(id, source) {
5779
+ if (id === void 0) {
5780
+ id = '';
5781
+ }
5782
+ if (source === void 0) {
5783
+ source = '';
5784
+ }
5785
+ return useQuery({
5786
+ queryKey: ['location-detail', {
5787
+ id: id,
5788
+ source: source
5789
+ }],
5790
+ queryFn: function queryFn() {
5791
+ return getLocationDetail(id, source);
5792
+ },
5793
+ enabled: !!id
5794
+ });
5795
+ };
5796
+
5787
5797
  var SearchDialog = function SearchDialog(_ref) {
5788
5798
  var isOpen = _ref.isOpen,
5789
- onClose = _ref.onClose,
5790
5799
  _ref$mapId = _ref.mapId,
5791
- mapId = _ref$mapId === void 0 ? '' : _ref$mapId;
5800
+ mapId = _ref$mapId === void 0 ? '' : _ref$mapId,
5801
+ _ref$onSelectLocation = _ref.onSelectLocation,
5802
+ onSelectLocation = _ref$onSelectLocation === void 0 ? function () {} : _ref$onSelectLocation,
5803
+ _ref$onUpdateMyLocati = _ref.onUpdateMyLocation,
5804
+ onUpdateMyLocation = _ref$onUpdateMyLocati === void 0 ? function () {} : _ref$onUpdateMyLocati,
5805
+ _ref$isMyLocationSele = _ref.isMyLocationSelected,
5806
+ isMyLocationSelected = _ref$isMyLocationSele === void 0 ? false : _ref$isMyLocationSele;
5807
+ var theme = useTheme();
5792
5808
  var _useCoreTranslation = useCoreTranslation(),
5793
5809
  t = _useCoreTranslation.t;
5794
- var _useState = useState(false),
5795
- isLoading = _useState[0],
5796
- setIsLoading = _useState[1];
5797
- var _useState2 = useState(false),
5798
- hasFailed = _useState2[0],
5799
- setHasFailed = _useState2[1];
5800
- return isOpen && mapId ? jsxs(Box$1, {
5810
+ var _useState = useState(''),
5811
+ inputValue = _useState[0],
5812
+ setInputValue = _useState[1];
5813
+ var _useState2 = useState(null),
5814
+ selectedValue = _useState2[0],
5815
+ setSelectedValue = _useState2[1];
5816
+ var debouncedInputValue = useDebounce(inputValue, 300);
5817
+ var _useLocationList = useLocationList(debouncedInputValue),
5818
+ locationListData = _useLocationList.data;
5819
+ var _useLocationDetail = useLocationDetail(selectedValue == null ? void 0 : selectedValue.id, selectedValue == null ? void 0 : selectedValue.source),
5820
+ locationDetail = _useLocationDetail.data,
5821
+ isFetchingDetail = _useLocationDetail.isFetching;
5822
+ useEffect(function () {
5823
+ if (isFetchingDetail || !isOpen) {
5824
+ return;
5825
+ }
5826
+ onSelectLocation(selectedValue ? locationDetail : undefined);
5827
+ }, [locationDetail, onSelectLocation, selectedValue, isFetchingDetail, isOpen]);
5828
+ return isOpen && mapId ? jsxs(Box, {
5801
5829
  sx: {
5802
5830
  display: 'flex',
5803
5831
  flexDirection: 'row',
5804
5832
  alignItems: 'center',
5805
5833
  position: 'absolute',
5806
5834
  pointerEvents: 'all',
5807
- zIndex: 999,
5835
+ zIndex: 99,
5808
5836
  left: 50,
5809
- top: 15,
5810
- borderBottom: '1px solid grey',
5811
- backgroundColor: function backgroundColor(theme) {
5812
- return theme.palette.background.paper;
5813
- }
5837
+ top: 8,
5838
+ backgroundColor: theme.palette.geowebColors.textInputField["default"].fill,
5839
+ height: 40,
5840
+ boxShadow: theme.shadows[6],
5841
+ width: 'calc(100% - 50px)',
5842
+ maxWidth: 380
5814
5843
  },
5815
5844
  children: [jsx(MyMapLocation, {
5816
5845
  mapId: mapId,
5817
- isLoading: isLoading,
5818
- hasFailed: hasFailed,
5819
- setIsLoading: setIsLoading,
5820
- setHasFailed: setHasFailed
5821
- }), jsx(TextField, {
5822
- id: "dummy-search-field",
5823
- label: t('search-title'),
5824
- variant: "filled",
5825
- slotProps: {
5826
- input: {
5827
- disableUnderline: true,
5828
- endAdornment: jsx(InputAdornment, {
5829
- position: "end",
5830
- children: jsx(CustomIconButton, {
5831
- tooltipTitle: t('actions-close'),
5832
- edge: "end",
5833
- onClick: onClose,
5834
- size: "large",
5846
+ onUpdateMyLocation: onUpdateMyLocation,
5847
+ isSelected: isMyLocationSelected
5848
+ }), jsx(Autocomplete, {
5849
+ disablePortal: true,
5850
+ selectOnFocus: true,
5851
+ sx: {
5852
+ width: '100%',
5853
+ '&.MuiAutocomplete-root .MuiFilledInput-root': {
5854
+ height: 40,
5855
+ padding: '0px!important',
5856
+ '&:before, &:hover:before': {
5857
+ borderColor: 'transparent'
5858
+ }
5859
+ },
5860
+ '&.MuiAutocomplete-root .MuiInputLabel-root': {
5861
+ lineHeight: '16px',
5862
+ maxWidth: 'calc(100% - 40px)',
5863
+ ':not(.MuiInputLabel-shrink)': {
5864
+ transform: 'translate(12px, 12px) scale(1)'
5865
+ }
5866
+ },
5867
+ '&.MuiAutocomplete-root .MuiFilledInput-input': {
5868
+ lineHeight: '20px',
5869
+ paddingLeft: '12px',
5870
+ paddingTop: '20px'
5871
+ }
5872
+ },
5873
+ getOptionLabel: function getOptionLabel(option) {
5874
+ return option.name;
5875
+ },
5876
+ getOptionKey: function getOptionKey(option) {
5877
+ return option.id + option.name;
5878
+ },
5879
+ filterOptions: function filterOptions(x) {
5880
+ return x;
5881
+ },
5882
+ options: locationListData || [],
5883
+ noOptionsText: t('search-no-results'),
5884
+ popupIcon: null,
5885
+ clearIcon: null,
5886
+ onChange: function onChange(_event, newValue) {
5887
+ if (newValue && typeof newValue !== 'string') {
5888
+ setSelectedValue(newValue);
5889
+ setInputValue(newValue.name);
5890
+ }
5891
+ },
5892
+ value: selectedValue,
5893
+ inputValue: inputValue,
5894
+ isOptionEqualToValue: function isOptionEqualToValue(option, value) {
5895
+ return option.id === value.id;
5896
+ },
5897
+ renderInput: function renderInput(params) {
5898
+ return jsx(TextField, Object.assign({}, params, {
5899
+ autoFocus: true,
5900
+ size: "medium",
5901
+ label: t('search-title-long'),
5902
+ fullWidth: true,
5903
+ variant: "filled",
5904
+ onChange: function onChange(event) {
5905
+ setInputValue(event.target.value);
5906
+ if (selectedValue) {
5907
+ setSelectedValue(null);
5908
+ }
5909
+ },
5910
+ InputProps: Object.assign({}, params.InputProps, {
5911
+ endAdornment: jsx(CustomIconButton, {
5912
+ tooltipTitle: t('search-clear'),
5913
+ onClick: function onClick() {
5914
+ setInputValue('');
5915
+ setSelectedValue(null);
5916
+ },
5917
+ sx: {
5918
+ marginRight: 1
5919
+ },
5835
5920
  children: jsx(Close, {})
5836
5921
  })
5837
5922
  })
5838
- }
5923
+ }));
5839
5924
  }
5840
5925
  })]
5841
5926
  }) : null;
5842
5927
  };
5843
5928
 
5844
- var SearchControlConnect = function SearchControlConnect(_ref) {
5845
- var mapId = _ref.mapId;
5929
+ /* *
5930
+ * Licensed under the Apache License, Version 2.0 (the "License");
5931
+ * you may not use this file except in compliance with the License.
5932
+ * You may obtain a copy of the License at
5933
+ *
5934
+ * http://www.apache.org/licenses/LICENSE-2.0
5935
+ *
5936
+ * Unless required by applicable law or agreed to in writing, software
5937
+ * distributed under the License is distributed on an "AS IS" BASIS,
5938
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5939
+ * See the License for the specific language governing permissions and
5940
+ * limitations under the License.
5941
+ *
5942
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5943
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
5944
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
5945
+ * */
5946
+ var myLocationDrawFunction = function myLocationDrawFunction(args) {
5947
+ var ctx = args.context,
5948
+ coord = args.coord;
5949
+ // Draw outer circle
5950
+ ctx.strokeStyle = '#fff';
5951
+ ctx.fillStyle = '#fff';
5952
+ ctx.shadowColor = '#00000080';
5953
+ ctx.shadowBlur = 4;
5954
+ ctx.beginPath();
5955
+ ctx.arc(coord.x, coord.y, 14, 0, 2 * Math.PI);
5956
+ ctx.fill();
5957
+ ctx.shadowBlur = 0;
5958
+ // Draw inner circle
5959
+ ctx.fillStyle = '#186dff';
5960
+ ctx.beginPath();
5961
+ ctx.arc(coord.x, coord.y, 10, 0, 2 * Math.PI);
5962
+ ctx.fill();
5963
+ };
5964
+ var selectedLocationDrawFunction = function selectedLocationDrawFunction(args) {
5965
+ var ctx = args.context,
5966
+ coord = args.coord;
5967
+ ctx.strokeStyle = '#051039';
5968
+ ctx.fillStyle = '#051039';
5969
+ ctx.beginPath();
5970
+ var topRadius = 7;
5971
+ var topHeight = 2 * topRadius;
5972
+ ctx.arc(coord.x, coord.y - topHeight, topRadius, Math.PI, Math.PI * 2);
5973
+ ctx.bezierCurveTo(coord.x + topRadius, coord.y - topHeight, coord.x + topRadius / 1.6, coord.y - topRadius, coord.x, coord.y);
5974
+ ctx.bezierCurveTo(coord.x, coord.y, coord.x - topRadius / 1.6, coord.y - topRadius, coord.x - topRadius, coord.y - topHeight);
5975
+ ctx.stroke();
5976
+ ctx.fill();
5977
+ /* Fill center circle */
5978
+ ctx.fillStyle = '#FFF';
5979
+ ctx.beginPath();
5980
+ ctx.arc(coord.x, coord.y - topHeight, topRadius / 2.5, Math.PI * 2, 0);
5981
+ ctx.fill();
5982
+ };
5983
+ var geometryStyling = {
5984
+ fill: '#FF7800',
5985
+ 'fill-opacity': 0.25,
5986
+ stroke: '#FF7800',
5987
+ 'stroke-opacity': 1,
5988
+ 'stroke-width': 4
5989
+ };
5990
+ var makeGeoJSONFeatureFromLocation = function makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId) {
5991
+ var _location$geometry;
5992
+ var collection = {
5993
+ type: 'FeatureCollection',
5994
+ features: []
5995
+ };
5996
+ var geometry = Object.assign({}, location.geometry, {
5997
+ properties: Object.assign({}, geometryStyling, {
5998
+ name: location.name,
5999
+ hoverDrawFunctionId: hoverDrawFunctionId
6000
+ })
6001
+ });
6002
+ var marker = {
6003
+ type: 'Feature',
6004
+ properties: {
6005
+ name: location.name,
6006
+ drawFunctionId: drawFunctionId,
6007
+ hoverDrawFunctionId: hoverDrawFunctionId
6008
+ },
6009
+ geometry: {
6010
+ type: 'Point',
6011
+ coordinates: [location.lon, location.lat]
6012
+ }
6013
+ };
6014
+ switch ((_location$geometry = location.geometry) == null ? void 0 : _location$geometry.geometry.type) {
6015
+ case 'Point':
6016
+ case 'MultiLineString':
6017
+ case undefined:
6018
+ collection.features.push(marker);
6019
+ break;
6020
+ default:
6021
+ collection.features.push(geometry);
6022
+ }
6023
+ return collection;
6024
+ };
6025
+ var fitText = function fitText(ctx, text, x, y, lineheight) {
6026
+ var lines = text.split('\n');
6027
+ for (var i = 0; i < lines.length; i += 1) {
6028
+ ctx.fillText(lines[i], x, y + i * lineheight);
6029
+ }
6030
+ };
6031
+ var roundRect = function roundRect(ctx, w, h, x, y, radius) {
6032
+ if (radius === void 0) {
6033
+ radius = 2;
6034
+ }
6035
+ var r = x + w;
6036
+ var b = y + h;
6037
+ ctx.beginPath();
6038
+ ctx.moveTo(x + radius, y);
6039
+ ctx.lineTo(r - radius, y);
6040
+ ctx.quadraticCurveTo(r, y, r, y + radius);
6041
+ ctx.lineTo(r, y + h - radius);
6042
+ ctx.quadraticCurveTo(r, b, r - radius, b);
6043
+ ctx.lineTo(x + radius, b);
6044
+ ctx.quadraticCurveTo(x, b, x, b - radius);
6045
+ ctx.lineTo(x, y + radius);
6046
+ ctx.quadraticCurveTo(x, y, x + radius, y);
6047
+ ctx.stroke();
6048
+ ctx.fill();
6049
+ };
6050
+ var hoverDrawFunction = function hoverDrawFunction(args) {
6051
+ var ctx = args.context,
6052
+ coord = args.coord,
6053
+ feature = args.feature;
6054
+ var fontSize = 16;
6055
+ var padding = 20;
6056
+ // eslint-disable-next-line no-param-reassign
6057
+ ctx.font = fontSize + "px Roboto";
6058
+ var x = coord.x,
6059
+ y = coord.y;
6060
+ ctx.strokeStyle = '#000';
6061
+ ctx.fillStyle = '#000';
6062
+ roundRect(ctx, ctx.measureText(feature.properties.name).width + padding, fontSize + padding, x - padding * 0.5 - ctx.measureText(feature.properties.name).width * 0.5, y + padding);
6063
+ // eslint-disable-next-line no-param-reassign
6064
+ ctx.fillStyle = '#FFF';
6065
+ // eslint-disable-next-line no-param-reassign
6066
+ ctx.textAlign = 'left';
6067
+ if (feature && feature.properties) {
6068
+ fitText(ctx, feature.properties.name, x - ctx.measureText(feature.properties.name).width * 0.5, y + padding * 2, fontSize);
6069
+ }
6070
+ };
6071
+ var useDrawOnMap = function useDrawOnMap(mapId, drawFunction) {
6072
+ var dispatch = useDispatch();
6073
+ var layerId = React__default.useRef(generateLayerId()).current;
6074
+ var isMapPresent = useSelector(function (store) {
6075
+ return mapSelectors.getIsMapPresent(store, mapId);
6076
+ });
6077
+ var isLayerPresent = useSelector(function (store) {
6078
+ return layerSelectors.getIsLayerPresent(store, layerId);
6079
+ });
6080
+ var shouldAddLayer = isMapPresent && !isLayerPresent;
6081
+ React__default.useEffect(function () {
6082
+ if (shouldAddLayer) {
6083
+ dispatch(layerActions.addLayer({
6084
+ mapId: mapId,
6085
+ layerId: layerId,
6086
+ layer: {
6087
+ geojson: emptyGeoJSON,
6088
+ layerType: LayerType.featureLayer
6089
+ },
6090
+ origin: 'SearchDialogConnect'
6091
+ }));
6092
+ }
6093
+ }, [dispatch, layerId, mapId, shouldAddLayer]);
6094
+ var drawFunctionId = React__default.useRef(registerDrawFunction(drawFunction)).current;
6095
+ var hoverDrawFunctionId = React__default.useRef(registerDrawFunction(hoverDrawFunction)).current;
6096
+ var updateGeoJSON = React__default.useCallback(function (location) {
6097
+ var geojson = location ? makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId) : emptyGeoJSON;
6098
+ dispatch(layerActions.updateFeature({
6099
+ layerId: layerId,
6100
+ geojson: geojson
6101
+ }));
6102
+ }, [dispatch, drawFunctionId, hoverDrawFunctionId, layerId]);
6103
+ var zoomToFeature = React__default.useCallback(function (location) {
6104
+ var webMap = getWMJSMapById(mapId);
6105
+ if (webMap) {
6106
+ webMap.calculateBoundingBoxAndZoom(location.lat, location.lon);
6107
+ }
6108
+ }, [mapId]);
6109
+ var onUpdateLocation = React__default.useCallback(function (location) {
6110
+ updateGeoJSON(location);
6111
+ if (location) {
6112
+ zoomToFeature(location);
6113
+ }
6114
+ }, [updateGeoJSON, zoomToFeature]);
6115
+ return [onUpdateLocation];
6116
+ };
6117
+
6118
+ var SearchDialogConnect = function SearchDialogConnect(_ref) {
6119
+ var _ref$mapId = _ref.mapId,
6120
+ mapId = _ref$mapId === void 0 ? '' : _ref$mapId;
5846
6121
  var dialogType = uiTypes.DialogTypes.Search + "-" + mapId;
5847
6122
  var _useSetupDialog = useSetupDialog(dialogType),
5848
- isDialogOpen = _useSetupDialog.isDialogOpen,
5849
- onCloseDialog = _useSetupDialog.onCloseDialog;
6123
+ isDialogOpen = _useSetupDialog.isDialogOpen;
6124
+ var _useDrawOnMap = useDrawOnMap(mapId, selectedLocationDrawFunction),
6125
+ updateMapPin = _useDrawOnMap[0];
6126
+ var _useDrawOnMap2 = useDrawOnMap(mapId, myLocationDrawFunction),
6127
+ updateMyLocation = _useDrawOnMap2[0];
6128
+ var mapLayers = useSelector(function (store) {
6129
+ return layerSelectors.getLayersByMapId(store, mapId);
6130
+ });
6131
+ var myLocationLayer = mapLayers.find(function (layer) {
6132
+ var _layer$geojson;
6133
+ if ((_layer$geojson = layer.geojson) != null && (_layer$geojson = _layer$geojson.features[0]) != null && (_layer$geojson = _layer$geojson.properties) != null && _layer$geojson.name) {
6134
+ if (layer.geojson.features[0].properties.name === MY_LOCATION) {
6135
+ return true;
6136
+ }
6137
+ }
6138
+ return false;
6139
+ });
6140
+ var isMyLocationSelected = !!myLocationLayer;
5850
6141
  return jsx(SearchDialog, {
5851
6142
  isOpen: isDialogOpen,
5852
- onClose: onCloseDialog,
5853
- mapId: mapId
6143
+ mapId: mapId,
6144
+ onSelectLocation: updateMapPin,
6145
+ onUpdateMyLocation: updateMyLocation,
6146
+ isMyLocationSelected: isMyLocationSelected
5854
6147
  });
5855
6148
  };
5856
6149
 
@@ -6477,26 +6770,26 @@ var MapViewConnect = function MapViewConnect(_ref) {
6477
6770
  var geojson = _ref2.geojson,
6478
6771
  reason = _ref2.reason,
6479
6772
  layerId = _ref2.layerId;
6480
- var activeDrawToolId = drawtoolSelectors.getActiveDrawToolId(store.getState());
6481
- var activeDrawMode = drawtoolSelectors.getActiveDrawMode(store.getState(), activeDrawToolId);
6773
+ var activeDrawToolId = drawingToolSelectors.getActiveDrawToolId(store.getState());
6774
+ var activeDrawMode = drawingToolSelectors.getActiveDrawMode(store.getState(), activeDrawToolId);
6482
6775
  dispatch(layerActions.updateFeature({
6483
6776
  geojson: geojson,
6484
6777
  reason: reason,
6485
6778
  layerId: layerId,
6486
- shouldAllowMultipleShapes: drawtoolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId),
6487
- geoJSONIntersectionLayerId: drawtoolSelectors.getGeoJSONIntersectionLayerId(store.getState(), activeDrawToolId),
6488
- geoJSONIntersectionBoundsLayerId: drawtoolSelectors.getGeoJSONIntersectionBoundsLayerId(store.getState(), activeDrawToolId),
6779
+ shouldAllowMultipleShapes: drawingToolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId),
6780
+ geoJSONIntersectionLayerId: drawingToolSelectors.getGeoJSONIntersectionLayerId(store.getState(), activeDrawToolId),
6781
+ geoJSONIntersectionBoundsLayerId: drawingToolSelectors.getGeoJSONIntersectionBoundsLayerId(store.getState(), activeDrawToolId),
6489
6782
  selectionType: activeDrawMode == null ? void 0 : activeDrawMode.selectionType
6490
6783
  }));
6491
6784
  }, [dispatch, store]);
6492
6785
  var exitFeatureDrawMode = React.useCallback(function (_ref3) {
6493
6786
  var reason = _ref3.reason,
6494
6787
  layerId = _ref3.layerId;
6495
- var activeDrawToolId = drawtoolSelectors.getActiveDrawToolId(store.getState());
6788
+ var activeDrawToolId = drawingToolSelectors.getActiveDrawToolId(store.getState());
6496
6789
  dispatch(layerActions.exitFeatureDrawMode({
6497
6790
  reason: reason,
6498
6791
  layerId: layerId,
6499
- shouldAllowMultipleShapes: drawtoolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId)
6792
+ shouldAllowMultipleShapes: drawingToolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId)
6500
6793
  }));
6501
6794
  }, [dispatch, store]);
6502
6795
  var isActiveWindowId = useSelector(function (store) {
@@ -6631,7 +6924,7 @@ var MapViewConnect = function MapViewConnect(_ref) {
6631
6924
  onLayerError: function onLayerError(_, error) {
6632
6925
  layerError({
6633
6926
  layerId: layer.id,
6634
- error: Error("" + error)
6927
+ error: (error == null ? void 0 : error.message) || 'unknown error'
6635
6928
  });
6636
6929
  }
6637
6930
  }, layer), layer.id);
@@ -6641,7 +6934,7 @@ var MapViewConnect = function MapViewConnect(_ref) {
6641
6934
  onLayerError: function onLayerError(_, error) {
6642
6935
  layerError({
6643
6936
  layerId: layer.id,
6644
- error: Error("" + error)
6937
+ error: (error == null ? void 0 : error.message) || 'unknown error'
6645
6938
  });
6646
6939
  }
6647
6940
  }, layer), layer.id);
@@ -6685,7 +6978,7 @@ var MapViewConnect = function MapViewConnect(_ref) {
6685
6978
  onLayerError: function onLayerError(_, error) {
6686
6979
  layerError({
6687
6980
  layerId: layer.id,
6688
- error: Error("" + error)
6981
+ error: (error == null ? void 0 : error.message) || 'unknown error'
6689
6982
  });
6690
6983
  },
6691
6984
  onClickFeature: function onClickFeature(event) {
@@ -6724,7 +7017,7 @@ var MapViewConnect = function MapViewConnect(_ref) {
6724
7017
  onLayerError: function onLayerError(_, error) {
6725
7018
  layerError({
6726
7019
  layerId: layer.id,
6727
- error: Error("" + error)
7020
+ error: (error == null ? void 0 : error.message) || 'unknown error'
6728
7021
  });
6729
7022
  }
6730
7023
  }, layer), layer.id);
@@ -6754,7 +7047,7 @@ var MapViewConnect = function MapViewConnect(_ref) {
6754
7047
  showMapId: true,
6755
7048
  mapId: mapId,
6756
7049
  multiLegend: controls == null ? void 0 : controls.multiLegend
6757
- }), jsx(SearchControlConnect, {
7050
+ }), (controls == null ? void 0 : controls.search) && jsx(SearchDialogConnect, {
6758
7051
  mapId: mapId
6759
7052
  }), (controls == null ? void 0 : controls.getFeatureInfo) && jsx(GetFeatureInfoConnect, {
6760
7053
  showMapId: true,
@@ -6981,7 +7274,8 @@ var TimeSpanButtonConnect = function TimeSpanButtonConnect(_ref) {
6981
7274
  }));
6982
7275
  dispatch(mapActions.setTimeSliderSpan({
6983
7276
  mapId: mapId,
6984
- timeSliderSpan: spanInSeconds
7277
+ timeSliderSpan: spanInSeconds,
7278
+ origin: mapEnums.MapActionOrigin.map
6985
7279
  }));
6986
7280
  dispatch(mapActions.setTimeSliderCenterTime({
6987
7281
  mapId: mapId,
@@ -7258,7 +7552,8 @@ var TimeSliderLegendConnect = function TimeSliderLegendConnect(_ref) {
7258
7552
  onSetTimeSliderSpan = _ref.onSetTimeSliderSpan,
7259
7553
  unfilteredSelectedTime = _ref.unfilteredSelectedTime,
7260
7554
  setUnfilteredSelectedTime = _ref.setUnfilteredSelectedTime,
7261
- mapWindowRef = _ref.mapWindowRef;
7555
+ mapWindowRef = _ref.mapWindowRef,
7556
+ adjustSelectedTimeOnWheel = _ref.adjustSelectedTimeOnWheel;
7262
7557
  var isTimeScrollingEnabled = useSelector(syncGroupsSelectors.isTimeScrollingEnabled);
7263
7558
  var centerTime = useSelector(function (store) {
7264
7559
  return mapSelectors.getMapTimeSliderCenterTime(store, mapId);
@@ -7390,7 +7685,8 @@ var TimeSliderLegendConnect = function TimeSliderLegendConnect(_ref) {
7390
7685
  }));
7391
7686
  }
7392
7687
  }
7393
- }
7688
+ },
7689
+ adjustSelectedTimeOnWheel: adjustSelectedTimeOnWheel
7394
7690
  });
7395
7691
  };
7396
7692
 
@@ -7450,10 +7746,7 @@ var useUpdateTimeSpan = function useUpdateTimeSpan(mapId, myOnSetTimeSliderSpan)
7450
7746
  }
7451
7747
  };
7452
7748
  React.useEffect(function () {
7453
- if (!activeLayerTimeDimension) {
7454
- return;
7455
- }
7456
- if (isTimeSpanAuto && autoTimeStepLayerId) {
7749
+ if (isTimeSpanAuto && autoTimeStepLayerId && activeLayerTimeDimension) {
7457
7750
  var _getTimeBounds = getTimeBounds([activeLayerTimeDimension]),
7458
7751
  startTime = _getTimeBounds.startTime,
7459
7752
  endTime = _getTimeBounds.endTime;
@@ -7468,7 +7761,7 @@ var useUpdateTimeSpan = function useUpdateTimeSpan(mapId, myOnSetTimeSliderSpan)
7468
7761
  updateTimeSliderSpan(_spanInSeconds, _newCenterTime, _newSecondsPerPx);
7469
7762
  }
7470
7763
  // eslint-disable-next-line react-hooks/exhaustive-deps
7471
- }, [autoTimeStepLayerId, isTimeSpanAuto, activeLayerTimeDimension, mapId]);
7764
+ }, [autoTimeStepLayerId, isTimeSpanAuto, mapId]);
7472
7765
  };
7473
7766
  var timeToIso = function timeToIso(selectedTime) {
7474
7767
  return handleDateUtilsISOString(dateUtils.fromUnix(selectedTime).toISOString());
@@ -7549,9 +7842,6 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7549
7842
  });
7550
7843
  useUpdateTimestep(mapId);
7551
7844
  useUpdateTimeSpan(mapId, onSetTimeSliderSpan);
7552
- var makeFilteredSelectedTime = function makeFilteredSelectedTime(timeValue) {
7553
- return getFilteredTime(timeValue, timeStep, dataStartTime, dataEndTime);
7554
- };
7555
7845
  // Local state for unfiltered selected time
7556
7846
  var _React$useState = React.useState(selectedTime),
7557
7847
  unfilteredSelectedTime = _React$useState[0],
@@ -7559,7 +7849,7 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7559
7849
  // Reference to the last time value set by this timeslider
7560
7850
  var lastTimeValueAsSetByThisTimeSlider = React.useRef();
7561
7851
  // Set new time in the redux state
7562
- var _onSetNewDate = function onSetNewDate(newDate) {
7852
+ var _onSetNewDate = React.useCallback(function (newDate) {
7563
7853
  // Remember that this timeslider has set this time
7564
7854
  lastTimeValueAsSetByThisTimeSlider.current = newDate;
7565
7855
  if (isAnimating) {
@@ -7572,7 +7862,7 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7572
7862
  origin: 'TimeSliderConnect',
7573
7863
  value: handleDateUtilsISOString(newDate)
7574
7864
  }));
7575
- };
7865
+ }, [dispatch, isAnimating, mapId, sourceId]);
7576
7866
  // Update local state when time is updated outside of this component, e.g. during animation or syncgroups
7577
7867
  React.useEffect(function () {
7578
7868
  var selectedTimeAsIsoString = timeToIso(selectedTime);
@@ -7581,13 +7871,16 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7581
7871
  }
7582
7872
  }, [selectedTime]);
7583
7873
  // Function used by timeslider components to update the unfiltered selected time
7584
- var setUnfilteredSelectedTime = function setUnfilteredSelectedTime(unfilteredSelectedTimeFromComponents) {
7874
+ var setUnfilteredSelectedTime = React.useCallback(function (unfilteredSelectedTimeFromComponents) {
7875
+ var makeFilteredSelectedTime = function makeFilteredSelectedTime(timeValue) {
7876
+ return getFilteredTime(timeValue, timeStep, dataStartTime, dataEndTime);
7877
+ };
7585
7878
  setUnfilteredSelectedTimeViaState(unfilteredSelectedTimeFromComponents);
7586
7879
  var filteredIsoTime = makeFilteredSelectedTime(unfilteredSelectedTimeFromComponents);
7587
7880
  if (selectedTime !== filteredIsoTime) {
7588
7881
  onsetNewDateDebounced(timeToIso(filteredIsoTime), _onSetNewDate);
7589
7882
  }
7590
- };
7883
+ }, [dataEndTime, dataStartTime, _onSetNewDate, selectedTime, timeStep]);
7591
7884
  // Move animation bar when user changes time using time picker
7592
7885
  // Animation bar however cannot be moved into a time where there is no data
7593
7886
  var moveAnimationUsingCalendar = function moveAnimationUsingCalendar(newTime) {
@@ -7613,6 +7906,40 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7613
7906
  setUnfilteredSelectedTime(newSelectedTime);
7614
7907
  moveAnimationUsingCalendar(newSelectedTime);
7615
7908
  };
7909
+ var secondsPerPx = useSelector(function (store) {
7910
+ return mapSelectors.getMapTimeSliderSecondsPerPx(store, mapId);
7911
+ }) || defaultSecondsPerPx;
7912
+ var timeSliderWidth = useSelector(function (store) {
7913
+ return mapSelectors.getMapTimeSliderWidth(store, mapId);
7914
+ }) || 0;
7915
+ var centerTime = useSelector(function (store) {
7916
+ return mapSelectors.getMapTimeSliderCenterTime(store, mapId);
7917
+ });
7918
+ var isTimeScrollingEnabled = useSelector(syncGroupsSelectors.isTimeScrollingEnabled);
7919
+ var adjustSelectedTimeOnWheel = React.useCallback(function (_ref2) {
7920
+ var event = _ref2.event,
7921
+ deltaY = _ref2.deltaY;
7922
+ if (!(event.ctrlKey || event.metaKey || event.shiftKey || event.altKey)) {
7923
+ var pixelsPerScroll = -deltaY * timeStep / (2 * secondsPerPx);
7924
+ moveSelectedTimePx(pixelsPerScroll, timeSliderWidth, centerTime, dataStartTime, dataEndTime, secondsPerPx, timeStep, unfilteredSelectedTime, setUnfilteredSelectedTime);
7925
+ }
7926
+ }, [timeSliderWidth, centerTime, dataEndTime, dataStartTime, secondsPerPx, setUnfilteredSelectedTime, timeStep, unfilteredSelectedTime]);
7927
+ React.useEffect(function () {
7928
+ if (isTimeScrollingEnabled && mapWindowRef != null && mapWindowRef.current) {
7929
+ var handleWheel = function handleWheel(event) {
7930
+ adjustSelectedTimeOnWheel({
7931
+ event: event,
7932
+ deltaY: event.deltaY
7933
+ });
7934
+ };
7935
+ var element = mapWindowRef.current;
7936
+ element.addEventListener('wheel', handleWheel);
7937
+ return function () {
7938
+ element.removeEventListener('wheel', handleWheel);
7939
+ };
7940
+ }
7941
+ return undefined;
7942
+ }, [isTimeScrollingEnabled, mapWindowRef, adjustSelectedTimeOnWheel]);
7616
7943
  return jsx(TimeSlider, {
7617
7944
  timeStep: timeStep,
7618
7945
  dataStartTime: dataStartTime,
@@ -7642,7 +7969,8 @@ var TimeSliderConnect = function TimeSliderConnect(_ref) {
7642
7969
  onSetTimeSliderSpan: onSetTimeSliderSpan,
7643
7970
  unfilteredSelectedTime: unfilteredSelectedTime,
7644
7971
  setUnfilteredSelectedTime: setUnfilteredSelectedTime,
7645
- mapWindowRef: mapWindowRef
7972
+ mapWindowRef: mapWindowRef,
7973
+ adjustSelectedTimeOnWheel: adjustSelectedTimeOnWheel
7646
7974
  }),
7647
7975
  mapIsActive: mapIsActive,
7648
7976
  onToggleTimeSlider: onToggleTimeSliderVisibility,
@@ -8138,6 +8466,9 @@ var useGetReferenceTimes = function useGetReferenceTimes(inputLayer) {
8138
8466
  var _React$useState = React.useState([]),
8139
8467
  referenceTimes = _React$useState[0],
8140
8468
  setReferenceTimes = _React$useState[1];
8469
+ var _React$useState2 = React.useState(null),
8470
+ error = _React$useState2[0],
8471
+ setError = _React$useState2[1];
8141
8472
  React.useEffect(function () {
8142
8473
  var referenceTimes = [];
8143
8474
  var wmLayer = new WMLayer(Object.assign({}, inputLayer));
@@ -8150,9 +8481,14 @@ var useGetReferenceTimes = function useGetReferenceTimes(inputLayer) {
8150
8481
  referenceTimes.push(referenceTimeValue);
8151
8482
  }
8152
8483
  setReferenceTimes(referenceTimes);
8153
- })["catch"](console.error);
8484
+ })["catch"](function (error) {
8485
+ setError(error);
8486
+ });
8154
8487
  }, [inputLayer]);
8155
- return referenceTimes;
8488
+ return {
8489
+ referenceTimes: referenceTimes,
8490
+ error: error
8491
+ };
8156
8492
  };
8157
8493
  var HarmonieTempAndPrecipPreset = function HarmonieTempAndPrecipPreset(_ref) {
8158
8494
  var layers = _ref.layers,
@@ -8161,7 +8497,14 @@ var HarmonieTempAndPrecipPreset = function HarmonieTempAndPrecipPreset(_ref) {
8161
8497
  var displayLayerManagerAndLegendButtonInAllTopRows = !useHasSyncGroupWithLayerActions(layers && layers.topRowSyncGroups);
8162
8498
  var displayLayerManagerAndLegendButtonInAllBottomRows = !useHasSyncGroupWithLayerActions(layers && layers.bottomRowSyncGroups);
8163
8499
  /* Get all the reference times for this layer */
8164
- var referenceTimes = useGetReferenceTimes(layers.topRow);
8500
+ var _useGetReferenceTimes = useGetReferenceTimes(layers.topRow),
8501
+ referenceTimes = _useGetReferenceTimes.referenceTimes,
8502
+ error = _useGetReferenceTimes.error;
8503
+ if (error) {
8504
+ return jsx(AlertBanner, {
8505
+ title: error.message
8506
+ });
8507
+ }
8165
8508
  if (referenceTimes.length === 0) {
8166
8509
  return jsx("div", {
8167
8510
  children: "Loading..."
@@ -8756,17 +9099,19 @@ var CoreThemeProvider = function CoreThemeProvider(_ref) {
8756
9099
  var children = _ref.children,
8757
9100
  _ref$theme = _ref.theme,
8758
9101
  theme = _ref$theme === void 0 ? lightTheme : _ref$theme;
8759
- return jsx(ThemeWrapper, {
8760
- theme: theme,
8761
- children: children
9102
+ var queryClient = new QueryClient({
9103
+ defaultOptions: {
9104
+ queries: {
9105
+ retry: false
9106
+ }
9107
+ }
8762
9108
  });
8763
- };
8764
- var ThemeWrapperWithModules = function ThemeWrapperWithModules(_ref2) {
8765
- var theme = _ref2.theme,
8766
- children = _ref2.children;
8767
- return jsx(CoreThemeProvider, {
9109
+ return jsx(ThemeWrapper, {
8768
9110
  theme: theme,
8769
- children: children
9111
+ children: jsx(QueryClientProvider, {
9112
+ client: queryClient,
9113
+ children: children
9114
+ })
8770
9115
  });
8771
9116
  };
8772
9117
  /**
@@ -8775,14 +9120,14 @@ var ThemeWrapperWithModules = function ThemeWrapperWithModules(_ref2) {
8775
9120
  * @param children
8776
9121
  * @returns
8777
9122
  */
8778
- var CoreThemeStoreProvider = function CoreThemeStoreProvider(_ref3) {
8779
- var children = _ref3.children,
8780
- _ref3$theme = _ref3.theme,
8781
- theme = _ref3$theme === void 0 ? lightTheme : _ref3$theme,
8782
- store = _ref3.store;
9123
+ var CoreThemeStoreProvider = function CoreThemeStoreProvider(_ref2) {
9124
+ var children = _ref2.children,
9125
+ _ref2$theme = _ref2.theme,
9126
+ theme = _ref2$theme === void 0 ? lightTheme : _ref2$theme,
9127
+ store = _ref2.store;
8783
9128
  return jsx(Provider, {
8784
9129
  store: store,
8785
- children: jsx(ThemeWrapperWithModules, {
9130
+ children: jsx(CoreThemeProvider, {
8786
9131
  theme: theme,
8787
9132
  children: jsx(SnackbarWrapperConnect, {
8788
9133
  children: children
@@ -8790,8 +9135,8 @@ var CoreThemeStoreProvider = function CoreThemeStoreProvider(_ref3) {
8790
9135
  })
8791
9136
  });
8792
9137
  };
8793
- var CoreI18nProvider = function CoreI18nProvider(_ref4) {
8794
- var children = _ref4.children;
9138
+ var CoreI18nProvider = function CoreI18nProvider(_ref3) {
9139
+ var children = _ref3.children;
8795
9140
  initCoreReactI18n();
8796
9141
  return jsx(I18nextProvider, {
8797
9142
  i18n: i18n,
@@ -9017,4 +9362,4 @@ var LanguageSelect = function LanguageSelect(_ref) {
9017
9362
  });
9018
9363
  };
9019
9364
 
9020
- export { CORE_NAMESPACE, ConfigurableMapConnect, CoreI18nProvider, CoreThemeProvider, CoreThemeStoreProvider, DemoWrapper, DemoWrapperConnect, HarmonieTempAndPrecipPreset, LanguageSelect, LayerInfoButtonConnect, LayerInfoDialogConnect, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, MyMapLocation, RouterWrapperConnect, SearchControlButtonConnect, SearchControlConnect, SearchDialog, SentryRecordButton, SyncGroupViewerConnect, ThemeWrapperWithModules, TimeSliderConnect, ZoomControlConnect, componentsLookUp, coreTranslations, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, filterTimeSeriesServices, getLanguageFromLocalStorage, languageLocalStorageKey, saveLanguageToLocalStorage, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };
9365
+ export { CORE_NAMESPACE, ConfigurableMapConnect, CoreI18nProvider, CoreThemeProvider, CoreThemeStoreProvider, DemoWrapper, DemoWrapperConnect, HarmonieTempAndPrecipPreset, LanguageSelect, LayerInfoButtonConnect, LayerInfoDialogConnect, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, MyMapLocation, RouterWrapperConnect, SearchControlButtonConnect, SearchDialog, SearchDialogConnect, SentryRecordButton, SyncGroupViewerConnect, TimeSliderConnect, ZoomControlConnect, componentsLookUp, coreTranslations, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, filterTimeSeriesServices, getLanguageFromLocalStorage, languageLocalStorageKey, saveLanguageToLocalStorage, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };