@opengeoweb/shared 4.17.0 → 4.19.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.umd.js CHANGED
@@ -161,6 +161,115 @@
161
161
  }, content));
162
162
  };
163
163
 
164
+ /* *
165
+ * Licensed under the Apache License, Version 2.0 (the "License");
166
+ * you may not use this file except in compliance with the License.
167
+ * You may obtain a copy of the License at
168
+ *
169
+ * http://www.apache.org/licenses/LICENSE-2.0
170
+ *
171
+ * Unless required by applicable law or agreed to in writing, software
172
+ * distributed under the License is distributed on an "AS IS" BASIS,
173
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
174
+ * See the License for the specific language governing permissions and
175
+ * limitations under the License.
176
+ *
177
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
178
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
179
+ * */
180
+ var defaultDelay = 1000;
181
+ var useControlledTooltip = function useControlledTooltip() {
182
+ var _a = __read(React__namespace.useState(false), 2),
183
+ tooltipOpen = _a[0],
184
+ setTooltipOpen = _a[1];
185
+
186
+ var _b = __read(React__namespace.useState(false), 2),
187
+ delayedTooltip = _b[0],
188
+ setDelayedTooltip = _b[1];
189
+
190
+ React__namespace.useEffect(function () {
191
+ if (tooltipOpen === true) {
192
+ var timer_1 = setTimeout(function () {
193
+ return setDelayedTooltip(true);
194
+ }, defaultDelay);
195
+ return function () {
196
+ clearTimeout(timer_1);
197
+ };
198
+ }
199
+
200
+ setDelayedTooltip(false);
201
+ return function () {};
202
+ }, [tooltipOpen]);
203
+ return [delayedTooltip, setTooltipOpen];
204
+ };
205
+ var CustomTooltip = function CustomTooltip(props) {
206
+ return /*#__PURE__*/React__namespace.createElement(material.Tooltip, __assign({}, props, {
207
+ enterDelay: defaultDelay,
208
+ enterNextDelay: defaultDelay,
209
+ disableInteractive: true
210
+ }));
211
+ };
212
+
213
+ /* *
214
+ * Licensed under the Apache License, Version 2.0 (the "License");
215
+ * you may not use this file except in compliance with the License.
216
+ * You may obtain a copy of the License at
217
+ *
218
+ * http://www.apache.org/licenses/LICENSE-2.0
219
+ *
220
+ * Unless required by applicable law or agreed to in writing, software
221
+ * distributed under the License is distributed on an "AS IS" BASIS,
222
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223
+ * See the License for the specific language governing permissions and
224
+ * limitations under the License.
225
+ *
226
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
227
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
228
+ * */
229
+ var CustomIconButton = /*#__PURE__*/React__namespace.forwardRef(function (_a, ref) {
230
+ var _b = _a.tooltipTitle,
231
+ tooltipTitle = _b === void 0 ? '' : _b,
232
+ _c = _a.variant,
233
+ variant = _c === void 0 ? 'flat' : _c,
234
+ _d = _a.isSelected,
235
+ isSelected = _d === void 0 ? false : _d,
236
+ _e = _a.shouldShowAsDisabled,
237
+ shouldShowAsDisabled = _e === void 0 ? false : _e,
238
+ _f = _a.size,
239
+ size = _f === void 0 ? 'small' : _f,
240
+ children = _a.children,
241
+ className = _a.className,
242
+ props = __rest(_a, ["tooltipTitle", "variant", "isSelected", "shouldShowAsDisabled", "size", "children", "className"]);
243
+
244
+ var classNames = __spreadArray(__spreadArray(__spreadArray([], __read(className ? [className] : [])), __read(isSelected ? ['Mui-selected'] : [])), [variant]).join(' ');
245
+
246
+ var renderIconButton = function renderIconButton() {
247
+ return /*#__PURE__*/React__namespace.createElement(material.IconButton, __assign({
248
+ "aria-label": tooltipTitle
249
+ }, props, {
250
+ size: size,
251
+ className: classNames,
252
+ ref: ref,
253
+ sx: __assign(__assign({}, props.sx), shouldShowAsDisabled && {
254
+ '&.MuiIconButton-root': {
255
+ color: "geowebColors.iconButtons." + variant + ".disabled.color"
256
+ },
257
+ '&.Mui-focusVisible': {
258
+ color: "geowebColors.iconButtons." + variant + ".default.color"
259
+ }
260
+ })
261
+ }), children);
262
+ };
263
+
264
+ return tooltipTitle ? /*#__PURE__*/React__namespace.createElement(CustomTooltip, {
265
+ title: tooltipTitle,
266
+ placement: "top",
267
+ sx: {
268
+ pointerEvents: 'none'
269
+ }
270
+ }, renderIconButton()) : renderIconButton();
271
+ });
272
+
164
273
  var CustomDialog = function CustomDialog(_a) {
165
274
  var title = _a.title,
166
275
  _onClose = _a.onClose,
@@ -202,13 +311,17 @@
202
311
  },
