@opengeoweb/shared 2.0.1

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.
Files changed (92) hide show
  1. package/README.md +38 -0
  2. package/index.d.ts +3 -0
  3. package/lib/components/AlertBanner/AlertBanner.d.ts +10 -0
  4. package/lib/components/AlertBanner/AlertBanner.spec.d.ts +1 -0
  5. package/lib/components/AlertBanner/AlertBanner.stories.d.ts +2 -0
  6. package/lib/components/AlertBanner/index.d.ts +1 -0
  7. package/lib/components/AppHeader/AppHeader.d.ts +8 -0
  8. package/lib/components/AppHeader/AppHeader.spec.d.ts +1 -0
  9. package/lib/components/AppHeader/AppHeader.stories.d.ts +2 -0
  10. package/lib/components/AppHeader/index.d.ts +1 -0
  11. package/lib/components/AppLayout/AppLayout.d.ts +7 -0
  12. package/lib/components/AppLayout/AppLayout.spec.d.ts +1 -0
  13. package/lib/components/AppLayout/AppLayout.stories.d.ts +7 -0
  14. package/lib/components/AppLayout/index.d.ts +1 -0
  15. package/lib/components/ConfirmationDialog/ConfirmationDialog.d.ts +17 -0
  16. package/lib/components/ConfirmationDialog/ConfirmationDialog.spec.d.ts +1 -0
  17. package/lib/components/ConfirmationDialog/ConfirmationDialog.stories.d.ts +2 -0
  18. package/lib/components/ConfirmationDialog/ConfirmationService.d.ts +18 -0
  19. package/lib/components/ConfirmationDialog/ConfirmationService.spec.d.ts +1 -0
  20. package/lib/components/ConfirmationDialog/index.d.ts +2 -0
  21. package/lib/components/CustomSlider/CustomSlider.d.ts +18 -0
  22. package/lib/components/CustomSlider/CustomSlider.spec.d.ts +1 -0
  23. package/lib/components/CustomSlider/CustomSlider.stories.d.ts +2 -0
  24. package/lib/components/CustomSlider/index.d.ts +1 -0
  25. package/lib/components/DraggableResizable/Draggable.d.ts +16 -0
  26. package/lib/components/DraggableResizable/Draggable.spec.d.ts +1 -0
  27. package/lib/components/DraggableResizable/Resizable.d.ts +4 -0
  28. package/lib/components/DraggableResizable/Resizable.spec.d.ts +1 -0
  29. package/lib/components/DraggableResizable/index.d.ts +2 -0
  30. package/lib/components/DraggableResizable/types.d.ts +20 -0
  31. package/lib/components/StatusTag/StatusTag.d.ts +7 -0
  32. package/lib/components/StatusTag/StatusTag.spec.d.ts +1 -0
  33. package/lib/components/StatusTag/StatusTag.stories.d.ts +2 -0
  34. package/lib/components/StatusTag/index.d.ts +1 -0
  35. package/lib/components/ToolContainer/ToolContainer.d.ts +5 -0
  36. package/lib/components/ToolContainer/ToolContainer.spec.d.ts +1 -0
  37. package/lib/components/ToolContainer/ToolContainer.stories.d.ts +12 -0
  38. package/lib/components/ToolContainer/ToolContainerDraggable.d.ts +18 -0
  39. package/lib/components/ToolContainer/ToolContainerDraggable.spec.d.ts +1 -0
  40. package/lib/components/ToolContainer/ToolContainerDraggable.stories.d.ts +7 -0
  41. package/lib/components/ToolContainer/ToolContainerSnapShots.stories.d.ts +13 -0
  42. package/lib/components/ToolContainer/ToolFooter.d.ts +3 -0
  43. package/lib/components/ToolContainer/ToolFooter.spec.d.ts +1 -0
  44. package/lib/components/ToolContainer/ToolHeader.d.ts +4 -0
  45. package/lib/components/ToolContainer/ToolHeader.spec.d.ts +1 -0
  46. package/lib/components/ToolContainer/ToolHeader.stories.d.ts +10 -0
  47. package/lib/components/ToolContainer/index.d.ts +5 -0
  48. package/lib/components/ToolContainer/types.d.ts +16 -0
  49. package/lib/components/UserMenu/CheatSheet/CheatSheet.d.ts +3 -0
  50. package/lib/components/UserMenu/CheatSheet/CheatSheet.spec.d.ts +1 -0
  51. package/lib/components/UserMenu/CheatSheet/CheatSheet.stories.d.ts +7 -0
  52. package/lib/components/UserMenu/CheatSheet/Icons.d.ts +7 -0
  53. package/lib/components/UserMenu/CheatSheet/ShortcutList.d.ts +14 -0
  54. package/lib/components/UserMenu/CheatSheet/ShortcutList.spec.d.ts +1 -0
  55. package/lib/components/UserMenu/CheatSheet/ShortcutSegment.d.ts +7 -0
  56. package/lib/components/UserMenu/CheatSheet/ShortcutSegment.spec.d.ts +1 -0
  57. package/lib/components/UserMenu/UserMenu.d.ts +10 -0
  58. package/lib/components/UserMenu/UserMenu.spec.d.ts +1 -0
  59. package/lib/components/UserMenu/UserMenu.stories.d.ts +7 -0
  60. package/lib/components/UserMenu/UserMenuItemCheatSheet.d.ts +3 -0
  61. package/lib/components/UserMenu/UserMenuItemCheatSheet.spec.d.ts +1 -0
  62. package/lib/components/UserMenu/UserMenuItemTheme.d.ts +3 -0
  63. package/lib/components/UserMenu/UserMenuItemTheme.spec.d.ts +1 -0
  64. package/lib/components/UserMenu/index.d.ts +5 -0
  65. package/lib/components/UserMenu/useUserMenu.d.ts +7 -0
  66. package/lib/components/UserMenu/useUserMenu.spec.d.ts +1 -0
  67. package/lib/components/UserMenu/utils.d.ts +1 -0
  68. package/lib/components/components.stories.d.ts +9 -0
  69. package/lib/components/index.d.ts +9 -0
  70. package/lib/hooks/hooks.stories.d.ts +7 -0
  71. package/lib/hooks/index.d.ts +5 -0
  72. package/lib/hooks/useDraftFormHelpers/useDraftFormHelpers.d.ts +8 -0
  73. package/lib/hooks/useDraftFormHelpers/useDraftFormHelpers.spec.d.ts +1 -0
  74. package/lib/hooks/useIsMounted/useIsMounted.d.ts +4 -0
  75. package/lib/hooks/useIsMounted/useIsMounted.spec.d.ts +1 -0
  76. package/lib/hooks/usePoller/usePoller.d.ts +2 -0
  77. package/lib/hooks/usePoller/usePoller.spec.d.ts +1 -0
  78. package/lib/hooks/usePoller/usePoller.stories.d.ts +2 -0
  79. package/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.d.ts +2 -0
  80. package/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.spec.d.ts +1 -0
  81. package/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.stories.d.ts +2 -0
  82. package/lib/hooks/usePrevious/usePrevious.d.ts +1 -0
  83. package/lib/hooks/usePrevious/usePrevious.spec.d.ts +1 -0
  84. package/lib/hooks/usePrevious/usePrevious.stories.d.ts +2 -0
  85. package/lib/storyshots/Storyshots.spec.d.ts +1 -0
  86. package/lib/utils/axiosErrorUtils/axiosErrorUtils.d.ts +3 -0
  87. package/lib/utils/axiosErrorUtils/axiosErrorUtils.spec.d.ts +1 -0
  88. package/lib/utils/axiosErrorUtils/index.d.ts +1 -0
  89. package/lib/utils/index.d.ts +1 -0
  90. package/package.json +31 -0
  91. package/shared.esm.js +2220 -0
  92. package/shared.umd.js +2232 -0
