@opengeoweb/shared 4.5.0 → 4.6.1

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
@@ -632,34 +632,55 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
632
632
  * */
633
633
  var adjustPosition = function adjustPosition(bbox, containingView, position, setPosition) {
634
634
  var isHorizontallyLarger = bbox.width > containingView.width;
635
- var isVerticallyLarger = bbox.height > containingView.height; // left screen
635
+ var isVerticallyLarger = bbox.height > containingView.height; // Check corner cases first
636
+ // bottom left
636
637
 
637
- if (bbox.x < containingView.x || isHorizontallyLarger) {
638
+ if (bbox.x < containingView.x && bbox.bottom >= containingView.bottom) {
638
639
  var diffX = containingView.x - bbox.x;
639
- setPosition(Object.assign(Object.assign({}, position), {
640
- x: position.x + diffX
641
- }));
642
- } // right screen
643
- else if (bbox.right >= containingView.right) {
640
+ var diffY = containingView.bottom - bbox.bottom;
641
+ setPosition({
642
+ x: position.x + diffX,
643
+ y: position.y + diffY
644
+ });
645
+ } // bottom right
646
+ else if (bbox.right >= containingView.right && bbox.bottom >= containingView.bottom) {
644
647
  var _diffX = containingView.right - bbox.right;
645
648
 
646
- setPosition(Object.assign(Object.assign({}, position), {
647
- x: position.x + _diffX
648
- }));
649
- } // top screen
650
- else if (bbox.y < containingView.y || isVerticallyLarger) {
651
- var diffY = containingView.y - bbox.y;
649
+ var _diffY = containingView.bottom - bbox.bottom;
650
+
651
+ setPosition({
652
+ x: position.x + _diffX,
653
+ y: position.y + _diffY
654
+ });
655
+ } // left screen
656
+ else if (bbox.x < containingView.x || isHorizontallyLarger) {
657
+ var _diffX2 = containingView.x - bbox.x;
658
+
652
659
  setPosition(Object.assign(Object.assign({}, position), {
653
- y: position.y + diffY
660
+ x: position.x + _diffX2
654
661
  }));
655
- } // bottom screen
656
- else if (bbox.bottom >= containingView.bottom) {
657
- var _diffY = containingView.bottom - bbox.bottom;
662
+ } // right screen
663
+ else if (bbox.right >= containingView.right) {
664
+ var _diffX3 = containingView.right - bbox.right;
658
665
 
659
666
  setPosition(Object.assign(Object.assign({}, position), {
660
- y: position.y + _diffY
667
+ x: position.x + _diffX3
661
668
  }));
662
- }
669
+ } // top screen
670
+ else if (bbox.y < containingView.y || isVerticallyLarger) {
671
+ var _diffY2 = containingView.y - bbox.y;
672
+
673
+ setPosition(Object.assign(Object.assign({}, position), {
674
+ y: position.y + _diffY2
675
+ }));
676
+ } // bottom screen
677
+ else if (bbox.bottom >= containingView.bottom) {
678
+ var _diffY3 = containingView.bottom - bbox.bottom;
679
+
680
+ setPosition(Object.assign(Object.assign({}, position), {
681
+ y: position.y + _diffY3
682
+ }));
683
+ }
663
684
  };
664
685
  var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
665
686
  var onResizeWindow = React__default.useCallback(function () {
@@ -1698,6 +1719,151 @@ var ToolContainer = function ToolContainer(_a) {
1698
1719
  }, children), isResizable && /*#__PURE__*/React__default.createElement(ToolFooter, null));
1699
1720
  };
1700
1721
 