203
312
  "data-testid": "customDialog-title",
204
313
  component: "span"
205
- }, title), /*#__PURE__*/React__namespace.createElement(material.IconButton, {
314
+ }, title), /*#__PURE__*/React__namespace.createElement(CustomIconButton, {
206
315
  "data-testid": "customDialog-close",
207
316
  "aria-label": "close",
208
317
  onClick: function onClick() {
209
318
  return _onClose('CLOSED');
210
319
  },
211
- size: "small"
320
+ sx: {
321
+ '&.MuiIconButton-root': {
322
+ color: 'geowebColors.greys.accessible'
323
+ }
324
+ }
212
325
  }, /*#__PURE__*/React__namespace.createElement(theme.Close, {
213
326
  "data-testid": "CloseIcon"
214
327
  }))), /*#__PURE__*/React__namespace.createElement(material.DialogContent, {
@@ -282,15 +395,14 @@
282
395
  sm: '150px'
283
396
  },
284
397
  '&:focus': {
285
- outline: theme.palette.geowebColors.buttons.focusDefault.outline,
398
+ outline: theme.palette.geowebColors.buttons.primary.focus.outline,
286
399
  borderColor: 'transparent'
287
400
  }
288
401
  };
289
402
  },
290
403
  onClick: function onClick() {
291
404
  return onClose('CANCELLED');
292
- },
293
- disableFocusRipple: true
405
+ }
294
406
  }, cancelLabel), isLoading ? /*#__PURE__*/React__namespace.createElement(material.Box, {
295
407
  "data-testid": "confirm-dialog-spinner",
296
408
  sx: __assign(__assign({}, confirmStyle), {
@@ -309,14 +421,13 @@
309
421
  sx: function sx(theme) {
310
422
  return __assign(__assign({}, confirmStyle), {
311
423
  '&:focus': {
312
- outline: theme.palette.geowebColors.buttons.focusDefault.outline,
424
+ outline: theme.palette.geowebColors.buttons.primary.focus.outline,
313
425
  borderColor: 'transparent'
314
426
  }
315
427
  });
316
428
  },
317
429
  onClick: onSubmit,
318
- autoFocus: !disableAutoFocus,
319
- disableFocusRipple: true
430
+ autoFocus: !disableAutoFocus
320
431
  }, confirmLabel))
321
432
  }, rest), content);
322
433
  };
@@ -502,7 +613,10 @@
502
613
  };
503
614
  var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
