@opengeoweb/shared 2.14.0 → 2.15.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,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default from 'react';
3
- import { Box, Typography, Dialog, DialogTitle, IconButton, DialogContent, DialogActions, Button, CircularProgress, Alert, AlertTitle, Grid, useTheme, Link, Avatar, Paper, ClickAwayListener, MenuList, MenuItem, RadioGroup, FormControlLabel, Radio, Tooltip, List, ListItem, Tabs, Tab, Backdrop, Slider, ToggleButton, Menu, ListItemIcon, Checkbox, Select } from '@mui/material';
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';
6
6
  import { isEmpty, errorMessages } from '@opengeoweb/form-fields';
@@ -870,7 +870,7 @@ var AlertBanner = function AlertBanner(_ref) {
870
870
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
871
871
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
872
872
  * */
873
- var useStyles$7 = makeStyles(function () {
873
+ var useStyles$6 = makeStyles(function () {
874
874
  return {
875
875
  wrapper: {
876
876
  height: '100vh',
@@ -887,7 +887,7 @@ var useStyles$7 = makeStyles(function () {
887
887
  var AppLayout = function AppLayout(_ref) {
888
888
  var header = _ref.header,
889
889
  children = _ref.children;
890
- var classes = useStyles$7();
890
+ var classes = useStyles$6();
891
891
  return /*#__PURE__*/React__default.createElement("div", {
892
892
  className: classes.wrapper
893
893
  }, header, /*#__PURE__*/React__default.createElement("main", {
@@ -895,7 +895,7 @@ var AppLayout = function AppLayout(_ref) {
895
895
  }, children));
896
896
  };
897
897
 
898
- var useStyles$6 = makeStyles(function (theme) {
898
+ var useStyles$5 = makeStyles(function (theme) {
899
899
  var _header;
900
900
 
901
901
  return {
@@ -929,7 +929,7 @@ var AppHeader = function AppHeader(_ref) {
929
929
  userMenu = _ref.userMenu,
930
930
  _ref$title = _ref.title,
931
931
  title = _ref$title === void 0 ? 'GeoWeb' : _ref$title;
932
- var classes = useStyles$6();
932
+ var classes = useStyles$5();
933
933
  return /*#__PURE__*/React__default.createElement("header", {
934
934
  className: classes.header
935
935
  }, /*#__PURE__*/React__default.createElement(Grid, {
@@ -1175,6 +1175,51 @@ ErrorBoundary.defaultProps = {
1175
1175
  }
1176
1176
  };
1177
1177
 
1178
+ /* *
1179
+ * Licensed under the Apache License, Version 2.0 (the "License");
1180
+ * you may not use this file except in compliance with the License.
1181
+ * You may obtain a copy of the License at
1182
+ *
1183
+ * http://www.apache.org/licenses/LICENSE-2.0
1184
+ *
1185
+ * Unless required by applicable law or agreed to in writing, software
1186
+ * distributed under the License is distributed on an "AS IS" BASIS,
1187
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1188
+ * See the License for the specific language governing permissions and
1189
+ * limitations under the License.
1190
+ *
1191
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1192
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
1193
+ * */
1194
+ var styles$3 = {
1195
+ small: {
1196
+ height: 16,
1197
+ width: 16,
1198
+ fontSize: '0.5rem'
1199
+ },
1200
+ large: {
1201
+ height: 32,
1202
+ width: 32,
1203
+ fontSize: '0.938rem'
1204
+ }
1205
+ };
1206
+
1207
+ var Avatar = function Avatar(_ref) {
1208
+ var children = _ref.children,
1209
+ _ref$size = _ref.size,
1210
+ size = _ref$size === void 0 ? 'large' : _ref$size;
1211
+ return /*#__PURE__*/React.createElement(Avatar$1, {
1212
+ "data-testid": "avatar",
1213
+ sx: Object.assign(Object.assign({}, styles$3[size]), {
1214
+ fontWeight: 500,
1215
+ color: 'geowebColors.brand.brand',
1216
+ backgroundColor: 'common.white',
1217
+ border: '0.1px solid',
1218
+ borderColor: 'geowebColors.brand.brand'
1219
+ })
1220
+ }, children);
1221
+ };
1222
+
1178
1223
  /* *
1179
1224
  * Licensed under the Apache License, Version 2.0 (the "License");
1180
1225
  * you may not use this file except in compliance with the License.
@@ -1191,40 +1236,30 @@ ErrorBoundary.defaultProps = {
1191
1236
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1192
1237
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
1193
1238
  * */
1194
- var useStyles$5 = makeStyles(function (theme) {
1195
- return {
1196
- container: {
1197
- position: 'absolute',
1198
- top: 38,
1199
- right: 20,
1200
- width: 256,
1201
- borderRadius: 0,
1202
- boxShadow: theme.shadows[5],
1203
- background: theme.palette.geowebColors.background.surface
1204
- },
1205
- userMenu: {
1206
- padding: 0,
1207
- '& > li': {
1208
- paddingTop: 24,
1209
- paddingBottom: 24,
1210
- paddingLeft: 16,
1211
- paddingRight: 16
1212
- }
1213
- },
1214
- button: {
1215
- color: theme.palette.common.white,
1216
- padding: 0
1217
- },
1218
- avatar: {
1219
- height: 32,
1220
- width: 32,
1221
- fontSize: '0.938rem',
1222
- fontWeight: 500,
1223
- color: theme.palette.geowebColors.brand.brand,
1224
- backgroundColor: theme.palette.common.white
1239
+ var styles$2 = {
1240
+ container: {
1241
+ position: 'absolute',
1242
+ top: 38,
1243
+ right: 20,
1244
+ width: 256,
1245
+ borderRadius: 0,
1246
+ boxShadow: 5,
1247
+ backgroundColor: 'geowebColors.background.surface'
1248
+ },
1249
+ userMenu: {
1250
+ padding: 0,
1251
+ '& > li': {
1252
+ paddingTop: 3,
1253
+ paddingBottom: 3,
1254
+ paddingLeft: 2,
1255
+ paddingRight: 2
1225
1256
  }
1226
- };
1227
- });
1257
+ },
1258
+ button: {
1259
+ color: 'common.white',
1260
+ padding: 0
1261
+ }
1262
+ };
1228
1263
 
1229
1264
  var UserMenu = function UserMenu(_ref) {
1230
1265
  var _ref$isOpen = _ref.isOpen,
@@ -1239,22 +1274,19 @@ var UserMenu = function UserMenu(_ref) {
1239
1274
  } : _ref$onClose,
1240
1275
  children = _ref.children,
1241
1276
  initials = _ref.initials;
1242
- var classes = useStyles$5();
1243
1277
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(IconButton, {
1244
1278
  "data-testid": "userButton",
1245
1279
  onClick: onToggle,
1246
- className: classes.button,
1280
+ sx: styles$2.button,
1247
1281
  size: "large"
1248
- }, /*#__PURE__*/React__default.createElement(Avatar, {
1249
- className: classes.avatar
1250
- }, initials)), isOpen && /*#__PURE__*/React__default.createElement(Paper, {
1251
- className: classes.container,
1282
+ }, /*#__PURE__*/React__default.createElement(Avatar, null, initials)), isOpen && /*#__PURE__*/React__default.createElement(Paper, {
1283
+ sx: styles$2.container,
1252
1284
  "data-testid": "userMenu"
1253
1285
  }, /*#__PURE__*/React__default.createElement(ClickAwayListener, {
1254
1286
  onClickAway: onClose,
1255
1287
  mouseEvent: "onMouseDown"
1256
1288
  }, /*#__PURE__*/React__default.createElement(MenuList, {
1257
- className: classes.userMenu,
1289
+ sx: styles$2.userMenu,
1258
1290
  variant: "menu"
1259
1291
  }, children))));
1260
1292
  };
@@ -2300,18 +2332,20 @@ var CustomSlider = function CustomSlider(_a) {
2300
2332
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2301
2333
  * */
2302
2334
 
2303
- var CustomToggleButton = function CustomToggleButton(_a) {
2335
+ var CustomToggleButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
2304
2336
  var _a$variant = _a.variant,
2305
2337
  variant = _a$variant === void 0 ? 'primary' : _a$variant,
2338
+ className = _a.className,
2306
2339
  _a$value = _a.value,
2307
2340
  value = _a$value === void 0 ? 0 : _a$value,
2308
- props = __rest(_a, ["variant", "value"]);
2341
+ props = __rest(_a, ["variant", "className", "value"]);
2309
2342
 
2310
2343
  return /*#__PURE__*/React.createElement(ToggleButton, Object.assign({
2311
- className: variant,
2344
+ ref: ref,
2345
+ className: "".concat(variant, " ").concat(className),
2312
2346
  value: value
2313
2347
  }, props));
2314
- };
2348
+ });
2315
2349
 
2316
2350
  /* *
2317
2351
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -2329,7 +2363,7 @@ var CustomToggleButton = function CustomToggleButton(_a) {
2329
2363
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2330
2364
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2331
2365
  * */
2332
- var ToolButton = function ToolButton(_a) {
2366
+ var ToolButton = /*#__PURE__*/React.forwardRef(function (_a, ref) {
2333
2367
  var active = _a.active,
2334
2368
  _a$width = _a.width,
2335
2369
  width = _a$width === void 0 ? '24px' : _a$width,
@@ -2345,6 +2379,7 @@ var ToolButton = function ToolButton(_a) {
2345
2379
  props = __rest(_a, ["active", "width", "height", "children", "value", "sx", "variant"]);
2346
2380
 
2347
2381
  return /*#__PURE__*/React.createElement(CustomToggleButton, Object.assign({
2382
+ ref: ref,
2348
2383
  variant: variant,
2349
2384
  disableRipple: true,
2350
2385
  selected: active,
@@ -2359,7 +2394,7 @@ var ToolButton = function ToolButton(_a) {
2359
2394
  }
2360
2395
  }, sx)
2361
2396
  }, props), children);
2362
- };
2397
+ });
2363
2398
 
2364
2399
  var getPosition = function getPosition(menuPosition) {
2365
2400
  switch (menuPosition) {
@@ -2882,7 +2917,8 @@ var TooltipSelect = function TooltipSelect(_a) {
2882
2917
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2883
2918
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2884
2919
  * */
2885
- // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2920
+ var DEFAULT_ERROR_MESSAGE = 'An error has occurred'; // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2921
+
2886
2922
  var isAxiosError = function isAxiosError(error) {
2887
2923
  return error.isAxiosError !== undefined;
2888
2924
  };
@@ -2897,7 +2933,18 @@ var getAxiosErrorMessage = function getAxiosErrorMessage(error) {
2897
2933
  return data.message;
2898
2934
  }
2899
2935
 
2900
- return 'An error has occurred';
2936
+ if (error.message) {
2937
+ return error.message;
2938
+ }
2939
+
2940
+ return DEFAULT_ERROR_MESSAGE;
2941
+ };
2942
+ var getErrorMessage = function getErrorMessage(error) {
2943
+ if (isAxiosError(error)) {
2944
+ return getAxiosErrorMessage(error);
2945
+ }
2946
+
2947
+ return error.message || DEFAULT_ERROR_MESSAGE;
2901
2948
  };
2902
2949
 
2903
- export { AlertBanner, AlertIcon, AppHeader, AppLayout, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, CustomToggleButton, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, calculateDialogSizeAndPosition, getAxiosErrorMessage, getInitials, getPosition, isAxiosError, showPrompt, sliderStyles, tooltipContainerStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, usePoller, usePreventBrowserClose, usePrevious, useUserMenu };
2950
+ export { AlertBanner, AlertIcon, AppHeader, AppLayout, Avatar, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, CustomToggleButton, DEFAULT_ERROR_MESSAGE, DraggableComponent$1 as Draggable, EnableButton, ErrorBoundary, HIDDEN_INPUT_HELPER_IS_DRAFT, ManagerButton, ManagerDeleteButton, ResizeComponent as Resizable, StatusTag, ToggleMenu, ToolButton, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, TooltipSelect, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, calculateDialogSizeAndPosition, getAxiosErrorMessage, getErrorMessage, getInitials, getPosition, isAxiosError, showPrompt, sliderStyles, tooltipContainerStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, usePoller, usePreventBrowserClose, usePrevious, useUserMenu };
package/index.umd.js CHANGED
@@ -723,7 +723,7 @@
723
723
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
724
724
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
725
725
  * */
726
- var useStyles$7 = makeStyles__default["default"](function () {
726
+ var useStyles$6 = makeStyles__default["default"](function () {
727
727
  return {
728
728
  wrapper: {
729
729
  height: '100vh',
@@ -740,7 +740,7 @@
740
740
  var AppLayout = function AppLayout(_a) {
741
741
  var header = _a.header,
742
742
  children = _a.children;
743
- var classes = useStyles$7();
743
+ var classes = useStyles$6();
744
744
  return /*#__PURE__*/React__default["default"].createElement("div", {
745
745
  className: classes.wrapper
746
746
  }, header, /*#__PURE__*/React__default["default"].createElement("main", {
@@ -764,7 +764,7 @@
764
764
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
765
765
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
766
766
  * */
767
- var useStyles$6 = makeStyles__default["default"](function (theme) {
767
+ var useStyles$5 = makeStyles__default["default"](function (theme) {
768
768
  var _a;
769
769
 
770
770
  return {
@@ -798,7 +798,7 @@
798
798
  userMenu = _a.userMenu,
799
799
  _b = _a.title,
800
800
  title = _b === void 0 ? 'GeoWeb' : _b;
801
- var classes = useStyles$6();
801
+ var classes = useStyles$5();
802
802
  return /*#__PURE__*/React__default["default"].createElement("header", {
803
803
  className: classes.header
804
804
  }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
@@ -1036,6 +1036,35 @@
1036
1036
  return ErrorBoundary;
1037
1037
  }(React__namespace.Component);
1038
1038
 
1039
+ var styles$3 = {
1040
+ small: {
1041
+ height: 16,
1042
+ width: 16,
1043
+ fontSize: '0.5rem'
1044
+ },
1045
+ large: {
1046
+ height: 32,
1047
+ width: 32,
1048
+ fontSize: '0.938rem'
1049
+ }
1050
+ };
1051
+
1052
+ var Avatar = function Avatar(_a) {
1053
+ var children = _a.children,
1054
+ _b = _a.size,
1055
+ size = _b === void 0 ? 'large' : _b;
1056
+ return /*#__PURE__*/React__namespace.createElement(material.Avatar, {
1057
+ "data-testid": "avatar",
1058
+ sx: __assign(__assign({}, styles$3[size]), {
1059
+ fontWeight: 500,
1060
+ color: 'geowebColors.brand.brand',
1061
+ backgroundColor: 'common.white',
1062
+ border: '0.1px solid',
1063
+ borderColor: 'geowebColors.brand.brand'
1064
+ })
1065
+ }, children);
1066
+ };
1067
+
1039
1068
  /* *
1040
1069
  * Licensed under the Apache License, Version 2.0 (the "License");
1041
1070
  * you may not use this file except in compliance with the License.
@@ -1052,40 +1081,30 @@
1052
1081
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1053
1082
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
1054
1083
  * */
1055
- var useStyles$5 = makeStyles__default["default"](function (theme) {
1056
- return {
1057
- container: {
1058
- position: 'absolute',
1059
- top: 38,
1060
- right: 20,
1061
- width: 256,
1062
- borderRadius: 0,
1063
- boxShadow: theme.shadows[5],
1064
- background: theme.palette.geowebColors.background.surface
1065
- },
1066
- userMenu: {
1067
- padding: 0,
1068
- '& > li': {
1069
- paddingTop: 24,
1070
- paddingBottom: 24,
1071
- paddingLeft: 16,
1072
- paddingRight: 16
1073
- }
1074
- },
1075
- button: {
1076
- color: theme.palette.common.white,
1077
- padding: 0
1078
- },
1079
- avatar: {
1080
- height: 32,
1081
- width: 32,
1082
- fontSize: '0.938rem',
1083
- fontWeight: 500,
1084
- color: theme.palette.geowebColors.brand.brand,
1085
- backgroundColor: theme.palette.common.white
1084
+ var styles$2 = {
1085
+ container: {
1086
+ position: 'absolute',
1087
+ top: 38,
1088
+ right: 20,
1089
+ width: 256,
1090
+ borderRadius: 0,
1091
+ boxShadow: 5,
1092
+ backgroundColor: 'geowebColors.background.surface'
1093
+ },
1094
+ userMenu: {
1095
+ padding: 0,
1096
+ '& > li': {
1097
+ paddingTop: 3,
1098
+ paddingBottom: 3,
1099
+ paddingLeft: 2,
1100
+ paddingRight: 2
1086
1101
  }
1087
- };
1088
- });
1102
+ },
1103
+ button: {
1104
+ color: 'common.white',
1105
+ padding: 0
1106
+ }
1107
+ };
1089
1108
 
1090
1109
  var UserMenu = function UserMenu(_a) {
1091
1110
  var _b = _a.isOpen,
@@ -1100,22 +1119,19 @@
1100
1119
  } : _d,
1101
1120
  children = _a.children,
1102
1121
  initials = _a.initials;
1103
- var classes = useStyles$5();
1104
1122
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.IconButton, {
1105
1123
  "data-testid": "userButton",
1106
1124
  onClick: onToggle,
1107
- className: classes.button,
1125
+ sx: styles$2.button,
1108
1126
  size: "large"
1109
- }, /*#__PURE__*/React__default["default"].createElement(material.Avatar, {
1110
- className: classes.avatar
1111
- }, initials)), isOpen && /*#__PURE__*/React__default["default"].createElement(material.Paper, {
1112
- className: classes.container,
1127
+ }, /*#__PURE__*/React__default["default"].createElement(Avatar, null, initials)), isOpen && /*#__PURE__*/React__default["default"].createElement(material.Paper, {
1128
+ sx: styles$2.container,
1113
1129
  "data-testid": "userMenu"
1114
1130
  }, /*#__PURE__*/React__default["default"].createElement(material.ClickAwayListener, {
1115
1131
  onClickAway: onClose,
1116
1132
  mouseEvent: "onMouseDown"
1117
1133
  }, /*#__PURE__*/React__default["default"].createElement(material.MenuList, {
1118
- className: classes.userMenu,
1134
+ sx: styles$2.userMenu,
1119
1135
  variant: "menu"
1120
1136
  }, children))));
1121
1137
  };
@@ -2194,18 +2210,20 @@
2194
2210
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2195
2211
  * */
2196
2212
 
2197
- var CustomToggleButton = function CustomToggleButton(_a) {
2213
+ var CustomToggleButton = /*#__PURE__*/React__namespace.forwardRef(function (_a, ref) {
2198
2214
  var _b = _a.variant,
2199
2215
  variant = _b === void 0 ? 'primary' : _b,
2216
+ className = _a.className,
2200
2217
  _c = _a.value,
2201
2218
  value = _c === void 0 ? 0 : _c,
2202
- props = __rest(_a, ["variant", "value"]);
2219
+ props = __rest(_a, ["variant", "className", "value"]);
2203
2220
 
2204
2221
  return /*#__PURE__*/React__namespace.createElement(material.ToggleButton, __assign({
2205
- className: variant,
2222
+ ref: ref,
2223
+ className: variant + " " + className,
2206
2224
  value: value
2207
2225
  }, props));
2208
- };
2226
+ });
2209
2227
 
2210
2228
  /* *
2211
2229
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -2223,7 +2241,7 @@
2223
2241
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2224
2242
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2225
2243
  * */
2226
- var ToolButton = function ToolButton(_a) {
2244
+ var ToolButton = /*#__PURE__*/React__namespace.forwardRef(function (_a, ref) {
2227
2245
  var active = _a.active,
2228
2246
  _b = _a.width,
2229
2247
  width = _b === void 0 ? '24px' : _b,
@@ -2239,6 +2257,7 @@
2239
2257
  props = __rest(_a, ["active", "width", "height", "children", "value", "sx", "variant"]);
2240
2258
 
2241
2259
  return /*#__PURE__*/React__namespace.createElement(CustomToggleButton, __assign({
2260
+ ref: ref,
2242
2261
  variant: variant,
2243
2262
  disableRipple: true,
2244
2263
  selected: active,
@@ -2253,7 +2272,7 @@
2253
2272
  }
2254
2273
  }, sx)
2255
2274
  }, props), children);
2256
- };
2275
+ });
2257
2276
 
2258
2277
  var getPosition = function getPosition(menuPosition) {
2259
2278
  switch (menuPosition) {
@@ -2792,7 +2811,8 @@
2792
2811
  * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2793
2812
  * Copyright 2021 - Finnish Meteorological Institute (FMI)
2794
2813
  * */
2795
- // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2814
+ var DEFAULT_ERROR_MESSAGE = 'An error has occurred'; // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2815
+
2796
2816
  var isAxiosError = function isAxiosError(error) {
2797
2817
  return error.isAxiosError !== undefined;
2798
2818
  };
@@ -2807,17 +2827,30 @@
2807
2827
  return data.message;
2808
2828
  }
2809
2829
 
2810
- return 'An error has occurred';
2830
+ if (error.message) {
2831
+ return error.message;
2832
+ }
2833
+
2834
+ return DEFAULT_ERROR_MESSAGE;
2835
+ };
2836
+ var getErrorMessage = function getErrorMessage(error) {
2837
+ if (isAxiosError(error)) {
2838
+ return getAxiosErrorMessage(error);
2839
+ }
2840
+
2841
+ return error.message || DEFAULT_ERROR_MESSAGE;
2811
2842
  };
2812
2843
 
2813
2844
  exports.AlertBanner = AlertBanner;
2814
2845
  exports.AlertIcon = AlertIcon;
2815
2846
  exports.AppHeader = AppHeader;
2816
2847
  exports.AppLayout = AppLayout;
2848
+ exports.Avatar = Avatar;
2817
2849
  exports.ConfirmationDialog = ConfirmationDialog;
2818
2850
  exports.ConfirmationServiceProvider = ConfirmationServiceProvider;
2819
2851
  exports.CustomSlider = CustomSlider;
2820
2852
  exports.CustomToggleButton = CustomToggleButton;
2853
+ exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
2821
2854
  exports.Draggable = DraggableComponent$1;
2822
2855
  exports.EnableButton = EnableButton;
2823
2856
  exports.ErrorBoundary = ErrorBoundary;
@@ -2838,6 +2871,7 @@
2838
2871
  exports.UserMenuItemTheme = MenuItemTheme;
2839
2872
  exports.calculateDialogSizeAndPosition = calculateDialogSizeAndPosition;
2840
2873
  exports.getAxiosErrorMessage = getAxiosErrorMessage;
2874
+ exports.getErrorMessage = getErrorMessage;
2841
2875
  exports.getInitials = getInitials;
2842
2876
  exports.getPosition = getPosition;
2843
2877
  exports.isAxiosError = isAxiosError;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ interface AvatarProps {
3
+ children: React.ReactNode;
4
+ size?: 'small' | 'large';
5
+ }
6
+ declare const Avatar: React.FC<AvatarProps>;
7
+ export default Avatar;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const AvatarLight: {
7
+ (): React.ReactElement;
8
+ storyName: string;
9
+ };
10
+ export declare const AvatarDark: {
11
+ (): React.ReactElement;
12
+ storyName: string;
13
+ };
@@ -0,0 +1 @@
1
+ export { default as Avatar } from './Avatar';
@@ -16,3 +16,4 @@ export * from './ManagerDeleteButton';
16
16
  export * from './EnableButton';
17
17
  export * from './AlertIcon';
18
18
  export * from './TooltipSelect';
19
+ export * from './Avatar';
@@ -1,3 +1,5 @@
1
1
  import { AxiosError } from 'axios';
2
+ export declare const DEFAULT_ERROR_MESSAGE = "An error has occurred";
2
3
  export declare const isAxiosError: (error: AxiosError | Error) => error is AxiosError<any, any>;
3
4
  export declare const getAxiosErrorMessage: (error: AxiosError) => string;
5
+ export declare const getErrorMessage: (error: Error | AxiosError) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/shared",
3
- "version": "2.14.0",
3
+ "version": "2.15.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": {
@@ -14,12 +14,12 @@
14
14
  "peerDependencies": {
15
15
  "react": "^17.0.2",
16
16
  "@mui/material": "^5.2.8",
17
- "@opengeoweb/theme": "2.14.0",
17
+ "@opengeoweb/theme": "2.15.0",
18
18
  "@mui/styles": "^5.2.3",
19
19
  "react-draggable": "^4.4.3",
20
20
  "re-resizable": "^6.9.0",
21
21
  "lodash": "^4.17.20",
22
- "@opengeoweb/form-fields": "2.14.0",
22
+ "@opengeoweb/form-fields": "2.15.0",
23
23
  "react-hook-form": "^6.12.1",
24
24
  "moment": "^2.29.0",
25
25
  "moment-timezone": "^0.5.31",