@opengeoweb/shared 4.1.0 → 4.3.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,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default from 'react';
2
+ import React__default, { useRef } from 'react';
3
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
4
  import { Close, Exclamation, Success, Info, ChevronRight, GeoWebLogo, Resize, useThemeContext, DragHandle, ArrowLeft, ArrowRight, KeyOption, ArrowUp, ArrowDown, KeyCommand, Options, Delete, VisibilityOff, Visibility } from '@opengeoweb/theme';
5
5
  import { useFormContext } from 'react-hook-form';
@@ -8,22 +8,33 @@ import Draggable from 'react-draggable';
8
8
  import { Resizable } from 're-resizable';
9
9
  import { throttle } from 'lodash';
10
10
 
11
- /* *
12
- * Licensed under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License.
14
- * You may obtain a copy of the License at
15
- *
16
- * http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software
19
- * distributed under the License is distributed on an "AS IS" BASIS,
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
- * See the License for the specific language governing permissions and
22
- * limitations under the License.
23
- *
24
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
25
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
26
- * */
11
+ /*! *****************************************************************************
12
+ Copyright (c) Microsoft Corporation.
13
+
14
+ Permission to use, copy, modify, and/or distribute this software for any
15
+ purpose with or without fee is hereby granted.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
+ PERFORMANCE OF THIS SOFTWARE.
24
+ ***************************************************************************** */
25
+
26
+ function __rest(s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
29
+ t[p] = s[p];
30
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
31
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
32
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
33
+ t[p[i]] = s[p[i]];
34
+ }
35
+ return t;
36
+ }
37
+
27
38
  var bgColors = {
28
39
  green: '#fcffeb',
29
40
  grey: '#f8f9f9',
@@ -57,47 +68,23 @@ var tagStyle = function tagStyle(color) {
57
68
  };
58
69
  };
59
70
 