504
615
  var onResizeWindow = React__default["default"].useCallback(function () {
505
- if (!nodeRef.current) return;
616
+ if (!nodeRef.current) {
617
+ return;
618
+ }
619
+
506
620
  var bbox = nodeRef.current.firstChild.getBoundingClientRect();
507
621
  var containingView = nodeRef.current.parentElement.getBoundingClientRect();
508
622
  adjustPosition(bbox, containingView, position, setPosition);
@@ -1059,8 +1173,8 @@
1059
1173
  return /*#__PURE__*/React__namespace.createElement(material.Box, {
1060
1174
  sx: {
1061
1175
  whiteSpace: 'pre-wrap',
1062
- width: 'inherit',
1063
- height: 'inherit',
1176
+ width: '100%',
1177
+ height: '100%',
1064
1178
  overflowY: 'scroll'
1065
1179
  }
1066
1180
  }, /*#__PURE__*/React__namespace.createElement(AlertBanner, {
@@ -1119,8 +1233,8 @@
1119
1233
  * See the License for the specific language governing permissions and
1120
1234
  * limitations under the License.
1121
1235
  *
1122
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1123
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1236
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1237
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
1124
1238
  * */
1125
1239
  var styles$3 = {
1126
1240
  container: {
@@ -1140,15 +1254,6 @@
1140
1254
  paddingLeft: 2,
1141
1255
  paddingRight: 2
1142
1256
  }
1143
- },
1144
- button: {
1145
- padding: 0,
1146
- border: 'none',
1147
- background: 'transparent',
1148
- '&:hover': {
1149
- border: 'none',
1150
- background: 'transparent'
1151
- }
1152
1257
  }
1153
1258
  };
1154
1259
 
@@ -1161,11 +1266,19 @@
1161
1266
  onClose = _d === void 0 ? function () {} : _d,
1162
1267
  children = _a.children,
1163
1268
  initials = _a.initials;
1164
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
1269
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1165
1270
  "data-testid": "userButton",
1166
1271
  onClick: onToggle,
1167
- sx: styles$3.button,
1168
- size: "large"
1272
+ sx: {
1273
+ '&.MuiButtonBase-root': {
1274
+ background: 'transparent',
1275
+ '&:hover': {
1276
+ border: 'none',
1277
+ background: 'transparent'
1278
+ }
1279
+ }
1280
+ },
1281
+ size: "medium"
1169
1282
  }, /*#__PURE__*/React__default["default"].createElement(Avatar, null, initials)), isOpen && /*#__PURE__*/React__default["default"].createElement(material.Paper, {
1170
1283
  sx: styles$3.container,
1171
1284
  "data-testid": "userMenu"
@@ -1268,57 +1381,8 @@
1268
1381
  * See the License for the specific language governing permissions and
1269
1382
  * limitations under the License.
1270
1383
  *
1271
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1272
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1273
- * */
1274
- var defaultDelay = 1000;
1275
- var useControlledTooltip = function useControlledTooltip() {
1276
- var _a = __read(React__namespace.useState(false), 2),
1277
- tooltipOpen = _a[0],
1278
- setTooltipOpen = _a[1];
1279
-
1280
- var _b = __read(React__namespace.useState(false), 2),
1281
- delayedTooltip = _b[0],
1282
- setDelayedTooltip = _b[1];
1283
-
1284
- React__namespace.useEffect(function () {
1285
- if (tooltipOpen === true) {
1286
- var timer_1 = setTimeout(function () {
1287
- return setDelayedTooltip(true);
1288
- }, defaultDelay);
1289
- return function () {
1290
- clearTimeout(timer_1);
1291
- };
1292
- }
1293
-
1294
- setDelayedTooltip(false);
1295
- return function () {};
1296
- }, [tooltipOpen]);
1297
- return [delayedTooltip, setTooltipOpen];
1298
- };
1299
- var CustomTooltip = function CustomTooltip(props) {
1300
- return /*#__PURE__*/React__namespace.createElement(material.Tooltip, __assign({}, props, {
1301
- enterDelay: defaultDelay,
1302
- enterNextDelay: defaultDelay,
1303
- disableInteractive: true
1304
- }));
1305
- };
1306
-
1307
- /* *
1308
- * Licensed under the Apache License, Version 2.0 (the "License");
1309
- * you may not use this file except in compliance with the License.
1310
- * You may obtain a copy of the License at
1311
- *
1312
- * http://www.apache.org/licenses/LICENSE-2.0
1313
- *
1314
- * Unless required by applicable law or agreed to in writing, software
1315
- * distributed under the License is distributed on an "AS IS" BASIS,
1316
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1317
- * See the License for the specific language governing permissions and
1318
- * limitations under the License.
1319
- *
1320
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1321
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
1384
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1385
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
1322
1386
  * */
1323
1387
 
1324
1388
  var getStyle = function getStyle(size) {
@@ -1416,13 +1480,13 @@
1416
1480
  }, isDraggable && size !== 'xxs' && !leftHeaderComponent && /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1417
1481
  container: true,
1418
1482
  justifyContent: "flex-start"
1419
- }, /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
1483
+ }, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1420
1484
  "data-testid": "dragBtn",
1421
1485
  disableRipple: true,
1422
- size: "large",
1423
- sx: __assign(__assign({}, iconStyle), {
1424
- pointerEvents: 'none'
1425
- })
1486
+ sx: {
1487
+ pointerEvents: 'none',
1488
+ '&.MuiIconButton-root': iconStyle
1489
+ }
1426
1490
  }, /*#__PURE__*/React__default["default"].createElement(theme.DragHandle, null))), leftHeaderComponent && leftHeaderComponent), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1427
1491
  className: "header-title",
1428
1492
  item: true,
@@ -1438,15 +1502,16 @@
1438
1502
  fontSize: styles.fontSize,
1439
1503
  fontWeight: styles.fontWeight
