@opengeoweb/shared 12.4.1 → 12.4.2

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
@@ -1816,6 +1816,55 @@ var useWheelStopPropagation = function useWheelStopPropagation() {
1816
1816
  return ref;
1817
1817
  };
1818
1818
 
1819
+ /* *
1820
+ * Licensed under the Apache License, Version 2.0 (the "License");
1821
+ * you may not use this file except in compliance with the License.
1822
+ * You may obtain a copy of the License at
1823
+ *
1824
+ * http://www.apache.org/licenses/LICENSE-2.0
1825
+ *
1826
+ * Unless required by applicable law or agreed to in writing, software
1827
+ * distributed under the License is distributed on an "AS IS" BASIS,
1828
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1829
+ * See the License for the specific language governing permissions and
1830
+ * limitations under the License.
1831
+ *
1832
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1833
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
1834
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
1835
+ * */
1836
+ /**
1837
+ * This hook allows to stop wheel events from propagating to parent elements.
1838
+ * Normally, when you scroll a child element, the scroll event will propagate to the parent element,
1839
+ * as calling event.stopPropagation() on syncthetic events does not stop the propagation
1840
+ */
1841
+ var useScrollingInIsolation = function useScrollingInIsolation(options) {
1842
+ var scrollInIsolationRef = React__default.useRef(null);
1843
+ React__default.useEffect(function () {
1844
+ var element = scrollInIsolationRef.current;
1845
+ if (!element) {
1846
+ return;
1847
+ }
1848
+ var handleWheel = function handleWheel(event) {
1849
+ if (event.metaKey || event.ctrlKey) {
1850
+ event.stopPropagation();
1851
+ event.preventDefault();
1852
+ }
1853
+ if (options != null && options.onWheel) {
1854
+ options.onWheel(event);
1855
+ }
1856
+ };
1857
+ element.addEventListener('wheel', handleWheel, {
1858
+ passive: false
1859
+ });
1860
+ // eslint-disable-next-line consistent-return
1861
+ return function () {
1862
+ element.removeEventListener('wheel', handleWheel);
1863
+ };
1864
+ }, [options]);
1865
+ return scrollInIsolationRef;
1866
+ };
1867
+
1819
1868
  var ConfirmationServiceContext = /*#__PURE__*/React.createContext(Promise.reject);
1820
1869
  var useConfirmationDialog = function useConfirmationDialog() {
1821
1870
  return React.useContext(ConfirmationServiceContext);
@@ -3990,7 +4039,7 @@ var CustomToggleButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
3990
4039
  }, props));
3991
4040
  });
3992
4041
 
3993
- var _excluded$4 = ["tooltip", "list", "currentIndex", "onChangeMouseWheel", "requiresCtrlToChange", "isEnabled", "hasBackgroundColor", "variant", "additionalStyling", "skipLocalStyling"],
4042
+ var _excluded$4 = ["tooltip", "list", "currentIndex", "onChangeMouseWheel", "isEnabled", "hasBackgroundColor", "variant", "additionalStyling", "skipLocalStyling"],
3994
4043
  _excluded2 = ["className", "additionalStyling"];
