@opengeoweb/core 9.32.0 → 9.33.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/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import { Grid2, Box, MenuItem, Typography, useTheme, Popper, Fade, Tooltip, styl
5
5
  import { SHARED_NAMESPACE, sharedTranslations, CustomIconButton, TooltipSelect, AlertIcon, sliderHeaderStyle, CustomSlider, ToggleMenu, CustomTooltip, tooltipContainerStyles, renderCounter, AlertBanner, CustomAccordion, PROJECTION, calculateStartSize, ToolContainerDraggable, useDebounce, dateUtils, withEggs, ErrorBoundary } from '@opengeoweb/shared';
6
6
  import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, LayersAdd, CloudLoading, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Add, MapAdd, WorldMapProjection, Layers, ExitDomain, Info, Search, Exclamation, MyLocation, Close, ThemeWrapper, lightTheme, FlagBritain, FlagNetherlands, FlagFinland, FlagNorway } from '@opengeoweb/theme';
7
7
  import i18n from 'i18next';
8
- import { useTranslation, initReactI18next, I18nextProvider } from 'react-i18next';
8
+ import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
9
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
10
  import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations, WEBMAP_NAMESPACE, webmapTranslations, LayerInfoButton, LayerInfoDialog, MapControlButton, MapDimensionSelect, dimensionConfig, DimensionSelectDialog, DimensionSelectButton, ZoomControls, MapView, MapViewLayer, LegendDialog, LegendButton, registerDrawFunction, emptyGeoJSON, MapControls, publicLayers } from '@opengeoweb/webmap-react';
11
11
  import { useDispatch, useSelector, connect, useStore, Provider } from 'react-redux';
@@ -17,7 +17,7 @@ import { Box as Box$1, styled as styled$1 } from '@mui/system';
17
17
  import _, { isEqual, range } from 'lodash';
18
18
  import { LayerSelectButtonConnect, LayerSelectConnect, layerSelectConfig } from '@opengeoweb/layer-select';
19
19
  import axios from 'axios';
20
- import * as DOMPurify from 'dompurify';
20
+ import DOMPurify from 'dompurify';
21
21
  import { SnackbarWrapperConnect } from '@opengeoweb/snackbar';
22
22
  import { useNavigate } from 'react-router-dom';
23
23
  import * as Sentry from '@sentry/react';
@@ -8683,11 +8683,31 @@ const TOUCH_PAN_STEP_PERCENTAGE = 0.02;
8683
8683
  * See the License for the specific language governing permissions and
8684
8684
  * limitations under the License.
8685
8685
  *
8686
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8687
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
8686
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8687
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
8688
8688
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
8689
8689
  * */
8690
- const useKeyboardZoomAndPan = (mapIsActive, mapId) => {
8690
+ const isDialogOpen = mapRef => {
8691
+ const backdrops = Array.from(document.querySelectorAll('.MuiBackdrop-root'));
8692
+ return backdrops.find(backdropNode => {
8693
+ var _backdropNode$parentE;
8694
+ return (_backdropNode$parentE = backdropNode.parentElement) == null ? void 0 : _backdropNode$parentE.contains(mapRef);
8695
+ }) !== undefined;
8696
+ };
8697
+ const isMapKeyboardControlsAllowed = (target, mapRef) => {
8698
+ if (isDialogOpen(mapRef)) {
8699
+ return false;
8700
+ }
8701
+ if (target.tagName !== 'BODY') {
8702
+ if (target.tagName === 'BUTTON') {
8703
+ // return true for element is active but not focus visible to the user
8704
+ return !target.classList.contains('Mui-focusVisible');
8705
+ }
8706
+ return false;
8707
+ }
8708
+ return true;
8709
+ };
8710
+ const useKeyboardZoomAndPan = (mapIsActive, mapId, mapRef) => {
8691
8711
  React.useEffect(() => {
8692
8712
  const keysPressedDown = {};
8693
8713
  const handleKeyPress = event => {
@@ -8698,7 +8718,7 @@ const useKeyboardZoomAndPan = (mapIsActive, mapId) => {
8698
8718
  type
8699
8719
  } = event;
8700
8720
  keysPressedDown[key] = type === 'keydown';
8701
- if (map && target.tagName !== 'INPUT' && mapIsActive) {
8721
+ if (map && mapIsActive && isMapKeyboardControlsAllowed(target, mapRef)) {
8702
8722
  if (keysPressedDown['+']) {
8703
8723
  map.zoomIn(1);
8704
8724
  } else if (keysPressedDown['-']) {
@@ -8734,7 +8754,7 @@ const useKeyboardZoomAndPan = (mapIsActive, mapId) => {
8734
8754
  document.removeEventListener('keydown', handleKeyPress);
8735
8755
  document.removeEventListener('keyup', handleKeyPress);
8736
8756
  };
8737
- }, [mapIsActive, mapId]);
8757
+ }, [mapIsActive, mapId, mapRef]);
8738
8758
  };
8739
8759
  const PAN_STEP_PERCENTAGE = 0.02;
8740
8760
 
@@ -8758,6 +8778,7 @@ const MapViewConnect = _ref => {
8758
8778
  children
8759
8779
  } = _ref,
8760
8780
  props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
8781
+ const mapRef = React.useRef(null);
8761
8782
  const store = useStore();
8762
8783
  const mapDimensions = useSelector(store => mapSelectors.getMapDimensions(store, mapId));
8763
8784
  const layers = useSelector(store => mapSelectors.getMapLayers(store, mapId));
@@ -8851,7 +8872,7 @@ const MapViewConnect = _ref => {
8851
8872
  }));
8852
8873
  }, [dispatch, store]);