1440
1504
  }
1441
- }, title), size === 'xxs' && /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
1505
+ }, title), size === 'xxs' && /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1442
1506
  "data-testid": "dragBtn-xxs",
1443
1507
  disableRipple: true,
1444
- size: "small",
1445
- sx: __assign(__assign({}, iconStyle), {
1508
+ sx: {
1446
1509
  pointerEvents: 'none',
1447
1510
  transform: 'rotate(90deg)',
1448
- height: 12
1449
- })
1511
+ '&.MuiButtonBase-root.MuiIconButton-root': __assign(__assign({}, iconStyle), {
1512
+ height: 12
1513
+ })
1514
+ }
1450
1515
  }, /*#__PURE__*/React__default["default"].createElement(theme.DragHandle, null)))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1451
1516
  className: "header-right",
1452
1517
  item: true,
@@ -1459,12 +1524,13 @@
1459
1524
  sx: {
1460
1525
  pointerEvents: 'none'
1461
1526
  }
1462
- }, /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
1527
+ }, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1463
1528
  "data-testid": "closeBtn",
1464
1529
  onClick: onClose,
1465
1530
  onTouchEnd: onClose,
1466
- size: "large",
1467
- sx: iconStyle
1531
+ sx: {
1532
+ '&.MuiButtonBase-root.MuiIconButton-root': iconStyle
1533
+ }
1468
1534
  }, /*#__PURE__*/React__default["default"].createElement(theme.Close, {
1469
1535
  "data-testid": "CloseIcon"
1470
1536
  }))))));
@@ -1689,8 +1755,8 @@
1689
1755
  * See the License for the specific language governing permissions and
1690
1756
  * limitations under the License.
1691
1757
  *
1692
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1693
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1758
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1759
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
1694
1760
  * */
1695
1761
 