60
- var StatusTag = function StatusTag(_ref) {
61
- var content = _ref.content,
62
- color = _ref.color;
71
+ var StatusTag = function StatusTag(_a) {
72
+ var content = _a.content,
73
+ color = _a.color,
74
+ props = __rest(_a, ["content", "color"]);
75
+
63
76
  return /*#__PURE__*/React.createElement(Box, {
64
77
  display: "flex",
65
78
  alignItems: "center",
66
79
  justifyContent: "center",
67
- sx: Object.assign({}, tagStyle(color)),
68
- "data-testid": "statusTag"
80
+ "data-testid": "statusTag",
81
+ className: "statusTag",
82
+ sx: Object.assign(Object.assign({}, tagStyle(color)), props.sx)
69
83
  }, /*#__PURE__*/React.createElement(Typography, {
70
84
  variant: "caption"
71
85
  }, content));
72
86
  };
73
87
 
74
- /*! *****************************************************************************
75
- Copyright (c) Microsoft Corporation.
76
-
77
- Permission to use, copy, modify, and/or distribute this software for any
78
- purpose with or without fee is hereby granted.
79
-
80
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
81
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
82
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
83
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
84
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
85
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
86
- PERFORMANCE OF THIS SOFTWARE.
87
- ***************************************************************************** */
88
-
89
- function __rest(s, e) {
90
- var t = {};
91
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
92
- t[p] = s[p];
93
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
94
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
95
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
96
- t[p[i]] = s[p[i]];
97
- }
98
- return t;
99
- }
100
-
101
88
  var confirmStyle = {
102
89
  width: {
103
90
  xs: '100%',
@@ -488,7 +475,7 @@ function usePreventBrowserClose(shouldPreventClose) {
488
475
  * */
489
476
  var usePoller = function usePoller(deps, callback) {
490
477
  var pollingInterval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 300000;
491
- var interval = React.useRef(null);
478
+ var interval = useRef(null);
492
479
  React.useEffect(function () {
493
480
  if (deps.filter(function (dep) {
494
481
  return dep !== null;
@@ -781,7 +768,11 @@ var AlertBanner = function AlertBanner(_ref) {
781
768
  isOpen = _React$useState2[0],
782
769
  setIsOpen = _React$useState2[1];
783
770
 
784
- return isOpen && /*#__PURE__*/React.createElement(Alert, {
771
+ if (!isOpen) {
772
+ return null;
773
+ }
774
+
775
+ return /*#__PURE__*/React.createElement(Alert, {
785
776
  "data-testid": dataTestId,
786
777
  severity: severity,
787
778
  icon: /*#__PURE__*/React.createElement(AlertIcon, {
@@ -1016,15 +1007,13 @@ var DraggableComponent$1 = function DraggableComponent(_a) {
1016
1007
  var ResizeComponent = function ResizeComponent(_a) {
1017
1008
  var _a$startPosition = _a.startPosition,
1018
1009
  startPosition = _a$startPosition === void 0 ? {
1019
- left: null,
1020
- right: null,
1021
- top: null
1010
+ left: undefined,
1011
+ right: undefined,
1012
+ top: undefined
1022
1013
  } : _a$startPosition,
1023
1014
  children = _a.children,
1024
1015
  _a$onResizeStart = _a.onResizeStart,
1025
- onResizeStart = _a$onResizeStart === void 0 ? function () {
1026
- return null;
1027
- } : _a$onResizeStart,
1016
+ onResizeStart = _a$onResizeStart === void 0 ? function () {} : _a$onResizeStart,
1028
1017
  size = _a.size,
1029
1018
  setSize = _a.setSize,
1030
1019
  _a$minHeight = _a.minHeight,
@@ -1113,8 +1102,8 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
1113
1102
 
1114
1103
  _this = _super.call(this, props);
1115
1104
  _this.state = {
1116
- error: null,
1117
- errorInfo: null
1105
+ error: undefined,
1106
+ errorInfo: undefined
1118
1107
  };
1119
1108
  return _this;
1120
1109
  }
@@ -1174,9 +1163,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
1174
1163
  return ErrorBoundary;
1175
1164
  }(React.Component);
1176
1165
  ErrorBoundary.defaultProps = {
1177
- onError: function onError() {
1178
- return null;
1179
- }
1166
+ onError: function onError() {}
1180
1167
  };
1181
1168
 
1182
1169
  /* *
@@ -1264,13 +1251,9 @@ var UserMenu = function UserMenu(_ref) {
1264
1251
  var _ref$isOpen = _ref.isOpen,
1265
1252
  isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
1266
1253
  _ref$onToggle = _ref.onToggle,
1267
- onToggle = _ref$onToggle === void 0 ? function () {
1268
- return null;
1269
- } : _ref$onToggle,
1254
+ onToggle = _ref$onToggle === void 0 ? function () {} : _ref$onToggle,
1270
1255
  _ref$onClose = _ref.onClose,
1271
- onClose = _ref$onClose === void 0 ? function () {
1272
- return null;
1273
- } : _ref$onClose,
1256
+ onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
1274
1257
  children = _ref.children,
1275
1258
  initials = _ref.initials;
1276
1259
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(IconButton, {
@@ -1622,27 +1605,21 @@ var DraggableComponent = function DraggableComponent(_a) {
1622
1605
  } : _a$startSize,
1623
1606
  _a$startPosition = _a.startPosition,
1624
1607
  startPosition = _a$startPosition === void 0 ? {
1625
- left: null,
1626
- right: null,
1627
- top: null
1608
+ left: undefined,
1609
+ right: undefined,
1610
+ top: undefined
1628
1611
  } : _a$startPosition,
1629
1612
  children = _a.children,
1630
1613
  _a$isOpen = _a.isOpen,
1631
1614
  isOpen = _a$isOpen === void 0 ? true : _a$isOpen,
1632
1615
  _a$onClose = _a.onClose,
1633
- onClose = _a$onClose === void 0 ? function () {
1634
- return null;
1635
- } : _a$onClose,
1616
+ onClose = _a$onClose === void 0 ? function () {} : _a$onClose,
1636
1617
  _a$initialMaxHeight = _a.initialMaxHeight,
1637
1618
  defaultInitialMaxHeight = _a$initialMaxHeight === void 0 ? 'initial' : _a$initialMaxHeight,
1638
1619
  _a$onChangeSize = _a.onChangeSize,
1639
- onChangeSize = _a$onChangeSize === void 0 ? function () {
1640
- return null;
1641
- } : _a$onChangeSize,
1620
+ onChangeSize = _a$onChangeSize === void 0 ? function () {} : _a$onChangeSize,
1642
1621
  _a$onMouseDown = _a.onMouseDown,
1643
- onMouseDown = _a$onMouseDown === void 0 ? function () {
1644
- return null;
1645
- } : _a$onMouseDown,
1622
+ onMouseDown = _a$onMouseDown === void 0 ? function () {} : _a$onMouseDown,
1646
1623
  _a$order = _a.order,
1647
1624
  order = _a$order === void 0 ? 1 : _a$order,
1648
1625
  _a$source = _a.source,
@@ -2456,11 +2433,11 @@ var ToggleMenu = function ToggleMenu(_ref) {
2456
2433
  transition: 'none'
2457
2434
  }
2458
2435
  },
2459
- MenuListProps: children && {
2436
+ MenuListProps: Object.assign({}, children && {
2460
2437
  style: {
2461
2438
  padding: '0px'
2462
2439
  }
2463
- }
2440
+ })
2464
2441
  }, menuItems && menuItems.map(function (menuItem) {
2465
2442
  var text = menuItem.text,
2466
2443
  icon = menuItem.icon,
@@ -2790,7 +2767,7 @@ var TooltipSelect = function TooltipSelect(_a) {
2790
2767
  title: tooltip,
2791
2768
  placement: "top",
2792
2769
  open: tooltipOpen,
2793
- sx: noStyling ? undefined : tooltipContainerStyles(isEnabled, hasBackgroundColor)
2770
+ sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
2794
2771
  }, /*#__PURE__*/React.createElement(Select, Object.assign({
2795
2772
  onOpen: onOpen,
2796
2773
  onClose: onClose,
package/index.umd.js CHANGED
@@ -144,13 +144,16 @@
144
144
 
145
145
  var StatusTag = function StatusTag(_a) {
146
146
  var content = _a.content,
147
- color = _a.color;
147
+ color = _a.color,
148
+ props = __rest(_a, ["content", "color"]);
149
+
148
150
  return /*#__PURE__*/React__namespace.createElement(material.Box, {
149
151
  display: "flex",
150
152
  alignItems: "center",
151
153
  justifyContent: "center",
152
- sx: __assign({}, tagStyle(color)),
153
- "data-testid": "statusTag"
154
+ "data-testid": "statusTag",
155
+ className: "statusTag",
156
+ sx: __assign(__assign({}, tagStyle(color)), props.sx)
154
157
  }, /*#__PURE__*/React__namespace.createElement(material.Typography, {
155
158
  variant: "caption"
156
159
  }, content));
@@ -357,7 +360,7 @@
357
360
  pollingInterval = 300000;
358
361
  }
359
362
 
360
- var interval = React__namespace.useRef(null);
363
+ var interval = React.useRef(null);
361
364
  React__namespace.useEffect(function () {
362
365
  if (deps.filter(function (dep) {
363
366
  return dep !== null;
@@ -634,7 +637,11 @@
634
637
  isOpen = _h[0],
635
638
  setIsOpen = _h[1];
636
639
 
637
- return isOpen && /*#__PURE__*/React__namespace.createElement(material.Alert, {
640
+ if (!isOpen) {
641
+ return null;
642
+ }
643
+
644
+ return /*#__PURE__*/React__namespace.createElement(material.Alert, {
638
645
  "data-testid": dataTestId,
639
646
  severity: severity,
640
647
  icon: /*#__PURE__*/React__namespace.createElement(AlertIcon, {
@@ -887,15 +894,13 @@
887
894
  var ResizeComponent = function ResizeComponent(_a) {
888
895
  var _b = _a.startPosition,
889
896
  startPosition = _b === void 0 ? {
890
- left: null,
891
- right: null,
892
- top: null
897
+ left: undefined,
898
+ right: undefined,
899
+ top: undefined
893
900
  } : _b,
894
901
  children = _a.children,
895
902
  _c = _a.onResizeStart,
896
- onResizeStart = _c === void 0 ? function () {
897
- return null;
898
- } : _c,
903
+ onResizeStart = _c === void 0 ? function () {} : _c,
899
904
  size = _a.size,
900
905
  setSize = _a.setSize,
901
906
  _d = _a.minHeight,
@@ -981,8 +986,8 @@
981
986
  var _this = _super.call(this, props) || this;
982
987
 
983
988
  _this.state = {
984
- error: null,
985
- errorInfo: null
989
+ error: undefined,
990
+ errorInfo: undefined
986
991
  };
987
992
  return _this;
988
993
  }
@@ -1035,9 +1040,7 @@
1035
1040
  };
1036
1041
 
1037
1042
  ErrorBoundary.defaultProps = {
1038
- onError: function onError() {
1039
- return null;
1040
- }
1043
+ onError: function onError() {}
1041
1044
  };
1042
1045
  return ErrorBoundary;
1043
1046
  }(React__namespace.Component);
@@ -1111,13 +1114,9 @@
1111
1114
  var _b = _a.isOpen,
1112
1115
  isOpen = _b === void 0 ? false : _b,
1113
1116
  _c = _a.onToggle,
1114
- onToggle = _c === void 0 ? function () {
1115
- return null;
1116
- } : _c,
1117
+ onToggle = _c === void 0 ? function () {} : _c,
1117
1118
  _d = _a.onClose,
1118
- onClose = _d === void 0 ? function () {
1119
- return null;
1120
- } : _d,
1119
+ onClose = _d === void 0 ? function () {} : _d,
1121
1120
  children = _a.children,
1122
1121
  initials = _a.initials;
1123
1122
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
@@ -1488,27 +1487,21 @@
1488
1487
  } : _d,
1489
1488
  _e = _a.startPosition,
1490
1489
  startPosition = _e === void 0 ? {
1491
- left: null,
1492
- right: null,
1493
- top: null
1490
+ left: undefined,
1491
+ right: undefined,
1492
+ top: undefined
1494
1493
  } : _e,
1495
1494
  children = _a.children,
1496
1495
  _f = _a.isOpen,
1497
1496
  isOpen = _f === void 0 ? true : _f,
1498
1497
  _g = _a.onClose,
1499
- onClose = _g === void 0 ? function () {
1500
- return null;
1501
- } : _g,
1498
+ onClose = _g === void 0 ? function () {} : _g,
1502
1499
  _h = _a.initialMaxHeight,
1503
1500
  defaultInitialMaxHeight = _h === void 0 ? 'initial' : _h,
1504
1501
  _j = _a.onChangeSize,
1505
- onChangeSize = _j === void 0 ? function () {
1506
- return null;
1507
- } : _j,
1502
+ onChangeSize = _j === void 0 ? function () {} : _j,
1508
1503
  _k = _a.onMouseDown,
1509
- onMouseDown = _k === void 0 ? function () {
1510
- return null;
1511
- } : _k,
1504
+ onMouseDown = _k === void 0 ? function () {} : _k,
1512
1505
  _l = _a.order,
1513
1506
  order = _l === void 0 ? 1 : _l,
1514
1507
  _m = _a.source,
@@ -2319,11 +2312,11 @@
2319
2312
  transition: 'none'
2320
2313
  }
2321
2314
  },
2322
- MenuListProps: children && {
2315
+ MenuListProps: __assign({}, children && {
2323
2316
  style: {
2324
2317
  padding: '0px'
2325
2318
  }
2326
- }
2319
+ })
2327
2320
  }, menuItems && menuItems.map(function (menuItem) {
2328
2321
  var text = menuItem.text,
2329
2322
  icon = menuItem.icon,
@@ -2670,7 +2663,7 @@
2670
2663
  title: tooltip,
2671
2664
  placement: "top",
2672
2665
  open: tooltipOpen,
2673
- sx: noStyling ? undefined : tooltipContainerStyles(isEnabled, hasBackgroundColor)
2666
+ sx: noStyling ? undefined : tooltipContainerStyles(!!isEnabled, hasBackgroundColor)
2674
2667
  }, /*#__PURE__*/React__namespace.createElement(material.Select, __assign({
2675
2668
  onOpen: onOpen,
2676
2669
  onClose: onClose,
@@ -5,25 +5,21 @@ declare const _default: {
5
5
  export default _default;
6
6
  export declare const AvatarLight: {
7
7
  (): React.ReactElement;
8
- story: {
9
- name: string;
10
- parameters: {
11
- zeplinLink: {
12
- name: string;
13
- link: string;
14
- }[];
15
- };
8
+ storyName: string;
9
+ parameters: {
10
+ zeplinLink: {
11
+ name: string;
12
+ link: string;
13
+ }[];
16
14
  };
17
15
  };
18
16
  export declare const AvatarDark: {
19
17
  (): React.ReactElement;
20
- story: {
21
- name: string;
22
- parameters: {
23
- zeplinLink: {
24
- name: string;
25
- link: string;
26
- }[];
27
- };
18
+ storyName: string;
19
+ parameters: {
20
+ zeplinLink: {
21
+ name: string;
22
+ link: string;
23
+ }[];
28
24
  };
29
25
  };
@@ -3,6 +3,6 @@ import { ToggleButtonProps } from '@mui/material';
3
3
  import { ButtonVariant } from '@opengeoweb/theme';
4
4
  export interface CustomToggleButtonProps extends Omit<ToggleButtonProps, 'value'> {
5
5
  variant?: ButtonVariant;
6
- value?: unknown;
6
+ value?: any;
7
7
  }
8
8
  export declare const CustomToggleButton: React.FC<CustomToggleButtonProps>;
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- interface StatusTagProps {
2
+ import { BoxProps } from '@mui/material';
3
+ interface StatusTagProps extends BoxProps {
3
4
  content: string;
4
5
  color: string;
5
6
  }
@@ -7,5 +7,6 @@ export interface ToolButtonProps extends CustomToggleButtonProps {
7
7
  height?: string;
8
8
  value?: unknown;
9
9
  sx?: SxProps<Theme>;
10
+ children?: React.ReactNode;
10
11
  }
11
12
  export declare const ToolButton: React.FC<ToolButtonProps>;
@@ -1,2 +1,2 @@
1
1
  import * as React from 'react';
2
- export declare const usePoller: (deps: unknown[], callback: () => void, pollingInterval?: number) => React.MutableRefObject<number>;
2
+ export declare const usePoller: (deps: unknown[], callback: () => void, pollingInterval?: number) => React.RefObject<ReturnType<typeof setTimeout>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "GeoWeb shared library with shared components and utils for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,16 +13,16 @@
13
13
  "dependencies": {},
14
14
  "peerDependencies": {
15
15
  "react": "^17.0.2",
16
- "@mui/material": "^5.2.8",
17
- "@opengeoweb/theme": "4.1.0",
18
- "react-draggable": "^4.4.3",
16
+ "@mui/material": "^5.10.8",
17
+ "@opengeoweb/theme": "4.3.0",
18
+ "react-draggable": "^4.4.5",
19
19
  "re-resizable": "^6.9.0",
20
20
  "lodash": "^4.17.20",
21
- "@opengeoweb/form-fields": "4.1.0",
21
+ "@opengeoweb/form-fields": "4.3.0",
22
22
  "react-hook-form": "^6.12.1",
23
23
  "moment": "^2.29.0",
24
24
  "moment-timezone": "^0.5.31",
25
- "@mui/lab": "^5.0.0-alpha.64",
25
+ "@mui/x-date-pickers": "^5.0.4",
26
26
  "axios": "^0.25.0"
27
27
  }
28
28
  }