1722
+ /* *
1723
+ * Licensed under the Apache License, Version 2.0 (the "License");
1724
+ * you may not use this file except in compliance with the License.
1725
+ * You may obtain a copy of the License at
1726
+ *
1727
+ * http://www.apache.org/licenses/LICENSE-2.0
1728
+ *
1729
+ * Unless required by applicable law or agreed to in writing, software
1730
+ * distributed under the License is distributed on an "AS IS" BASIS,
1731
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1732
+ * See the License for the specific language governing permissions and
1733
+ * limitations under the License.
1734
+ *
1735
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1736
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
1737
+ * */
1738
+ var getRightPositionAndSize = function getRightPositionAndSize(_ref) {
1739
+ var currentX = _ref.currentX,
1740
+ currentWidth = _ref.currentWidth,
1741
+ newWidth = _ref.newWidth,
1742
+ maxWidth = _ref.maxWidth,
1743
+ position = _ref.position,
1744
+ startSize = _ref.startSize;
1745
+ var newSize = Object.assign(Object.assign({}, startSize), {
1746
+ width: newWidth
1747
+ }); // if new size is bigger than the window
1748
+
1749
+ if (newWidth >= maxWidth) {
1750
+ return {
1751
+ size: Object.assign(Object.assign({}, newSize), {
1752
+ width: maxWidth
1753
+ }),
1754
+ position: Object.assign(Object.assign({}, position), {
1755
+ x: position.x + (maxWidth - (currentX + currentWidth))
1756
+ })
1757
+ };
1758
+ } // if new size overlaps left side of screen
1759
+
1760
+
1761
+ var newStartX = currentX - (newWidth - currentWidth);
1762
+
1763
+ if (newStartX <= 0) {
1764
+ return {
1765
+ size: newSize,
1766
+ position: Object.assign(Object.assign({}, position), {
1767
+ x: position.x - newStartX
1768
+ })
1769
+ };
1770
+ } // there is room to grow
1771
+
1772
+
1773
+ return {
1774
+ size: newSize,
1775
+ position: position
1776
+ };
1777
+ };
1778
+ var getLeftPositionAndSize = function getLeftPositionAndSize(_ref2) {
1779
+ var currentX = _ref2.currentX,
1780
+ newWidth = _ref2.newWidth,
1781
+ maxWidth = _ref2.maxWidth,
1782
+ position = _ref2.position,
1783
+ startSize = _ref2.startSize;
1784
+ var newSize = Object.assign(Object.assign({}, startSize), {
1785
+ width: newWidth
1786
+ }); // if new size is bigger than the window
1787
+
1788
+ if (newWidth >= maxWidth) {
1789
+ return {
1790
+ size: Object.assign(Object.assign({}, newSize), {
1791
+ width: maxWidth
1792
+ }),
1793
+ position: Object.assign(Object.assign({}, position), {
1794
+ x: position.x - currentX
1795
+ })
1796
+ };
1797
+ } // if new size overlaps right side of screen
1798
+
1799
+
1800
+ var newEndX = currentX + newWidth;
1801
+
1802
+ if (newEndX >= maxWidth) {
1803
+ return {
1804
+ size: newSize,
1805
+ position: Object.assign(Object.assign({}, position), {
1806
+ x: position.x + (maxWidth - newEndX)
1807
+ })
1808
+ };
1809
+ } // there is room to grow
1810
+
1811
+
1812
+ return {
1813
+ size: newSize,
1814
+ position: position
1815
+ };
1816
+ };
1817
+ var useHandleSizeFromOutsideComponent = function useHandleSizeFromOutsideComponent(_ref3) {
1818
+ var nodeRef = _ref3.nodeRef,
1819
+ startSize = _ref3.startSize,
1820
+ bounds = _ref3.bounds,
1821
+ isRightAligned = _ref3.isRightAligned,
1822
+ size = _ref3.size,
1823
+ setSize = _ref3.setSize,
1824
+ position = _ref3.position,
1825
+ setPosition = _ref3.setPosition;
1826
+ React__default.useEffect(function () {
1827
+ var _a, _b; // update size when startSize has changed outside the component
1828
+
1829
+
1830
+ if (startSize !== size) {
1831
+ var node = (_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.firstChild;
1832
+ var boundsNode = bounds === 'parent' ? (_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.parentNode : document.querySelector(bounds);
1833
+
1834
+ var _boundsNode$getBoundi = boundsNode.getBoundingClientRect(),
1835
+ maxWidth = _boundsNode$getBoundi.width;
1836
+
1837
+ var newWidth = Number(startSize.width);
1838
+
1839
+ var _node$getBoundingClie = node.getBoundingClientRect(),
1840
+ currentX = _node$getBoundingClie.x,
1841
+ currentWidth = _node$getBoundingClie.width;
1842
+
1843
+ var _ref4 = isRightAligned ? getRightPositionAndSize({
1844
+ currentX: currentX,
1845
+ currentWidth: currentWidth,
1846
+ newWidth: newWidth,
1847
+ maxWidth: maxWidth,
1848
+ position: position,
1849
+ startSize: startSize
1850
+ }) : getLeftPositionAndSize({
1851
+ currentX: currentX,
1852
+ newWidth: newWidth,
1853
+ maxWidth: maxWidth,
1854
+ position: position,
1855
+ startSize: startSize
1856
+ }),
1857
+ newPosition = _ref4.position,
1858
+ newSize = _ref4.size;
1859
+
1860
+ setSize(newSize);
1861
+ setPosition(newPosition);
1862
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
1863
+
1864
+ }, [startSize.width, startSize.height]);
1865
+ };
1866
+
1701
1867
  var calculateDialogSizeAndPosition = function calculateDialogSizeAndPosition() {
1702
1868
  var width = window.innerWidth * 0.85;
1703
1869
  var height = window.innerHeight * 0.85;
@@ -1836,43 +2002,18 @@ var DraggableComponent = function DraggableComponent(_a) {
1836
2002
  };
1837
2003
 
1838
2004
  useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
2005
+ useHandleSizeFromOutsideComponent({
2006
+ nodeRef: nodeRef,
2007
+ startSize: startSize,
2008
+ bounds: bounds,
2009
+ isRightAligned: isRightAligned,
2010
+ size: size,
2011
+ setSize: setSize,
2012
+ position: position,
2013
+ setPosition: setPosition
2014
+ });
1839
2015
  var toolcontainerId = React__default.useRef(Date.now().toString()).current;
1840
2016
  var headerClassName = "header-".concat(className || toolcontainerId);
1841
- React__default.useEffect(function () {
1842
- var _a, _b; // update size when startSize has changed outside the component
1843
-
1844
-
1845
- if (startSize !== size) {
1846
- var node = (_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.firstChild;
1847
- var boundsNode = bounds === 'parent' ? (_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.parentNode : document.querySelector(bounds);
1848
- var startWidth = Number(startSize.width);
1849
-
1850
- var _node$getBoundingClie2 = node.getBoundingClientRect(),
1851
- currentX = _node$getBoundingClie2.x,
1852
- currentWidth = _node$getBoundingClie2.width;
1853
-
1854
- var _boundsNode$getBoundi = boundsNode.getBoundingClientRect(),
1855
- maxWidth = _boundsNode$getBoundi.width; // TODO: fix screen hugging issues in https://gitlab.com/opengeoweb/opengeoweb/-/issues/2924
1856
-
1857
-
1858
- if (isRightAligned) {
1859
- var newWidth = currentX + currentWidth - startWidth < 0 ? currentX + currentWidth : startWidth;
1860
- var newSize = Object.assign(Object.assign({}, startSize), {
1861
- width: newWidth
1862
- });
1863
- setSize(newSize);
1864
- } else {
1865
- var _newWidth = currentX + startWidth >= maxWidth ? maxWidth - currentX : startWidth;
1866
-
1867
- var _newSize = Object.assign(Object.assign({}, startSize), {
1868
- width: _newWidth
1869
- });
1870
-
1871
- setSize(_newSize);
1872
- }
1873
- } // eslint-disable-next-line react-hooks/exhaustive-deps
1874
-
1875
- }, [startSize.width, startSize.height]);
1876
2017
  return isOpen ? /*#__PURE__*/React__default.createElement(DraggableComponent$1, {
1877
2018
  nodeRef: nodeRef,
1878
2019
  bounds: bounds,
@@ -2852,15 +2993,15 @@ var tooltipContainerStyles = function tooltipContainerStyles(isEnabled) {
2852
2993
  '& .MuiOutlinedInput-notchedOutline': {
2853
2994
  borderColor: 'transparent!important'
2854
2995
  },
2855
- '&:hover .MuiSelect-select': {
2856
- outline: function outline(theme) {
2857
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2858
- }
2996
+ '&:hover': {
2997
+ backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2998
+ borderRadius: 0
2859
2999
  },
2860
3000
  '&.Mui-focused .MuiSelect-select': {
2861
3001
  outline: function outline(theme) {
2862
3002
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2863
- }
3003
+ },
3004
+ borderRadius: 0
2864
3005
  },
2865
3006
  '& .MuiSvgIcon-root': {
2866
3007
  transition: 'none',
@@ -2869,18 +3010,20 @@ var tooltipContainerStyles = function tooltipContainerStyles(isEnabled) {
2869
3010
  }
2870
3011
  },
2871
3012
  '&>div': {
2872
- paddingLeft: 1
3013
+ paddingLeft: '8px!important'
2873
3014
  }
2874
3015
  }, hasBackgroundColor && backgroundColor);
2875
3016
  };
2876
3017
  var backgroundColor = {
2877
3018
  '&:hover .MuiSelect-select': {
3019
+ backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
3020
+ borderRadius: 0
3021
+ },
3022
+ '&.Mui-focused .MuiSelect-select': {
2878
3023
  outline: function outline(theme) {
2879
3024
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2880
3025
  },
2881
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2882
- },
2883
- '&.Mui-focused .MuiSelect-select': {
3026
+ borderRadius: 0,
2884
3027
  backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2885
3028
  },
2886
3029
  '&:hover&.MuiButton-root': {
@@ -2927,8 +3070,13 @@ var TooltipSelect = function TooltipSelect(_a) {
2927
3070
  if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
2928
3071
  if (selectOpen) return;
2929
3072
  var direction = event.deltaY < 0 ? 1 : -1;
2930
- var newValue = list[Math.min(Math.max(currentIndex - direction, 0), list.length - 1)];
2931
- onChangeMouseWheel(newValue);
3073
+ var newIndex = currentIndex - direction;
3074
+
3075
+ if (newIndex < 0 || newIndex >= list.length) {
3076
+ return;
3077
+ }
3078
+
3079
+ onChangeMouseWheel(list[newIndex]);
2932
3080
  }
2933
3081
  }, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
2934
3082
  var onOpen = React.useCallback(function () {
@@ -2953,8 +3101,7 @@ var TooltipSelect = function TooltipSelect(_a) {
2953
3101
  return /*#__PURE__*/React.createElement(CustomTooltip, {
2954
3102
  title: tooltip,
2955
3103
  placement: "top",
2956
- open: tooltipOpen,
2957
- sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
3104
+ open: tooltipOpen
2958
3105
  }, /*#__PURE__*/React.createElement(Select, Object.assign({
2959
3106
  onOpen: onOpen,
2960
3107
  onClose: onClose,
@@ -3005,7 +3152,8 @@ var TooltipSelect = function TooltipSelect(_a) {
3005
3152
  }
3006
3153
  }
3007
3154
  }
3008
- }
3155
+ },
3156
+ sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
3009
3157
  }, otherProps)));
3010
3158
  };
3011
3159
 
package/index.umd.js CHANGED
@@ -485,32 +485,49 @@
485
485
 
486
486
  var adjustPosition = function adjustPosition(bbox, containingView, position, setPosition) {
487
487
  var isHorizontallyLarger = bbox.width > containingView.width;
488
- var isVerticallyLarger = bbox.height > containingView.height; // left screen
488
+ var isVerticallyLarger = bbox.height > containingView.height; // Check corner cases first
489
+ // bottom left
489
490
 
490
- if (bbox.x < containingView.x || isHorizontallyLarger) {
491
+ if (bbox.x < containingView.x && bbox.bottom >= containingView.bottom) {
491
492
  var diffX = containingView.x - bbox.x;
492
- setPosition(__assign(__assign({}, position), {
493
- x: position.x + diffX
494
- }));
495
- } // right screen
496
- else if (bbox.right >= containingView.right) {
493
+ var diffY = containingView.bottom - bbox.bottom;
494
+ setPosition({
495
+ x: position.x + diffX,
496
+ y: position.y + diffY
497
+ });
498
+ } // bottom right
499
+ else if (bbox.right >= containingView.right && bbox.bottom >= containingView.bottom) {
497
500
  var diffX = containingView.right - bbox.right;
498
- setPosition(__assign(__assign({}, position), {
499
- x: position.x + diffX
500
- }));
501
- } // top screen
502
- else if (bbox.y < containingView.y || isVerticallyLarger) {
503
- var diffY = containingView.y - bbox.y;
501
+ var diffY = containingView.bottom - bbox.bottom;
502
+ setPosition({
503
+ x: position.x + diffX,
504
+ y: position.y + diffY
505
+ });
506
+ } // left screen
507
+ else if (bbox.x < containingView.x || isHorizontallyLarger) {
508
+ var diffX = containingView.x - bbox.x;
504
509
  setPosition(__assign(__assign({}, position), {
505
- y: position.y + diffY
510
+ x: position.x + diffX
506
511
  }));
507
- } // bottom screen
508
- else if (bbox.bottom >= containingView.bottom) {
509
- var diffY = containingView.bottom - bbox.bottom;
512
+ } // right screen
513
+ else if (bbox.right >= containingView.right) {
514
+ var diffX = containingView.right - bbox.right;
510
515
  setPosition(__assign(__assign({}, position), {
511
- y: position.y + diffY
516
+ x: position.x + diffX
512
517
  }));
513
- }
518
+ } // top screen
519
+ else if (bbox.y < containingView.y || isVerticallyLarger) {
520
+ var diffY = containingView.y - bbox.y;
521
+ setPosition(__assign(__assign({}, position), {
522
+ y: position.y + diffY
523
+ }));
524
+ } // bottom screen
525
+ else if (bbox.bottom >= containingView.bottom) {
526
+ var diffY = containingView.bottom - bbox.bottom;
527
+ setPosition(__assign(__assign({}, position), {
528
+ y: position.y + diffY
529
+ }));
530
+ }
514
531
  };
515
532
  var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
516
533
  var onResizeWindow = React__default["default"].useCallback(function () {
@@ -1558,6 +1575,136 @@
1558
1575
  }, children), isResizable && /*#__PURE__*/React__default["default"].createElement(ToolFooter, null));
1559
1576
  };
1560
1577
 
1578
+ var getRightPositionAndSize = function getRightPositionAndSize(_a) {
1579
+ var currentX = _a.currentX,
1580
+ currentWidth = _a.currentWidth,
1581
+ newWidth = _a.newWidth,
1582
+ maxWidth = _a.maxWidth,
1583
+ position = _a.position,
1584
+ startSize = _a.startSize;
1585
+
1586
+ var newSize = __assign(__assign({}, startSize), {
1587
+ width: newWidth
1588
+ }); // if new size is bigger than the window
1589
+
1590
+
1591
+ if (newWidth >= maxWidth) {
1592
+ return {
1593
+ size: __assign(__assign({}, newSize), {
1594
+ width: maxWidth
1595
+ }),
1596
+ position: __assign(__assign({}, position), {
1597
+ x: position.x + (maxWidth - (currentX + currentWidth))
1598
+ })
1599
+ };
1600
+ } // if new size overlaps left side of screen
1601
+
1602
+
1603
+ var newStartX = currentX - (newWidth - currentWidth);
1604
+
1605
+ if (newStartX <= 0) {
1606
+ return {
1607
+ size: newSize,
1608
+ position: __assign(__assign({}, position), {
1609
+ x: position.x - newStartX
1610
+ })
1611
+ };
1612
+ } // there is room to grow
1613
+
1614
+
1615
+ return {
1616
+ size: newSize,
1617
+ position: position
1618
+ };
1619
+ };
1620
+ var getLeftPositionAndSize = function getLeftPositionAndSize(_a) {
1621
+ var currentX = _a.currentX,
1622
+ newWidth = _a.newWidth,
1623
+ maxWidth = _a.maxWidth,
1624
+ position = _a.position,
1625
+ startSize = _a.startSize;
1626
+
1627
+ var newSize = __assign(__assign({}, startSize), {
1628
+ width: newWidth
1629
+ }); // if new size is bigger than the window
1630
+
1631
+
1632
+ if (newWidth >= maxWidth) {
1633
+ return {
1634
+ size: __assign(__assign({}, newSize), {
1635
+ width: maxWidth
1636
+ }),
1637
+ position: __assign(__assign({}, position), {
1638
+ x: position.x - currentX
1639
+ })
1640
+ };
1641
+ } // if new size overlaps right side of screen
1642
+
1643
+
1644
+ var newEndX = currentX + newWidth;
1645
+
1646
+ if (newEndX >= maxWidth) {
1647
+ return {
1648
+ size: newSize,
1649
+ position: __assign(__assign({}, position), {
1650
+ x: position.x + (maxWidth - newEndX)
1651
+ })
1652
+ };
1653
+ } // there is room to grow
1654
+
1655
+
1656
+ return {
1657
+ size: newSize,
1658
+ position: position
1659
+ };
1660
+ };
1661
+ var useHandleSizeFromOutsideComponent = function useHandleSizeFromOutsideComponent(_a) {
1662
+ var nodeRef = _a.nodeRef,
1663
+ startSize = _a.startSize,
1664
+ bounds = _a.bounds,
1665
+ isRightAligned = _a.isRightAligned,
1666
+ size = _a.size,
1667
+ setSize = _a.setSize,
1668
+ position = _a.position,
1669
+ setPosition = _a.setPosition;
1670
+ React__default["default"].useEffect(function () {
1671
+ var _a, _b; // update size when startSize has changed outside the component
1672
+
1673
+
1674
+ if (startSize !== size) {
1675
+ var node = (_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.firstChild;
1676
+ var boundsNode = bounds === 'parent' ? (_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.parentNode : document.querySelector(bounds);
1677
+ var maxWidth = boundsNode.getBoundingClientRect().width;
1678
+ var newWidth = Number(startSize.width);
1679
+
1680
+ var _c = node.getBoundingClientRect(),
1681
+ currentX = _c.x,
1682
+ currentWidth = _c.width;
1683
+
1684
+ var _d = isRightAligned ? getRightPositionAndSize({
1685
+ currentX: currentX,
1686
+ currentWidth: currentWidth,
1687
+ newWidth: newWidth,
1688
+ maxWidth: maxWidth,
1689
+ position: position,
1690
+ startSize: startSize
1691
+ }) : getLeftPositionAndSize({
1692
+ currentX: currentX,
1693
+ newWidth: newWidth,
1694
+ maxWidth: maxWidth,
1695
+ position: position,
1696
+ startSize: startSize
1697
+ }),
1698
+ newPosition = _d.position,
1699
+ newSize = _d.size;
1700
+
1701
+ setSize(newSize);
1702
+ setPosition(newPosition);
1703
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
1704
+
1705
+ }, [startSize.width, startSize.height]);
1706
+ };
1707
+
1561
1708
  /* *
1562
1709
  * Licensed under the Apache License, Version 2.0 (the "License");
1563
1710
  * you may not use this file except in compliance with the License.
@@ -1708,43 +1855,18 @@
1708
1855
  };
1709
1856
 
1710
1857
  useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
1858
+ useHandleSizeFromOutsideComponent({
1859
+ nodeRef: nodeRef,
1860
+ startSize: startSize,
1861
+ bounds: bounds,
1862
+ isRightAligned: isRightAligned,
1863
+ size: size,
1864
+ setSize: setSize,
1865
+ position: position,
1866
+ setPosition: setPosition
1867
+ });
1711
1868
  var toolcontainerId = React__default["default"].useRef(Date.now().toString()).current;
1712
1869
  var headerClassName = "header-" + (className || toolcontainerId);
1713
- React__default["default"].useEffect(function () {
1714
- var _a, _b; // update size when startSize has changed outside the component
1715
-
1716
-
1717
- if (startSize !== size) {
1718
- var node = (_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.firstChild;
1719
- var boundsNode = bounds === 'parent' ? (_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.parentNode : document.querySelector(bounds);
1720
- var startWidth = Number(startSize.width);
1721
-
1722
- var _c = node.getBoundingClientRect(),
1723
- currentX = _c.x,
1724
- currentWidth = _c.width;
1725
-
1726
- var maxWidth = boundsNode.getBoundingClientRect().width; // TODO: fix screen hugging issues in https://gitlab.com/opengeoweb/opengeoweb/-/issues/2924
1727
-
1728
- if (isRightAligned) {
1729
- var newWidth = currentX + currentWidth - startWidth < 0 ? currentX + currentWidth : startWidth;
1730
-
1731
- var newSize = __assign(__assign({}, startSize), {
1732
- width: newWidth
1733
- });
1734
-
1735
- setSize(newSize);
1736
- } else {
1737
- var newWidth = currentX + startWidth >= maxWidth ? maxWidth - currentX : startWidth;
1738
-
1739
- var newSize = __assign(__assign({}, startSize), {
1740
- width: newWidth
1741
- });
1742
-
1743
- setSize(newSize);
1744
- }
1745
- } // eslint-disable-next-line react-hooks/exhaustive-deps
1746
-
1747
- }, [startSize.width, startSize.height]);
1748
1870
  return isOpen ? /*#__PURE__*/React__default["default"].createElement(DraggableComponent$1, {
1749
1871
  nodeRef: nodeRef,
1750
1872
  bounds: bounds,
@@ -2727,15 +2849,15 @@
2727
2849
  '& .MuiOutlinedInput-notchedOutline': {
2728
2850
  borderColor: 'transparent!important'
2729
2851
  },
2730
- '&:hover .MuiSelect-select': {
2731
- outline: function outline(theme) {
2732
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2733
- }
2852
+ '&:hover': {
2853
+ backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2854
+ borderRadius: 0
2734
2855
  },
2735
2856
  '&.Mui-focused .MuiSelect-select': {
2736
2857
  outline: function outline(theme) {
2737
2858
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2738
- }
2859
+ },
2860
+ borderRadius: 0
2739
2861
  },
2740
2862
  '& .MuiSvgIcon-root': {
2741
2863
  transition: 'none',
@@ -2744,18 +2866,20 @@
2744
2866
  }
2745
2867
  },
2746
2868
  '&>div': {
2747
- paddingLeft: 1
2869
+ paddingLeft: '8px!important'
2748
2870
  }
2749
2871
  }, hasBackgroundColor && backgroundColor);
2750
2872
  };
2751
2873
  var backgroundColor = {
2752
2874
  '&:hover .MuiSelect-select': {
2875
+ backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2876
+ borderRadius: 0
2877
+ },
2878
+ '&.Mui-focused .MuiSelect-select': {
2753
2879
  outline: function outline(theme) {
2754
2880
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2755
2881
  },
2756
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2757
- },
2758
- '&.Mui-focused .MuiSelect-select': {
2882
+ borderRadius: 0,
2759
2883
  backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2760
2884
  },
2761
2885
  '&:hover&.MuiButton-root': {
@@ -2816,8 +2940,13 @@
2816
2940
  if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
2817
2941
  if (selectOpen) return;
2818
2942
  var direction = event.deltaY < 0 ? 1 : -1;
2819
- var newValue = list[Math.min(Math.max(currentIndex - direction, 0), list.length - 1)];
2820
- onChangeMouseWheel(newValue);
2943
+ var newIndex = currentIndex - direction;
2944
+
2945
+ if (newIndex < 0 || newIndex >= list.length) {
2946
+ return;
2947
+ }
2948
+
2949
+ onChangeMouseWheel(list[newIndex]);
2821
2950
  }
2822
2951
  }, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
2823
2952
  var onOpen = React__namespace.useCallback(function () {
@@ -2842,8 +2971,7 @@
2842
2971
  return /*#__PURE__*/React__namespace.createElement(CustomTooltip, {
2843
2972
  title: tooltip,
2844
2973
  placement: "top",
2845
- open: tooltipOpen,
2846
- sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
2974
+ open: tooltipOpen
2847
2975
  }, /*#__PURE__*/React__namespace.createElement(material.Select, __assign({
2848
2976
  onOpen: onOpen,
2849
2977
  onClose: onClose,
@@ -2894,7 +3022,8 @@
2894
3022
  }
2895
3023
  }
2896
3024
  }
2897
- }
3025
+ },
3026
+ sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
2898
3027
  }, otherProps)));
2899
3028
  };