1696
1762
  var calculateDialogSizeAndPosition = function calculateDialogSizeAndPosition() {
@@ -1766,33 +1832,37 @@
1766
1832
  onResizeStop = _m === void 0 ? function () {} : _m,
1767
1833
  _o = _a.onDragEnd,
1768
1834
  onDragEnd = _o === void 0 ? function () {} : _o,
1769
- _p = _a.order,
1770
- order = _p === void 0 ? 1 : _p,
1771
- _q = _a.source,
1772
- source = _q === void 0 ? 'app' : _q,
1773
- _r = _a.leftHeaderComponent,
1774
- leftHeaderComponent = _r === void 0 ? null : _r,
1775
- _s = _a.rightHeaderComponent,
1776
- rightHeaderComponent = _s === void 0 ? null : _s,
1835
+ _p = _a.onFocus,
1836
+ onFocus = _p === void 0 ? function () {} : _p,
1837
+ _q = _a.onBlur,
1838
+ onBlur = _q === void 0 ? function () {} : _q,
1839
+ _r = _a.order,
1840
+ order = _r === void 0 ? 1 : _r,
1841
+ _s = _a.source,
1842
+ source = _s === void 0 ? 'app' : _s,
1843
+ _t = _a.leftHeaderComponent,
1844
+ leftHeaderComponent = _t === void 0 ? null : _t,
1845
+ _u = _a.rightHeaderComponent,
1846
+ rightHeaderComponent = _u === void 0 ? null : _u,
1777
1847
  className = _a.className,
1778
- _t = _a.sx,
1779
- sx = _t === void 0 ? {} : _t,
1780
- props = __rest(_a, ["title", "bounds", "cancel", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "className", "sx"]);
1848
+ _v = _a.sx,
1849
+ sx = _v === void 0 ? {} : _v,
1850
+ props = __rest(_a, ["title", "bounds", "cancel", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "onFocus", "onBlur", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "className", "sx"]);
1781
1851
 
1782
1852
  var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
1783
1853
  var elevation = BASE_ELEVATION + order;
1784
1854
  var nodeRef = React__default["default"].useRef(null);
1785
1855
 
1786
- var _u = __read(React__default["default"].useState({
1856
+ var _w = __read(React__default["default"].useState({
1787
1857
  x: 0,
1788
1858
  y: 0
1789
1859
  }), 2),
1790
- position = _u[0],
1791
- setPosition = _u[1];
1860
+ position = _w[0],
1861
+ setPosition = _w[1];
1792
1862
 
1793
- var _v = __read(React__default["default"].useState(startSize), 2),
1794
- size = _v[0],
1795
- setSize = _v[1];
1863
+ var _x = __read(React__default["default"].useState(startSize), 2),
1864
+ size = _x[0],
1865
+ setSize = _x[1];
1796
1866
 
1797
1867
  var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
1798
1868
  var onStopDrag = React__default["default"].useCallback(function (_event, position) {
@@ -1800,9 +1870,9 @@
1800
1870
  onDragEnd(position, size);
1801
1871
  }, [setPosition, onDragEnd, size]);
1802
1872
 
1803
- var _w = __read(React__default["default"].useState(defaultInitialMaxHeight), 2),
1804
- initialMaxHeight = _w[0],
1805
- setInitialMaxHeight = _w[1];
1873
+ var _y = __read(React__default["default"].useState(defaultInitialMaxHeight), 2),
1874
+ initialMaxHeight = _y[0],
1875
+ setInitialMaxHeight = _y[1];
1806
1876
 
1807
1877
  var onStartResize = function onStartResize() {
1808
1878
  setInitialMaxHeight('initial');
@@ -1849,6 +1919,9 @@
1849
1919
  handle: "." + headerClassName,
1850
1920
  onMouseDown: onMouseDown
1851
1921
  }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
1922
+ tabIndex: -1,
1923
+ onFocus: onFocus,
1924
+ onBlur: onBlur,
1852
1925
  sx: __assign(__assign(__assign({
1853
1926
  position: 'absolute',
1854
1927
  pointerEvents: 'all',
@@ -2318,7 +2391,10 @@
2318
2391
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2319
2392
  * */
2320
2393
  var getInitials = function getInitials(name) {
2321
- if (!name) return '';
2394
+ if (!name) {
2395
+ return '';
2396
+ }
2397
+
2322
2398
  var nameWithoutEmail = name.split('@')[0];
2323
2399
  var array = nameWithoutEmail.split('.');
2324
2400
 
@@ -2417,7 +2493,10 @@
2417
2493
  first = _a[0],
2418
2494
  rest = _a.slice(1);
2419
2495
 
2420
- if (first) first.classList.add('selectedLabel');
2496
+ if (first) {
2497
+ first.classList.add('selectedLabel');
2498
+ }
2499
+
2421
2500
  rest.forEach(function (element) {
2422
2501
  return element.classList.remove('selectedLabel');
2423
2502
  });
@@ -2614,7 +2693,10 @@
2614
2693
  anchorEl: anchorEl,
2615
2694
  open: isOpen,
2616
2695
  onClose: function onClose(event, reason) {
2617
- if (reason === 'tabKeyDown') return;
2696
+ if (reason === 'tabKeyDown') {
2697
+ return;
2698
+ }
2699
+
2618
2700
  handleClose(event);
2619
2701
  },
2620
2702
  anchorOrigin: anchorOrigin,
@@ -2636,7 +2718,7 @@
2636
2718
  sx: {
2637
2719
  fontSize: '12px'
2638
2720
  }
2639
- }, menuTitle)), menuItems && menuItems.map(function (menuItem) {
2721
+ }, menuTitle)), menuItems && menuItems.length ? menuItems.map(function (menuItem) {
2640
2722
  var text = menuItem.text,
2641
2723
  icon = menuItem.icon,
2642
2724
  action = menuItem.action;
@@ -2647,207 +2729,8 @@
2647
2729
  handleClose(event);
2648
2730
  }
2649
2731
  }, icon && /*#__PURE__*/React__namespace.createElement(material.ListItemIcon, null, icon), /*#__PURE__*/React__namespace.createElement(material.Typography, null, text));
2650
- }), children));
2651
- };
2652
-
2653
- /* *
2654
- * Licensed under the Apache License, Version 2.0 (the "License");
2655
- * you may not use this file except in compliance with the License.
2656
- * You may obtain a copy of the License at
2657
- *
2658
- * http://www.apache.org/licenses/LICENSE-2.0
2659
- *
2660
- * Unless required by applicable law or agreed to in writing, software
2661
- * distributed under the License is distributed on an "AS IS" BASIS,
2662
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2663
- * See the License for the specific language governing permissions and
2664
- * limitations under the License.
2665
- *
2666
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2667
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
2668
- * */
2669
-
2670
- var makeButtonStyles = function makeButtonStyles(isActive, isEnabled, isAccessible) {
2671
- return {
2672
- height: '24px',
2673
- width: '24px',
2674
- borderRadius: '5px',
2675
- marginTop: 'auto',
2676
- marginBottom: 'auto',
2677
- color: function color() {
2678
- if (!isEnabled) {
2679
- return 'geowebColors.buttons.flat.disabled.color';
2680
- }
2681
-
2682
- if (isAccessible) {
2683
- return 'geowebColors.greys.accessible';
2684
- }
2685
-
2686
- if (isActive) {
2687
- return 'common.white';
2688
- }
2689
-
2690
- return 'geowebColors.buttons.flat.default.color';
2691
- },
2692
- backgroundColor: function backgroundColor() {
2693
- return isActive ? 'geowebColors.buttons.primary.active.fill' : 'inherit';
2694
- },
2695
- '&:focus': {
2696
- backgroundColor: function backgroundColor() {
2697
- return isActive ? 'geowebColors.buttons.primary.mouseOver.fill' : 'geowebColors.buttons.flat.mouseOver.fill';
2698
- },
2699
- outline: 'geowebColors.buttons.focusDefault.outline',
2700
- borderRadius: 0
2701
- },
2702
- '&:hover': {
2703
- backgroundColor: function backgroundColor() {
2704
- return isActive ? 'geowebColors.buttons.primary.mouseOver.fill' : 'geowebColors.buttons.flat.mouseOver.fill';
2705
- }
2706
- }
2707
- };
2708
- };
2709
-
2710
- var ManagerButton = function ManagerButton(_a) {
2711
- var _b = _a.tooltipTitle,
2712
- tooltipTitle = _b === void 0 ? '' : _b,
2713
- _c = _a.onClick,
2714
- onClick = _c === void 0 ? function () {} : _c,
2715
- _d = _a.isActive,
2716
- isActive = _d === void 0 ? false : _d,
2717
- _e = _a.isEnabled,
2718
- isEnabled = _e === void 0 ? true : _e,
2719
- icon = _a.icon,
2720
- testId = _a.testId,
2721
- _f = _a.isAccessible,
2722
- isAccessible = _f === void 0 ? false : _f,
2723
- sx = _a.sx,
2724
- children = _a.children,
2725
- props = __rest(_a, ["tooltipTitle", "onClick", "isActive", "isEnabled", "icon", "testId", "isAccessible", "sx", "children"]);
2726
-
2727
- var buttonStyles = makeButtonStyles(isActive, isEnabled, isAccessible);
2728
-
2729
- var handleClick = function handleClick(event) {
2730
- onClick(event);
2731
- };
2732
-
2733
- return /*#__PURE__*/React__namespace.createElement(CustomTooltip, {
2734
- title: tooltipTitle,
2735
- placement: "top",
2736
- sx: {
2737
- pointerEvents: 'none'
2738
- }
2739
- }, children || /*#__PURE__*/React__namespace.createElement(material.IconButton, __assign({
2740
- size: "small",
2741
- onClick: handleClick,
2742
- "data-testid": testId,
2743
- sx: __assign(__assign({}, buttonStyles), sx),
2744
- disableFocusRipple: true
2745
- }, props), icon));
2746
- };
2747
-
2748
- /* *
2749
- * Licensed under the Apache License, Version 2.0 (the "License");
2750
- * you may not use this file except in compliance with the License.
2751
- * You may obtain a copy of the License at
2752
- *
2753
- * http://www.apache.org/licenses/LICENSE-2.0
2754
- *
2755
- * Unless required by applicable law or agreed to in writing, software
2756
- * distributed under the License is distributed on an "AS IS" BASIS,
2757
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2758
- * See the License for the specific language governing permissions and
2759
- * limitations under the License.
2760
- *
2761
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2762
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2763
- * */
2764
- var ManagerDeleteButton = function ManagerDeleteButton(_a) {
2765
- var tooltipTitle = _a.tooltipTitle,
2766
- onClickDelete = _a.onClickDelete,
2767
- _b = _a.isEnabled,
2768
- isEnabled = _b === void 0 ? true : _b,
2769
- sx = _a.sx;
2770
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(ManagerButton, {
2771
- tooltipTitle: tooltipTitle,
2772
- onClick: onClickDelete,
2773
- testId: "deleteButtonMedium",
2774
- isEnabled: isEnabled,
2775
- icon: /*#__PURE__*/React__namespace.createElement(theme.Delete, null)
2776
- }, /*#__PURE__*/React__namespace.createElement(material.Button, {
2777
- className: "deleteBtnMedium",
2778
- variant: "tertiary",
2779
- onClick: onClickDelete,
2780
- startIcon: /*#__PURE__*/React__namespace.createElement(theme.Delete, null),
2781
- sx: __assign({
2782
- display: 'none'
2783
- }, sx)
2784
- }, "Delete")), /*#__PURE__*/React__namespace.createElement(ManagerButton, {
2785
- tooltipTitle: tooltipTitle,
2786
- onClick: onClickDelete,
2787
- icon: /*#__PURE__*/React__namespace.createElement(theme.Delete, null),
2788
- testId: "deleteButton",
2789
- isEnabled: isEnabled,
2790
- sx: sx
2791
- }));
2792
- };
2793
-
2794
- /* *
2795
- * Licensed under the Apache License, Version 2.0 (the "License");
2796
- * you may not use this file except in compliance with the License.
2797
- * You may obtain a copy of the License at
2798
- *
2799
- * http://www.apache.org/licenses/LICENSE-2.0
2800
- *
2801
- * Unless required by applicable law or agreed to in writing, software
2802
- * distributed under the License is distributed on an "AS IS" BASIS,
2803
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2804
- * See the License for the specific language governing permissions and
2805
- * limitations under the License.
2806
- *
2807
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2808
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2809
- * */
2810
- var EnableButton = function EnableButton(_a) {
2811
- var isEnabled = _a.isEnabled,
2812
- title = _a.title,
2813
- onChangeEnableLayer = _a.onChangeEnableLayer,
2814
- className = _a.className,
2815
- _b = _a.id,
2816
- id = _b === void 0 ? 'enableButton' : _b;
2817
-
2818
- var onClick = function onClick(event) {
2819
- event.stopPropagation();
2820
- onChangeEnableLayer(!isEnabled);
2821
- };
2822
-
2823
- return /*#__PURE__*/React__namespace.createElement(ManagerButton, {
2824
- tooltipTitle: title,
2825
- onClick: onClick,
2826
- icon: /*#__PURE__*/React__namespace.createElement(material.Checkbox, {
2827
- sx: {
2828
- color: 'inherit',
2829
- padding: 0.5,
2830
- borderRadius: 1.25,
2831
- '&.Mui-focusVisible': {
2832
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2833
- },
2834
- '&:hover': {
2835
- backgroundColor: 'transparent!important'
2836
- },
2837
- '&.Mui-checked': {
2838
- color: 'inherit'
2839
- }
2840
- },
2841
- icon: /*#__PURE__*/React__namespace.createElement(theme.VisibilityOff, null),
2842
- checkedIcon: /*#__PURE__*/React__namespace.createElement(theme.Visibility, null),
2843
- checked: isEnabled,
2844
- disableFocusRipple: true,
2845
- tabIndex: -1
2846
- }),
2847
- testId: id,
2848
- isEnabled: isEnabled,
2849
- className: className
2850
- });
2732
+ }) : /*#__PURE__*/React__namespace.createElement("div", null) // Needed to make the menu work without any menuItems
2733
+ , children));
2851
2734
  };
