@opengeoweb/shared 4.4.0 → 4.5.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
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useRef } from 'react';
3
- import { Box, Typography, Dialog, DialogTitle, IconButton, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, Grid, useTheme, Link, Avatar as Avatar$1, Paper, ClickAwayListener, MenuList, MenuItem, RadioGroup, FormControlLabel, Radio, Tooltip, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListItemIcon, Checkbox, Select } from '@mui/material';
4
- import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, Delete, VisibilityOff, Visibility } from '@opengeoweb/theme';
3
+ import { Box, Typography, Dialog, DialogTitle, IconButton, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, Grid, useTheme, Link, Avatar as Avatar$1, Paper, ClickAwayListener, MenuList, MenuItem, RadioGroup, FormControlLabel, Radio, Tooltip, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListItemIcon, Checkbox, Select, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
4
+ import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, Delete, VisibilityOff, Visibility, ChevronDown } from '@opengeoweb/theme';
5
5
  import { useFormContext } from 'react-hook-form';
6
6
  import { isEmpty, errorMessages } from '@opengeoweb/form-fields';
7
7
  import { throttle } from 'lodash';
@@ -630,39 +630,43 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
630
630
  * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
631
631
  * Copyright 2022 - Finnish Meteorological Institute (FMI)
632
632
  * */