8853
8874
  const isActiveWindowId = useSelector(store => uiSelectors.getIsActiveWindowId(store, mapId));
8854
- useKeyboardZoomAndPan(isActiveWindowId, mapId);
8875
+ useKeyboardZoomAndPan(isActiveWindowId, mapId, mapRef.current);
8855
8876
  useTouchZoomPan(isActiveWindowId, mapId);
8856
8877
  const unRegister = React.useCallback(mapId => {
8857
8878
  unregisterMap({
@@ -8902,6 +8923,7 @@ const MapViewConnect = _ref => {
8902
8923
  style: {
8903
8924
  height: '100%'
8904
8925
  },
8926
+ ref: mapRef,
8905
8927
  children: jsxs(MapView, Object.assign({}, props, {
8906
8928
  mapId: mapId,
8907
8929
  srs: srs,
@@ -9162,8 +9184,8 @@ const getLayersToUpdate = (layers, mapId) => {
9162
9184
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
9163
9185
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
9164
9186
  * */
9165
- const sanitizeHTML = htmlToBeSanitezed => ({
9166
- __html: DOMPurify.sanitize(htmlToBeSanitezed, {
9187
+ const sanitizeHTML = htmlToBeSanitized => ({
9188
+ __html: DOMPurify.sanitize(htmlToBeSanitized, {
9167
9189
  ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'a', 'table', 'td', 'tr', 'br', 'hr', 'th'],
9168
9190
  ALLOWED_ATTR: ['href']
9169
9191
  })
@@ -11820,4 +11842,4 @@ const LanguageSelect = ({
11820
11842
  });
11821
11843
  };
11822
11844
 
11823
- export { CORE_NAMESPACE, ConfigurableMapConnect, 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, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };
11845
+ 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, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "9.32.0",
3
+ "version": "9.33.0",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1 +1,3 @@
1
- export declare const useKeyboardZoomAndPan: (mapIsActive: boolean, mapId: string) => void;
1
+ export declare const isDialogOpen: (mapRef: HTMLElement | null) => boolean;
2
+ export declare const isMapKeyboardControlsAllowed: (target: Element, mapRef: HTMLElement | null) => boolean;
3
+ export declare const useKeyboardZoomAndPan: (mapIsActive: boolean, mapId: string, mapRef: HTMLElement | null) => void;
@@ -6,6 +6,9 @@ interface CoreThemeProviderProps {
6
6
  children?: React.ReactNode;
7
7
  theme?: Theme;
8
8
  }
9
+ interface CoreTranslationWrapperProps {
10
+ children?: React.ReactNode;
11
+ }
9
12
  /**
10
13
  * A Provider component which provides the GeoWeb theme
11
14
  * @param children
@@ -23,6 +26,7 @@ interface CoreThemeStoreProviderProps extends CoreThemeProviderProps {
23
26
  * @returns
24
27
  */
25
28
  export declare const CoreThemeStoreProvider: React.FC<CoreThemeStoreProviderProps>;
29
+ export declare const CoreI18nProvider: React.FC<CoreTranslationWrapperProps>;
26
30
  export declare const DemoWrapper: React.FC<CoreThemeProviderProps>;
27
31
  export declare const DemoWrapperConnect: React.FC<CoreThemeStoreProviderProps>;
28
32
  export {};
@@ -1,3 +1,3 @@
1
- export declare const sanitizeHTML: (htmlToBeSanitezed: string) => {
1
+ export declare const sanitizeHTML: (htmlToBeSanitized: string) => {
2
2
  __html: string;
3
3
  };