2852
2735
 
2853
2736
  /* *
@@ -2891,7 +2774,7 @@
2891
2774
  },
2892
2775
  '&.Mui-focused .MuiSelect-select': {
2893
2776
  outline: function outline(theme) {
2894
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2777
+ return theme.palette.geowebColors.buttons.tool.focus.outline;
2895
2778
  },
2896
2779
  borderRadius: 0
2897
2780
  },
@@ -2913,7 +2796,7 @@
2913
2796
  },
2914
2797
  '&.Mui-focused .MuiSelect-select': {
2915
2798
  outline: function outline(theme) {
2916
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2799
+ return theme.palette.geowebColors.buttons.tool.focus.outline;
2917
2800
  },
2918
2801
  borderRadius: 0,
2919
2802
  backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
@@ -2923,7 +2806,7 @@
2923
2806
  },
2924
2807
  '&:focus&.MuiButton-root': {
2925
2808
  border: function border(theme) {
2926
- return theme.palette.geowebColors.buttons.focusDefault.outline;
2809
+ return theme.palette.geowebColors.buttons.tool.focus.outline;
2927
2810
  },
2928
2811
  backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2929
2812
  transition: 'border'
@@ -2971,7 +2854,10 @@
2971
2854
 
2972
2855
  var onWheel = React__namespace.useCallback(function (event) {
2973
2856
  if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
2974
- if (selectOpen) return;
2857
+ if (selectOpen) {
2858
+ return;
2859
+ }
2860
+
2975
2861
  var direction = event.deltaY < 0 ? 1 : -1;
2976
2862
  var newIndex = currentIndex - direction;
2977
2863
 
@@ -2990,7 +2876,9 @@
2990
2876
  setSelectOpen(false);
2991
2877
  }, []);
2992
2878
  var onMouseEnter = React__namespace.useCallback(function () {
2993
- if (!selectOpen) setTooltipOpen(true);
2879
+ if (!selectOpen) {
2880
+ setTooltipOpen(true);
2881
+ }
2994
2882
  }, [selectOpen, setTooltipOpen]);
2995
2883
  var onMouseLeave = React__namespace.useCallback(function () {
2996
2884
  setTooltipOpen(false);
@@ -3042,6 +2930,9 @@
3042
2930
  },
3043
2931
  '&:focus': {
3044
2932
  backgroundColor: 'geowebColors.buttons.tool.activeMouseOver.fill'
2933
+ },
2934
+ '.MuiListItemIcon-root': {
2935
+ color: 'geowebColors.buttons.tool.active.color'
3045
2936
  }
3046
2937
  },
3047
2938
  '&:after': {
@@ -3419,6 +3310,48 @@
3419
3310
 
3420
3311
  return new Date(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds);
3421
3312
  };
3313
+ /**
3314
+ *
3315
+ * @param date
3316
+ * @param duration
3317
+ * @returns {Date} the new Date
3318
+ */
3319
+
3320
+ var add = function add(date, duration) {
3321
+ return dateFns.add(date, duration);
3322
+ };
3323
+ /**
3324
+ *
3325
+ * @param date
3326
+ * @param duration
3327
+ * @returns {Date} the new Date
3328
+ */
3329
+
3330
+ var sub = function sub(date, duration) {
3331
+ return dateFns.sub(date, duration);
3332
+ };
3333
+ /**
3334
+ * Finds the number of minuts between to dates
3335
+ *
3336
+ * @param dateLeft - the later date
3337
+ * @param dateRight - the earlier date
3338
+ * @returns {number} the number of minutes
3339
+ */
3340
+
3341
+ var differenceInMinutes = function differenceInMinutes(dateLeft, dateRight) {
3342
+ return dateFns.differenceInMinutes(dateLeft, dateRight);
3343
+ };
3344
+ /**
3345
+ * Finds the number of hours between to dates
3346
+ *
3347
+ * @param dateLeft - the later date
3348
+ * @param dateRight - the earlier date
3349
+ * @returns {number} the number of hours
3350
+ */
3351
+
3352
+ var differenceInHours = function differenceInHours(dateLeft, dateRight) {
3353
+ return dateFns.differenceInHours(dateLeft, dateRight);
3354
+ };
3422
3355
 