633
- var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
634
- var onResizeWindow = React__default.useCallback(function (event) {
635
- if (!nodeRef.current) return;
636
- var bbox = nodeRef.current.firstChild.getBoundingClientRect();
637
- var windowTarget = event.currentTarget;
638
- if (!windowTarget) return;
639
- var innerHeight = windowTarget.innerHeight,
640
- innerWidth = windowTarget.innerWidth;
641
- var isHorizontallyLarger = bbox.width > innerWidth;
642
- var isVerticallyLarger = bbox.height > innerHeight; // left screen
643
-
644
- if (bbox.x < 0 || isHorizontallyLarger) {
633
+ var adjustPosition = function adjustPosition(bbox, containingView, position, setPosition) {
634
+ var isHorizontallyLarger = bbox.width > containingView.width;
635
+ var isVerticallyLarger = bbox.height > containingView.height; // left screen
636
+
637
+ if (bbox.x < containingView.x || isHorizontallyLarger) {
638
+ 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) {
644
+ var _diffX = containingView.right - bbox.right;
645
+
645
646
  setPosition(Object.assign(Object.assign({}, position), {
646
- x: position.x - bbox.x
647
+ x: position.x + _diffX
647
648
  }));
648
- } // right screen
649
- else if (bbox.x + bbox.width >= innerWidth) {
650
- var diffX = innerWidth - bbox.x - bbox.width;
649
+ } // top screen
650
+ else if (bbox.y < containingView.y || isVerticallyLarger) {
651
+ var diffY = containingView.y - bbox.y;
651
652
  setPosition(Object.assign(Object.assign({}, position), {
652
- x: position.x + diffX
653
+ y: position.y + diffY
653
654
  }));
654
- } // top screen
655
- else if (bbox.y < 0 || isVerticallyLarger) {
655
+ } // bottom screen
656
+ else if (bbox.bottom >= containingView.bottom) {
657
+ var _diffY = containingView.bottom - bbox.bottom;
658
+
656
659
  setPosition(Object.assign(Object.assign({}, position), {
657
- y: position.y - bbox.y
660
+ y: position.y + _diffY
658
661
  }));
659
- } // bottom screen
660
- else if (bbox.y + bbox.height >= innerHeight) {
661
- var diffY = innerHeight - bbox.y - bbox.height;
662
- setPosition(Object.assign(Object.assign({}, position), {
663
- y: position.y + diffY
664
- }));
665
- }
662
+ }
663
+ };
664
+ var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
665
+ var onResizeWindow = React__default.useCallback(function () {
666
+ if (!nodeRef.current) return;
667
+ var bbox = nodeRef.current.firstChild.getBoundingClientRect();
668
+ var containingView = nodeRef.current.parentElement.getBoundingClientRect();
669
+ adjustPosition(bbox, containingView, position, setPosition);
666
670
  }, [nodeRef, position, setPosition]);
667
671
  React__default.useEffect(function () {
668
672
  var throttledResize = throttle(onResizeWindow, 100);
@@ -1065,29 +1069,26 @@ var DraggableComponent$1 = function DraggableComponent(_a) {
1065
1069
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1066
1070
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
1067
1071
  * */
1072
+ var isDraggingClassName = 'is-dragging';
1068
1073
 
1069
1074
  var ResizeComponent = function ResizeComponent(_a) {
1070
- var _a$startPosition = _a.startPosition,
1071
- startPosition = _a$startPosition === void 0 ? {
1072
- left: undefined,
1073
- right: undefined,
1074
- top: undefined
1075
- } : _a$startPosition,
1076
- children = _a.children,
1075
+ var children = _a.children,
1077
1076
  _a$onResizeStart = _a.onResizeStart,
1078
1077
  onResizeStart = _a$onResizeStart === void 0 ? function () {} : _a$onResizeStart,
1078
+ _a$onResizeStop = _a.onResizeStop,
1079
+ onResizeStop = _a$onResizeStop === void 0 ? function () {} : _a$onResizeStop,
1079
1080
  size = _a.size,
1080
1081
  setSize = _a.setSize,
1081
1082
  _a$minHeight = _a.minHeight,
1082
1083
  minHeight = _a$minHeight === void 0 ? 50 : _a$minHeight,
1083
1084
  _a$minWidth = _a.minWidth,
1084
1085
  minWidth = _a$minWidth === void 0 ? 50 : _a$minWidth,
1085
- props = __rest(_a, ["startPosition", "children", "onResizeStart", "size", "setSize", "minHeight", "minWidth"]);
1086
+ props = __rest(_a, ["children", "onResizeStart", "onResizeStop", "size", "setSize", "minHeight", "minWidth"]);
1086
1087
 
1087
1088
  var theme = useTheme();
1088
- var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
1089
1089
  var onStartResize = React__default.useCallback(function (event, _direction, node) {
1090
1090
  event.stopPropagation();
1091
+ node.classList.add(isDraggingClassName);
1091
1092
 
1092
1093
  var _node$getBoundingClie = node.getBoundingClientRect(),
1093
1094
  width = _node$getBoundingClie.width,
@@ -1102,32 +1103,42 @@ var ResizeComponent = function ResizeComponent(_a) {
1102
1103
  node.style.height = "".concat(height, "px");
1103
1104
  onResizeStart();
1104
1105
  }, [onResizeStart, setSize]);
1105
- var onResizeStop = React__default.useCallback(function (_event, _direction, _ref, delta) {
1106
+ var onStopResize = React__default.useCallback(function (event, direction, node, delta) {
1107
+ node.classList.remove(isDraggingClassName);
1106
1108
  var width = parseInt(size.width, 10) + delta.width;
1107
1109
  var height = parseInt(size.height, 10) + delta.height;
1108
1110
  setSize({
1109
1111
  width: width,
1110
1112
  height: height
1111
1113
  });
1112
- }, [setSize, size]);
1114
+ onResizeStop(event, direction, node, delta);
1115
+ }, [setSize, onResizeStop, size]);
1113
1116
  return /*#__PURE__*/React__default.createElement(Resizable // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
1114
1117
  , Object.assign({
1115
1118
  // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
1116
1119
  minHeight: minHeight,
1117
1120
  minWidth: minWidth,
1118
1121
  size: size,
1119
- onResizeStop: onResizeStop,
1122
+ onResizeStop: onStopResize,
1120
1123
  handleComponent: {
1121
1124
  bottomRight: /*#__PURE__*/React__default.createElement(Resize, {
1122
1125
  style: {
1123
1126
  fill: "".concat(theme.palette.geowebColors.buttons.flat["default"].color)
1124
- }
1127
+ },
1128
+ sx: {
1129
+ display: 'none'
1130
+ },
1131
+ className: "resizableHandle"
1125
1132
  }),
1126
1133
  bottomLeft: /*#__PURE__*/React__default.createElement(Resize, {
1127
1134
  isRightAligned: true,
1128
1135
  style: {
1129
1136
  fill: "".concat(theme.palette.geowebColors.buttons.flat["default"].color)
1130
- }
1137
+ },
1138
+ sx: {
1139
+ display: 'none'
1140
+ },
1141
+ className: "resizableHandle"
1131
1142
  })
1132
1143
  },
1133
1144
  enable: {
@@ -1136,8 +1147,8 @@ var ResizeComponent = function ResizeComponent(_a) {
1136
1147
  bottom: false,
1137
1148
  left: false,
1138
1149
  topRight: false,
1139
- bottomRight: !isRightAligned,
1140
- bottomLeft: isRightAligned,
1150
+ bottomRight: true,
1151
+ bottomLeft: true,
1141
1152
  topLeft: false
1142
1153
  },
1143
1154
  onResizeStart: onStartResize
@@ -1412,6 +1423,41 @@ var ToolFooter = function ToolFooter() {
1412
1423
  });
1413
1424
  };
1414
1425
 
1426
+ var defaultDelay = 1000;
1427
+ var useControlledTooltip = function useControlledTooltip() {
1428
+ var _React$useState = React.useState(false),
1429
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1430
+ tooltipOpen = _React$useState2[0],
1431
+ setTooltipOpen = _React$useState2[1];
1432
+
1433
+ var _React$useState3 = React.useState(false),
1434
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
1435
+ delayedTooltip = _React$useState4[0],
1436
+ setDelayedTooltip = _React$useState4[1];
1437
+
1438
+ React.useEffect(function () {
1439
+ if (tooltipOpen === true) {
1440
+ var timer = setTimeout(function () {
1441
+ return setDelayedTooltip(true);
1442
+ }, defaultDelay);
1443
+ return function () {
1444
+ clearTimeout(timer);
1445
+ };
1446
+ }
1447
+
1448
+ setDelayedTooltip(false);
1449
+ return function () {};
1450
+ }, [tooltipOpen]);
1451
+ return [delayedTooltip, setTooltipOpen];
1452
+ };
1453
+ var CustomTooltip = function CustomTooltip(props) {
1454
+ return /*#__PURE__*/React.createElement(Tooltip, Object.assign({}, props, {
1455
+ enterDelay: defaultDelay,
1456
+ enterNextDelay: defaultDelay,
1457
+ disableInteractive: true
1458
+ }));
1459
+ };
1460
+
1415
1461
  /* *
1416
1462
  * Licensed under the Apache License, Version 2.0 (the "License");
1417
1463
  * you may not use this file except in compliance with the License.
@@ -1453,7 +1499,8 @@ var getStyle = function getStyle(size) {
1453
1499
  return {
1454
1500
  fontSize: 20,
1455
1501
  fontWeight: 400,
1456
- padding: '8px'
1502
+ padding: '4px 8px',
1503
+ height: 40
1457
1504
  };
1458
1505
  }
1459
1506
 
@@ -1490,31 +1537,37 @@ var ToolHeader = function ToolHeader(_ref) {
1490
1537
  isDraggable = _ref$isDraggable === void 0 ? false : _ref$isDraggable,
1491
1538
  _ref$className = _ref.className,
1492
1539
  className = _ref$className === void 0 ? '' : _ref$className,
1493
- _ref$leftComponent = _ref.leftComponent,
1494
- leftComponent = _ref$leftComponent === void 0 ? null : _ref$leftComponent;
1540
+ _ref$leftHeaderCompon = _ref.leftHeaderComponent,
1541
+ leftHeaderComponent = _ref$leftHeaderCompon === void 0 ? null : _ref$leftHeaderCompon,
1542
+ _ref$rightHeaderCompo = _ref.rightHeaderComponent,
1543
+ rightHeaderComponent = _ref$rightHeaderCompo === void 0 ? null : _ref$rightHeaderCompo;
1495
1544
  var styles = getStyle(size);
1496
- var columnSizeIcon = leftComponent ? 3 : 1;
1497
- var columnSizeTitle = leftComponent ? 6 : 10;
1545
+ var columnSizeIcon = leftHeaderComponent || rightHeaderComponent ? 4 : 1;
1546
+ var columnSizeTitle = leftHeaderComponent || rightHeaderComponent ? 4 : 10;
1498
1547
  return /*#__PURE__*/React__default.createElement(Box, {
1499
1548
  component: "header",
1500
1549
  className: className,
1501
1550
  sx: {
1502
1551
  boxShadow: 1,
1503
1552
  backgroundColor: 'geowebColors.background.surface',
1504
- padding: styles.padding,
1505
1553
  zIndex: 2,
1506
1554
  cursor: isDraggable ? 'move' : null
1507
1555
  }
1508
1556
  }, /*#__PURE__*/React__default.createElement(Grid, {
1509
1557
  container: true,
1510
- alignItems: "center"
1558
+ alignItems: "center",
1559
+ sx: {
1560
+ padding: styles.padding,
1561
+ height: styles.height
1562
+ }
1511
1563
  }, /*#__PURE__*/React__default.createElement(Grid, {
1564
+ className: "header-left",
1512
1565
  item: true,
1513
1566
  xs: columnSizeIcon,
1514
1567
  sx: {
1515
1568
  paddingRight: 1
1516
1569
  }
1517
- }, isDraggable && size !== 'xxs' && !leftComponent && /*#__PURE__*/React__default.createElement(Grid, {
1570
+ }, isDraggable && size !== 'xxs' && !leftHeaderComponent && /*#__PURE__*/React__default.createElement(Grid, {
1518
1571
  container: true,
1519
1572
  justifyContent: "flex-start"
1520
1573
  }, /*#__PURE__*/React__default.createElement(IconButton, {
@@ -1524,7 +1577,8 @@ var ToolHeader = function ToolHeader(_ref) {
1524
1577
  sx: Object.assign(Object.assign({}, iconStyle), {
1525
1578
  pointerEvents: 'none'
1526
1579
  })
1527
- }, /*#__PURE__*/React__default.createElement(DragHandle, null))), leftComponent && leftComponent), /*#__PURE__*/React__default.createElement(Grid, {
1580
+ }, /*#__PURE__*/React__default.createElement(DragHandle, null))), leftHeaderComponent && leftHeaderComponent), /*#__PURE__*/React__default.createElement(Grid, {
1581
+ className: "header-title",
1528
1582
  item: true,
1529
1583
  xs: columnSizeTitle
1530
1584
  }, /*#__PURE__*/React__default.createElement(Grid, {
@@ -1548,11 +1602,12 @@ var ToolHeader = function ToolHeader(_ref) {
1548
1602
  height: 12
1549
1603
  })
1550
1604
  }, /*#__PURE__*/React__default.createElement(DragHandle, null)))), /*#__PURE__*/React__default.createElement(Grid, {
1605
+ className: "header-right",
1551
1606
  item: true,
1552
1607
  xs: columnSizeIcon,
1553
1608
  container: true,
1554
1609
  justifyContent: "flex-end"
1555
- }, onClose && /*#__PURE__*/React__default.createElement(Tooltip, {
1610
+ }, rightHeaderComponent && rightHeaderComponent, onClose && /*#__PURE__*/React__default.createElement(CustomTooltip, {
1556
1611
  title: "Close",
1557
1612
  placement: "bottom",
1558
1613
  sx: {
@@ -1618,9 +1673,11 @@ var ToolContainer = function ToolContainer(_a) {
1618
1673
  elevation = _a$elevation === void 0 ? BASE_ELEVATION : _a$elevation,
1619
1674
  _a$headerClassName = _a.headerClassName,
1620
1675
  headerClassName = _a$headerClassName === void 0 ? '' : _a$headerClassName,
1621
- _a$leftComponent = _a.leftComponent,
1622
- leftComponent = _a$leftComponent === void 0 ? null : _a$leftComponent,
1623
- props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName", "leftComponent"]);
1676
+ _a$leftHeaderComponen = _a.leftHeaderComponent,
1677
+ leftHeaderComponent = _a$leftHeaderComponen === void 0 ? null : _a$leftHeaderComponen,
1678
+ _a$rightHeaderCompone = _a.rightHeaderComponent,
1679
+ rightHeaderComponent = _a$rightHeaderCompone === void 0 ? null : _a$rightHeaderCompone,
1680
+ props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName", "leftHeaderComponent", "rightHeaderComponent"]);
1624
1681
 
1625
1682
  return /*#__PURE__*/React__default.createElement(Paper, Object.assign({
1626
1683
  elevation: elevation,
@@ -1631,7 +1688,8 @@ var ToolContainer = function ToolContainer(_a) {
1631
1688
  isDraggable: isDraggable,
1632
1689
  onClose: onClose,
1633
1690
  className: headerClassName,
1634
- leftComponent: leftComponent
1691
+ leftHeaderComponent: leftHeaderComponent,
1692
+ rightHeaderComponent: rightHeaderComponent
1635
1693
  })), /*#__PURE__*/React__default.createElement(Box, {
1636
1694
  sx: styles$2.content,
1637
1695
  style: {
@@ -1682,16 +1740,27 @@ var DraggableComponent = function DraggableComponent(_a) {
1682
1740
  onChangeSize = _a$onChangeSize === void 0 ? function () {} : _a$onChangeSize,
1683
1741
  _a$onMouseDown = _a.onMouseDown,
1684
1742
  onMouseDown = _a$onMouseDown === void 0 ? function () {} : _a$onMouseDown,
1743
+ _a$onResizeStop = _a.onResizeStop,
1744
+ onResizeStop = _a$onResizeStop === void 0 ? function () {} : _a$onResizeStop,
1745
+ _a$onDragEnd = _a.onDragEnd,
1746
+ onDragEnd = _a$onDragEnd === void 0 ? function () {} : _a$onDragEnd,
1685
1747
  _a$order = _a.order,
1686
1748
  order = _a$order === void 0 ? 1 : _a$order,
1687
1749
  _a$source = _a.source,
1688
1750
  source = _a$source === void 0 ? 'app' : _a$source,
1689
- _a$leftComponent = _a.leftComponent,
1690
- leftComponent = _a$leftComponent === void 0 ? null : _a$leftComponent,
1691
- props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "order", "source", "leftComponent"]);
1751
+ _a$leftHeaderComponen = _a.leftHeaderComponent,
1752
+ leftHeaderComponent = _a$leftHeaderComponen === void 0 ? null : _a$leftHeaderComponen,
1753
+ _a$rightHeaderCompone = _a.rightHeaderComponent,
1754
+ rightHeaderComponent = _a$rightHeaderCompone === void 0 ? null : _a$rightHeaderCompone,
1755
+ _a$hasElevation = _a.hasElevation,
1756
+ hasElevation = _a$hasElevation === void 0 ? true : _a$hasElevation,
1757
+ className = _a.className,
1758
+ _a$sx = _a.sx,
1759
+ sx = _a$sx === void 0 ? {} : _a$sx,
1760
+ props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "hasElevation", "className", "sx"]);
1692
1761
 
1693
1762
  var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
1694
- var elevation = BASE_ELEVATION + order;
1763
+ var elevation = hasElevation ? BASE_ELEVATION + order : 0;
1695
1764
  var nodeRef = React__default.useRef(null);
1696
1765
 
1697
1766
  var _React$useState = React__default.useState({
@@ -1707,20 +1776,28 @@ var DraggableComponent = function DraggableComponent(_a) {
1707
1776
  size = _React$useState4[0],
1708
1777
  setSize = _React$useState4[1];
1709
1778
 
1779
+ var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
1710
1780
  var onStopDrag = React__default.useCallback(function (_event, position) {
1711
1781
  setPosition(position);
1712
- }, [setPosition]);
1782
+ onDragEnd(position, size);
1783
+ }, [setPosition, onDragEnd, size]);
1713
1784
 
1714
1785
  var _React$useState5 = React__default.useState(defaultInitialMaxHeight),
1715
1786
  _React$useState6 = _slicedToArray(_React$useState5, 2),
1716
1787
  initialMaxHeight = _React$useState6[0],
1717
1788
  setInitialMaxHeight = _React$useState6[1];
1718
1789
 
1790
+ var _React$useState7 = React__default.useState(0),
1791
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
1792
+ initialDragPositionX = _React$useState8[0],
1793
+ setInitialDragPositionX = _React$useState8[1];
1794
+
1719
1795
  var onStartResize = function onStartResize() {
1720
1796
  setInitialMaxHeight('initial');
1797
+ setInitialDragPositionX(position.x);
1721
1798
  };
1722
1799
 
1723
- var onResize = React__default.useCallback(function (_event, _handle, node) {
1800
+ var onResize = React__default.useCallback(function (_event, _handle, node, delta) {
1724
1801
  var _node$getBoundingClie = node.getBoundingClientRect(),
1725
1802
  width = _node$getBoundingClie.width,
1726
1803
  height = _node$getBoundingClie.height;
@@ -1728,11 +1805,74 @@ var DraggableComponent = function DraggableComponent(_a) {
1728
1805
  onChangeSize({
1729
1806
  width: width,
1730
1807
  height: height
1731
- });
1732
- }, [onChangeSize]);
1808
+ }); // If dragging the same side as alignment, adjust position
1809
+
1810
+ if (isRightAligned && _handle === 'bottomRight') {
1811
+ var newX = initialDragPositionX + delta.width; // eslint-disable-next-line no-param-reassign
1812
+
1813
+ node.parentNode.style.transform = "translate(".concat(newX, "px, ").concat(position.y, "px)");
1814
+ } else if (!isRightAligned && _handle === 'bottomLeft') {
1815
+ var _newX = initialDragPositionX - delta.width; // eslint-disable-next-line no-param-reassign
1816
+
1817
+
1818
+ node.parentNode.style.transform = "translate(".concat(_newX, "px, ").concat(position.y, "px)");
1819
+ }
1820
+ }, [onChangeSize, initialDragPositionX, isRightAligned, position]);
1821
+
1822
+ var onStopResize = function onStopResize(_event, direction, node, delta) {
1823
+ if (isRightAligned && direction === 'bottomRight') {
1824
+ setPosition({
1825
+ x: initialDragPositionX + delta.width,
1826
+ y: position.y
1827
+ });
1828
+ } else if (!isRightAligned && direction === 'bottomLeft') {
1829
+ setPosition({
1830
+ x: initialDragPositionX - delta.width,
1831
+ y: position.y
1832
+ });
1833
+ }
1834
+
1835
+ onResizeStop(_event, direction, node, delta);
1836
+ };
1837
+
1733
1838
  useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
1734
1839
  var toolcontainerId = React__default.useRef(Date.now().toString()).current;
1735
- var headerClassName = "header-".concat(toolcontainerId);
1840
+ 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]);
1736
1876
  return isOpen ? /*#__PURE__*/React__default.createElement(DraggableComponent$1, {
1737
1877
  nodeRef: nodeRef,
1738
1878
  bounds: bounds,
@@ -1740,18 +1880,23 @@ var DraggableComponent = function DraggableComponent(_a) {
1740
1880
  onStop: onStopDrag,
1741
1881
  handle: ".".concat(headerClassName),
1742
1882
  onMouseDown: onMouseDown
1743
- }, /*#__PURE__*/React__default.createElement("div", {
1744
- style: Object.assign({
1883
+ }, /*#__PURE__*/React__default.createElement(Box, {
1884
+ sx: Object.assign(Object.assign(Object.assign({
1745
1885
  position: 'absolute',
1746
1886
  pointerEvents: 'all',
1747
1887
  zIndex: zIndex
1748
- }, startPosition),
1749
- ref: nodeRef
1888
+ }, startPosition), sx), {
1889
+ '&:hover .resizableHandle': {
1890
+ display: 'inline'
1891
+ }
1892
+ }),
1893
+ ref: nodeRef,
1894
+ className: "toolContainerDraggable"
1750
1895
  }, /*#__PURE__*/React__default.createElement(ResizeComponent, Object.assign({}, props, {
1751
- startPosition: startPosition,
1752
1896
  size: size,
1753
1897
  setSize: setSize,
1754
1898
  onResizeStart: onStartResize,
1899
+ onResizeStop: onStopResize,
1755
1900
  onResize: onResize
1756
1901
  }), /*#__PURE__*/React__default.createElement(ToolContainer, {
1757
1902
  maxHeight: initialMaxHeight,
@@ -1762,7 +1907,9 @@ var DraggableComponent = function DraggableComponent(_a) {
1762
1907
  isResizable: true,
1763
1908
  elevation: elevation,
1764
1909
  headerClassName: headerClassName,
1765
- leftComponent: leftComponent
1910
+ leftHeaderComponent: leftHeaderComponent,
1911
+ rightHeaderComponent: rightHeaderComponent,
1912
+ className: className
1766
1913
  }, children)))) : null;
1767
1914
  };
1768
1915
 
@@ -2434,7 +2581,7 @@ var ToggleMenu = function ToggleMenu(_ref) {
2434
2581
  setAnchorEl(document.getElementById(buttonTestId));
2435
2582
  }
2436
2583
  }, [isDefaultOpen, buttonTestId]);
2437
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
2584
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomTooltip, {
2438
2585
  placement: "top",
2439
2586
  title: tooltipTitle
2440
2587
  }, /*#__PURE__*/React.createElement(ToolButton, {
@@ -2497,7 +2644,8 @@ var makeButtonStyles = function makeButtonStyles(isActive, isEnabled, isAccessib
2497
2644
  height: '24px',
2498
2645
  width: '24px',
2499
2646
  borderRadius: '5px',
2500
- marginTop: '4px',
2647
+ marginTop: 'auto',
2648
+ marginBottom: 'auto',
2501
2649
  color: function color() {
2502
2650
  if (!isEnabled) {
2503
2651
  return 'geowebColors.buttons.flat.disabled.color';
@@ -2545,7 +2693,8 @@ var ManagerButton = function ManagerButton(_a) {
2545
2693
  _a$isAccessible = _a.isAccessible,
2546
2694
  isAccessible = _a$isAccessible === void 0 ? false : _a$isAccessible,
2547
2695
  sx = _a.sx,
2548
- props = __rest(_a, ["tooltipTitle", "onClick", "isActive", "isEnabled", "icon", "testId", "isAccessible", "sx"]);
2696
+ children = _a.children,
2697
+ props = __rest(_a, ["tooltipTitle", "onClick", "isActive", "isEnabled", "icon", "testId", "isAccessible", "sx", "children"]);
2549
2698
 
2550
2699
  var buttonStyles = makeButtonStyles(isActive, isEnabled, isAccessible);
2551
2700
 
@@ -2553,13 +2702,13 @@ var ManagerButton = function ManagerButton(_a) {
2553
2702
  onClick(event);
2554
2703
  };
2555
2704
 
2556
- return /*#__PURE__*/React.createElement(Tooltip, {
2705
+ return /*#__PURE__*/React.createElement(CustomTooltip, {
2557
2706
  title: tooltipTitle,
2558
2707
  placement: "top",
2559
2708
  sx: {
2560
2709
  pointerEvents: 'none'
2561
2710
  }
2562
- }, /*#__PURE__*/React.createElement(IconButton, Object.assign({
2711
+ }, children || /*#__PURE__*/React.createElement(IconButton, Object.assign({
2563
2712
  size: "small",
2564
2713
  onClick: handleClick,
2565
2714
  "data-testid": testId,
@@ -2589,13 +2738,27 @@ var ManagerDeleteButton = function ManagerDeleteButton(_ref) {
2589
2738
  onClickDelete = _ref.onClickDelete,
2590
2739
  _ref$isEnabled = _ref.isEnabled,
2591
2740
  isEnabled = _ref$isEnabled === void 0 ? true : _ref$isEnabled;
2592
- return /*#__PURE__*/React.createElement(ManagerButton, {
2741
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ManagerButton, {
2742
+ tooltipTitle: tooltipTitle,
2743
+ onClick: onClickDelete,
2744
+ testId: "deleteButtonMedium",
2745
+ isEnabled: isEnabled,
2746
+ icon: /*#__PURE__*/React.createElement(Delete, null)
2747
+ }, /*#__PURE__*/React.createElement(Button, {
2748
+ className: "deleteBtnMedium",
2749
+ variant: "tertiary",
2750
+ onClick: onClickDelete,
2751
+ startIcon: /*#__PURE__*/React.createElement(Delete, null),
2752
+ sx: {
2753
+ display: 'none'
2754
+ }
2755
+ }, "Delete")), /*#__PURE__*/React.createElement(ManagerButton, {
2593
2756
  tooltipTitle: tooltipTitle,
2594
2757
  onClick: onClickDelete,
2595
2758
  icon: /*#__PURE__*/React.createElement(Delete, null),
2596
2759
  testId: "deleteButton",
2597
2760
  isEnabled: isEnabled
2598
- });
2761
+ }));
2599
2762
  };
2600
2763
 
2601
2764
  /* *
@@ -2617,9 +2780,13 @@ var ManagerDeleteButton = function ManagerDeleteButton(_ref) {
2617
2780
  var EnableButton = function EnableButton(_ref) {
2618
2781
  var isEnabled = _ref.isEnabled,
2619
2782
  title = _ref.title,
2620
- onChangeEnableLayer = _ref.onChangeEnableLayer;
2783
+ onChangeEnableLayer = _ref.onChangeEnableLayer,
2784
+ className = _ref.className,
2785
+ _ref$id = _ref.id,
2786
+ id = _ref$id === void 0 ? 'enableButton' : _ref$id;
2621
2787
 
2622
- var onClick = function onClick() {
2788
+ var onClick = function onClick(event) {
2789
+ event.stopPropagation();
2623
2790
  onChangeEnableLayer(!isEnabled);
2624
2791
  };
2625
2792
 
@@ -2647,8 +2814,9 @@ var EnableButton = function EnableButton(_ref) {
2647
2814
  disableFocusRipple: true,
2648
2815
  tabIndex: -1
2649
2816
  }),
2650
- testId: "enableButton",
2651
- isEnabled: isEnabled
2817
+ testId: id,
2818
+ isEnabled: isEnabled,
2819
+ className: className
2652
2820
  });
2653
2821
  };
2654
2822
 
@@ -2694,11 +2862,6 @@ var tooltipContainerStyles = function tooltipContainerStyles(isEnabled) {
2694
2862
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2695
2863
  }
2696
2864
  },
2697
- '&:focus&.MuiButton-root': {
2698
- outline: function outline(theme) {
2699
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2700
- }
2701
- },
2702
2865
  '& .MuiSvgIcon-root': {
2703
2866
  transition: 'none',
2704
2867
  fill: function fill(theme) {
@@ -2724,10 +2887,11 @@ var backgroundColor = {
2724
2887
  backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2725
2888
  },
2726
2889
  '&:focus&.MuiButton-root': {
2727
- outline: function outline(theme) {
2890
+ border: function border(theme) {
2728
2891
  return theme.palette.geowebColors.buttons.focusDefault.outline;
2729
2892
  },
2730
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2893
+ backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2894
+ transition: 'border'
2731
2895
  }
2732
2896
  };
2733
2897
 
@@ -2754,10 +2918,10 @@ var TooltipSelect = function TooltipSelect(_a) {
2754
2918
  selectOpen = _React$useState2[0],
2755
2919
  setSelectOpen = _React$useState2[1];
2756
2920
 
2757
- var _React$useState3 = React.useState(false),
2758
- _React$useState4 = _slicedToArray(_React$useState3, 2),
2759
- tooltipOpen = _React$useState4[0],
2760
- setTooltipOpen = _React$useState4[1];
2921
+ var _useControlledTooltip = useControlledTooltip(),
2922
+ _useControlledTooltip2 = _slicedToArray(_useControlledTooltip, 2),
2923
+ tooltipOpen = _useControlledTooltip2[0],
2924
+ setTooltipOpen = _useControlledTooltip2[1];
2761
2925
 
2762
2926
  var onWheel = React.useCallback(function (event) {
2763
2927
  if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
@@ -2770,23 +2934,23 @@ var TooltipSelect = function TooltipSelect(_a) {
2770
2934
  var onOpen = React.useCallback(function () {
2771
2935
  setSelectOpen(true);
2772
2936
  setTooltipOpen(false);
2773
- }, []);
2937
+ }, [setTooltipOpen]);
2774
2938
  var onClose = React.useCallback(function () {
2775
2939
  setSelectOpen(false);
2776
2940
  }, []);
2777
2941
  var onMouseEnter = React.useCallback(function () {
2778
2942
  if (!selectOpen) setTooltipOpen(true);
2779
- }, [selectOpen]);
2943
+ }, [selectOpen, setTooltipOpen]);
2780
2944
  var onMouseLeave = React.useCallback(function () {
2781
2945
  setTooltipOpen(false);
2782
- }, []);
2946
+ }, [setTooltipOpen]);
2783
2947
  var onFocus = React.useCallback(function () {
2784
2948
  setTooltipOpen(true);
2785
- }, []);
2949
+ }, [setTooltipOpen]);
2786
2950
  var onBlur = React.useCallback(function () {
2787
2951
  setTooltipOpen(false);
2788
- }, []);
2789
- return /*#__PURE__*/React.createElement(Tooltip, {
2952
+ }, [setTooltipOpen]);
2953
+ return /*#__PURE__*/React.createElement(CustomTooltip, {
2790
2954
  title: tooltip,
2791
2955
  placement: "top",
2792
2956
  open: tooltipOpen,
@@ -2867,6 +3031,44 @@ function withEggs(eggs) {
2867
3031
  };
2868
3032
  }
2869
3033
 
3034
+ var CustomAccordion = function CustomAccordion(_a) {
3035
+ var title = _a.title,
3036
+ _a$defaultExpanded = _a.defaultExpanded,
3037
+ defaultExpanded = _a$defaultExpanded === void 0 ? true : _a$defaultExpanded,
3038
+ _a$disableGutters = _a.disableGutters,
3039
+ disableGutters = _a$disableGutters === void 0 ? true : _a$disableGutters,
3040
+ _a$expandedElevation = _a.expandedElevation,
3041
+ expandedElevation = _a$expandedElevation === void 0 ? 3 : _a$expandedElevation,
3042
+ _a$collapsedElevation = _a.collapsedElevation,
3043
+ collapsedElevation = _a$collapsedElevation === void 0 ? 0 : _a$collapsedElevation,
3044
+ _a$transitionDuration = _a.transitionDuration,
3045
+ transitionDuration = _a$transitionDuration === void 0 ? 150 : _a$transitionDuration,
3046
+ detailsSx = _a.detailsSx,
3047
+ children = _a.children,
3048
+ props = __rest(_a, ["title", "defaultExpanded", "disableGutters", "expandedElevation", "collapsedElevation", "transitionDuration", "detailsSx", "children"]);
3049
+
3050
+ var _React$useState = React.useState(defaultExpanded),
3051
+ _React$useState2 = _slicedToArray(_React$useState, 2),
3052
+ expanded = _React$useState2[0],
3053
+ setExpanded = _React$useState2[1];
3054
+
3055
+ return /*#__PURE__*/React.createElement(Accordion, Object.assign({}, props, {
3056
+ defaultExpanded: defaultExpanded,
3057
+ elevation: expanded ? expandedElevation : collapsedElevation,
3058
+ onChange: function onChange(_event, expanded) {
3059
+ return setExpanded(expanded);
3060
+ },
3061
+ disableGutters: disableGutters,
3062
+ TransitionProps: {
3063
+ timeout: transitionDuration
3064
+ }
3065
+ }), /*#__PURE__*/React.createElement(AccordionSummary, {
3066
+ expandIcon: /*#__PURE__*/React.createElement(ChevronDown, null)
3067
+ }, title), /*#__PURE__*/React.createElement(AccordionDetails, {
3068
+ sx: detailsSx
3069
+ }, children));
3070
+ };
3071
+
2870
3072
  /* *
2871
3073
  * Licensed under the Apache License, Version 2.0 (the "License");
2872
3074
  * you may not use this file except in compliance with the License.
@@ -2929,4 +3131,24 @@ var getWarningMessage = function getWarningMessage(error) {
2929
3131
  return '';
2930
3132
  };
2931
3133
 
2932
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, CustomToggleButton, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, calculateDialogSizeAndPosition, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };
3134
+ /* *
3135
+ * Licensed under the Apache License, Version 2.0 (the "License");
3136
+ * you may not use this file except in compliance with the License.
3137
+ * You may obtain a copy of the License at
3138
+ *
3139
+ * http://www.apache.org/licenses/LICENSE-2.0
3140
+ *
3141
+ * Unless required by applicable law or agreed to in writing, software
3142
+ * distributed under the License is distributed on an "AS IS" BASIS,
3143
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3144
+ * See the License for the specific language governing permissions and
3145
+ * limitations under the License.
3146
+ *
3147
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3148
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
3149
+ * */
3150
+ // TODO: https://gitlab.com/opengeoweb/geoweb-assets/-/issues/2350
3151
+ // temporary check until we get the unit test passing with container queries
3152
+ var IS_JEST = typeof jest !== 'undefined';
3153
+
3154
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomAccordion, CustomSlider, CustomToggleButton, CustomTooltip, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, IS_JEST, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, adjustPosition, calculateDialogSizeAndPosition, defaultDelay, getAxiosErrorMessage, getAxiosWarningMessage, getErrorMessage, getInitials, getPosition, getWarningMessage, isAxiosError, showPrompt, sliderHeaderStyle, tooltipContainerStyles, useConfirmationDialog, useControlledTooltip, useDialogActions, useDraftFormHelpers, useIsMounted, useMakeSureContainerStaysInsideWindow, usePoller, usePreventBrowserClose, usePrevious, useUserMenu, withEggs };