@opengeoweb/core 9.6.0 → 9.7.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
@@ -495,7 +495,8 @@ var HeaderOptions = function HeaderOptions(_ref) {
495
495
  shortcutsEnabled = _ref.shortcutsEnabled,
496
496
  onClickDockButton = _ref.onClickDockButton,
497
497
  onChangeSize = _ref.onChangeSize,
498
- buttonSettings = _ref.buttonSettings;
498
+ buttonSettings = _ref.buttonSettings,
499
+ mapWidth = _ref.mapWidth;
499
500
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
500
501
  React.useEffect(function () {
501
502
  var handleKeyDown = function handleKeyDown(event) {
@@ -518,21 +519,27 @@ var HeaderOptions = function HeaderOptions(_ref) {
518
519
  tooltipTitle: "small",
519
520
  "data-testid": "collapseSmall-btn",
520
521
  onClick: function onClick() {
521
- return onChangeSize(sizeSmall);
522
+ if (mapWidth && mapWidth > sizeSmall.width) {
523
+ onChangeSize(sizeSmall);
524
+ }
522
525
  },
523
526
  className: "collapseSmall-btn"
524
527
  }, (_c = (_b = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.small) === null || _b === void 0 ? void 0 : _b.icon) !== null && _c !== void 0 ? _c : /*#__PURE__*/React.createElement(CollapseSmall, null))), !((_d = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.medium) === null || _d === void 0 ? void 0 : _d.isDisabled) && ( /*#__PURE__*/React.createElement(CustomIconButton, {
525
528
  tooltipTitle: "medium",
526
529
  "data-testid": "collapseMedium-btn",
527
530
  onClick: function onClick() {
528
- return onChangeSize(sizeMedium);
531
+ if (mapWidth && mapWidth > sizeMedium.width) {
532
+ onChangeSize(sizeMedium);
533
+ }
529
534
  },
530
535
  className: "collapseMedium-btn"
531
536
  }, (_f = (_e = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.medium) === null || _e === void 0 ? void 0 : _e.icon) !== null && _f !== void 0 ? _f : /*#__PURE__*/React.createElement(CollapseMedium, null))), !((_g = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.large) === null || _g === void 0 ? void 0 : _g.isDisabled) && ( /*#__PURE__*/React.createElement(CustomIconButton, {
532
537
  tooltipTitle: "large",
533
538
  "data-testid": "collapseLarge-btn",
534
539
  onClick: function onClick() {
535
- return onChangeSize(sizeLarge);
540
+ if (mapWidth && mapWidth > sizeLarge.width) {
541
+ onChangeSize(sizeLarge);
542
+ }
536
543
  },
537
544
  className: "collapseLarge-btn"
538
545
  }, (_j = (_h = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.large) === null || _h === void 0 ? void 0 : _h.icon) !== null && _j !== void 0 ? _j : /*#__PURE__*/React.createElement(CollapseLarge, null))), !((_k = buttonSettings === null || buttonSettings === void 0 ? void 0 : buttonSettings.dock) === null || _k === void 0 ? void 0 : _k.isDisabled) && ( /*#__PURE__*/React.createElement(CustomIconButton, {
@@ -4233,7 +4240,8 @@ var HeaderOptionsConnect = function HeaderOptionsConnect(_ref) {
4233
4240
  mapId = _ref.mapId,
4234
4241
  onClickDockButton = _ref.onClickDockButton,
4235
4242
  onChangeSize = _ref.onChangeSize,
4236
- buttonSettings = _ref.buttonSettings;
4243
+ buttonSettings = _ref.buttonSettings,
4244
+ mapWidth = _ref.mapWidth;
4237
4245
  var activeMapId = useSelector(function (store) {
4238
4246
  return uiSelectors.getActiveWindowId(store);
4239
4247
  });
@@ -4246,7 +4254,8 @@ var HeaderOptionsConnect = function HeaderOptionsConnect(_ref) {
4246
4254
  shortcutsEnabled: shortcutsEnabled,
4247
4255
  onClickDockButton: onClickDockButton,
4248
4256
  onChangeSize: onChangeSize,
4249
- buttonSettings: buttonSettings
4257
+ buttonSettings: buttonSettings,
4258
+ mapWidth: mapWidth
4250
4259
  });
4251
4260
  };
4252
4261
 
@@ -4495,19 +4504,51 @@ var LayerManager = function LayerManager(_ref) {
4495
4504
  settings = _ref.settings,
4496
4505
  _ref$headerSize = _ref.headerSize,
4497
4506
  headerSize = _ref$headerSize === void 0 ? 'medium' : _ref$headerSize,
4498
- isMultiMap = _ref.isMultiMap;
4507
+ isMultiMap = _ref.isMultiMap,
4508
+ mapWidthRef = _ref.mapWidthRef;
4499
4509
  var _a, _b, _c, _d, _e, _f, _g;
4500
4510
  var minSize = {
4501
4511
  width: 100,
4502
4512
  height: 126
4503
4513
  };
4514
+ var theme = useTheme();
4515
+ renderCounter.count(LayerManager.name);
4504
4516
  var startSizeCalc = calculateStartSize(minSize, size, startPosition);
4505
4517
  var _React$useState = React.useState(startSizeCalc),
4506
4518
  _React$useState2 = _slicedToArray(_React$useState, 2),
4507
4519
  sizeInState = _React$useState2[0],
4508
4520
  setSizeInState = _React$useState2[1];
4509
- var theme = useTheme();
4510
- renderCounter.count(LayerManager.name);
4521
+ var _React$useState3 = React.useState(),
4522
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
4523
+ mapWidth = _React$useState4[0],
4524
+ setMapWidth = _React$useState4[1];
4525
+ React.useEffect(function () {
4526
+ var _a;
4527
+ setMapWidth((_a = mapWidthRef === null || mapWidthRef === void 0 ? void 0 : mapWidthRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth);
4528
+ }, [mapWidthRef, setMapWidth]);
4529
+ React.useEffect(function () {
4530
+ var _a;
4531
+ var resizeThreshold = 65;
4532
+ if (((_a = mapWidthRef === null || mapWidthRef === void 0 ? void 0 : mapWidthRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) === mapWidth) {
4533
+ return;
4534
+ }
4535
+ if (mapWidth) {
4536
+ if (mapWidth < sizeMedium.width + resizeThreshold) {
4537
+ setSizeInState(sizeSmall);
4538
+ } else if (mapWidth >= sizeMedium.width + resizeThreshold && mapWidth < sizeLarge.width + resizeThreshold && sizeInState.width !== sizeSmall.width) {
4539
+ setSizeInState(sizeMedium);
4540
+ }
4541
+ }
4542
+ }, [mapWidth, sizeInState, mapWidthRef]);
4543
+ var returnSizeValue = function returnSizeValue(sizeInState) {
4544
+ if (sizeInState === sizeSmall) {
4545
+ return 'sizeSmall';
4546
+ }
4547
+ if (sizeInState === sizeMedium) {
4548
+ return 'sizeMedium';
4549
+ }
4550
+ return 'sizeLarge';
4551
+ };
4511
4552
  return /*#__PURE__*/React.createElement(ToolContainerDraggable, {
4512
4553
  title: title,
4513
4554
  startSize: sizeInState,
@@ -4519,6 +4560,7 @@ var LayerManager = function LayerManager(_ref) {
4519
4560
  headerSize: headerSize,
4520
4561
  bounds: bounds,
4521
4562
  "data-testid": "layerManagerWindow",
4563
+ "data-size": returnSizeValue(sizeInState),
4522
4564
  onMouseDown: onMouseDown,
4523
4565
  onFocus: function onFocus() {
4524
4566
  return setFocused(true);
@@ -4533,6 +4575,7 @@ var LayerManager = function LayerManager(_ref) {
4533
4575
  isDockedLayerManager: isDockedLayerManager,
4534
4576
  mapId: mapId,
4535
4577
  onClickDockButton: onToggleDock,
4578
+ mapWidth: mapWidth,
4536
4579
  onChangeSize: function onChangeSize(_ref2) {
4537
4580
  var width = _ref2.width;
4538
4581
  setSizeInState(Object.assign(Object.assign({}, sizeInState), {
@@ -4698,7 +4741,8 @@ var LayerManagerConnect = function LayerManagerConnect(_ref) {
4698
4741
  _ref$isDocked = _ref.isDocked,
4699
4742
  isDocked = _ref$isDocked === void 0 ? false : _ref$isDocked,
4700
4743
  _ref$source = _ref.source,
4701
- source = _ref$source === void 0 ? 'app' : _ref$source;
4744
+ source = _ref$source === void 0 ? 'app' : _ref$source,
4745
+ mapWidthRef = _ref.mapWidthRef;
4702
4746
  var dispatch = useDispatch();
4703
4747
  var dialogType = getDialogType(initialMapId, isMultiMap, isDocked);
4704
4748
  var activeMapId = useSelector(function (store) {
@@ -4767,9 +4811,10 @@ var LayerManagerConnect = function LayerManagerConnect(_ref) {
4767
4811
  } : {
4768
4812
  top: 85,
4769
4813
  left: 50
4770
- }
4814
+ },
4815
+ mapWidthRef: mapWidthRef
4771
4816
  });
4772
- }, [bounds, dialogOrder, dockedLayerManagerSize, initialMapId, isDialogOpen, isDocked, isMultiMap, leftHeaderComponent, mapId, onCloseDialog, onToggleDock, preloadedAvailableBaseLayers, preloadedBaseServices, setDialogOrder, setFocused, showMapIdInTitle, title, uiError, uiIsLoading, uiSource]);
4817
+ }, [bounds, dialogOrder, dockedLayerManagerSize, initialMapId, isDialogOpen, isDocked, isMultiMap, leftHeaderComponent, mapId, onCloseDialog, onToggleDock, preloadedAvailableBaseLayers, preloadedBaseServices, setDialogOrder, setFocused, showMapIdInTitle, title, uiError, uiIsLoading, uiSource, mapWidthRef]);
4773
4818
  };
4774
4819
 
4775
4820
  /* *
@@ -6784,6 +6829,7 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
6784
6829
  // eslint-disable-next-line react-hooks/exhaustive-deps
6785
6830
  }, []);
6786
6831
  var mapControlsPositionTop = title ? 24 : 8;
6832
+ var mapWidthRef = /*#__PURE__*/React__default.createRef();
6787
6833
  return React__default.useMemo(function () {
6788
6834
  renderCounter.count("".concat(ConfigurableMapConnect.name, "_").concat(mapId));
6789
6835
  return /*#__PURE__*/React__default.createElement(Box, {
@@ -6793,7 +6839,8 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
6793
6839
  position: 'relative',
6794
6840
  overflow: 'hidden'
6795
6841
  },
6796
- "data-testid": "ConfigurableMap"
6842
+ "data-testid": "ConfigurableMap",
6843
+ ref: mapWidthRef
6797
6844
  }, title && ( /*#__PURE__*/React__default.createElement(Typography, {
6798
6845
  "data-testid": "mapTitle",
6799
6846
  sx: titleStyle
@@ -6845,9 +6892,10 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
6845
6892
  })), /*#__PURE__*/React__default.createElement(LayerManagerConnect, {
6846
6893
  mapId: mapId,
6847
6894
  bounds: "parent",
6848
- isDocked: true
6895
+ isDocked: true,
6896
+ mapWidthRef: mapWidthRef
6849
6897
  }));
6850
- }, [children, disableTimeSlider, displayDimensionSelectButtonInMap, displayGetFeatureInfoButtonInMap, displayLayerManagerAndLegendButtonInMap, displaySearchButtonInMap, displayTimeInMap, id, mapControls, mapControlsPositionTop, mapId, multiLegend, showClock, title]);
6898
+ }, [children, disableTimeSlider, displayDimensionSelectButtonInMap, displayGetFeatureInfoButtonInMap, displayLayerManagerAndLegendButtonInMap, displaySearchButtonInMap, displayTimeInMap, id, mapControls, mapControlsPositionTop, mapId, multiLegend, showClock, title, mapWidthRef]);
6851
6899
  };
6852
6900
 
6853
6901
  /* *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "9.6.0",
3
+ "version": "9.7.0",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,6 +26,7 @@ interface LayerManagerProps {
26
26
  settings?: LayerManagerCustomSettings;
27
27
  headerSize?: HeaderSize;
28
28
  isMultiMap?: boolean;
29
+ mapWidthRef?: React.RefObject<HTMLDivElement>;
29
30
  }
30
31
  declare const LayerManager: React.FC<LayerManagerProps>;
31
32
  export default LayerManager;
@@ -14,6 +14,7 @@ interface LayerManagerConnectProps {
14
14
  isMultiMap?: boolean;
15
15
  isDocked?: boolean;
16
16
  source?: uiTypes.Source;
17
+ mapWidthRef?: React.RefObject<HTMLDivElement>;
17
18
  }
18
19
  /**
19
20
  * Layer Managerconnected to the store displaying the layers forthe active map Id
@@ -29,6 +29,7 @@ interface HeaderOptionsProps {
29
29
  onClickDockButton: () => void;
30
30
  onChangeSize: (size: Size) => void;
31
31
  buttonSettings?: ToolbarButtonSettings;
32
+ mapWidth?: number;
32
33
  }
33
34
  export declare const sizeSmall: {
34
35
  width: number;
@@ -6,6 +6,7 @@ interface HeaderOptionsProps {
6
6
  onClickDockButton: () => void;
7
7
  onChangeSize: (size: Size) => void;
8
8
  buttonSettings?: ToolbarButtonSettings;
9
+ mapWidth?: number;
9
10
  }
10
11
  export declare const areShortcutsEnabled: (activeMapId: string, mapId: string, floatingLmOpen: boolean, isDockedLayerManager: boolean) => boolean;
11
12
  declare const HeaderOptionsConnect: React.FC<HeaderOptionsProps>;
@@ -9,7 +9,7 @@ interface ActionCardProps {
9
9
  name: string;
10
10
  description: string;
11
11
  exampleLayers?: ExampleLayer[];
12
- children?: React.ReactChild;
12
+ children?: React.ReactNode;
13
13
  }
14
14
  export declare const ActionCard: React.FC<ActionCardProps>;
15
15
  export {};