2900
3029
 
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { ControlPosition } from 'react-draggable';
3
+ import { Size } from '../DraggableResizable/types';
4
+ interface PositionAndSizeProps {
5
+ currentX: number;
6
+ newWidth: number;
7
+ maxWidth: number;
8
+ position: ControlPosition;
9
+ startSize: Size;
10
+ }
11
+ interface PositionAndSizePropsRight extends PositionAndSizeProps {
12
+ currentWidth: number;
13
+ }
14
+ export declare const getRightPositionAndSize: ({ currentX, currentWidth, newWidth, maxWidth, position, startSize, }: PositionAndSizePropsRight) => {
15
+ size: Size;
16
+ position: ControlPosition;
17
+ };
18
+ export declare const getLeftPositionAndSize: ({ currentX, newWidth, maxWidth, position, startSize, }: PositionAndSizeProps) => {
19
+ size: Size;
20
+ position: ControlPosition;
21
+ };
22
+ interface UseHandleSizeFromOutsideComponentProps {
23
+ nodeRef: React.RefObject<HTMLDivElement>;
24
+ startSize: Size;
25
+ bounds?: 'parent' | string;
26
+ isRightAligned: boolean;
27
+ size: Size;
28
+ setSize: (size: Size) => void;
29
+ position: ControlPosition;
30
+ setPosition: (position: ControlPosition) => void;
31
+ }
32
+ export declare const useHandleSizeFromOutsideComponent: ({ nodeRef, startSize, bounds, isRightAligned, size, setSize, position, setPosition, }: UseHandleSizeFromOutsideComponentProps) => void;
33
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "4.5.0",
3
+ "version": "4.6.1",
4
4
  "description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,12 +14,12 @@
14
14
  "peerDependencies": {
15
15
  "react": "^17.0.2",
16
16
  "@mui/material": "^5.10.8",
17
- "@opengeoweb/theme": "4.5.0",
17
+ "@opengeoweb/theme": "4.6.1",
18
18
  "react-draggable": "^4.4.5",
19
19
  "re-resizable": "^6.9.0",
20
20
  "@redux-eggs/core": "^2.2.0",
21
21
  "react-redux": "^8.0.4",
22
- "@opengeoweb/form-fields": "4.5.0",
22
+ "@opengeoweb/form-fields": "4.6.1",
23
23
  "react-hook-form": "^6.12.1",
24
24
  "moment": "^2.29.0",
25
25
  "moment-timezone": "^0.5.31",