3423
3356
  /* *
3424
3357
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -3444,7 +3377,11 @@
3444
3377
  setUTCDate: setUTCDate,
3445
3378
  dateToString: dateToString,
3446
3379
  isBetween: isBetween,
3447
- createDate: createDate
3380
+ createDate: createDate,
3381
+ add: add,
3382
+ sub: sub,
3383
+ differenceInMinutes: differenceInMinutes,
3384
+ differenceInHours: differenceInHours
3448
3385
  });
3449
3386
 
3450
3387
  exports.AlertBanner = AlertBanner;
@@ -3456,15 +3393,13 @@
3456
3393
  exports.ConfirmationServiceProvider = ConfirmationServiceProvider;
3457
3394
  exports.CustomAccordion = CustomAccordion;
3458
3395
  exports.CustomDialog = CustomDialog;
3396
+ exports.CustomIconButton = CustomIconButton;
3459
3397
  exports.CustomSlider = CustomSlider;
3460
3398
  exports.CustomToggleButton = CustomToggleButton;
3461
3399
  exports.CustomTooltip = CustomTooltip;
3462
3400
  exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
3463
3401
  exports.Draggable = DraggableComponent$1;
3464
- exports.EnableButton = EnableButton;
3465
3402
  exports.ErrorBoundary = ErrorBoundary;
3466
- exports.ManagerButton = ManagerButton;
3467
- exports.ManagerDeleteButton = ManagerDeleteButton;
3468
3403
  exports.Resizable = ResizeComponent;
3469
3404
  exports.StatusTag = StatusTag;
3470
3405
  exports.ToggleMenu = ToggleMenu;