@opengeoweb/shared 4.4.0 → 4.6.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 +480 -115
- package/index.umd.js +483 -122
- package/lib/components/CustomAccordion/CustomAccordion.d.ts +10 -0
- package/lib/components/CustomAccordion/CustomAccordion.spec.d.ts +1 -0
- package/lib/components/CustomAccordion/CustomAccordion.stories.d.ts +13 -0
- package/lib/components/CustomAccordion/index.d.ts +1 -0
- package/lib/components/CustomTooltip/CustomTooltip.d.ts +8 -0
- package/lib/components/CustomTooltip/CustomTooltip.spec.d.ts +1 -0
- package/lib/components/CustomTooltip/index.d.ts +1 -0
- package/lib/components/DraggableResizable/Resizable.d.ts +1 -0
- package/lib/components/DraggableResizable/types.d.ts +1 -3
- package/lib/components/EnableButton/EnableButton.d.ts +2 -0
- package/lib/components/ManagerButton/ManagerButton.d.ts +1 -0
- package/lib/components/ToolContainer/ToolContainerDraggable.d.ts +9 -2
- package/lib/components/ToolContainer/types.d.ts +2 -1
- package/lib/components/ToolContainer/useHandleSizeFromOutsideComponent.d.ts +33 -0
- package/lib/components/ToolContainer/useHandleSizeFromOutsideComponent.spec.d.ts +1 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.d.ts +1 -0
- package/lib/utils/containerQueryHelper.d.ts +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/package.json +3 -3
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,64 @@ 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
|
|
634
|
-
var
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
var
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
633
|
+
var adjustPosition = function adjustPosition(bbox, containingView, position, setPosition) {
|
|
634
|
+
var isHorizontallyLarger = bbox.width > containingView.width;
|
|
635
|
+
var isVerticallyLarger = bbox.height > containingView.height; // Check corner cases first
|
|
636
|
+
// bottom left
|
|
637
|
+
|
|
638
|
+
if (bbox.x < containingView.x && bbox.bottom >= containingView.bottom) {
|
|
639
|
+
var diffX = containingView.x - bbox.x;
|
|
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) {
|
|
647
|
+
var _diffX = containingView.right - bbox.right;
|
|
648
|
+
|
|
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
|
+
|
|
651
659
|
setPosition(Object.assign(Object.assign({}, position), {
|
|
652
|
-
x: position.x +
|
|
660
|
+
x: position.x + _diffX2
|
|
653
661
|
}));
|
|
654
|
-
} //
|
|
655
|
-
else if (bbox.
|
|
662
|
+
} // right screen
|
|
663
|
+
else if (bbox.right >= containingView.right) {
|
|
664
|
+
var _diffX3 = containingView.right - bbox.right;
|
|
665
|
+
|
|
656
666
|
setPosition(Object.assign(Object.assign({}, position), {
|
|
657
|
-
|
|
667
|
+
x: position.x + _diffX3
|
|
658
668
|
}));
|
|
659
|
-
} //
|
|
660
|
-
else if (bbox.y
|
|
661
|
-
var
|
|
669
|
+
} // top screen
|
|
670
|
+
else if (bbox.y < containingView.y || isVerticallyLarger) {
|
|
671
|
+
var _diffY2 = containingView.y - bbox.y;
|
|
672
|
+
|
|
662
673
|
setPosition(Object.assign(Object.assign({}, position), {
|
|
663
|
-
y: position.y +
|
|
674
|
+
y: position.y + _diffY2
|
|
664
675
|
}));
|
|
665
|
-
}
|
|
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
|
+
}
|
|
684
|
+
};
|
|
685
|
+
var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
|
|
686
|
+
var onResizeWindow = React__default.useCallback(function () {
|
|
687
|
+
if (!nodeRef.current) return;
|
|
688
|
+
var bbox = nodeRef.current.firstChild.getBoundingClientRect();
|
|
689
|
+
var containingView = nodeRef.current.parentElement.getBoundingClientRect();
|
|
690
|
+
adjustPosition(bbox, containingView, position, setPosition);
|
|
666
691
|
}, [nodeRef, position, setPosition]);
|
|
667
692
|
React__default.useEffect(function () {
|
|
668
693
|
var throttledResize = throttle(onResizeWindow, 100);
|
|
@@ -1065,29 +1090,26 @@ var DraggableComponent$1 = function DraggableComponent(_a) {
|
|
|
1065
1090
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
1066
1091
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
1067
1092
|
* */
|
|
1093
|
+
var isDraggingClassName = 'is-dragging';
|
|
1068
1094
|
|
|
1069
1095
|
var ResizeComponent = function ResizeComponent(_a) {
|
|
1070
|
-
var
|
|
1071
|
-
startPosition = _a$startPosition === void 0 ? {
|
|
1072
|
-
left: undefined,
|
|
1073
|
-
right: undefined,
|
|
1074
|
-
top: undefined
|
|
1075
|
-
} : _a$startPosition,
|
|
1076
|
-
children = _a.children,
|
|
1096
|
+
var children = _a.children,
|
|
1077
1097
|
_a$onResizeStart = _a.onResizeStart,
|
|
1078
1098
|
onResizeStart = _a$onResizeStart === void 0 ? function () {} : _a$onResizeStart,
|
|
1099
|
+
_a$onResizeStop = _a.onResizeStop,
|
|
1100
|
+
onResizeStop = _a$onResizeStop === void 0 ? function () {} : _a$onResizeStop,
|
|
1079
1101
|
size = _a.size,
|
|
1080
1102
|
setSize = _a.setSize,
|
|
1081
1103
|
_a$minHeight = _a.minHeight,
|
|
1082
1104
|
minHeight = _a$minHeight === void 0 ? 50 : _a$minHeight,
|
|
1083
1105
|
_a$minWidth = _a.minWidth,
|
|
1084
1106
|
minWidth = _a$minWidth === void 0 ? 50 : _a$minWidth,
|
|
1085
|
-
props = __rest(_a, ["
|
|
1107
|
+
props = __rest(_a, ["children", "onResizeStart", "onResizeStop", "size", "setSize", "minHeight", "minWidth"]);
|
|
1086
1108
|
|
|
1087
1109
|
var theme = useTheme();
|
|
1088
|
-
var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
|
|
1089
1110
|
var onStartResize = React__default.useCallback(function (event, _direction, node) {
|
|
1090
1111
|
event.stopPropagation();
|
|
1112
|
+
node.classList.add(isDraggingClassName);
|
|
1091
1113
|
|
|
1092
1114
|
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1093
1115
|
width = _node$getBoundingClie.width,
|
|
@@ -1102,32 +1124,42 @@ var ResizeComponent = function ResizeComponent(_a) {
|
|
|
1102
1124
|
node.style.height = "".concat(height, "px");
|
|
1103
1125
|
onResizeStart();
|
|
1104
1126
|
}, [onResizeStart, setSize]);
|
|
1105
|
-
var
|
|
1127
|
+
var onStopResize = React__default.useCallback(function (event, direction, node, delta) {
|
|
1128
|
+
node.classList.remove(isDraggingClassName);
|
|
1106
1129
|
var width = parseInt(size.width, 10) + delta.width;
|
|
1107
1130
|
var height = parseInt(size.height, 10) + delta.height;
|
|
1108
1131
|
setSize({
|
|
1109
1132
|
width: width,
|
|
1110
1133
|
height: height
|
|
1111
1134
|
});
|
|
1112
|
-
|
|
1135
|
+
onResizeStop(event, direction, node, delta);
|
|
1136
|
+
}, [setSize, onResizeStop, size]);
|
|
1113
1137
|
return /*#__PURE__*/React__default.createElement(Resizable // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
|
|
1114
1138
|
, Object.assign({
|
|
1115
1139
|
// TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
|
|
1116
1140
|
minHeight: minHeight,
|
|
1117
1141
|
minWidth: minWidth,
|
|
1118
1142
|
size: size,
|
|
1119
|
-
onResizeStop:
|
|
1143
|
+
onResizeStop: onStopResize,
|
|
1120
1144
|
handleComponent: {
|
|
1121
1145
|
bottomRight: /*#__PURE__*/React__default.createElement(Resize, {
|
|
1122
1146
|
style: {
|
|
1123
1147
|
fill: "".concat(theme.palette.geowebColors.buttons.flat["default"].color)
|
|
1124
|
-
}
|
|
1148
|
+
},
|
|
1149
|
+
sx: {
|
|
1150
|
+
display: 'none'
|
|
1151
|
+
},
|
|
1152
|
+
className: "resizableHandle"
|
|
1125
1153
|
}),
|
|
1126
1154
|
bottomLeft: /*#__PURE__*/React__default.createElement(Resize, {
|
|
1127
1155
|
isRightAligned: true,
|
|
1128
1156
|
style: {
|
|
1129
1157
|
fill: "".concat(theme.palette.geowebColors.buttons.flat["default"].color)
|
|
1130
|
-
}
|
|
1158
|
+
},
|
|
1159
|
+
sx: {
|
|
1160
|
+
display: 'none'
|
|
1161
|
+
},
|
|
1162
|
+
className: "resizableHandle"
|
|
1131
1163
|
})
|
|
1132
1164
|
},
|
|
1133
1165
|
enable: {
|
|
@@ -1136,8 +1168,8 @@ var ResizeComponent = function ResizeComponent(_a) {
|
|
|
1136
1168
|
bottom: false,
|
|
1137
1169
|
left: false,
|
|
1138
1170
|
topRight: false,
|
|
1139
|
-
bottomRight:
|
|
1140
|
-
bottomLeft:
|
|
1171
|
+
bottomRight: true,
|
|
1172
|
+
bottomLeft: true,
|
|
1141
1173
|
topLeft: false
|
|
1142
1174
|
},
|
|
1143
1175
|
onResizeStart: onStartResize
|
|
@@ -1412,6 +1444,41 @@ var ToolFooter = function ToolFooter() {
|
|
|
1412
1444
|
});
|
|
1413
1445
|
};
|
|
1414
1446
|
|
|
1447
|
+
var defaultDelay = 1000;
|
|
1448
|
+
var useControlledTooltip = function useControlledTooltip() {
|
|
1449
|
+
var _React$useState = React.useState(false),
|
|
1450
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
1451
|
+
tooltipOpen = _React$useState2[0],
|
|
1452
|
+
setTooltipOpen = _React$useState2[1];
|
|
1453
|
+
|
|
1454
|
+
var _React$useState3 = React.useState(false),
|
|
1455
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
1456
|
+
delayedTooltip = _React$useState4[0],
|
|
1457
|
+
setDelayedTooltip = _React$useState4[1];
|
|
1458
|
+
|
|
1459
|
+
React.useEffect(function () {
|
|
1460
|
+
if (tooltipOpen === true) {
|
|
1461
|
+
var timer = setTimeout(function () {
|
|
1462
|
+
return setDelayedTooltip(true);
|
|
1463
|
+
}, defaultDelay);
|
|
1464
|
+
return function () {
|
|
1465
|
+
clearTimeout(timer);
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
setDelayedTooltip(false);
|
|
1470
|
+
return function () {};
|
|
1471
|
+
}, [tooltipOpen]);
|
|
1472
|
+
return [delayedTooltip, setTooltipOpen];
|
|
1473
|
+
};
|
|
1474
|
+
var CustomTooltip = function CustomTooltip(props) {
|
|
1475
|
+
return /*#__PURE__*/React.createElement(Tooltip, Object.assign({}, props, {
|
|
1476
|
+
enterDelay: defaultDelay,
|
|
1477
|
+
enterNextDelay: defaultDelay,
|
|
1478
|
+
disableInteractive: true
|
|
1479
|
+
}));
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1415
1482
|
/* *
|
|
1416
1483
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1417
1484
|
* you may not use this file except in compliance with the License.
|
|
@@ -1453,7 +1520,8 @@ var getStyle = function getStyle(size) {
|
|
|
1453
1520
|
return {
|
|
1454
1521
|
fontSize: 20,
|
|
1455
1522
|
fontWeight: 400,
|
|
1456
|
-
padding: '8px'
|
|
1523
|
+
padding: '4px 8px',
|
|
1524
|
+
height: 40
|
|
1457
1525
|
};
|
|
1458
1526
|
}
|
|
1459
1527
|
|
|
@@ -1490,31 +1558,37 @@ var ToolHeader = function ToolHeader(_ref) {
|
|
|
1490
1558
|
isDraggable = _ref$isDraggable === void 0 ? false : _ref$isDraggable,
|
|
1491
1559
|
_ref$className = _ref.className,
|
|
1492
1560
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1493
|
-
_ref$
|
|
1494
|
-
|
|
1561
|
+
_ref$leftHeaderCompon = _ref.leftHeaderComponent,
|
|
1562
|
+
leftHeaderComponent = _ref$leftHeaderCompon === void 0 ? null : _ref$leftHeaderCompon,
|
|
1563
|
+
_ref$rightHeaderCompo = _ref.rightHeaderComponent,
|
|
1564
|
+
rightHeaderComponent = _ref$rightHeaderCompo === void 0 ? null : _ref$rightHeaderCompo;
|
|
1495
1565
|
var styles = getStyle(size);
|
|
1496
|
-
var columnSizeIcon =
|
|
1497
|
-
var columnSizeTitle =
|
|
1566
|
+
var columnSizeIcon = leftHeaderComponent || rightHeaderComponent ? 4 : 1;
|
|
1567
|
+
var columnSizeTitle = leftHeaderComponent || rightHeaderComponent ? 4 : 10;
|
|
1498
1568
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
1499
1569
|
component: "header",
|
|
1500
1570
|
className: className,
|
|
1501
1571
|
sx: {
|
|
1502
1572
|
boxShadow: 1,
|
|
1503
1573
|
backgroundColor: 'geowebColors.background.surface',
|
|
1504
|
-
padding: styles.padding,
|
|
1505
1574
|
zIndex: 2,
|
|
1506
1575
|
cursor: isDraggable ? 'move' : null
|
|
1507
1576
|
}
|
|
1508
1577
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
1509
1578
|
container: true,
|
|
1510
|
-
alignItems: "center"
|
|
1579
|
+
alignItems: "center",
|
|
1580
|
+
sx: {
|
|
1581
|
+
padding: styles.padding,
|
|
1582
|
+
height: styles.height
|
|
1583
|
+
}
|
|
1511
1584
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
1585
|
+
className: "header-left",
|
|
1512
1586
|
item: true,
|
|
1513
1587
|
xs: columnSizeIcon,
|
|
1514
1588
|
sx: {
|
|
1515
1589
|
paddingRight: 1
|
|
1516
1590
|
}
|
|
1517
|
-
}, isDraggable && size !== 'xxs' && !
|
|
1591
|
+
}, isDraggable && size !== 'xxs' && !leftHeaderComponent && /*#__PURE__*/React__default.createElement(Grid, {
|
|
1518
1592
|
container: true,
|
|
1519
1593
|
justifyContent: "flex-start"
|
|
1520
1594
|
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
@@ -1524,7 +1598,8 @@ var ToolHeader = function ToolHeader(_ref) {
|
|
|
1524
1598
|
sx: Object.assign(Object.assign({}, iconStyle), {
|
|
1525
1599
|
pointerEvents: 'none'
|
|
1526
1600
|
})
|
|
1527
|
-
}, /*#__PURE__*/React__default.createElement(DragHandle, null))),
|
|
1601
|
+
}, /*#__PURE__*/React__default.createElement(DragHandle, null))), leftHeaderComponent && leftHeaderComponent), /*#__PURE__*/React__default.createElement(Grid, {
|
|
1602
|
+
className: "header-title",
|
|
1528
1603
|
item: true,
|
|
1529
1604
|
xs: columnSizeTitle
|
|
1530
1605
|
}, /*#__PURE__*/React__default.createElement(Grid, {
|
|
@@ -1548,11 +1623,12 @@ var ToolHeader = function ToolHeader(_ref) {
|
|
|
1548
1623
|
height: 12
|
|
1549
1624
|
})
|
|
1550
1625
|
}, /*#__PURE__*/React__default.createElement(DragHandle, null)))), /*#__PURE__*/React__default.createElement(Grid, {
|
|
1626
|
+
className: "header-right",
|
|
1551
1627
|
item: true,
|
|
1552
1628
|
xs: columnSizeIcon,
|
|
1553
1629
|
container: true,
|
|
1554
1630
|
justifyContent: "flex-end"
|
|
1555
|
-
}, onClose && /*#__PURE__*/React__default.createElement(
|
|
1631
|
+
}, rightHeaderComponent && rightHeaderComponent, onClose && /*#__PURE__*/React__default.createElement(CustomTooltip, {
|
|
1556
1632
|
title: "Close",
|
|
1557
1633
|
placement: "bottom",
|
|
1558
1634
|
sx: {
|
|
@@ -1618,9 +1694,11 @@ var ToolContainer = function ToolContainer(_a) {
|
|
|
1618
1694
|
elevation = _a$elevation === void 0 ? BASE_ELEVATION : _a$elevation,
|
|
1619
1695
|
_a$headerClassName = _a.headerClassName,
|
|
1620
1696
|
headerClassName = _a$headerClassName === void 0 ? '' : _a$headerClassName,
|
|
1621
|
-
_a$
|
|
1622
|
-
|
|
1623
|
-
|
|
1697
|
+
_a$leftHeaderComponen = _a.leftHeaderComponent,
|
|
1698
|
+
leftHeaderComponent = _a$leftHeaderComponen === void 0 ? null : _a$leftHeaderComponen,
|
|
1699
|
+
_a$rightHeaderCompone = _a.rightHeaderComponent,
|
|
1700
|
+
rightHeaderComponent = _a$rightHeaderCompone === void 0 ? null : _a$rightHeaderCompone,
|
|
1701
|
+
props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName", "leftHeaderComponent", "rightHeaderComponent"]);
|
|
1624
1702
|
|
|
1625
1703
|
return /*#__PURE__*/React__default.createElement(Paper, Object.assign({
|
|
1626
1704
|
elevation: elevation,
|
|
@@ -1631,7 +1709,8 @@ var ToolContainer = function ToolContainer(_a) {
|
|
|
1631
1709
|
isDraggable: isDraggable,
|
|
1632
1710
|
onClose: onClose,
|
|
1633
1711
|
className: headerClassName,
|
|
1634
|
-
|
|
1712
|
+
leftHeaderComponent: leftHeaderComponent,
|
|
1713
|
+
rightHeaderComponent: rightHeaderComponent
|
|
1635
1714
|
})), /*#__PURE__*/React__default.createElement(Box, {
|
|
1636
1715
|
sx: styles$2.content,
|
|
1637
1716
|
style: {
|
|
@@ -1640,6 +1719,151 @@ var ToolContainer = function ToolContainer(_a) {
|
|
|
1640
1719
|
}, children), isResizable && /*#__PURE__*/React__default.createElement(ToolFooter, null));
|
|
1641
1720
|
};
|
|
1642
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
|
+
|
|
1643
1867
|
var calculateDialogSizeAndPosition = function calculateDialogSizeAndPosition() {
|
|
1644
1868
|
var width = window.innerWidth * 0.85;
|
|
1645
1869
|
var height = window.innerHeight * 0.85;
|
|
@@ -1682,16 +1906,27 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1682
1906
|
onChangeSize = _a$onChangeSize === void 0 ? function () {} : _a$onChangeSize,
|
|
1683
1907
|
_a$onMouseDown = _a.onMouseDown,
|
|
1684
1908
|
onMouseDown = _a$onMouseDown === void 0 ? function () {} : _a$onMouseDown,
|
|
1909
|
+
_a$onResizeStop = _a.onResizeStop,
|
|
1910
|
+
onResizeStop = _a$onResizeStop === void 0 ? function () {} : _a$onResizeStop,
|
|
1911
|
+
_a$onDragEnd = _a.onDragEnd,
|
|
1912
|
+
onDragEnd = _a$onDragEnd === void 0 ? function () {} : _a$onDragEnd,
|
|
1685
1913
|
_a$order = _a.order,
|
|
1686
1914
|
order = _a$order === void 0 ? 1 : _a$order,
|
|
1687
1915
|
_a$source = _a.source,
|
|
1688
1916
|
source = _a$source === void 0 ? 'app' : _a$source,
|
|
1689
|
-
_a$
|
|
1690
|
-
|
|
1691
|
-
|
|
1917
|
+
_a$leftHeaderComponen = _a.leftHeaderComponent,
|
|
1918
|
+
leftHeaderComponent = _a$leftHeaderComponen === void 0 ? null : _a$leftHeaderComponen,
|
|
1919
|
+
_a$rightHeaderCompone = _a.rightHeaderComponent,
|
|
1920
|
+
rightHeaderComponent = _a$rightHeaderCompone === void 0 ? null : _a$rightHeaderCompone,
|
|
1921
|
+
_a$hasElevation = _a.hasElevation,
|
|
1922
|
+
hasElevation = _a$hasElevation === void 0 ? true : _a$hasElevation,
|
|
1923
|
+
className = _a.className,
|
|
1924
|
+
_a$sx = _a.sx,
|
|
1925
|
+
sx = _a$sx === void 0 ? {} : _a$sx,
|
|
1926
|
+
props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "hasElevation", "className", "sx"]);
|
|
1692
1927
|
|
|
1693
1928
|
var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
|
|
1694
|
-
var elevation = BASE_ELEVATION + order;
|
|
1929
|
+
var elevation = hasElevation ? BASE_ELEVATION + order : 0;
|
|
1695
1930
|
var nodeRef = React__default.useRef(null);
|
|
1696
1931
|
|
|
1697
1932
|
var _React$useState = React__default.useState({
|
|
@@ -1707,20 +1942,28 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1707
1942
|
size = _React$useState4[0],
|
|
1708
1943
|
setSize = _React$useState4[1];
|
|
1709
1944
|
|
|
1945
|
+
var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
|
|
1710
1946
|
var onStopDrag = React__default.useCallback(function (_event, position) {
|
|
1711
1947
|
setPosition(position);
|
|
1712
|
-
|
|
1948
|
+
onDragEnd(position, size);
|
|
1949
|
+
}, [setPosition, onDragEnd, size]);
|
|
1713
1950
|
|
|
1714
1951
|
var _React$useState5 = React__default.useState(defaultInitialMaxHeight),
|
|
1715
1952
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
1716
1953
|
initialMaxHeight = _React$useState6[0],
|
|
1717
1954
|
setInitialMaxHeight = _React$useState6[1];
|
|
1718
1955
|
|
|
1956
|
+
var _React$useState7 = React__default.useState(0),
|
|
1957
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
1958
|
+
initialDragPositionX = _React$useState8[0],
|
|
1959
|
+
setInitialDragPositionX = _React$useState8[1];
|
|
1960
|
+
|
|
1719
1961
|
var onStartResize = function onStartResize() {
|
|
1720
1962
|
setInitialMaxHeight('initial');
|
|
1963
|
+
setInitialDragPositionX(position.x);
|
|
1721
1964
|
};
|
|
1722
1965
|
|
|
1723
|
-
var onResize = React__default.useCallback(function (_event, _handle, node) {
|
|
1966
|
+
var onResize = React__default.useCallback(function (_event, _handle, node, delta) {
|
|
1724
1967
|
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1725
1968
|
width = _node$getBoundingClie.width,
|
|
1726
1969
|
height = _node$getBoundingClie.height;
|
|
@@ -1728,11 +1971,49 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1728
1971
|
onChangeSize({
|
|
1729
1972
|
width: width,
|
|
1730
1973
|
height: height
|
|
1731
|
-
});
|
|
1732
|
-
|
|
1974
|
+
}); // If dragging the same side as alignment, adjust position
|
|
1975
|
+
|
|
1976
|
+
if (isRightAligned && _handle === 'bottomRight') {
|
|
1977
|
+
var newX = initialDragPositionX + delta.width; // eslint-disable-next-line no-param-reassign
|
|
1978
|
+
|
|
1979
|
+
node.parentNode.style.transform = "translate(".concat(newX, "px, ").concat(position.y, "px)");
|
|
1980
|
+
} else if (!isRightAligned && _handle === 'bottomLeft') {
|
|
1981
|
+
var _newX = initialDragPositionX - delta.width; // eslint-disable-next-line no-param-reassign
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
node.parentNode.style.transform = "translate(".concat(_newX, "px, ").concat(position.y, "px)");
|
|
1985
|
+
}
|
|
1986
|
+
}, [onChangeSize, initialDragPositionX, isRightAligned, position]);
|
|
1987
|
+
|
|
1988
|
+
var onStopResize = function onStopResize(_event, direction, node, delta) {
|
|
1989
|
+
if (isRightAligned && direction === 'bottomRight') {
|
|
1990
|
+
setPosition({
|
|
1991
|
+
x: initialDragPositionX + delta.width,
|
|
1992
|
+
y: position.y
|
|
1993
|
+
});
|
|
1994
|
+
} else if (!isRightAligned && direction === 'bottomLeft') {
|
|
1995
|
+
setPosition({
|
|
1996
|
+
x: initialDragPositionX - delta.width,
|
|
1997
|
+
y: position.y
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
onResizeStop(_event, direction, node, delta);
|
|
2002
|
+
};
|
|
2003
|
+
|
|
1733
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
|
+
});
|
|
1734
2015
|
var toolcontainerId = React__default.useRef(Date.now().toString()).current;
|
|
1735
|
-
var headerClassName = "header-".concat(toolcontainerId);
|
|
2016
|
+
var headerClassName = "header-".concat(className || toolcontainerId);
|
|
1736
2017
|
return isOpen ? /*#__PURE__*/React__default.createElement(DraggableComponent$1, {
|
|
1737
2018
|
nodeRef: nodeRef,
|
|
1738
2019
|
bounds: bounds,
|
|
@@ -1740,18 +2021,23 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1740
2021
|
onStop: onStopDrag,
|
|
1741
2022
|
handle: ".".concat(headerClassName),
|
|
1742
2023
|
onMouseDown: onMouseDown
|
|
1743
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
1744
|
-
|
|
2024
|
+
}, /*#__PURE__*/React__default.createElement(Box, {
|
|
2025
|
+
sx: Object.assign(Object.assign(Object.assign({
|
|
1745
2026
|
position: 'absolute',
|
|
1746
2027
|
pointerEvents: 'all',
|
|
1747
2028
|
zIndex: zIndex
|
|
1748
|
-
}, startPosition),
|
|
1749
|
-
|
|
2029
|
+
}, startPosition), sx), {
|
|
2030
|
+
'&:hover .resizableHandle': {
|
|
2031
|
+
display: 'inline'
|
|
2032
|
+
}
|
|
2033
|
+
}),
|
|
2034
|
+
ref: nodeRef,
|
|
2035
|
+
className: "toolContainerDraggable"
|
|
1750
2036
|
}, /*#__PURE__*/React__default.createElement(ResizeComponent, Object.assign({}, props, {
|
|
1751
|
-
startPosition: startPosition,
|
|
1752
2037
|
size: size,
|
|
1753
2038
|
setSize: setSize,
|
|
1754
2039
|
onResizeStart: onStartResize,
|
|
2040
|
+
onResizeStop: onStopResize,
|
|
1755
2041
|
onResize: onResize
|
|
1756
2042
|
}), /*#__PURE__*/React__default.createElement(ToolContainer, {
|
|
1757
2043
|
maxHeight: initialMaxHeight,
|
|
@@ -1762,7 +2048,9 @@ var DraggableComponent = function DraggableComponent(_a) {
|
|
|
1762
2048
|
isResizable: true,
|
|
1763
2049
|
elevation: elevation,
|
|
1764
2050
|
headerClassName: headerClassName,
|
|
1765
|
-
|
|
2051
|
+
leftHeaderComponent: leftHeaderComponent,
|
|
2052
|
+
rightHeaderComponent: rightHeaderComponent,
|
|
2053
|
+
className: className
|
|
1766
2054
|
}, children)))) : null;
|
|
1767
2055
|
};
|
|
1768
2056
|
|
|
@@ -2434,7 +2722,7 @@ var ToggleMenu = function ToggleMenu(_ref) {
|
|
|
2434
2722
|
setAnchorEl(document.getElementById(buttonTestId));
|
|
2435
2723
|
}
|
|
2436
2724
|
}, [isDefaultOpen, buttonTestId]);
|
|
2437
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(
|
|
2725
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CustomTooltip, {
|
|
2438
2726
|
placement: "top",
|
|
2439
2727
|
title: tooltipTitle
|
|
2440
2728
|
}, /*#__PURE__*/React.createElement(ToolButton, {
|
|
@@ -2497,7 +2785,8 @@ var makeButtonStyles = function makeButtonStyles(isActive, isEnabled, isAccessib
|
|
|
2497
2785
|
height: '24px',
|
|
2498
2786
|
width: '24px',
|
|
2499
2787
|
borderRadius: '5px',
|
|
2500
|
-
marginTop: '
|
|
2788
|
+
marginTop: 'auto',
|
|
2789
|
+
marginBottom: 'auto',
|
|
2501
2790
|
color: function color() {
|
|
2502
2791
|
if (!isEnabled) {
|
|
2503
2792
|
return 'geowebColors.buttons.flat.disabled.color';
|
|
@@ -2545,7 +2834,8 @@ var ManagerButton = function ManagerButton(_a) {
|
|
|
2545
2834
|
_a$isAccessible = _a.isAccessible,
|
|
2546
2835
|
isAccessible = _a$isAccessible === void 0 ? false : _a$isAccessible,
|
|
2547
2836
|
sx = _a.sx,
|
|
2548
|
-
|
|
2837
|
+
children = _a.children,
|
|
2838
|
+
props = __rest(_a, ["tooltipTitle", "onClick", "isActive", "isEnabled", "icon", "testId", "isAccessible", "sx", "children"]);
|
|
2549
2839
|
|
|
2550
2840
|
var buttonStyles = makeButtonStyles(isActive, isEnabled, isAccessible);
|
|
2551
2841
|
|
|
@@ -2553,13 +2843,13 @@ var ManagerButton = function ManagerButton(_a) {
|
|
|
2553
2843
|
onClick(event);
|
|
2554
2844
|
};
|
|
2555
2845
|
|
|
2556
|
-
return /*#__PURE__*/React.createElement(
|
|
2846
|
+
return /*#__PURE__*/React.createElement(CustomTooltip, {
|
|
2557
2847
|
title: tooltipTitle,
|
|
2558
2848
|
placement: "top",
|
|
2559
2849
|
sx: {
|
|
2560
2850
|
pointerEvents: 'none'
|
|
2561
2851
|
}
|
|
2562
|
-
}, /*#__PURE__*/React.createElement(IconButton, Object.assign({
|
|
2852
|
+
}, children || /*#__PURE__*/React.createElement(IconButton, Object.assign({
|
|
2563
2853
|
size: "small",
|
|
2564
2854
|
onClick: handleClick,
|
|
2565
2855
|
"data-testid": testId,
|
|
@@ -2589,13 +2879,27 @@ var ManagerDeleteButton = function ManagerDeleteButton(_ref) {
|
|
|
2589
2879
|
onClickDelete = _ref.onClickDelete,
|
|
2590
2880
|
_ref$isEnabled = _ref.isEnabled,
|
|
2591
2881
|
isEnabled = _ref$isEnabled === void 0 ? true : _ref$isEnabled;
|
|
2592
|
-
return /*#__PURE__*/React.createElement(ManagerButton, {
|
|
2882
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ManagerButton, {
|
|
2883
|
+
tooltipTitle: tooltipTitle,
|
|
2884
|
+
onClick: onClickDelete,
|
|
2885
|
+
testId: "deleteButtonMedium",
|
|
2886
|
+
isEnabled: isEnabled,
|
|
2887
|
+
icon: /*#__PURE__*/React.createElement(Delete, null)
|
|
2888
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
2889
|
+
className: "deleteBtnMedium",
|
|
2890
|
+
variant: "tertiary",
|
|
2891
|
+
onClick: onClickDelete,
|
|
2892
|
+
startIcon: /*#__PURE__*/React.createElement(Delete, null),
|
|
2893
|
+
sx: {
|
|
2894
|
+
display: 'none'
|
|
2895
|
+
}
|
|
2896
|
+
}, "Delete")), /*#__PURE__*/React.createElement(ManagerButton, {
|
|
2593
2897
|
tooltipTitle: tooltipTitle,
|
|
2594
2898
|
onClick: onClickDelete,
|
|
2595
2899
|
icon: /*#__PURE__*/React.createElement(Delete, null),
|
|
2596
2900
|
testId: "deleteButton",
|
|
2597
2901
|
isEnabled: isEnabled
|
|
2598
|
-
});
|
|
2902
|
+
}));
|
|
2599
2903
|
};
|
|
2600
2904
|
|
|
2601
2905
|
/* *
|
|
@@ -2617,9 +2921,13 @@ var ManagerDeleteButton = function ManagerDeleteButton(_ref) {
|
|
|
2617
2921
|
var EnableButton = function EnableButton(_ref) {
|
|
2618
2922
|
var isEnabled = _ref.isEnabled,
|
|
2619
2923
|
title = _ref.title,
|
|
2620
|
-
onChangeEnableLayer = _ref.onChangeEnableLayer
|
|
2924
|
+
onChangeEnableLayer = _ref.onChangeEnableLayer,
|
|
2925
|
+
className = _ref.className,
|
|
2926
|
+
_ref$id = _ref.id,
|
|
2927
|
+
id = _ref$id === void 0 ? 'enableButton' : _ref$id;
|
|
2621
2928
|
|
|
2622
|
-
var onClick = function onClick() {
|
|
2929
|
+
var onClick = function onClick(event) {
|
|
2930
|
+
event.stopPropagation();
|
|
2623
2931
|
onChangeEnableLayer(!isEnabled);
|
|
2624
2932
|
};
|
|
2625
2933
|
|
|
@@ -2647,8 +2955,9 @@ var EnableButton = function EnableButton(_ref) {
|
|
|
2647
2955
|
disableFocusRipple: true,
|
|
2648
2956
|
tabIndex: -1
|
|
2649
2957
|
}),
|
|
2650
|
-
testId:
|
|
2651
|
-
isEnabled: isEnabled
|
|
2958
|
+
testId: id,
|
|
2959
|
+
isEnabled: isEnabled,
|
|
2960
|
+
className: className
|
|
2652
2961
|
});
|
|
2653
2962
|
};
|
|
2654
2963
|
|
|
@@ -2684,20 +2993,15 @@ var tooltipContainerStyles = function tooltipContainerStyles(isEnabled) {
|
|
|
2684
2993
|
'& .MuiOutlinedInput-notchedOutline': {
|
|
2685
2994
|
borderColor: 'transparent!important'
|
|
2686
2995
|
},
|
|
2687
|
-
'&:hover
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
}
|
|
2996
|
+
'&:hover': {
|
|
2997
|
+
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
|
|
2998
|
+
borderRadius: 0
|
|
2691
2999
|
},
|
|
2692
3000
|
'&.Mui-focused .MuiSelect-select': {
|
|
2693
3001
|
outline: function outline(theme) {
|
|
2694
3002
|
return theme.palette.geowebColors.buttons.focusDefault.outline;
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
'&:focus&.MuiButton-root': {
|
|
2698
|
-
outline: function outline(theme) {
|
|
2699
|
-
return theme.palette.geowebColors.buttons.focusDefault.outline;
|
|
2700
|
-
}
|
|
3003
|
+
},
|
|
3004
|
+
borderRadius: 0
|
|
2701
3005
|
},
|
|
2702
3006
|
'& .MuiSvgIcon-root': {
|
|
2703
3007
|
transition: 'none',
|
|
@@ -2706,28 +3010,31 @@ var tooltipContainerStyles = function tooltipContainerStyles(isEnabled) {
|
|
|
2706
3010
|
}
|
|
2707
3011
|
},
|
|
2708
3012
|
'&>div': {
|
|
2709
|
-
paddingLeft:
|
|
3013
|
+
paddingLeft: '8px!important'
|
|
2710
3014
|
}
|
|
2711
3015
|
}, hasBackgroundColor && backgroundColor);
|
|
2712
3016
|
};
|
|
2713
3017
|
var backgroundColor = {
|
|
2714
3018
|
'&:hover .MuiSelect-select': {
|
|
3019
|
+
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
|
|
3020
|
+
borderRadius: 0
|
|
3021
|
+
},
|
|
3022
|
+
'&.Mui-focused .MuiSelect-select': {
|
|
2715
3023
|
outline: function outline(theme) {
|
|
2716
3024
|
return theme.palette.geowebColors.buttons.focusDefault.outline;
|
|
2717
3025
|
},
|
|
2718
|
-
|
|
2719
|
-
},
|
|
2720
|
-
'&.Mui-focused .MuiSelect-select': {
|
|
3026
|
+
borderRadius: 0,
|
|
2721
3027
|
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
|
|
2722
3028
|
},
|
|
2723
3029
|
'&:hover&.MuiButton-root': {
|
|
2724
3030
|
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
|
|
2725
3031
|
},
|
|
2726
3032
|
'&:focus&.MuiButton-root': {
|
|
2727
|
-
|
|
3033
|
+
border: function border(theme) {
|
|
2728
3034
|
return theme.palette.geowebColors.buttons.focusDefault.outline;
|
|
2729
3035
|
},
|
|
2730
|
-
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
|
|
3036
|
+
backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
|
|
3037
|
+
transition: 'border'
|
|
2731
3038
|
}
|
|
2732
3039
|
};
|
|
2733
3040
|
|
|
@@ -2754,10 +3061,10 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2754
3061
|
selectOpen = _React$useState2[0],
|
|
2755
3062
|
setSelectOpen = _React$useState2[1];
|
|
2756
3063
|
|
|
2757
|
-
var
|
|
2758
|
-
|
|
2759
|
-
tooltipOpen =
|
|
2760
|
-
setTooltipOpen =
|
|
3064
|
+
var _useControlledTooltip = useControlledTooltip(),
|
|
3065
|
+
_useControlledTooltip2 = _slicedToArray(_useControlledTooltip, 2),
|
|
3066
|
+
tooltipOpen = _useControlledTooltip2[0],
|
|
3067
|
+
setTooltipOpen = _useControlledTooltip2[1];
|
|
2761
3068
|
|
|
2762
3069
|
var onWheel = React.useCallback(function (event) {
|
|
2763
3070
|
if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
|
|
@@ -2770,27 +3077,26 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2770
3077
|
var onOpen = React.useCallback(function () {
|
|
2771
3078
|
setSelectOpen(true);
|
|
2772
3079
|
setTooltipOpen(false);
|
|
2773
|
-
}, []);
|
|
3080
|
+
}, [setTooltipOpen]);
|
|
2774
3081
|
var onClose = React.useCallback(function () {
|
|
2775
3082
|
setSelectOpen(false);
|
|
2776
3083
|
}, []);
|
|
2777
3084
|
var onMouseEnter = React.useCallback(function () {
|
|
2778
3085
|
if (!selectOpen) setTooltipOpen(true);
|
|
2779
|
-
}, [selectOpen]);
|
|
3086
|
+
}, [selectOpen, setTooltipOpen]);
|
|
2780
3087
|
var onMouseLeave = React.useCallback(function () {
|
|
2781
3088
|
setTooltipOpen(false);
|
|
2782
|
-
}, []);
|
|
3089
|
+
}, [setTooltipOpen]);
|
|
2783
3090
|
var onFocus = React.useCallback(function () {
|
|
2784
3091
|
setTooltipOpen(true);
|
|
2785
|
-
}, []);
|
|
3092
|
+
}, [setTooltipOpen]);
|
|
2786
3093
|
var onBlur = React.useCallback(function () {
|
|
2787
3094
|
setTooltipOpen(false);
|
|
2788
|
-
}, []);
|
|
2789
|
-
return /*#__PURE__*/React.createElement(
|
|
3095
|
+
}, [setTooltipOpen]);
|
|
3096
|
+
return /*#__PURE__*/React.createElement(CustomTooltip, {
|
|
2790
3097
|
title: tooltip,
|
|
2791
3098
|
placement: "top",
|
|
2792
|
-
open: tooltipOpen
|
|
2793
|
-
sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
|
|
3099
|
+
open: tooltipOpen
|
|
2794
3100
|
}, /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
2795
3101
|
onOpen: onOpen,
|
|
2796
3102
|
onClose: onClose,
|
|
@@ -2841,7 +3147,8 @@ var TooltipSelect = function TooltipSelect(_a) {
|
|
|
2841
3147
|
}
|
|
2842
3148
|
}
|
|
2843
3149
|
}
|
|
2844
|
-
}
|
|
3150
|
+
},
|
|
3151
|
+
sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
|
|
2845
3152
|
}, otherProps)));
|
|
2846
3153
|
};
|
|
2847
3154
|
|
|
@@ -2867,6 +3174,44 @@ function withEggs(eggs) {
|
|
|
2867
3174
|
};
|
|
2868
3175
|
}
|
|
2869
3176
|
|
|
3177
|
+
var CustomAccordion = function CustomAccordion(_a) {
|
|
3178
|
+
var title = _a.title,
|
|
3179
|
+
_a$defaultExpanded = _a.defaultExpanded,
|
|
3180
|
+
defaultExpanded = _a$defaultExpanded === void 0 ? true : _a$defaultExpanded,
|
|
3181
|
+
_a$disableGutters = _a.disableGutters,
|
|
3182
|
+
disableGutters = _a$disableGutters === void 0 ? true : _a$disableGutters,
|
|
3183
|
+
_a$expandedElevation = _a.expandedElevation,
|
|
3184
|
+
expandedElevation = _a$expandedElevation === void 0 ? 3 : _a$expandedElevation,
|
|
3185
|
+
_a$collapsedElevation = _a.collapsedElevation,
|
|
3186
|
+
collapsedElevation = _a$collapsedElevation === void 0 ? 0 : _a$collapsedElevation,
|
|
3187
|
+
_a$transitionDuration = _a.transitionDuration,
|
|
3188
|
+
transitionDuration = _a$transitionDuration === void 0 ? 150 : _a$transitionDuration,
|
|
3189
|
+
detailsSx = _a.detailsSx,
|
|
3190
|
+
children = _a.children,
|
|
3191
|
+
props = __rest(_a, ["title", "defaultExpanded", "disableGutters", "expandedElevation", "collapsedElevation", "transitionDuration", "detailsSx", "children"]);
|
|
3192
|
+
|
|
3193
|
+
var _React$useState = React.useState(defaultExpanded),
|
|
3194
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
3195
|
+
expanded = _React$useState2[0],
|
|
3196
|
+
setExpanded = _React$useState2[1];
|
|
3197
|
+
|
|
3198
|
+
return /*#__PURE__*/React.createElement(Accordion, Object.assign({}, props, {
|
|
3199
|
+
defaultExpanded: defaultExpanded,
|
|
3200
|
+
elevation: expanded ? expandedElevation : collapsedElevation,
|
|
3201
|
+
onChange: function onChange(_event, expanded) {
|
|
3202
|
+
return setExpanded(expanded);
|
|
3203
|
+
},
|
|
3204
|
+
disableGutters: disableGutters,
|
|
3205
|
+
TransitionProps: {
|
|
3206
|
+
timeout: transitionDuration
|
|
3207
|
+
}
|
|
3208
|
+
}), /*#__PURE__*/React.createElement(AccordionSummary, {
|
|
3209
|
+
expandIcon: /*#__PURE__*/React.createElement(ChevronDown, null)
|
|
3210
|
+
}, title), /*#__PURE__*/React.createElement(AccordionDetails, {
|
|
3211
|
+
sx: detailsSx
|
|
3212
|
+
}, children));
|
|
3213
|
+
};
|
|
3214
|
+
|
|
2870
3215
|
/* *
|
|
2871
3216
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2872
3217
|
* you may not use this file except in compliance with the License.
|
|
@@ -2929,4 +3274,24 @@ var getWarningMessage = function getWarningMessage(error) {
|
|
|
2929
3274
|
return '';
|
|
2930
3275
|
};
|
|
2931
3276
|
|
|
2932
|
-
|
|
3277
|
+
/* *
|
|
3278
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3279
|
+
* you may not use this file except in compliance with the License.
|
|
3280
|
+
* You may obtain a copy of the License at
|
|
3281
|
+
*
|
|
3282
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3283
|
+
*
|
|
3284
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3285
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3286
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3287
|
+
* See the License for the specific language governing permissions and
|
|
3288
|
+
* limitations under the License.
|
|
3289
|
+
*
|
|
3290
|
+
* Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
3291
|
+
* Copyright 2022 - Finnish Meteorological Institute (FMI)
|
|
3292
|
+
* */
|
|
3293
|
+
// TODO: https://gitlab.com/opengeoweb/geoweb-assets/-/issues/2350
|
|
3294
|
+
// temporary check until we get the unit test passing with container queries
|
|
3295
|
+
var IS_JEST = typeof jest !== 'undefined';
|
|
3296
|
+
|
|
3297
|
+
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 };
|