3995
4044
  var TooltipSelect = function TooltipSelect(_ref) {
3996
4045
  var _ref$tooltip = _ref.tooltip,
@@ -4001,8 +4050,6 @@ var TooltipSelect = function TooltipSelect(_ref) {
4001
4050
  currentIndex = _ref$currentIndex === void 0 ? -1 : _ref$currentIndex,
4002
4051
  _ref$onChangeMouseWhe = _ref.onChangeMouseWheel,
4003
4052
  onChangeMouseWheel = _ref$onChangeMouseWhe === void 0 ? function () {} : _ref$onChangeMouseWhe,
4004
- _ref$requiresCtrlToCh = _ref.requiresCtrlToChange,
4005
- requiresCtrlToChange = _ref$requiresCtrlToCh === void 0 ? false : _ref$requiresCtrlToCh,
4006
4053
  isEnabled = _ref.isEnabled,
4007
4054
  hasBackgroundColor = _ref.hasBackgroundColor,
4008
4055
  _ref$variant = _ref.variant,
@@ -4019,10 +4066,10 @@ var TooltipSelect = function TooltipSelect(_ref) {
4019
4066
  tooltipOpen = _useControlledTooltip[0],
4020
4067
  setTooltipOpen = _useControlledTooltip[1];
4021
4068
  var onWheel = React.useCallback(function (event) {
4022
- if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
4023
- if (selectOpen) {
4024
- return;
4025
- }
4069
+ if (selectOpen) {
4070
+ return;
4071
+ }
4072
+ if (event.ctrlKey || event.metaKey) {
4026
4073
  var direction = event.deltaY < 0 ? 1 : -1;
4027
4074
  var newIndex = currentIndex - direction;
4028
4075
  if (newIndex < 0 || newIndex >= list.length) {
@@ -4030,7 +4077,7 @@ var TooltipSelect = function TooltipSelect(_ref) {
4030
4077
  }
4031
4078
  onChangeMouseWheel(list[newIndex]);
4032
4079
  }
4033
- }, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
4080
+ }, [selectOpen, currentIndex, list, onChangeMouseWheel]);
4034
4081
  var onOpen = React.useCallback(function () {
4035
4082
  setSelectOpen(true);
4036
4083
  setTooltipOpen(false);
@@ -4054,11 +4101,15 @@ var TooltipSelect = function TooltipSelect(_ref) {
4054
4101
  var onBlur = React.useCallback(function () {
4055
4102
  setTooltipOpen(false);
4056
4103
  }, [setTooltipOpen]);
4104
+ var scrollInIsolationRef = useScrollingInIsolation({
4105
+ onWheel: onWheel
4106
+ });
4057
4107
  return jsx(CustomTooltip, {
4058
4108
  title: tooltip,
4059
4109
  placement: "top",
4060
4110
  open: tooltipOpen,
4061
4111
  children: jsx(StyledSelect, Object.assign({
4112
+ ref: scrollInIsolationRef,
4062
4113
  variant: variant,
4063
4114
  disableUnderline: true,
4064
4115
  onOpen: onOpen,
@@ -4067,7 +4118,6 @@ var TooltipSelect = function TooltipSelect(_ref) {
4067
4118
  onMouseLeave: onMouseLeave,
4068
4119
  onFocus: onFocus,
4069
4120
  onBlur: onBlur,
4070
- onWheel: onWheel,
4071
4121
  isEnabled: isEnabled,
4072
4122
  hasBackgroundColor: hasBackgroundColor,
4073
4123
  additionalStyling: additionalStyling,
@@ -6282,4 +6332,4 @@ var SystemScope = {
6282
6332
  system: 'system'
6283
6333
  };
6284
6334
 
6285
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, CanvasComponent, ConfirmationButtons, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomDialogHeader, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEBOUNCE_TIMEOUT, DEFAULT_ERROR_MESSAGE, DEFAULT_FILTER_HEIGHT, DraggableComponent$1 as Draggable, ErrorBoundary, Filter, FilterChip, FilterOption, LastUpdateTime, PROJECTION, ResizeComponent as Resizable, SHARED_NAMESPACE, SearchField$1 as SearchField, SearchFieldButton, SearchHighlight, SessionStorageKey, StatusTag, StorybookDocsWrapper, StyledSelect, SwitchButton, SystemScope, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, UserMenuItemSentryRecording, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, calculateStartSize, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getLastUpdateTitle, getPosition, getWarningMessage, isAxiosAuthError, isAxiosError, loadAllTranslations, pollingIntervalTimeout, renderCounter, safelyInitI18nForTestsAndStories, sessionStorageProvider, sharedTranslations, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDebounce, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, useWheelStopPropagation };
6335
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, CanvasComponent, ConfirmationButtons, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomDialog, CustomDialogHeader, CustomIconButton, CustomSlider, CustomToggleButton, CustomTooltip, DEBOUNCE_TIMEOUT, DEFAULT_ERROR_MESSAGE, DEFAULT_FILTER_HEIGHT, DraggableComponent$1 as Draggable, ErrorBoundary, Filter, FilterChip, FilterOption, LastUpdateTime, PROJECTION, ResizeComponent as Resizable, SHARED_NAMESPACE, SearchField$1 as SearchField, SearchFieldButton, SearchHighlight, SessionStorageKey, StatusTag, StorybookDocsWrapper, StyledSelect, SwitchButton, SystemScope, ToggleMenu, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, UserMenuItemSentryRecording, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, calculateStartSize, index as dateUtils, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getLastUpdateTitle, getPosition, getWarningMessage, isAxiosAuthError, isAxiosError, loadAllTranslations, pollingIntervalTimeout, renderCounter, safelyInitI18nForTestsAndStories, sessionStorageProvider, sharedTranslations, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDebounce, useDialogActions, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useScrollingInIsolation, useUserMenu, useWheelStopPropagation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "12.4.1",
3
+ "version": "12.4.2",
4
4
  "description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,7 +8,7 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/theme": "12.4.1",
11
+ "@opengeoweb/theme": "12.4.2",
12
12
  "react-draggable": "^4.4.6",
13
13
  "re-resizable": "^6.9.11",
14
14
  "lodash": "^4.17.21",
@@ -8,7 +8,6 @@ type TooltipSelectProps = Omit<BaseSelectProps, 'sx'> & {
8
8
  list?: ListElement[];
9
9
  currentIndex?: number;
10
10
  onChangeMouseWheel?: (element: ListElement) => void;
11
- requiresCtrlToChange?: boolean;
12
11
  isEnabled?: boolean;
13
12
  hasBackgroundColor?: boolean;
14
13
  variant?: SelectVariants;
@@ -5,3 +5,4 @@ export * from './useIsMounted/useIsMounted';
5
5
  export * from './useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow';
6
6
  export * from './useDebounce/useDebounce';
7
7
  export * from './useWheelStopPropagation/useWheelStopPropagation';
8
+ export * from './useScrollingInIsolation/useScrollingInIsolation';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This hook allows to stop wheel events from propagating to parent elements.
3
+ * Normally, when you scroll a child element, the scroll event will propagate to the parent element,
4
+ * as calling event.stopPropagation() on syncthetic events does not stop the propagation
5
+ */
6
+ import React from 'react';
7
+ interface ScrollInIsolationProps {
8
+ onWheel?: (event: WheelEvent) => void;
9
+ }
10
+ export declare const useScrollingInIsolation: <T extends HTMLElement>(options?: ScrollInIsolationProps) => React.RefObject<T>;
11
+ export {};