package/shared.esm.js ADDED
@@ -0,0 +1,2220 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import { Box, Typography, makeStyles, Dialog, DialogTitle, IconButton, DialogContent, DialogActions, Button, SvgIcon, Grid, useTheme, Avatar, Paper, ClickAwayListener, MenuList, MenuItem, RadioGroup, FormControlLabel, Radio, List, ListItem, Tabs, Tab, Backdrop, withStyles, Slider } from '@material-ui/core';
4
+ import { Close, DragIndicator } from '@material-ui/icons';
5
+ import { useFormContext } from 'react-hook-form';
6
+ import { isEmpty, errorMessages } from '@opengeoweb/form-fields';
7
+ import { Alert, AlertTitle } from '@material-ui/lab';
8
+ import Draggable from 'react-draggable';
9
+ import { Resizable } from 're-resizable';
10
+ import { useThemeContext } from '@opengeoweb/theme';
11
+ import { throttle } from 'lodash';
12
+
13
+ /* *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ *
26
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
27
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
28
+ * */
29
+ var bgColors = {
30
+ green: '#fcffeb',
31
+ grey: '#f8f9f9',
32
+ purple: '#f8f9f9',
33
+ red: '#f9e8ea',
34
+ yellow: '#fff8eb'
35
+ };
36
+ var borderColors = {
37
+ green: '#72bb23',
38
+ grey: '#9b9fb0',
39
+ purple: '#9d9df2',
40
+ red: '#f24a00',
41
+ yellow: '#ffa800'
42
+ };
43
+
44
+ var tagStyle = function tagStyle(color) {
45
+ // Set color to grey for summary
46
+ var bgcolor = bgColors[color];
47
+ var borderColor = borderColors[color];
48
+ return {
49
+ bgcolor: bgcolor,
50
+ borderColor: borderColor,
51
+ m: 0,
52
+ p: 0.5,
53
+ border: 2,
54
+ borderRadius: 4,
55
+ style: {
56
+ width: '85px',
57
+ height: '20px'
58
+ },
59
+ color: '#051039',
60
+ maxHeight: '1em',
61
+ boxSizing: 'content-box'
62
+ };
63
+ };
64
+
65
+ var StatusTag = function StatusTag(_ref) {
66
+ var content = _ref.content,
67
+ color = _ref.color;
68
+ return /*#__PURE__*/React.createElement(Box, Object.assign({
69
+ display: "flex",
70
+ alignItems: "center",
71
+ justifyContent: "center"
72
+ }, tagStyle(color), {
73
+ "data-testid": "statusTag"
74
+ }), /*#__PURE__*/React.createElement(Typography, {
75
+ variant: "caption"
76
+ }, content));
77
+ };
78
+
79
+ /*! *****************************************************************************
80
+ Copyright (c) Microsoft Corporation.
81
+
82
+ Permission to use, copy, modify, and/or distribute this software for any
83
+ purpose with or without fee is hereby granted.
84
+
85
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
86
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
87
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
88
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
89
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
90
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
91
+ PERFORMANCE OF THIS SOFTWARE.
92
+ ***************************************************************************** */
93
+
94
+ function __rest(s, e) {
95
+ var t = {};
96
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
97
+ t[p] = s[p];
98
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
99
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
100
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
101
+ t[p[i]] = s[p[i]];
102
+ }
103
+ return t;
104
+ }
105
+
106
+ var useStyles$d = makeStyles(function () {
107
+ return {
108
+ dialogHeader: {
109
+ zIndex: 1,
110
+ padding: '8px 20px',
111
+ display: 'flex',
112
+ justifyContent: 'space-between',
113
+ alignItems: 'center'
114
+ },
115
+ dialogContent: {
116
+ padding: '40px 20px 0px 20px'
117
+ },
118
+ dialogOptions: {
119
+ padding: '4px 20px 16px 20px'
120
+ }
121
+ };
122
+ });
123
+ var ConfirmationDialog = function ConfirmationDialog(_a) {
124
+ var open = _a.open,
125
+ title = _a.title,
126
+ _a$description = _a.description,
127
+ description = _a$description === void 0 ? 'Are you sure?' : _a$description,
128
+ _a$confirmLabel = _a.confirmLabel,
129
+ confirmLabel = _a$confirmLabel === void 0 ? 'Submit' : _a$confirmLabel,
130
+ _a$cancelLabel = _a.cancelLabel,
131
+ cancelLabel = _a$cancelLabel === void 0 ? 'Go back' : _a$cancelLabel,
132
+ onSubmit = _a.onSubmit,
133
+ onClose = _a.onClose,
134
+ _a$content = _a.content,
135
+ content = _a$content === void 0 ? null : _a$content,
136
+ other = __rest(_a, ["open", "title", "description", "confirmLabel", "cancelLabel", "onSubmit", "onClose", "content"]);
137
+
138
+ var classes = useStyles$d();
139
+
140
+ other.catchOnCancel;
141
+ var rest = __rest(other, ["catchOnCancel"]); // remove unwanted props
142
+
143
+
144
+ return /*#__PURE__*/React.createElement(Dialog, Object.assign({
145
+ "data-testid": "confirmationDialog",
146
+ open: open,
147
+ maxWidth: "sm",
148
+ fullWidth: true,
149
+ disableBackdropClick: true,
150
+ transitionDuration: 0
151
+ }, rest), /*#__PURE__*/React.createElement(DialogTitle, {
152
+ disableTypography: true,
153
+ className: classes.dialogHeader
154
+ }, /*#__PURE__*/React.createElement(Typography, {
155
+ variant: "h5",
156
+ "data-testid": "confirmationDialog-title"
157
+ }, title), /*#__PURE__*/React.createElement(IconButton, {
158
+ "data-testid": "confirmationDialog-close",
159
+ "aria-label": "close",
160
+ onClick: function onClick() {
161
+ return onClose('CLOSED');
162
+ },
163
+ size: "small"
164
+ }, /*#__PURE__*/React.createElement(Close, null))), /*#__PURE__*/React.createElement(DialogContent, {
165
+ className: classes.dialogContent
166
+ }, /*#__PURE__*/React.createElement(Typography, {
167
+ variant: "body1"
168
+ }, description), content), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
169
+ "data-testid": "conformationDialog-cancel",
170
+ color: "secondary",
171
+ variant: "outlined",
172
+ onClick: function onClick() {
173
+ return onClose('CANCELLED');
174
+ },
175
+ autoFocus: true
176
+ }, cancelLabel), /*#__PURE__*/React.createElement(Button, {
177
+ "data-testid": "conformationDialog-confirm",
178
+ color: "secondary",
179
+ variant: "contained",
180
+ onClick: onSubmit
181
+ }, confirmLabel)));
182
+ };
183
+
184
+ function _defineProperty(obj, key, value) {
185
+ if (key in obj) {
186
+ Object.defineProperty(obj, key, {
187
+ value: value,
188
+ enumerable: true,
189
+ configurable: true,
190
+ writable: true
191
+ });
192
+ } else {
193
+ obj[key] = value;
194
+ }
195
+
196
+ return obj;
197
+ }
198
+
199
+ function _slicedToArray(arr, i) {
200
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
201
+ }
202
+
203
+ function _toArray(arr) {
204
+ return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
205
+ }
206
+
207
+ function _toConsumableArray(arr) {
208
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
209
+ }
210
+
211
+ function _arrayWithoutHoles(arr) {
212
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
213
+ }
214
+
215
+ function _arrayWithHoles(arr) {
216
+ if (Array.isArray(arr)) return arr;
217
+ }
218
+
219
+ function _iterableToArray(iter) {
220
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
221
+ }
222
+
223
+ function _iterableToArrayLimit(arr, i) {
224
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
225
+ var _arr = [];
226
+ var _n = true;
227
+ var _d = false;
228
+ var _e = undefined;
229
+
230
+ try {
231
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
232
+ _arr.push(_s.value);
233
+
234
+ if (i && _arr.length === i) break;
235
+ }
236
+ } catch (err) {
237
+ _d = true;
238
+ _e = err;
239
+ } finally {
240
+ try {
241
+ if (!_n && _i["return"] != null) _i["return"]();
242
+ } finally {
243
+ if (_d) throw _e;
244
+ }
245
+ }
246
+
247
+ return _arr;
248
+ }
249
+
250
+ function _unsupportedIterableToArray(o, minLen) {
251
+ if (!o) return;
252
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
253
+ var n = Object.prototype.toString.call(o).slice(8, -1);
254
+ if (n === "Object" && o.constructor) n = o.constructor.name;
255
+ if (n === "Map" || n === "Set") return Array.from(o);
256
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
257
+ }
258
+
259
+ function _arrayLikeToArray(arr, len) {
260
+ if (len == null || len > arr.length) len = arr.length;
261
+
262
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
263
+
264
+ return arr2;
265
+ }
266
+
267
+ function _nonIterableSpread() {
268
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
269
+ }
270
+
271
+ function _nonIterableRest() {
272
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
273
+ }
274
+
275
+ /* *
276
+ * Licensed under the Apache License, Version 2.0 (the "License");
277
+ * you may not use this file except in compliance with the License.
278
+ * You may obtain a copy of the License at
279
+ *
280
+ * http://www.apache.org/licenses/LICENSE-2.0
281
+ *
282
+ * Unless required by applicable law or agreed to in writing, software
283
+ * distributed under the License is distributed on an "AS IS" BASIS,
284
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
285
+ * See the License for the specific language governing permissions and
286
+ * limitations under the License.
287
+ *
288
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
289
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
290
+ * */
291
+ var showPrompt = function showPrompt(event) {
292
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
293
+ // @ts-ignore
294
+ // eslint-disable-next-line no-param-reassign
295
+ event.returnValue = 'Changes that you made may not be saved.'; // changes are your browser have default text to overrule this
296
+ };
297
+ function usePreventBrowserClose(shouldPreventClose) {
298
+ React.useEffect(function () {
299
+ if (shouldPreventClose) {
300
+ window.addEventListener('beforeunload', showPrompt);
301
+ } else {
302
+ window.removeEventListener('beforeunload', showPrompt);
303
+ }
304
+
305
+ return function () {
306
+ window.removeEventListener('beforeunload', showPrompt);
307
+ };
308
+ }, [shouldPreventClose]);
309
+ }
310
+
311
+ /* *
312
+ * Licensed under the Apache License, Version 2.0 (the "License");
313
+ * you may not use this file except in compliance with the License.
314
+ * You may obtain a copy of the License at
315
+ *
316
+ * http://www.apache.org/licenses/LICENSE-2.0
317
+ *
318
+ * Unless required by applicable law or agreed to in writing, software
319
+ * distributed under the License is distributed on an "AS IS" BASIS,
320
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
321
+ * See the License for the specific language governing permissions and
322
+ * limitations under the License.
323
+ *
324
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
325
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
326
+ * */
327
+ var usePoller = function usePoller(deps, callback) {
328
+ var pollingInterval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 300000;
329
+ var interval = React.useRef(null);
330
+ React.useEffect(function () {
331
+ if (deps.filter(function (dep) {
332
+ return dep !== null;
333
+ }).length > 0) {
334
+ if (interval.current) {
335
+ clearInterval(interval.current);
336
+ }
337
+
338
+ interval.current = setInterval(function () {
339
+ callback();
340
+ }, pollingInterval);
341
+ }
342
+
343
+ return function () {
344
+ if (interval.current) {
345
+ clearInterval(interval.current);
346
+ }
347
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
348
+ }, [deps]);
349
+ return interval;
350
+ };
351
+
352
+ /* *
353
+ * Licensed under the Apache License, Version 2.0 (the "License");
354
+ * you may not use this file except in compliance with the License.
355
+ * You may obtain a copy of the License at
356
+ *
357
+ * http://www.apache.org/licenses/LICENSE-2.0
358
+ *
359
+ * Unless required by applicable law or agreed to in writing, software
360
+ * distributed under the License is distributed on an "AS IS" BASIS,
361
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
362
+ * See the License for the specific language governing permissions and
363
+ * limitations under the License.
364
+ *
365
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
366
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
367
+ * */
368
+ function usePrevious(value) {
369
+ var ref = React.useRef();
370
+ React.useEffect(function () {
371
+ ref.current = value;
372
+ });
373
+ return ref.current;
374
+ }
375
+
376
+ /* *
377
+ * Licensed under the Apache License, Version 2.0 (the "License");
378
+ * you may not use this file except in compliance with the License.
379
+ * You may obtain a copy of the License at
380
+ *
381
+ * http://www.apache.org/licenses/LICENSE-2.0
382
+ *
383
+ * Unless required by applicable law or agreed to in writing, software
384
+ * distributed under the License is distributed on an "AS IS" BASIS,
385
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
386
+ * See the License for the specific language governing permissions and
387
+ * limitations under the License.
388
+ *
389
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
390
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
391
+ * */
392
+ var useIsMounted = function useIsMounted() {
393
+ var isMounted = React.useRef(false);
394
+ React.useEffect(function () {
395
+ isMounted.current = true;
396
+ return function () {
397
+ isMounted.current = false;
398
+ };
399
+ }, []);
400
+ return {
401
+ isMounted: isMounted
402
+ };
403
+ };
404
+
405
+ /* *
406
+ * Licensed under the Apache License, Version 2.0 (the "License");
407
+ * you may not use this file except in compliance with the License.
408
+ * You may obtain a copy of the License at
409
+ *
410
+ * http://www.apache.org/licenses/LICENSE-2.0
411
+ *
412
+ * Unless required by applicable law or agreed to in writing, software
413
+ * distributed under the License is distributed on an "AS IS" BASIS,
414
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
415
+ * See the License for the specific language governing permissions and
416
+ * limitations under the License.
417
+ *
418
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
419
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
420
+ * */
421
+
422
+ var HIDDEN_INPUT_HELPER_IS_DRAFT = 'IS_DRAFT';
423
+ var useDraftFormHelpers = function useDraftFormHelpers() {
424
+ var _useFormContext = useFormContext(),
425
+ getValues = _useFormContext.getValues,
426
+ setValue = _useFormContext.setValue,
427
+ register = _useFormContext.register;
428
+
429
+ var isDraft = function isDraft() {
430
+ return getValues(HIDDEN_INPUT_HELPER_IS_DRAFT) === true;
431
+ };
432
+
433
+ var isRequired = function isRequired(value) {
434
+ if (!isDraft() && isEmpty(value)) {
435
+ return errorMessages.required;
436
+ }
437
+
438
+ return true;
439
+ };
440
+
441
+ var toggleIsDraft = function toggleIsDraft(isDraft) {
442
+ return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft);
443
+ };
444
+
445
+ var DraftFieldHelper = function DraftFieldHelper() {
446
+ return /*#__PURE__*/React.createElement("input", Object.assign({
447
+ defaultValue: "false"
448
+ }, register(HIDDEN_INPUT_HELPER_IS_DRAFT), {
449
+ type: "hidden"
450
+ }));
451
+ };
452
+
453
+ return {
454
+ isRequired: isRequired,
455
+ toggleIsDraft: toggleIsDraft,
456
+ isDraft: isDraft,
457
+ DraftFieldHelper: DraftFieldHelper
458
+ };
459
+ };
460
+
461
+ var ConfirmationServiceContext = /*#__PURE__*/React.createContext(Promise.reject);
462
+ var useConfirmationDialog = function useConfirmationDialog() {
463
+ return React.useContext(ConfirmationServiceContext);
464
+ };
465
+ var useDialogActions = function useDialogActions(awaitingPromiseRef) {
466
+ var defaultOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
467
+
468
+ var _useIsMounted = useIsMounted(),
469
+ isMounted = _useIsMounted.isMounted;
470
+
471
+ var _React$useState = React.useState(defaultOptions),
472
+ _React$useState2 = _slicedToArray(_React$useState, 2),
473
+ confirmationState = _React$useState2[0],
474
+ setConfirmationState = _React$useState2[1];
475
+
476
+ var openConfirmation = function openConfirmation(options) {
477
+ setConfirmationState(options);
478
+ return new Promise(function (resolve, reject) {
479
+ // since this is a React.ref it's safe to reassign it, although eslint says no
480
+ // eslint-disable-next-line no-param-reassign
481
+ awaitingPromiseRef.current = {
482
+ resolve: resolve,
483
+ reject: reject
484
+ };
485
+ });
486
+ }; // clears state with timeout delay so optional values provided by the prop 'content' of ConfirmationDialog can be read
487
+
488
+
489
+ var clearState = function clearState() {
490
+ return setTimeout(function () {
491
+ if (isMounted.current) {
492
+ setConfirmationState(null);
493
+ }
494
+ }, 0);
495
+ };
496
+
497
+ var handleClose = function handleClose(reason) {
498
+ if (confirmationState && confirmationState.catchOnCancel && awaitingPromiseRef.current) {
499
+ awaitingPromiseRef.current.reject(reason);
500
+ }
501
+
502
+ clearState();
503
+ };
504
+
505
+ var handleSubmit = function handleSubmit() {
506
+ if (awaitingPromiseRef.current) {
507
+ awaitingPromiseRef.current.resolve();
508
+ }
509
+
510
+ clearState();
511
+ };
512
+
513
+ return {
514
+ openConfirmation: openConfirmation,
515
+ confirmationState: confirmationState,
516
+ handleSubmit: handleSubmit,
517
+ handleClose: handleClose
518
+ };
519
+ };
520
+ var ConfirmationServiceProvider = function ConfirmationServiceProvider(_ref) {
521
+ var children = _ref.children;
522
+ var awaitingPromiseRef = React.useRef();
523
+
524
+ var _useDialogActions = useDialogActions(awaitingPromiseRef),
525
+ openConfirmation = _useDialogActions.openConfirmation,
526
+ confirmationState = _useDialogActions.confirmationState,
527
+ handleSubmit = _useDialogActions.handleSubmit,
528
+ handleClose = _useDialogActions.handleClose;
529
+
530
+ return /*#__PURE__*/React.createElement(ConfirmationServiceContext.Provider, {
531
+ value: openConfirmation
532
+ }, children, /*#__PURE__*/React.createElement(ConfirmationDialog, Object.assign({
533
+ open: Boolean(confirmationState),
534
+ onSubmit: handleSubmit,
535
+ onClose: handleClose
536
+ }, confirmationState)));
537
+ };
538
+
539
+ /* *
540
+ * Licensed under the Apache License, Version 2.0 (the "License");
541
+ * you may not use this file except in compliance with the License.
542
+ * You may obtain a copy of the License at
543
+ *
544
+ * http://www.apache.org/licenses/LICENSE-2.0
545
+ *
546
+ * Unless required by applicable law or agreed to in writing, software
547
+ * distributed under the License is distributed on an "AS IS" BASIS,
548
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
549
+ * See the License for the specific language governing permissions and
550
+ * limitations under the License.
551
+ *
552
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
553
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
554
+ * */
555
+ var useStyles$c = makeStyles(function () {
556
+ return {
557
+ title: {
558
+ fontSize: '14px',
559
+ fontWeight: 'normal',
560
+ marginTop: '0px!important'
561
+ },
562
+ info: {
563
+ fontSize: '16px'
564
+ }
565
+ };
566
+ });
567
+
568
+ var getIcon = function getIcon(severity) {
569
+ switch (severity) {
570
+ case 'info':
571
+ return /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("rect", {
572
+ width: 24,
573
+ height: 24,
574
+ fill: "transparent"
575
+ }), /*#__PURE__*/React.createElement("path", {
576
+ d: "M12 4c4.418 0 8 3.581 8 8 0 4.418-3.582 8-8 8s-8-3.582-8-8c0-4.419 3.582-8 8-8zm1.052 6H10v1.613h.949v3.774H10V17h4v-1.613h-.948V10zM11.99 6c-.837 0-1.491.654-1.491 1.49 0 .837.654 1.51 1.49 1.51.837 0 1.51-.673 1.51-1.51 0-.836-.673-1.49-1.51-1.49z",
577
+ transform: "translate(-946.000000, -368.000000) translate(930.000000, 356.000000) translate(16.000000, 12.000000)",
578
+ fill: "#0062E6"
579
+ }));
580
+
581
+ case 'success':
582
+ return /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("rect", {
583
+ width: 24,
584
+ height: 24,
585
+ fill: "transparent"
586
+ }), /*#__PURE__*/React.createElement("path", {
587
+ d: "M16.51 10.034l-5.633 5.633-3.387-3.386c-.369-.37-.369-.973 0-1.343.36-.357.983-.357 1.342 0l2.045 2.046 4.292-4.291c.357-.357.983-.359 1.342 0 .368.369.368.97 0 1.341M12 4C7.582 4 4 7.582 4 12s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8",
588
+ transform: "translate(-96.000000, -368.000000) translate(80.000000, 356.000000) translate(16.000000, 12.000000)",
589
+ fill: "#72BB23"
590
+ }));
591
+
592
+ case 'warning':
593
+ return /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("rect", {
594
+ width: 24,
595
+ height: 24,
596
+ fill: "transparent"
597
+ }), /*#__PURE__*/React.createElement("path", {
598
+ d: "M12.862 16.72c-.22.226-.507.339-.86.339-.364 0-.662-.113-.894-.34-.232-.226-.347-.52-.347-.885 0-.32.118-.59.356-.81.236-.22.531-.331.884-.331.332 0 .613.11.845.33.232.222.347.491.347.811 0 .365-.11.66-.33.886zm.216-9.805l-.134 6.669H11.06l-.15-6.67h2.169zM12 4.5c-4.141 0-7.5 3.359-7.5 7.501s3.359 7.5 7.5 7.5c4.142 0 7.5-3.358 7.5-7.5C19.5 7.86 16.142 4.5 12 4.5z",
599
+ transform: "translate(-521.000000, -368.000000) translate(505.000000, 356.000000) translate(16.000000, 12.000000)",
600
+ fill: "#FFA800"
601
+ }));
602
+
603
+ case 'error':
604
+ default:
605
+ return /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("rect", {
606
+ width: 24,
607
+ height: 24,
608
+ fill: "transparent"
609
+ }), /*#__PURE__*/React.createElement("path", {
610
+ d: "M12.862 16.72c-.22.226-.507.339-.86.339-.364 0-.662-.113-.894-.34-.232-.226-.347-.52-.347-.885 0-.32.118-.59.356-.81.236-.22.531-.331.884-.331.332 0 .613.11.845.33.232.222.347.491.347.811 0 .365-.11.66-.33.886zm.216-9.805l-.134 6.669H11.06l-.15-6.67h2.169zM12 4.5c-4.141 0-7.5 3.359-7.5 7.501s3.359 7.5 7.5 7.5c4.142 0 7.5-3.358 7.5-7.5C19.5 7.86 16.142 4.5 12 4.5z",
611
+ transform: "translate(-1371.000000, -368.000000) translate(1355.000000, 356.000000) translate(16.000000, 12.000000)",
612
+ fill: "#C00000"
613
+ }));
614
+ }
615
+ };
616
+
617
+ var AlertBanner = function AlertBanner(_ref) {
618
+ var title = _ref.title,
619
+ _ref$severity = _ref.severity,
620
+ severity = _ref$severity === void 0 ? 'error' : _ref$severity,
621
+ _ref$info = _ref.info,
622
+ info = _ref$info === void 0 ? '' : _ref$info,
623
+ _ref$dataTestId = _ref.dataTestId,
624
+ dataTestId = _ref$dataTestId === void 0 ? 'alert-banner' : _ref$dataTestId;
625
+ var classes = useStyles$c();
626
+ return /*#__PURE__*/React.createElement(Alert, {
627
+ "data-testid": dataTestId,
628
+ severity: severity,
629
+ icon: getIcon(severity)
630
+ }, /*#__PURE__*/React.createElement(AlertTitle, {
631
+ className: classes.title
632
+ }, title), info && /*#__PURE__*/React.createElement("div", {
633
+ className: classes.info
634
+ }, info));
635
+ };
636
+
637
+ /* *
638
+ * Licensed under the Apache License, Version 2.0 (the "License");
639
+ * you may not use this file except in compliance with the License.
640
+ * You may obtain a copy of the License at
641
+ *
642
+ * http://www.apache.org/licenses/LICENSE-2.0
643
+ *
644
+ * Unless required by applicable law or agreed to in writing, software
645
+ * distributed under the License is distributed on an "AS IS" BASIS,
646
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
647
+ * See the License for the specific language governing permissions and
648
+ * limitations under the License.
649
+ *
650
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
651
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
652
+ * */
653
+ var useStyles$b = makeStyles(function () {
654
+ return {
655
+ wrapper: {
656
+ height: '100vh',
657
+ display: 'flex',
658
+ flexDirection: 'column'
659
+ },
660
+ main: {
661
+ flex: 1,
662
+ position: 'relative'
663
+ }
664
+ };
665
+ });
666
+
667
+ var AppLayout = function AppLayout(_ref) {
668
+ var header = _ref.header,
669
+ children = _ref.children;
670
+ var classes = useStyles$b();
671
+ return /*#__PURE__*/React__default.createElement("div", {
672
+ className: classes.wrapper
673
+ }, header, /*#__PURE__*/React__default.createElement("main", {
674
+ className: classes.main
675
+ }, children));
676
+ };
677
+
678
+ var img = "data:image/svg+xml,%3c!--Licensed under the Apache License%2c Version 2.0 (the 'License')%3byou may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing%2c softwaredistributed under the License is distributed on an 'AS IS' BASIS%2cWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND%2c either express or implied.See the License for the specific language governing permissions andlimitations under the License.Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)Copyright 2021 - Finnish Meteorological Institute (FMI)--%3e%3csvg id='svg4550' xmlnsRdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns='http://www.w3.org/2000/svg' height='55.156mm' viewBox='0 0 289.84072 195.43326' width='81.799mm' version='1.1' xmlnsCc='http://creativecommons.org/ns%23' xmlnsXlink='http://www.w3.org/1999/xlink' xmlnsDc='http://purl.org/dc/elements/1.1/'%3e %3cdefs id='defs14'%3e %3clinearGradient id='linearGradient4263' y2='113.1' gradientUnits='userSpaceOnUse' y1='76.066' gradientTransform='translate(0 -.0012816)' x2='199.26' x1='160.9'%3e %3cstop id='stop4259' stop-color='white' stop-opacity='.33333' offset='0'/%3e %3cstop id='stop4261' stop-color='white' stop-opacity='0' offset='1'/%3e %3c/linearGradient%3e %3clinearGradient id='linearGradient4240' y2='79.833' gradientUnits='userSpaceOnUse' x2='120.82' y1='120.77' x1='128.56'%3e %3cstop id='stop4236' stop-color='white' stop-opacity='0' offset='0'/%3e %3cstop id='stop4238' stop-color='white' stop-opacity='.33333' offset='1'/%3e %3c/linearGradient%3e %3c/defs%3e %3cg id='layer1' transform='translate(353.49 -626.07)'%3e %3cg id='g4'%3e %3cpath id='path4220' d='m-207 679.86c-7.6546-3.9726-16.149-6.0541-24.773-6.0703-24.585 0.0315-46.045 16.665-52.207 40.465-2.23-0.35755-4.4838-0.54689-6.7422-0.56642-24.881-0.00043-45.051 20.17-45.051 45.051-0.00043 24.881 20.17 45.051 45.051 45.051 36.152-0.20272 72.845-0.0898 109.18-0.0898 8.9834 0 22.962 0.009 36.879 0.0165 9.7409 0.38215 35.645-0.43398 53.537-23.548 17.892-23.115 7.1203-72.79-0.31513-94.017s-30.566-42.361-53.247-42.361c-26.664 0-50.367 14.562-62.311 36.07z' style='color-rendering:auto%3bcolor:black%3bisolation:auto%3bmix-blend-mode:normal%3bshape-rendering:auto%3bsolid-color:black%3bimage-rendering:auto' fill='%230b9ee5'/%3e %3cpath id='path4220-7' opacity='.98' d='m-335.78 758.74c-0.00043 24.881 20.17 45.051 45.051 45.051 36.152-0.20272 72.845-0.0898 109.18-0.0898 10.101 0 27.126 0.009 42.523 0.0156 11.975-0.4199 32.775-4.017 47.893-23.547 4.439-5.7347 7.1108-13.107 8.5098-21.271-35.448-0.0105-239.67-0.15823-253.16-0.15823z' fill='%2360bce9'/%3e %3c/g%3e %3cpath id='path4220-2' d='m-144.69 643.79c-19.529 0-37.464 7.8167-50.359 20.447-4.6476 4.6419-8.6513 9.9041-11.953 15.623 0 40.944 0.0195 77.914 0.0195 123.83 8.4824 0.007 16.983 0.0137 25.438 0.0137 10.101 0 27.126 0.009 42.523 0.0156 11.975-0.4199 32.775-4.017 47.893-23.547 17.892-23.115 7.1209-72.791-0.31446-94.018s-30.565-42.361-53.246-42.361z' style='color-rendering:auto%3bcolor:black%3bisolation:auto%3bmix-blend-mode:normal%3bshape-rendering:auto%3bsolid-color:black%3bimage-rendering:auto' fill='white' fill-opacity='.31373'/%3e %3c/g%3e %3cg id='g4244' transform='translate(2.926 -1.3827)'%3e %3cpath id='path4329' style='color-rendering:auto%3bcolor:black%3bisolation:auto%3bmix-blend-mode:normal%3bshape-rendering:auto%3bsolid-color:black%3bimage-rendering:auto' fill='%23003232' d='m211.54 98.88c11.484 8.7901 14.857 8.43 22.486 19.238 3.6519 5.1733 5.5602 11.69 5.5645 18.164-0.00018 17.949-14.551 32.499-32.5 32.498-17.948-0.00018-32.498-14.55-32.498-32.498 0.006-0.50098 0.0236-1.0018 0.0527-1.502-3.4629-1.1175-6.9173-1.9297-9.6543-1.9297-2.7565 0-6.2409 0.82134-9.7285 1.9512 0.036 0.49286 0.0607 0.98649 0.0742 1.4805-0.00018 17.948-14.55 32.498-32.498 32.498-17.948-0.00019-32.498-14.55-32.498-32.498 0.006-3.5239 0.71774-6.9687 1.8781-10.26 5.474-20.521 8.7944-44.229 27.665-46.855 8.2552-1.1488 15.952 8.848 25.107 8.848 9.1558-0.00028 9.318-14.58 23.088-14.836 16.828-0.3123 31.185 16.304 43.462 25.701zm-4.7539 13.92c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24zm-84.125 0c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24z'/%3e %3cpath id='path4329-2' style='color-rendering:auto%3bcolor:black%3bisolation:auto%3bmix-blend-mode:normal%3bshape-rendering:auto%3bsolid-color:black%3bimage-rendering:auto' fill='url(%23linearGradient4263)' d='m157.24 77.869c-2.1199 2.1753-3.6401 4.4832-5.4018 6.5241-0.53185 0.61614-1.2448 1.3191-1.8477 1.7949-1.2058 0.9517-2.5477 1.6107-4.168 1.7793-0.27005 0.0281-0.54787 0.04296-0.83398 0.04297 5.0928 13.298 11.821 26.014 20 44.834 2.737 0 6.1914 0.8122 9.6543 1.9297-0.0291 0.5002-0.0467 1.001-0.0527 1.502 0 8.4131 3.196 16.08 8.4414 21.852 0.34969 0.38474 0.70861 0.75939 1.0762 1.127 5.881 5.8809 14.007 9.5194 22.98 9.5195 0.5609 0.00004 1.118-0.0149 1.6719-0.043 3.3236-0.16829 6.5154-0.83435 9.502-1.9277 0.99554-0.36446 1.9688-0.77802 2.916-1.2344 1.4208-0.68453 2.7833-1.4677 4.0801-2.3438 8.645-5.84 14.33-15.731 14.33-26.949-0.004-6.474-2.0849-12.873-5.5645-18.164-7.0668-10.745-14.684-12.763-22.486-19.238-11.815-9.8048-26.968-25.716-42.627-25.716-6.2104 0-9.3385 2.3185-11.67 4.7112zm49.543 34.924c4.9706 0 9.5876 1.5119 13.418 4.0996 0.6384 0.43129 1.255 0.89176 1.8476 1.3809 0.59266 0.4891 1.1622 1.0059 1.7051 1.5488 4.3431 4.3431 7.0293 10.343 7.0293 16.971 0 12.841-10.085 23.326-22.766 23.969-0.40906 0.0207-0.82015 0.0312-1.2344 0.0312-4.97 0-9.5878-1.5105-13.418-4.0976-0.00044-0.0003-0.002 0.00029-0.002 0-6.384-4.3129-10.58-11.618-10.58-19.902 0-6.6275 2.6862-12.628 7.0293-16.971 0.54288-0.54289 1.1124-1.0597 1.7051-1.5488 0.59266-0.4891 1.2073-0.94957 1.8457-1.3809 3.8304-2.5878 8.4493-4.0996 13.42-4.0996z'/%3e %3cpath id='path4329-7' style='color-rendering:auto%3bcolor:black%3bisolation:auto%3bmix-blend-mode:normal%3bshape-rendering:auto%3bsolid-color:black%3bimage-rendering:auto' d='m121.43 79.077c-0.51208-0.01011-1.027 0.01805-1.543 0.08985-18.871 2.626-22.19 26.335-27.664 46.856-1.1604 3.2913-1.8729 6.7359-1.8789 10.26 0 17.948 14.55 32.498 32.498 32.498s32.498-14.55 32.498-32.498c-0.0135-0.49402-0.0382-0.98762-0.0742-1.4805 3.5012-1.0071 5.7853-1.8693 9.6893-1.9248-4.8944-11.377-14.29-31.914-19.961-44.863-8.5828 0.000001-15.883-8.7859-23.565-8.9376zm1.2344 33.723c13.255 0 24 10.745 24 24s-10.745 24-24 24-24-10.745-24-24 10.745-24 24-24z' fill='url(%23linearGradient4240)'/%3e %3c/g%3e%3c/svg%3e";
679
+
680
+ var useStyles$a = makeStyles(function (theme) {
681
+ var _header;
682
+
683
+ return {
684
+ header: (_header = {
685
+ height: 40,
686
+ background: theme.palette.geowebColors.brand.brand,
687
+ color: theme.palette.common.white,
688
+ boxShadow: theme.shadows[1],
689
+ zIndex: 1000
690
+ }, _defineProperty(_header, theme.breakpoints.down('sm'), {
691
+ padding: '0 8px'
692
+ }), _defineProperty(_header, theme.breakpoints.up('sm'), {
693
+ padding: '0 24px'
694
+ }), _header),
695
+ logo: {
696
+ height: 30
697
+ },
698
+ title: {
699
+ marginLeft: 6,
700
+ fontSize: '1.25rem',
701
+ fontWeight: 400,
702
+ overflow: 'hidden',
703
+ whiteSpace: 'nowrap',
704
+ textOverflow: 'ellipsis'
705
+ },
706
+ container: {
707
+ height: '100%'
708
+ }
709
+ };
710
+ });
711
+
712
+ var AppHeader = function AppHeader(_ref) {
713
+ var menu = _ref.menu,
714
+ userMenu = _ref.userMenu,
715
+ _ref$title = _ref.title,
716
+ title = _ref$title === void 0 ? 'GeoWeb' : _ref$title;
717
+ var classes = useStyles$a();
718
+ return /*#__PURE__*/React__default.createElement("header", {
719
+ className: classes.header
720
+ }, /*#__PURE__*/React__default.createElement(Grid, {
721
+ className: classes.container,
722
+ container: true,
723
+ alignItems: "center"
724
+ }, /*#__PURE__*/React__default.createElement(Grid, {
725
+ item: true,
726
+ xs: 1,
727
+ sm: 3
728
+ }, /*#__PURE__*/React__default.createElement(Grid, {
729
+ container: true,
730
+ justify: "flex-start"
731
+ }, menu)), /*#__PURE__*/React__default.createElement(Grid, {
732
+ item: true,
733
+ xs: 10,
734
+ sm: 6
735
+ }, /*#__PURE__*/React__default.createElement(Grid, {
736
+ container: true,
737
+ justify: "center",
738
+ alignItems: "center",
739
+ wrap: "nowrap"
740
+ }, /*#__PURE__*/React__default.createElement("img", {
741
+ alt: title,
742
+ className: classes.logo,
743
+ src: img
744
+ }), /*#__PURE__*/React__default.createElement(Typography, {
745
+ variant: "h1",
746
+ className: classes.title
747
+ }, title))), /*#__PURE__*/React__default.createElement(Grid, {
748
+ item: true,
749
+ xs: 1,
750
+ sm: 3,
751
+ container: true,
752
+ justify: "flex-end"
753
+ }, userMenu)));
754
+ };
755
+
756
+ /* *
757
+ * Licensed under the Apache License, Version 2.0 (the "License");
758
+ * you may not use this file except in compliance with the License.
759
+ * You may obtain a copy of the License at
760
+ *
761
+ * http://www.apache.org/licenses/LICENSE-2.0
762
+ *
763
+ * Unless required by applicable law or agreed to in writing, software
764
+ * distributed under the License is distributed on an "AS IS" BASIS,
765
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
766
+ * See the License for the specific language governing permissions and
767
+ * limitations under the License.
768
+ *
769
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
770
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
771
+ * */
772
+
773
+ var DraggableComponent$1 = function DraggableComponent(_a) {
774
+ var _a$bounds = _a.bounds,
775
+ bounds = _a$bounds === void 0 ? 'body' : _a$bounds,
776
+ children = _a.children,
777
+ props = __rest(_a, ["bounds", "children"]);
778
+
779
+ return /*#__PURE__*/React__default.createElement(Draggable, Object.assign({
780
+ bounds: bounds
781
+ }, props), children);
782
+ };
783
+
784
+ /* *
785
+ * Licensed under the Apache License, Version 2.0 (the "License");
786
+ * you may not use this file except in compliance with the License.
787
+ * You may obtain a copy of the License at
788
+ *
789
+ * http://www.apache.org/licenses/LICENSE-2.0
790
+ *
791
+ * Unless required by applicable law or agreed to in writing, software
792
+ * distributed under the License is distributed on an "AS IS" BASIS,
793
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794
+ * See the License for the specific language governing permissions and
795
+ * limitations under the License.
796
+ *
797
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
798
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
799
+ * */
800
+
801
+ var useStyles$9 = function useStyles(isRightAligned) {
802
+ return makeStyles(function () {
803
+ return {
804
+ icon: Object.assign(Object.assign({
805
+ width: 20,
806
+ height: 20,
807
+ top: -10,
808
+ position: 'relative'
809
+ }, isRightAligned ? {
810
+ left: -10
811
+ } : {
812
+ left: 10,
813
+ transform: 'rotate(90deg)'
814
+ }), {
815
+ zIndex: 100
816
+ })
817
+ };
818
+ });
819
+ };
820
+
821
+ var ResizeHandle = function ResizeHandle(_ref2) {
822
+ var isRightAligned = _ref2.isRightAligned;
823
+ var theme = useTheme();
824
+ var styles = useStyles$9(isRightAligned)();
825
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
826
+ className: styles.icon,
827
+ "data-testid": "resizeHandle"
828
+ }, /*#__PURE__*/React__default.createElement("rect", {
829
+ fill: "#ffffff"
830
+ }), /*#__PURE__*/React__default.createElement("path", {
831
+ d: "M19.687 18.037v1h-6v-1h6zm3.5-3.5v1h-13v-1h13z",
832
+ fill: "".concat(theme.palette.geowebColors.greys.accessible),
833
+ transform: "rotate(-45 16.687 16.787)"
834
+ }));
835
+ };
836
+
837
+ var ResizeComponent = function ResizeComponent(_a) {
838
+ var _a$startPosition = _a.startPosition,
839
+ startPosition = _a$startPosition === void 0 ? {
840
+ left: null,
841
+ right: null,
842
+ top: null
843
+ } : _a$startPosition,
844
+ children = _a.children,
845
+ _a$onResizeStart = _a.onResizeStart,
846
+ onResizeStart = _a$onResizeStart === void 0 ? function () {
847
+ return null;
848
+ } : _a$onResizeStart,
849
+ size = _a.size,
850
+ setSize = _a.setSize,
851
+ _a$minHeight = _a.minHeight,
852
+ minHeight = _a$minHeight === void 0 ? 50 : _a$minHeight,
853
+ _a$minWidth = _a.minWidth,
854
+ minWidth = _a$minWidth === void 0 ? 50 : _a$minWidth,
855
+ props = __rest(_a, ["startPosition", "children", "onResizeStart", "size", "setSize", "minHeight", "minWidth"]);
856
+
857
+ var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
858
+ var onStartResize = React__default.useCallback(function (event, _direction, node) {
859
+ event.stopPropagation();
860
+
861
+ var _node$getBoundingClie = node.getBoundingClientRect(),
862
+ width = _node$getBoundingClie.width,
863
+ height = _node$getBoundingClie.height;
864
+
865
+ setSize({
866
+ width: width,
867
+ height: height
868
+ }); // fix for when initial maxHeight gets cleared
869
+ // eslint-disable-next-line no-param-reassign
870
+
871
+ node.style.height = "".concat(height, "px");
872
+ onResizeStart();
873
+ }, [onResizeStart, setSize]);
874
+ var onResizeStop = React__default.useCallback(function (_event, _direction, _ref, delta) {
875
+ var width = parseInt(size.width, 10) + delta.width;
876
+ var height = parseInt(size.height, 10) + delta.height;
877
+ setSize({
878
+ width: width,
879
+ height: height
880
+ });
881
+ }, [setSize, size]);
882
+ return /*#__PURE__*/React__default.createElement(Resizable // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
883
+ , Object.assign({
884
+ // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
885
+ minHeight: minHeight,
886
+ minWidth: minWidth,
887
+ size: size,
888
+ onResizeStop: onResizeStop,
889
+ handleComponent: {
890
+ bottomRight: /*#__PURE__*/React__default.createElement(ResizeHandle, {
891
+ isRightAligned: true
892
+ }),
893
+ bottomLeft: /*#__PURE__*/React__default.createElement(ResizeHandle, null)
894
+ },
895
+ enable: {
896
+ top: false,
897
+ right: false,
898
+ bottom: false,
899
+ left: false,
900
+ topRight: false,
901
+ bottomRight: !isRightAligned,
902
+ bottomLeft: isRightAligned,
903
+ topLeft: false
904
+ },
905
+ onResizeStart: onStartResize
906
+ }, props), children);
907
+ };
908
+
909
+ /* *
910
+ * Licensed under the Apache License, Version 2.0 (the "License");
911
+ * you may not use this file except in compliance with the License.
912
+ * You may obtain a copy of the License at
913
+ *
914
+ * http://www.apache.org/licenses/LICENSE-2.0
915
+ *
916
+ * Unless required by applicable law or agreed to in writing, software
917
+ * distributed under the License is distributed on an "AS IS" BASIS,
918
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
919
+ * See the License for the specific language governing permissions and
920
+ * limitations under the License.
921
+ *
922
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
923
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
924
+ * */
925
+ var useStyles$8 = makeStyles(function (theme) {
926
+ return {
927
+ container: {
928
+ position: 'absolute',
929
+ top: 38,
930
+ right: 20,
931
+ width: 256,
932
+ borderRadius: 0,
933
+ boxShadow: theme.shadows[5],
934
+ background: theme.palette.geowebColors.background.surface
935
+ },
936
+ userMenu: {
937
+ padding: 0,
938
+ '& > li': {
939
+ paddingTop: 24,
940
+ paddingBottom: 24,
941
+ paddingLeft: 16,
942
+ paddingRight: 16
943
+ }
944
+ },
945
+ button: {
946
+ color: theme.palette.common.white,
947
+ padding: 0
948
+ },
949
+ avatar: {
950
+ height: 32,
951
+ width: 32,
952
+ fontSize: '0.938rem',
953
+ fontWeight: 500,
954
+ color: theme.palette.geowebColors.brand.brand,
955
+ backgroundColor: theme.palette.common.white
956
+ }
957
+ };
958
+ });
959
+
960
+ var UserMenu = function UserMenu(_ref) {
961
+ var _ref$isOpen = _ref.isOpen,
962
+ isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
963
+ _ref$onToggle = _ref.onToggle,
964
+ onToggle = _ref$onToggle === void 0 ? function () {
965
+ return null;
966
+ } : _ref$onToggle,
967
+ _ref$onClose = _ref.onClose,
968
+ onClose = _ref$onClose === void 0 ? function () {
969
+ return null;
970
+ } : _ref$onClose,
971
+ children = _ref.children,
972
+ initials = _ref.initials;
973
+ var classes = useStyles$8();
974
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(IconButton, {
975
+ "data-testid": "userButton",
976
+ onClick: onToggle,
977
+ className: classes.button
978
+ }, /*#__PURE__*/React__default.createElement(Avatar, {
979
+ className: classes.avatar
980
+ }, initials)), isOpen && /*#__PURE__*/React__default.createElement(Paper, {
981
+ className: classes.container,
982
+ "data-testid": "userMenu"
983
+ }, /*#__PURE__*/React__default.createElement(ClickAwayListener, {
984
+ onClickAway: onClose,
985
+ mouseEvent: "onMouseDown"
986
+ }, /*#__PURE__*/React__default.createElement(MenuList, {
987
+ className: classes.userMenu,
988
+ variant: "menu"
989
+ }, children))));
990
+ };
991
+
992
+ /* *
993
+ * Licensed under the Apache License, Version 2.0 (the "License");
994
+ * you may not use this file except in compliance with the License.
995
+ * You may obtain a copy of the License at
996
+ *
997
+ * http://www.apache.org/licenses/LICENSE-2.0
998
+ *
999
+ * Unless required by applicable law or agreed to in writing, software
1000
+ * distributed under the License is distributed on an "AS IS" BASIS,
1001
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1002
+ * See the License for the specific language governing permissions and
1003
+ * limitations under the License.
1004
+ *
1005
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1006
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1007
+ * */
1008
+
1009
+ var MenuItemTheme = function MenuItemTheme() {
1010
+ var _useThemeContext = useThemeContext(),
1011
+ isDark = _useThemeContext.isDark,
1012
+ toggleTheme = _useThemeContext.toggleTheme;
1013
+
1014
+ return /*#__PURE__*/React__default.createElement(MenuItem, null, /*#__PURE__*/React__default.createElement(Grid, {
1015
+ container: true
1016
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1017
+ item: true
1018
+ }, "Choose your default app mode"), /*#__PURE__*/React__default.createElement(Grid, {
1019
+ item: true
1020
+ }, /*#__PURE__*/React__default.createElement(RadioGroup, {
1021
+ onChange: toggleTheme
1022
+ }, /*#__PURE__*/React__default.createElement(FormControlLabel, {
1023
+ value: true,
1024
+ control: /*#__PURE__*/React__default.createElement(Radio, {
1025
+ checked: !isDark
1026
+ }),
1027
+ label: "Light"
1028
+ }), /*#__PURE__*/React__default.createElement(FormControlLabel, {
1029
+ value: false,
1030
+ control: /*#__PURE__*/React__default.createElement(Radio, {
1031
+ checked: isDark
1032
+ }),
1033
+ label: "Dark"
1034
+ })))));
1035
+ };
1036
+
1037
+ /* *
1038
+ * Licensed under the Apache License, Version 2.0 (the "License");
1039
+ * you may not use this file except in compliance with the License.
1040
+ * You may obtain a copy of the License at
1041
+ *
1042
+ * http://www.apache.org/licenses/LICENSE-2.0
1043
+ *
1044
+ * Unless required by applicable law or agreed to in writing, software
1045
+ * distributed under the License is distributed on an "AS IS" BASIS,
1046
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1047
+ * See the License for the specific language governing permissions and
1048
+ * limitations under the License.
1049
+ *
1050
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1051
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1052
+ * */
1053
+ var useStyles$7 = makeStyles(function (theme) {
1054
+ return {
1055
+ footer: {
1056
+ boxShadow: theme.shadows[1],
1057
+ background: theme.palette.geowebColors.background.surface,
1058
+ textAlign: 'right',
1059
+ height: 18,
1060
+ zIndex: 1
1061
+ }
1062
+ };
1063
+ }); // drag handles will be handled by DraggableResizable/Resizable
1064
+
1065
+ var ToolFooter = function ToolFooter() {
1066
+ var classes = useStyles$7();
1067
+ return /*#__PURE__*/React__default.createElement("footer", {
1068
+ className: classes.footer
1069
+ });
1070
+ };
1071
+
1072
+ /* *
1073
+ * Licensed under the Apache License, Version 2.0 (the "License");
1074
+ * you may not use this file except in compliance with the License.
1075
+ * You may obtain a copy of the License at
1076
+ *
1077
+ * http://www.apache.org/licenses/LICENSE-2.0
1078
+ *
1079
+ * Unless required by applicable law or agreed to in writing, software
1080
+ * distributed under the License is distributed on an "AS IS" BASIS,
1081
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1082
+ * See the License for the specific language governing permissions and
1083
+ * limitations under the License.
1084
+ *
1085
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1086
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1087
+ * */
1088
+
1089
+ var getStyle = function getStyle(size) {
1090
+ switch (size) {
1091
+ case 'xs':
1092
+ {
1093
+ return {
1094
+ fontSize: 10,
1095
+ fontWeight: 500
1096
+ };
1097
+ }
1098
+
1099
+ case 'small':
1100
+ {
1101
+ return {
1102
+ fontSize: 16,
1103
+ fontWeight: 500,
1104
+ padding: 4
1105
+ };
1106
+ }
1107
+
1108
+ case 'medium':
1109
+ {
1110
+ return {
1111
+ fontSize: 20,
1112
+ fontWeight: 400,
1113
+ padding: 8
1114
+ };
1115
+ }
1116
+
1117
+ case 'large':
1118
+ {
1119
+ return {
1120
+ fontSize: 16,
1121
+ fontWeight: 500,
1122
+ padding: 12
1123
+ };
1124
+ }
1125
+
1126
+ default:
1127
+ {
1128
+ return {};
1129
+ }
1130
+ }
1131
+ };
1132
+
1133
+ var useStyles$6 = makeStyles(function (theme) {
1134
+ return {
1135
+ header: {
1136
+ boxShadow: theme.shadows[1],
1137
+ background: theme.palette.geowebColors.background.surface,
1138
+ padding: function padding(props) {
1139
+ return props.styles.padding;
1140
+ },
1141
+ zIndex: 1,
1142
+ cursor: function cursor(props) {
1143
+ return props.isDraggable ? 'move' : null;
1144
+ }
1145
+ },
1146
+ title: {
1147
+ fontSize: function fontSize(props) {
1148
+ return props.styles.fontSize;
1149
+ },
1150
+ fontWeight: function fontWeight(props) {
1151
+ return props.styles.fontWeight;
1152
+ }
1153
+ },
1154
+ iconClose: {
1155
+ color: theme.palette.geowebColors.greys.accessible,
1156
+ padding: 0
1157
+ },
1158
+ iconDrag: {
1159
+ color: theme.palette.geowebColors.greys.accessible,
1160
+ padding: 0,
1161
+ pointerEvents: 'none'
1162
+ },
1163
+ iconDragHorizontal: {
1164
+ color: theme.palette.geowebColors.greys.accessible,
1165
+ padding: 0,
1166
+ pointerEvents: 'none',
1167
+ transform: 'rotate(90deg)',
1168
+ height: 12
1169
+ }
1170
+ };
1171
+ });
1172
+
1173
+ var ToolHeader = function ToolHeader(_ref) {
1174
+ var size = _ref.size,
1175
+ title = _ref.title,
1176
+ _ref$onClose = _ref.onClose,
1177
+ onClose = _ref$onClose === void 0 ? null : _ref$onClose,
1178
+ _ref$isDraggable = _ref.isDraggable,
1179
+ isDraggable = _ref$isDraggable === void 0 ? false : _ref$isDraggable,
1180
+ _ref$className = _ref.className,
1181
+ className = _ref$className === void 0 ? '' : _ref$className;
1182
+ var styles = getStyle(size);
1183
+ var classes = useStyles$6({
1184
+ styles: styles,
1185
+ isDraggable: isDraggable
1186
+ });
1187
+
1188
+ var onClickClose = function onClickClose() {
1189
+ return onClose();
1190
+ };
1191
+
1192
+ return /*#__PURE__*/React__default.createElement("header", {
1193
+ className: "".concat(classes.header, " ").concat(className)
1194
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1195
+ container: true,
1196
+ alignItems: "center"
1197
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1198
+ item: true,
1199
+ xs: 1
1200
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1201
+ container: true,
1202
+ justify: "flex-start"
1203
+ }, isDraggable && size !== 'xxs' && /*#__PURE__*/React__default.createElement(IconButton, {
1204
+ "data-testid": "dragBtn",
1205
+ className: classes.iconDrag,
1206
+ disableRipple: true
1207
+ }, /*#__PURE__*/React__default.createElement(DragIndicator, null)))), /*#__PURE__*/React__default.createElement(Grid, {
1208
+ item: true,
1209
+ xs: 10
1210
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1211
+ container: true,
1212
+ justify: "center",
1213
+ alignItems: "center"
1214
+ }, title && /*#__PURE__*/React__default.createElement(Typography, {
1215
+ variant: "h2",
1216
+ className: classes.title
1217
+ }, title), size === 'xxs' && /*#__PURE__*/React__default.createElement(IconButton, {
1218
+ "data-testid": "dragBtn",
1219
+ className: classes.iconDragHorizontal,
1220
+ disableRipple: true,
1221
+ size: "small"
1222
+ }, /*#__PURE__*/React__default.createElement(DragIndicator, null)))), /*#__PURE__*/React__default.createElement(Grid, {
1223
+ item: true,
1224
+ xs: 1,
1225
+ container: true,
1226
+ justify: "flex-end"
1227
+ }, onClose && /*#__PURE__*/React__default.createElement(IconButton, {
1228
+ "data-testid": "closeBtn",
1229
+ className: classes.iconClose,
1230
+ onClick: onClickClose
1231
+ }, /*#__PURE__*/React__default.createElement(Close, null)))));
1232
+ };
1233
+
1234
+ /* *
1235
+ * Licensed under the Apache License, Version 2.0 (the "License");
1236
+ * you may not use this file except in compliance with the License.
1237
+ * You may obtain a copy of the License at
1238
+ *
1239
+ * http://www.apache.org/licenses/LICENSE-2.0
1240
+ *
1241
+ * Unless required by applicable law or agreed to in writing, software
1242
+ * distributed under the License is distributed on an "AS IS" BASIS,
1243
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244
+ * See the License for the specific language governing permissions and
1245
+ * limitations under the License.
1246
+ *
1247
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1248
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1249
+ * */
1250
+ var useStyles$5 = makeStyles(function () {
1251
+ return {
1252
+ container: {
1253
+ overflow: 'hidden',
1254
+ borderRadius: 0,
1255
+ display: 'flex',
1256
+ flexDirection: 'column',
1257
+ height: '100%'
1258
+ },
1259
+ content: {
1260
+ flex: 1,
1261
+ overflowY: 'auto',
1262
+ zIndex: 2,
1263
+ position: 'relative'
1264
+ }
1265
+ };
1266
+ });
1267
+ var BASE_ELEVATION = 5;
1268
+
1269
+ var ToolContainer = function ToolContainer(_a) {
1270
+ var _a$title = _a.title,
1271
+ title = _a$title === void 0 ? '' : _a$title,
1272
+ _a$size = _a.size,
1273
+ size = _a$size === void 0 ? 'medium' : _a$size,
1274
+ children = _a.children,
1275
+ onClose = _a.onClose,
1276
+ _a$isResizable = _a.isResizable,
1277
+ isResizable = _a$isResizable === void 0 ? false : _a$isResizable,
1278
+ _a$isDraggable = _a.isDraggable,
1279
+ isDraggable = _a$isDraggable === void 0 ? false : _a$isDraggable,
1280
+ _a$maxHeight = _a.maxHeight,
1281
+ maxHeight = _a$maxHeight === void 0 ? 'initial' : _a$maxHeight,
1282
+ _a$elevation = _a.elevation,
1283
+ elevation = _a$elevation === void 0 ? BASE_ELEVATION : _a$elevation,
1284
+ _a$headerClassName = _a.headerClassName,
1285
+ headerClassName = _a$headerClassName === void 0 ? '' : _a$headerClassName,
1286
+ props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName"]);
1287
+
1288
+ var classes = useStyles$5();
1289
+ return /*#__PURE__*/React__default.createElement(Paper, Object.assign({
1290
+ elevation: elevation,
1291
+ className: classes.container
1292
+ }, props), /*#__PURE__*/React__default.createElement(ToolHeader, {
1293
+ title: title,
1294
+ size: size,
1295
+ isDraggable: isDraggable,
1296
+ onClose: onClose,
1297
+ className: headerClassName
1298
+ }), /*#__PURE__*/React__default.createElement("div", {
1299
+ className: classes.content,
1300
+ style: {
1301
+ maxHeight: maxHeight
1302
+ }
1303
+ }, children), isResizable && /*#__PURE__*/React__default.createElement(ToolFooter, null));
1304
+ };
1305
+
1306
+ var BASE_Z_INDEX = 100;
1307
+
1308
+ var DraggableComponent = function DraggableComponent(_a) {
1309
+ var title = _a.title,
1310
+ _a$bounds = _a.bounds,
1311
+ bounds = _a$bounds === void 0 ? 'body' : _a$bounds,
1312
+ _a$headerSize = _a.headerSize,
1313
+ headerSize = _a$headerSize === void 0 ? 'small' : _a$headerSize,
1314
+ _a$startSize = _a.startSize,
1315
+ startSize = _a$startSize === void 0 ? {
1316
+ width: 'auto',
1317
+ height: 'auto'
1318
+ } : _a$startSize,
1319
+ _a$startPosition = _a.startPosition,
1320
+ startPosition = _a$startPosition === void 0 ? {
1321
+ left: null,
1322
+ right: null,
1323
+ top: null
1324
+ } : _a$startPosition,
1325
+ children = _a.children,
1326
+ _a$isOpen = _a.isOpen,
1327
+ isOpen = _a$isOpen === void 0 ? true : _a$isOpen,
1328
+ _a$onClose = _a.onClose,
1329
+ onClose = _a$onClose === void 0 ? function () {
1330
+ return null;
1331
+ } : _a$onClose,
1332
+ _a$initialMaxHeight = _a.initialMaxHeight,
1333
+ defaultInitialMaxHeight = _a$initialMaxHeight === void 0 ? 'initial' : _a$initialMaxHeight,
1334
+ _a$onChangeSize = _a.onChangeSize,
1335
+ onChangeSize = _a$onChangeSize === void 0 ? function () {
1336
+ return null;
1337
+ } : _a$onChangeSize,
1338
+ _a$onMouseDown = _a.onMouseDown,
1339
+ onMouseDown = _a$onMouseDown === void 0 ? function () {
1340
+ return null;
1341
+ } : _a$onMouseDown,
1342
+ _a$order = _a.order,
1343
+ order = _a$order === void 0 ? 1 : _a$order,
1344
+ _a$source = _a.source,
1345
+ source = _a$source === void 0 ? 'app' : _a$source,
1346
+ props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "order", "source"]);
1347
+
1348
+ var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
1349
+ var elevation = BASE_ELEVATION + order;
1350
+ var nodeRef = React__default.useRef(null);
1351
+
1352
+ var _React$useState = React__default.useState({
1353
+ x: 0,
1354
+ y: 0
1355
+ }),
1356
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1357
+ position = _React$useState2[0],
1358
+ setPosition = _React$useState2[1];
1359
+
1360
+ var _React$useState3 = React__default.useState(startSize),
1361
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
1362
+ size = _React$useState4[0],
1363
+ setSize = _React$useState4[1];
1364
+
1365
+ var onStopDrag = React__default.useCallback(function (_event, position) {
1366
+ setPosition(position);
1367
+ }, [setPosition]);
1368
+
1369
+ var _React$useState5 = React__default.useState(defaultInitialMaxHeight),
1370
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
1371
+ initialMaxHeight = _React$useState6[0],
1372
+ setInitialMaxHeight = _React$useState6[1];
1373
+
1374
+ var onStartResize = function onStartResize() {
1375
+ setInitialMaxHeight('initial');
1376
+ };
1377
+
1378
+ var onResize = React__default.useCallback(function (_event, _handle, node) {
1379
+ var _node$getBoundingClie = node.getBoundingClientRect(),
1380
+ width = _node$getBoundingClie.width,
1381
+ height = _node$getBoundingClie.height;
1382
+
1383
+ onChangeSize({
1384
+ width: width,
1385
+ height: height
1386
+ });
1387
+ }, [onChangeSize]);
1388
+ var onResizeWindow = React__default.useCallback(function (event) {
1389
+ if (!nodeRef.current) return;
1390
+ var bbox = nodeRef.current.firstChild.getBoundingClientRect();
1391
+ var windowTarget = event.currentTarget;
1392
+ if (!windowTarget) return;
1393
+ var innerHeight = windowTarget.innerHeight,
1394
+ innerWidth = windowTarget.innerWidth;
1395
+ var isHorizontallyLarger = bbox.width > innerWidth;
1396
+ var isVerticallyLarger = bbox.height > innerHeight; // left screen
1397
+
1398
+ if (bbox.x < 0 || isHorizontallyLarger) {
1399
+ setPosition(Object.assign(Object.assign({}, position), {
1400
+ x: position.x - bbox.x
1401
+ }));
1402
+ } // right screen
1403
+ else if (bbox.x + bbox.width >= innerWidth) {
1404
+ var diffX = innerWidth - bbox.x - bbox.width;
1405
+ setPosition(Object.assign(Object.assign({}, position), {
1406
+ x: position.x + diffX
1407
+ }));
1408
+ } // top screen
1409
+ else if (bbox.y < 0 || isVerticallyLarger) {
1410
+ setPosition(Object.assign(Object.assign({}, position), {
1411
+ y: position.y - bbox.y
1412
+ }));
1413
+ } // bottom screen
1414
+ else if (bbox.y + bbox.height >= innerHeight) {
1415
+ var diffY = innerHeight - bbox.y - bbox.height;
1416
+ setPosition(Object.assign(Object.assign({}, position), {
1417
+ y: position.y + diffY
1418
+ }));
1419
+ }
1420
+ }, [position]);
1421
+ React__default.useEffect(function () {
1422
+ var throttledResize = throttle(onResizeWindow, 100);
1423
+ window.addEventListener('resize', throttledResize);
1424
+ return function () {
1425
+ window.removeEventListener('resize', throttledResize);
1426
+ };
1427
+ }, [onResizeWindow]);
1428
+ var toolcontainerId = React__default.useRef(Date.now().toString()).current;
1429
+ var headerClassName = "header-".concat(toolcontainerId);
1430
+ return isOpen ? /*#__PURE__*/React__default.createElement(DraggableComponent$1, {
1431
+ nodeRef: nodeRef,
1432
+ bounds: bounds,
1433
+ position: position,
1434
+ onStop: onStopDrag,
1435
+ handle: ".".concat(headerClassName),
1436
+ onMouseDown: onMouseDown
1437
+ }, /*#__PURE__*/React__default.createElement("div", {
1438
+ style: Object.assign({
1439
+ position: 'absolute',
1440
+ zIndex: zIndex
1441
+ }, startPosition),
1442
+ ref: nodeRef
1443
+ }, /*#__PURE__*/React__default.createElement(ResizeComponent, Object.assign({}, props, {
1444
+ startPosition: startPosition,
1445
+ size: size,
1446
+ setSize: setSize,
1447
+ onResizeStart: onStartResize,
1448
+ onResize: onResize
1449
+ }), /*#__PURE__*/React__default.createElement(ToolContainer, {
1450
+ maxHeight: initialMaxHeight,
1451
+ onClose: onClose,
1452
+ title: title,
1453
+ size: headerSize,
1454
+ isDraggable: true,
1455
+ isResizable: true,
1456
+ elevation: elevation,
1457
+ headerClassName: headerClassName
1458
+ }, children)))) : null;
1459
+ };
1460
+
1461
+ /* *
1462
+ * Licensed under the Apache License, Version 2.0 (the "License");
1463
+ * you may not use this file except in compliance with the License.
1464
+ * You may obtain a copy of the License at
1465
+ *
1466
+ * http://www.apache.org/licenses/LICENSE-2.0
1467
+ *
1468
+ * Unless required by applicable law or agreed to in writing, software
1469
+ * distributed under the License is distributed on an "AS IS" BASIS,
1470
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1471
+ * See the License for the specific language governing permissions and
1472
+ * limitations under the License.
1473
+ *
1474
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1475
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1476
+ * */
1477
+ var useStyles$4 = makeStyles(function (theme) {
1478
+ return {
1479
+ icon: {
1480
+ backgroundColor: theme.palette.geowebColors.textInputField["default"].rgba,
1481
+ width: 40,
1482
+ height: 40,
1483
+ display: 'inline-flex',
1484
+ verticalAlign: 'middle',
1485
+ alignItems: 'center',
1486
+ borderRadius: theme.shape.borderRadius,
1487
+ '&>span': {
1488
+ textAlign: 'center',
1489
+ fontSize: 14,
1490
+ fontWeight: 500,
1491
+ display: 'flex',
1492
+ margin: 'auto',
1493
+ letterSpacing: 0.25
1494
+ }
1495
+ },
1496
+ segment: {
1497
+ margin: '0 2px',
1498
+ verticalAlign: 'middle',
1499
+ fontSize: 14,
1500
+ fontWeight: 500,
1501
+ letterSpacing: 0.25
1502
+ },
1503
+ connect: {
1504
+ fontSize: 18
1505
+ },
1506
+ divider: {
1507
+ margin: '0 6px',
1508
+ fontSize: 18
1509
+ }
1510
+ };
1511
+ });
1512
+
1513
+ var ShortCutSegment = function ShortCutSegment(_ref) {
1514
+ var _ref$type = _ref.type,
1515
+ type = _ref$type === void 0 ? 'text' : _ref$type,
1516
+ children = _ref.children;
1517
+ var classes = useStyles$4();
1518
+
1519
+ if (type === 'divider') {
1520
+ return /*#__PURE__*/React__default.createElement(Typography, {
1521
+ "data-testid": "segment-divider",
1522
+ className: "".concat(classes.segment, " ").concat(classes.divider),
1523
+ component: "span"
1524
+ }, children);
1525
+ }
1526
+
1527
+ if (type === 'icon') {
1528
+ return /*#__PURE__*/React__default.createElement("span", {
1529
+ "data-testid": "segment-icon",
1530
+ className: "".concat(classes.segment, " ").concat(classes.icon)
1531
+ }, /*#__PURE__*/React__default.createElement(Typography, {
1532
+ component: "span"
1533
+ }, children));
1534
+ }
1535
+
1536
+ if (type === 'connect') {
1537
+ return /*#__PURE__*/React__default.createElement(Typography, {
1538
+ className: "".concat(classes.segment, " ").concat(classes.connect),
1539
+ "data-testid": "segment-connect",
1540
+ component: "span"
1541
+ }, children);
1542
+ }
1543
+
1544
+ return /*#__PURE__*/React__default.createElement(Typography, {
1545
+ className: classes.segment,
1546
+ "data-testid": "segment-text",
1547
+ component: "span"
1548
+ }, children);
1549
+ };
1550
+
1551
+ /* *
1552
+ * Licensed under the Apache License, Version 2.0 (the "License");
1553
+ * you may not use this file except in compliance with the License.
1554
+ * You may obtain a copy of the License at
1555
+ *
1556
+ * http://www.apache.org/licenses/LICENSE-2.0
1557
+ *
1558
+ * Unless required by applicable law or agreed to in writing, software
1559
+ * distributed under the License is distributed on an "AS IS" BASIS,
1560
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1561
+ * See the License for the specific language governing permissions and
1562
+ * limitations under the License.
1563
+ *
1564
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1565
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1566
+ * */
1567
+ var useStyles$3 = makeStyles(function (theme) {
1568
+ return {
1569
+ icon: {
1570
+ fill: theme.palette.geowebColors.typographyAndIcons.text
1571
+ }
1572
+ };
1573
+ });
1574
+ var OptionIcon = function OptionIcon() {
1575
+ var classes = useStyles$3();
1576
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1577
+ viewBox: "0 0 12 11",
1578
+ style: {
1579
+ width: 12,
1580
+ height: 11
1581
+ }
1582
+ }, /*#__PURE__*/React__default.createElement("title", null, "Option"), /*#__PURE__*/React__default.createElement("g", {
1583
+ id: "Symbols:-General",
1584
+ stroke: "none",
1585
+ strokeWidth: "1",
1586
+ fill: "none",
1587
+ fillRule: "evenodd"
1588
+ }, /*#__PURE__*/React__default.createElement("g", {
1589
+ id: "Shortcut-Option-\"\u2325\"",
1590
+ transform: "translate(-14.000000, -13.000000)",
1591
+ className: classes.icon
1592
+ }, /*#__PURE__*/React__default.createElement("path", {
1593
+ d: "M18.01,13.88 L22.56,22.99 L25.7,22.99 L25.7,24 L21.74,24 L17.19,14.9 L14.06,14.9 L14.06,13.88 L18.01,13.88 Z M25.7,13.88 L25.7,14.9 L20.97,14.9 L20.97,13.88 L25.7,13.88 Z",
1594
+ id: "Option"
1595
+ }))));
1596
+ };
1597
+ var CommandIcon = function CommandIcon() {
1598
+ var classes = useStyles$3();
1599
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1600
+ viewBox: "0 0 12 12",
1601
+ style: {
1602
+ width: 12,
1603
+ height: 12
1604
+ }
1605
+ }, /*#__PURE__*/React__default.createElement("title", null, "Command"), /*#__PURE__*/React__default.createElement("g", {
1606
+ id: "Symbols:-General",
1607
+ stroke: "none",
1608
+ strokeWidth: "1",
1609
+ fill: "none",
1610
+ fillRule: "evenodd"
1611
+ }, /*#__PURE__*/React__default.createElement("g", {
1612
+ id: "Shortcut-Command-\"\u2318\"",
1613
+ transform: "translate(-14.000000, -13.000000)",
1614
+ className: classes.icon
1615
+ }, /*#__PURE__*/React__default.createElement("path", {
1616
+ d: "M23.04,13.63 C24.08,13.63 25.19,14.44 25.19,15.8 C25.19,16.8 24.4,17.93 23.04,17.93 L23.04,17.93 L21.9,17.93 L21.9,19.95 L23,19.95 C24.4,19.95 25.19,21.1 25.19,22 C25.19,23.6 24,24.26 23,24.26 C22,24.26 20.89,23.5 20.89,22 L20.89,22 L20.89,20.97 L18.86,20.97 L18.86,22 C18.86,23.5 17.75,24.26 16.71,24.26 C15.7,24.26 14.56,23.5 14.56,22 C14.56,21 15.55,19.95 16.71,19.95 L16.71,19.95 L17.85,19.95 L17.85,17.93 L16.71,17.93 C15.55,17.93 14.525085,17 14.5614747,15.7207438 C14.5978644,14.4414876 15.7,13.63 16.71,13.63 C17.75,13.63 18.86,14.38 18.86,15.8 L18.86,15.8 L18.86,16.92 L20.89,16.92 L20.89,15.8 C20.89,14.38 22,13.63 23.04,13.63 Z M17.85,20.96 L16.71,20.96 C16.0803954,20.96 15.57,21.4703954 15.57,22.1 C15.57,22.7296046 16.0803954,23.24 16.71,23.24 C17.3396046,23.24 17.85,22.7296046 17.85,22.1 L17.85,22.1 L17.85,20.96 Z M23.04,20.96 L21.9,20.96 L21.9,22.1 L21.9066894,22.2242156 C21.9685825,22.7953889 22.452369,23.24 23.04,23.24 C23.6696046,23.24 24.18,22.7296046 24.18,22.1 C24.18,21.4703954 23.6696046,20.96 23.04,20.96 L23.04,20.96 Z M20.89,17.93 L18.86,17.93 L18.86,19.95 L20.89,19.95 L20.89,17.93 Z M16.71,14.64 C16.0803954,14.64 15.57,15.1503954 15.57,15.78 C15.57,16.4096046 16.0803954,16.92 16.71,16.92 L16.71,16.92 L17.85,16.92 L17.85,15.78 L17.8433106,15.6557844 C17.7814175,15.0846111 17.297631,14.64 16.71,14.64 Z M23.04,14.64 C22.4103954,14.64 21.9,15.1503954 21.9,15.78 L21.9,15.78 L21.9,16.92 L23.04,16.92 C23.6696046,16.92 24.18,16.4096046 24.18,15.78 C24.18,15.1503954 23.6696046,14.64 23.04,14.64 Z",
1617
+ id: "Command"
1618
+ }))));
1619
+ };
1620
+ var ArrowLeftIcon = function ArrowLeftIcon() {
1621
+ var classes = useStyles$3();
1622
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1623
+ viewBox: "0 0 12 6",
1624
+ style: {
1625
+ width: 12,
1626
+ height: 6
1627
+ }
1628
+ }, /*#__PURE__*/React__default.createElement("title", null, "Arrow left"), /*#__PURE__*/React__default.createElement("g", {
1629
+ id: "Symbols:-General",
1630
+ stroke: "none",
1631
+ strokeWidth: "1",
1632
+ fill: "none",
1633
+ fillRule: "evenodd"
1634
+ }, /*#__PURE__*/React__default.createElement("g", {
1635
+ id: "Shortcut-Arrow-left-\"\u2190\"",
1636
+ transform: "translate(-14.000000, -16.000000)",
1637
+ className: classes.icon
1638
+ }, /*#__PURE__*/React__default.createElement("polygon", {
1639
+ id: "Arrow-left",
1640
+ transform: "translate(19.880000, 18.960000) rotate(90.000000) translate(-19.880000, -18.960000) ",
1641
+ points: "16.92 21.485 19.88 24.445 22.84 21.485 20.39 21.485 20.39 13.475 19.37 13.475 19.37 21.485"
1642
+ }))));
1643
+ };
1644
+ var ArrowRightIcon = function ArrowRightIcon() {
1645
+ var classes = useStyles$3();
1646
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1647
+ viewBox: "0 0 12 6",
1648
+ style: {
1649
+ width: 12,
1650
+ height: 6
1651
+ }
1652
+ }, /*#__PURE__*/React__default.createElement("title", null, "Arrow right"), /*#__PURE__*/React__default.createElement("g", {
1653
+ id: "Symbols:-General",
1654
+ stroke: "none",
1655
+ strokeWidth: "1",
1656
+ fill: "none",
1657
+ fillRule: "evenodd"
1658
+ }, /*#__PURE__*/React__default.createElement("g", {
1659
+ id: "Shortcut-Arrow-right-\"\u2192\"",
1660
+ transform: "translate(-14.000000, -16.000000)",
1661
+ className: classes.icon
1662
+ }, /*#__PURE__*/React__default.createElement("polygon", {
1663
+ id: "Arrow-right",
1664
+ transform: "translate(19.880000, 18.960000) rotate(-90.000000) translate(-19.880000, -18.960000) ",
1665
+ points: "16.92 21.485 19.88 24.445 22.84 21.485 20.39 21.485 20.39 13.475 19.37 13.475 19.37 21.485"
1666
+ }))));
1667
+ };
1668
+ var ArrowDownIcon = function ArrowDownIcon() {
1669
+ var classes = useStyles$3();
1670
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1671
+ viewBox: "0 0 6 12",
1672
+ style: {
1673
+ width: 6,
1674
+ height: 12
1675
+ }
1676
+ }, /*#__PURE__*/React__default.createElement("title", null, "Arrow down"), /*#__PURE__*/React__default.createElement("g", {
1677
+ id: "Symbols:-General",
1678
+ stroke: "none",
1679
+ strokeWidth: "1",
1680
+ fill: "none",
1681
+ fillRule: "evenodd"
1682
+ }, /*#__PURE__*/React__default.createElement("g", {
1683
+ id: "Shortcut-Arrow-down-\"\u2193\"",
1684
+ transform: "translate(-17.000000, -13.000000)",
1685
+ className: classes.icon
1686
+ }, /*#__PURE__*/React__default.createElement("polygon", {
1687
+ id: "Arrow-down",
1688
+ points: "16.92 21.89 19.88 24.85 22.84 21.89 20.39 21.89 20.39 13.88 19.37 13.88 19.37 21.89"
1689
+ }))));
1690
+ };
1691
+ var ArrowUpIcon = function ArrowUpIcon() {
1692
+ var classes = useStyles$3();
1693
+ return /*#__PURE__*/React__default.createElement(SvgIcon, {
1694
+ viewBox: "0 0 6 11",
1695
+ style: {
1696
+ width: 6,
1697
+ height: 11
1698
+ }
1699
+ }, /*#__PURE__*/React__default.createElement("title", null, "Arrow up"), /*#__PURE__*/React__default.createElement("g", {
1700
+ id: "Symbols:-General",
1701
+ stroke: "none",
1702
+ strokeWidth: "1",
1703
+ fill: "none",
1704
+ fillRule: "evenodd"
1705
+ }, /*#__PURE__*/React__default.createElement("g", {
1706
+ id: "Shortcut-Arrow-up-\"\u2191\"",
1707
+ transform: "translate(-17.000000, -13.000000)",
1708
+ className: classes.icon
1709
+ }, /*#__PURE__*/React__default.createElement("polygon", {
1710
+ id: "Arrow-up",
1711
+ transform: "translate(19.880000, 18.485000) scale(1, -1) translate(-19.880000, -18.485000) ",
1712
+ points: "16.92 21.01 19.88 23.97 22.84 21.01 20.39 21.01 20.39 13 19.37 13 19.37 21.01"
1713
+ }))));
1714
+ };
1715
+
1716
+ /* *
1717
+ * Licensed under the Apache License, Version 2.0 (the "License");
1718
+ * you may not use this file except in compliance with the License.
1719
+ * You may obtain a copy of the License at
1720
+ *
1721
+ * http://www.apache.org/licenses/LICENSE-2.0
1722
+ *
1723
+ * Unless required by applicable law or agreed to in writing, software
1724
+ * distributed under the License is distributed on an "AS IS" BASIS,
1725
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1726
+ * See the License for the specific language governing permissions and
1727
+ * limitations under the License.
1728
+ *
1729
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1730
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1731
+ * */
1732
+ var shortcuts = [{
1733
+ title: 'Choose a selected time',
1734
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "Left click on the time slider rail")
1735
+ }, {
1736
+ title: 'Move backwards/forwards in selected time',
1737
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "Mouse scroll over the time slider rail")
1738
+ }, {
1739
+ title: 'Move 1 step backwards/forwards in selected time',
1740
+ description: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1741
+ type: "icon"
1742
+ }, "Ctrl"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1743
+ type: "connect"
1744
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1745
+ type: "icon"
1746
+ }, /*#__PURE__*/React__default.createElement(ArrowLeftIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1747
+ type: "divider"
1748
+ }, "or"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1749
+ type: "icon"
1750
+ }, /*#__PURE__*/React__default.createElement(ArrowRightIcon, null))),
1751
+ descriptionMac: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1752
+ type: "icon"
1753
+ }, /*#__PURE__*/React__default.createElement(OptionIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1754
+ type: "connect"
1755
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1756
+ type: "icon"
1757
+ }, /*#__PURE__*/React__default.createElement(CommandIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1758
+ type: "connect"
1759
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1760
+ type: "icon"
1761
+ }, /*#__PURE__*/React__default.createElement(ArrowLeftIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1762
+ type: "divider"
1763
+ }, "or"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1764
+ type: "icon"
1765
+ }, /*#__PURE__*/React__default.createElement(ArrowRightIcon, null)))
1766
+ }, {
1767
+ title: 'Toggle hide/show time slider',
1768
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1769
+ type: "icon"
1770
+ }, "t")
1771
+ }, {
1772
+ title: 'Change time slider scale (visible timespan)',
1773
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "Hold left click over Time Slider legend + drag left or right")
1774
+ }, {
1775
+ title: 'Expand/shrink time slider scale (visible timespan)',
1776
+ description: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1777
+ type: "icon"
1778
+ }, "Ctrl"), /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "+ Scroll the slider rail"))
1779
+ }, {
1780
+ title: 'Mouseover to change selected time',
1781
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "Hover over Time Slider rail or time indicator")
1782
+ }, {
1783
+ title: 'Mouseover switch on/off',
1784
+ description: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1785
+ type: "icon"
1786
+ }, "Ctrl"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1787
+ type: "connect"
1788
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1789
+ type: "icon"
1790
+ }, "Alt"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1791
+ type: "connect"
1792
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1793
+ type: "icon"
1794
+ }, "h")),
1795
+ descriptionMac: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1796
+ type: "icon"
1797
+ }, "Ctrl"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1798
+ type: "connect"
1799
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1800
+ type: "icon"
1801
+ }, /*#__PURE__*/React__default.createElement(OptionIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1802
+ type: "connect"
1803
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1804
+ type: "icon"
1805
+ }, "h"))
1806
+ }, {
1807
+ title: 'Change time step or animation speed',
1808
+ description: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1809
+ type: "icon"
1810
+ }, "Ctrl"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1811
+ type: "connect"
1812
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1813
+ type: "icon"
1814
+ }, /*#__PURE__*/React__default.createElement(ArrowUpIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1815
+ type: "divider"
1816
+ }, "or"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1817
+ type: "icon"
1818
+ }, /*#__PURE__*/React__default.createElement(ArrowDownIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "(when slider active)")),
1819
+ descriptionMac: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1820
+ type: "icon"
1821
+ }, /*#__PURE__*/React__default.createElement(CommandIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1822
+ type: "connect"
1823
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1824
+ type: "icon"
1825
+ }, /*#__PURE__*/React__default.createElement(ArrowUpIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1826
+ type: "divider"
1827
+ }, "or"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1828
+ type: "icon"
1829
+ }, /*#__PURE__*/React__default.createElement(ArrowDownIcon, null)), /*#__PURE__*/React__default.createElement(ShortCutSegment, null, "(when slider active)"))
1830
+ }, {
1831
+ title: 'Return to current time',
1832
+ description: /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1833
+ type: "icon"
1834
+ }, "Home"),
1835
+ descriptionMac: /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1836
+ type: "icon"
1837
+ }, "fn"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1838
+ type: "connect"
1839
+ }, "+"), /*#__PURE__*/React__default.createElement(ShortCutSegment, {
1840
+ type: "icon"
1841
+ }, /*#__PURE__*/React__default.createElement(ArrowLeftIcon, null)))
1842
+ }];
1843
+ var getShortcutList = function getShortcutList(shortcutList) {
1844
+ var platform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'windows';
1845
+ return shortcutList.map(function (_ref) {
1846
+ var title = _ref.title,
1847
+ description = _ref.description,
1848
+ descriptionMac = _ref.descriptionMac;
1849
+ return Object.assign({
1850
+ title: title,
1851
+ description: description
1852
+ }, platform === 'windows' ? {
1853
+ description: description
1854
+ } : {
1855
+ description: descriptionMac || description
1856
+ });
1857
+ });
1858
+ };
1859
+ var useStyles$2 = makeStyles(function () {
1860
+ return {
1861
+ row: {
1862
+ minHeight: 56
1863
+ },
1864
+ title: {
1865
+ fontSize: 12,
1866
+ fontWeight: 300,
1867
+ letterSpacing: 0.4,
1868
+ opacity: 0.67
1869
+ },
1870
+ description: {
1871
+ alignItems: 'center'
1872
+ }
1873
+ };
1874
+ });
1875
+
1876
+ var ShortcutList = function ShortcutList(_ref2) {
1877
+ var _ref2$platform = _ref2.platform,
1878
+ platform = _ref2$platform === void 0 ? 'windows' : _ref2$platform;
1879
+ var classes = useStyles$2();
1880
+ var rows = getShortcutList(shortcuts, platform);
1881
+ return /*#__PURE__*/React__default.createElement(List, {
1882
+ "data-testid": "list-".concat(platform)
1883
+ }, rows.map(function (row, index) {
1884
+ return /*#__PURE__*/React__default.createElement(ListItem, {
1885
+ className: classes.row,
1886
+ divider: index !== rows.length - 1,
1887
+ key: row.title
1888
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1889
+ container: true,
1890
+ direction: "row",
1891
+ justify: "space-between",
1892
+ alignItems: "center"
1893
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1894
+ item: true,
1895
+ className: classes.title
1896
+ }, row.title), /*#__PURE__*/React__default.createElement(Grid, {
1897
+ item: true
1898
+ }, /*#__PURE__*/React__default.createElement("div", {
1899
+ className: classes.description
1900
+ }, row.description))));
1901
+ }));
1902
+ };
1903
+
1904
+ var TabPanel = function TabPanel(_ref) {
1905
+ var children = _ref.children,
1906
+ value = _ref.value,
1907
+ index = _ref.index;
1908
+ return /*#__PURE__*/React__default.createElement("div", {
1909
+ role: "tabpanel",
1910
+ hidden: value !== index,
1911
+ id: "tabpanel-".concat(index),
1912
+ "aria-labelledby": "tab-".concat(index)
1913
+ }, value === index && children);
1914
+ };
1915
+
1916
+ var useStyles$1 = makeStyles(function () {
1917
+ return {
1918
+ container: {
1919
+ margin: '0px 20px'
1920
+ },
1921
+ tab: {
1922
+ fontSize: 12
1923
+ }
1924
+ };
1925
+ });
1926
+
1927
+ var CheatSheet = function CheatSheet() {
1928
+ var classes = useStyles$1();
1929
+
1930
+ var _React$useState = React__default.useState(0),
1931
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1932
+ activeTab = _React$useState2[0],
1933
+ onChangeActiveTab = _React$useState2[1];
1934
+
1935
+ var onChangeTab = function onChangeTab(_event, newValue) {
1936
+ onChangeActiveTab(newValue);
1937
+ };
1938
+
1939
+ return /*#__PURE__*/React__default.createElement("div", {
1940
+ className: classes.container
1941
+ }, /*#__PURE__*/React__default.createElement(Tabs, {
1942
+ value: activeTab,
1943
+ onChange: onChangeTab,
1944
+ "aria-label": "platform"
1945
+ }, /*#__PURE__*/React__default.createElement(Tab, {
1946
+ className: classes.tab,
1947
+ label: "Windows"
1948
+ }), /*#__PURE__*/React__default.createElement(Tab, {
1949
+ className: classes.tab,
1950
+ label: "Mac"
1951
+ })), /*#__PURE__*/React__default.createElement(TabPanel, {
1952
+ value: activeTab,
1953
+ index: 0
1954
+ }, /*#__PURE__*/React__default.createElement(ShortcutList, null)), /*#__PURE__*/React__default.createElement(TabPanel, {
1955
+ value: activeTab,
1956
+ index: 1
1957
+ }, /*#__PURE__*/React__default.createElement(ShortcutList, {
1958
+ platform: "mac"
1959
+ })));
1960
+ };
1961
+
1962
+ var useStyles = makeStyles(function () {
1963
+ return {
1964
+ backdrop: {
1965
+ zIndex: 1
1966
+ }
1967
+ };
1968
+ });
1969
+
1970
+ var UserMenuItemCheatSheet = function UserMenuItemCheatSheet() {
1971
+ var classes = useStyles();
1972
+
1973
+ var _React$useState = React__default.useState(false),
1974
+ _React$useState2 = _slicedToArray(_React$useState, 2),
1975
+ open = _React$useState2[0],
1976
+ setOpen = _React$useState2[1];
1977
+
1978
+ var onClose = function onClose() {
1979
+ setOpen(false);
1980
+ };
1981
+
1982
+ var onOpen = function onOpen() {
1983
+ setOpen(true);
1984
+ };
1985
+
1986
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MenuItem, {
1987
+ "data-testid": "cheatsheet-btn",
1988
+ onClick: onOpen
1989
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1990
+ container: true
1991
+ }, /*#__PURE__*/React__default.createElement(Grid, {
1992
+ item: true
1993
+ }, "Cheat sheet"))), /*#__PURE__*/React__default.createElement(Backdrop, {
1994
+ "data-testid": "cheatsheet-content",
1995
+ open: open,
1996
+ className: classes.backdrop
1997
+ }, /*#__PURE__*/React__default.createElement(DraggableComponent, {
1998
+ startSize: {
1999
+ width: 700
2000
+ },
2001
+ minHeight: 300,
2002
+ minWidth: 500,
2003
+ title: "Cheat sheet",
2004
+ headerSize: "small",
2005
+ isOpen: true,
2006
+ onClose: onClose,
2007
+ bounds: "parent"
2008
+ }, /*#__PURE__*/React__default.createElement(CheatSheet, null))));
2009
+ };
2010
+
2011
+ var useUserMenu = function useUserMenu() {
2012
+ var open = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2013
+
2014
+ var _React$useState = React__default.useState(open),
2015
+ _React$useState2 = _slicedToArray(_React$useState, 2),
2016
+ isOpen = _React$useState2[0],
2017
+ setOpen = _React$useState2[1];
2018
+
2019
+ var onClose = function onClose() {
2020
+ return setOpen(false);
2021
+ };
2022
+
2023
+ var onToggle = function onToggle() {
2024
+ return setOpen(!isOpen);
2025
+ };
2026
+
2027
+ return {
2028
+ isOpen: isOpen,
2029
+ onClose: onClose,
2030
+ onToggle: onToggle
2031
+ };
2032
+ };
2033
+
2034
+ /* *
2035
+ * Licensed under the Apache License, Version 2.0 (the "License");
2036
+ * you may not use this file except in compliance with the License.
2037
+ * You may obtain a copy of the License at
2038
+ *
2039
+ * http://www.apache.org/licenses/LICENSE-2.0
2040
+ *
2041
+ * Unless required by applicable law or agreed to in writing, software
2042
+ * distributed under the License is distributed on an "AS IS" BASIS,
2043
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2044
+ * See the License for the specific language governing permissions and
2045
+ * limitations under the License.
2046
+ *
2047
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2048
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
2049
+ * */
2050
+ var getInitials = function getInitials(name) {
2051
+ if (!name) return '';
2052
+ var nameWithoutEmail = name.split('@')[0];
2053
+ var array = nameWithoutEmail.split('.');
2054
+
2055
+ switch (array.length) {
2056
+ case 1:
2057
+ return array[0].charAt(0).toUpperCase();
2058
+
2059
+ default:
2060
+ return array[0].charAt(0).toUpperCase() + array[array.length - 1].charAt(0).toUpperCase();
2061
+ }
2062
+ };
2063
+
2064
+ var sliderStyles = makeStyles(function (theme) {
2065
+ return {
2066
+ sliderHeader: {
2067
+ fontFamily: 'Roboto-Black, Roboto',
2068
+ fontSize: 12,
2069
+ color: theme.palette.geowebColors.typographyAndIcons.text,
2070
+ padding: '11px 0 11px 16px'
2071
+ }
2072
+ };
2073
+ });
2074
+ var CustomSliderComponent = withStyles(function (theme) {
2075
+ return {
2076
+ root: {
2077
+ marginLeft: '16px',
2078
+ // highlight selected label
2079
+ '& span.selectedLabel': {
2080
+ fontWeight: 'bold'
2081
+ }
2082
+ },
2083
+ thumb: {
2084
+ width: 20,
2085
+ height: 20,
2086
+ marginLeft: '-7px !important',
2087
+ marginBottom: '-10px !important',
2088
+ backgroundColor: theme.palette.geowebColors.customSlider.thumb,
2089
+ '$disabled &': {
2090
+ width: 20,
2091
+ height: 20,
2092
+ backgroundColor: theme.palette.geowebColors.customSlider.thumbDisabled
2093
+ },
2094
+ boxShadow: '0px 3px 5px 1px rgba(0,0,0,0.3)',
2095
+ '&:focus, &:hover, &:active': {
2096
+ boxShadow: '0px 3px 5px 2px rgba(0,0,0,0.4)'
2097
+ }
2098
+ },
2099
+ mark: {
2100
+ height: '2px',
2101
+ width: '2px',
2102
+ marginLeft: '2px',
2103
+ backgroundColor: theme.palette.geowebColors.customSlider.mark,
2104
+ '$disabled &': {
2105
+ backgroundColor: theme.palette.geowebColors.customSlider.markDisabled
2106
+ }
2107
+ },
2108
+ markLabel: {
2109
+ fontFamily: 'Roboto-Black, Roboto',
2110
+ fontSize: 12,
2111
+ color: theme.palette.geowebColors.typographyAndIcons.text
2112
+ },
2113
+ track: {
2114
+ borderRadius: '0 0 4.5px 4.5px',
2115
+ width: '6px !important',
2116
+ backgroundColor: theme.palette.geowebColors.customSlider.track,
2117
+ '$disabled &': {
2118
+ backgroundColor: theme.palette.geowebColors.customSlider.trackDisabled
2119
+ }
2120
+ },
2121
+ rail: {
2122
+ width: '4px !important',
2123
+ borderRadius: 4.5,
2124
+ backgroundColor: theme.palette.geowebColors.customSlider.rail,
2125
+ marginLeft: '1px',
2126
+ opacity: 1,
2127
+ '$disabled &': {
2128
+ backgroundColor: theme.palette.geowebColors.customSlider.railDisabled,
2129
+ opacity: 1
2130
+ }
2131
+ },
2132
+ disabled: {// this has to exist, because otherwise '$disabled &' rules above has no effect ???
2133
+ }
2134
+ };
2135
+ })(Slider);
2136
+ var CustomSlider = function CustomSlider(_ref) {
2137
+ var value = _ref.value,
2138
+ onChange = _ref.onChange,
2139
+ onKeyDown = _ref.onKeyDown,
2140
+ _ref$dataTestId = _ref.dataTestId,
2141
+ dataTestId = _ref$dataTestId === void 0 ? 'customSlider' : _ref$dataTestId,
2142
+ _ref$orientation = _ref.orientation,
2143
+ orientation = _ref$orientation === void 0 ? 'vertical' : _ref$orientation,
2144
+ max = _ref.max,
2145
+ min = _ref.min,
2146
+ step = _ref.step,
2147
+ _ref$marks = _ref.marks,
2148
+ marks = _ref$marks === void 0 ? [] : _ref$marks,
2149
+ _ref$disabled = _ref.disabled,
2150
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
2151
+ ThumbComponent = _ref.ThumbComponent;
2152
+ // Add custom class (for bold text) to label adjacent to thumb component.
2153
+ // Material UI doesn't support highlighing only adjacent label
2154
+ // when track is highlighted everywhere below selected value.
2155
+ var element = React.useRef(null);
2156
+ var themeContext = useThemeContext();
2157
+ React.useEffect(function () {
2158
+ var activeMarkLabelElements = element.current.getElementsByClassName('MuiSlider-markLabelActive');
2159
+
2160
+ var _reverse = _toConsumableArray(activeMarkLabelElements).reverse(),
2161
+ _reverse2 = _toArray(_reverse),
2162
+ first = _reverse2[0],
2163
+ rest = _reverse2.slice(1);
2164
+
2165
+ if (first) first.classList.add('selectedLabel');
2166
+ rest.forEach(function (element) {
2167
+ return element.classList.remove('selectedLabel');
2168
+ });
2169
+ }, [value, themeContext.isDark]);
2170
+ return /*#__PURE__*/React.createElement(CustomSliderComponent, {
2171
+ ref: element,
2172
+ "data-testid": dataTestId,
2173
+ orientation: orientation,
2174
+ value: value,
2175
+ step: step,
2176
+ max: max,
2177
+ min: min,
2178
+ marks: marks,
2179
+ onChange: onChange,
2180
+ onKeyDown: onKeyDown,
2181
+ disabled: disabled,
2182
+ ThumbComponent: ThumbComponent
2183
+ });
2184
+ };
2185
+
2186
+ /* *
2187
+ * Licensed under the Apache License, Version 2.0 (the "License");
2188
+ * you may not use this file except in compliance with the License.
2189
+ * You may obtain a copy of the License at
2190
+ *
2191
+ * http://www.apache.org/licenses/LICENSE-2.0
2192
+ *
2193
+ * Unless required by applicable law or agreed to in writing, software
2194
+ * distributed under the License is distributed on an "AS IS" BASIS,
2195
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2196
+ * See the License for the specific language governing permissions and
2197
+ * limitations under the License.
2198
+ *
2199
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2200
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
2201
+ * */
2202
+ // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2203
+ var isAxiosError = function isAxiosError(error) {
2204
+ return error.isAxiosError !== undefined;
2205
+ };
2206
+ var getAxiosErrorMessage = function getAxiosErrorMessage(error) {
2207
+ var data = error.response && error.response.data;
2208
+
2209
+ if (data && typeof data === 'string') {
2210
+ return data;
2211
+ }
2212
+
2213
+ if (data && data.message && typeof data.message === 'string') {
2214
+ return data.message;
2215
+ }
2216
+
2217
+ return 'An error has occurred';
2218
+ };
2219
+
2220
+ export { AlertBanner, AppHeader, AppLayout, ConfirmationDialog, ConfirmationServiceProvider, CustomSlider, DraggableComponent$1 as Draggable, HIDDEN_INPUT_HELPER_IS_DRAFT, ResizeComponent as Resizable, StatusTag, ToolContainer, DraggableComponent as ToolContainerDraggable, ToolFooter, ToolHeader, UserMenu, UserMenuItemCheatSheet, MenuItemTheme as UserMenuItemTheme, getAxiosErrorMessage, getInitials, isAxiosError, showPrompt, sliderStyles, useConfirmationDialog, useDialogActions, useDraftFormHelpers, useIsMounted, usePoller, usePreventBrowserClose, usePrevious, useUserMenu };