@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.umd.js ADDED
@@ -0,0 +1,2232 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@material-ui/core'), require('@material-ui/icons'), require('react-hook-form'), require('@opengeoweb/form-fields'), require('@material-ui/lab'), require('react-draggable'), require('re-resizable'), require('@opengeoweb/theme'), require('lodash')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@material-ui/core', '@material-ui/icons', 'react-hook-form', '@opengeoweb/form-fields', '@material-ui/lab', 'react-draggable', 're-resizable', '@opengeoweb/theme', 'lodash'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.core, global.icons, global.reactHookForm, global.formFields, global.lab, global.Draggable, global.reResizable, global.theme, global.lodash));
5
+ })(this, (function (exports, React, core, icons, reactHookForm, formFields, lab, Draggable, reResizable, theme, lodash) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
+ var Draggable__default = /*#__PURE__*/_interopDefaultLegacy(Draggable);
30
+
31
+ /*! *****************************************************************************
32
+ Copyright (c) Microsoft Corporation.
33
+
34
+ Permission to use, copy, modify, and/or distribute this software for any
35
+ purpose with or without fee is hereby granted.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
38
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
40
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
41
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
42
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
43
+ PERFORMANCE OF THIS SOFTWARE.
44
+ ***************************************************************************** */
45
+
46
+ var __assign = function() {
47
+ __assign = Object.assign || function __assign(t) {
48
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
49
+ s = arguments[i];
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
51
+ }
52
+ return t;
53
+ };
54
+ return __assign.apply(this, arguments);
55
+ };
56
+
57
+ function __rest(s, e) {
58
+ var t = {};
59
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
60
+ t[p] = s[p];
61
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
62
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
63
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
64
+ t[p[i]] = s[p[i]];
65
+ }
66
+ return t;
67
+ }
68
+
69
+ function __read(o, n) {
70
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
71
+ if (!m) return o;
72
+ var i = m.call(o), r, ar = [], e;
73
+ try {
74
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
75
+ }
76
+ catch (error) { e = { error: error }; }
77
+ finally {
78
+ try {
79
+ if (r && !r.done && (m = i["return"])) m.call(i);
80
+ }
81
+ finally { if (e) throw e.error; }
82
+ }
83
+ return ar;
84
+ }
85
+
86
+ function __spreadArray(to, from) {
87
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
88
+ to[j] = from[i];
89
+ return to;
90
+ }
91
+
92
+ var bgColors = {
93
+ green: '#fcffeb',
94
+ grey: '#f8f9f9',
95
+ purple: '#f8f9f9',
96
+ red: '#f9e8ea',
97
+ yellow: '#fff8eb'
98
+ };
99
+ var borderColors = {
100
+ green: '#72bb23',
101
+ grey: '#9b9fb0',
102
+ purple: '#9d9df2',
103
+ red: '#f24a00',
104
+ yellow: '#ffa800'
105
+ };
106
+
107
+ var tagStyle = function tagStyle(color) {
108
+ // Set color to grey for summary
109
+ var bgcolor = bgColors[color];
110
+ var borderColor = borderColors[color];
111
+ return {
112
+ bgcolor: bgcolor,
113
+ borderColor: borderColor,
114
+ m: 0,
115
+ p: 0.5,
116
+ border: 2,
117
+ borderRadius: 4,
118
+ style: {
119
+ width: '85px',
120
+ height: '20px'
121
+ },
122
+ color: '#051039',
123
+ maxHeight: '1em',
124
+ boxSizing: 'content-box'
125
+ };
126
+ };
127
+
128
+ var StatusTag = function StatusTag(_a) {
129
+ var content = _a.content,
130
+ color = _a.color;
131
+ return /*#__PURE__*/React__namespace.createElement(core.Box, __assign({
132
+ display: "flex",
133
+ alignItems: "center",
134
+ justifyContent: "center"
135
+ }, tagStyle(color), {
136
+ "data-testid": "statusTag"
137
+ }), /*#__PURE__*/React__namespace.createElement(core.Typography, {
138
+ variant: "caption"
139
+ }, content));
140
+ };
141
+
142
+ var useStyles$d = core.makeStyles(function () {
143
+ return {
144
+ dialogHeader: {
145
+ zIndex: 1,
146
+ padding: '8px 20px',
147
+ display: 'flex',
148
+ justifyContent: 'space-between',
149
+ alignItems: 'center'
150
+ },
151
+ dialogContent: {
152
+ padding: '40px 20px 0px 20px'
153
+ },
154
+ dialogOptions: {
155
+ padding: '4px 20px 16px 20px'
156
+ }
157
+ };
158
+ });
159
+ var ConfirmationDialog = function ConfirmationDialog(_a) {
160
+ var open = _a.open,
161
+ title = _a.title,
162
+ _b = _a.description,
163
+ description = _b === void 0 ? 'Are you sure?' : _b,
164
+ _c = _a.confirmLabel,
165
+ confirmLabel = _c === void 0 ? 'Submit' : _c,
166
+ _d = _a.cancelLabel,
167
+ cancelLabel = _d === void 0 ? 'Go back' : _d,
168
+ onSubmit = _a.onSubmit,
169
+ onClose = _a.onClose,
170
+ _e = _a.content,
171
+ content = _e === void 0 ? null : _e,
172
+ other = __rest(_a, ["open", "title", "description", "confirmLabel", "cancelLabel", "onSubmit", "onClose", "content"]);
173
+
174
+ var classes = useStyles$d();
175
+
176
+ other.catchOnCancel;
177
+ var rest = __rest(other, ["catchOnCancel"]); // remove unwanted props
178
+
179
+
180
+ return /*#__PURE__*/React__namespace.createElement(core.Dialog, __assign({
181
+ "data-testid": "confirmationDialog",
182
+ open: open,
183
+ maxWidth: "sm",
184
+ fullWidth: true,
185
+ disableBackdropClick: true,
186
+ transitionDuration: 0
187
+ }, rest), /*#__PURE__*/React__namespace.createElement(core.DialogTitle, {
188
+ disableTypography: true,
189
+ className: classes.dialogHeader
190
+ }, /*#__PURE__*/React__namespace.createElement(core.Typography, {
191
+ variant: "h5",
192
+ "data-testid": "confirmationDialog-title"
193
+ }, title), /*#__PURE__*/React__namespace.createElement(core.IconButton, {
194
+ "data-testid": "confirmationDialog-close",
195
+ "aria-label": "close",
196
+ onClick: function onClick() {
197
+ return onClose('CLOSED');
198
+ },
199
+ size: "small"
200
+ }, /*#__PURE__*/React__namespace.createElement(icons.Close, null))), /*#__PURE__*/React__namespace.createElement(core.DialogContent, {
201
+ className: classes.dialogContent
202
+ }, /*#__PURE__*/React__namespace.createElement(core.Typography, {
203
+ variant: "body1"
204
+ }, description), content), /*#__PURE__*/React__namespace.createElement(core.DialogActions, null, /*#__PURE__*/React__namespace.createElement(core.Button, {
205
+ "data-testid": "conformationDialog-cancel",
206
+ color: "secondary",
207
+ variant: "outlined",
208
+ onClick: function onClick() {
209
+ return onClose('CANCELLED');
210
+ },
211
+ autoFocus: true
212
+ }, cancelLabel), /*#__PURE__*/React__namespace.createElement(core.Button, {
213
+ "data-testid": "conformationDialog-confirm",
214
+ color: "secondary",
215
+ variant: "contained",
216
+ onClick: onSubmit
217
+ }, confirmLabel)));
218
+ };
219
+
220
+ /* *
221
+ * Licensed under the Apache License, Version 2.0 (the "License");
222
+ * you may not use this file except in compliance with the License.
223
+ * You may obtain a copy of the License at
224
+ *
225
+ * http://www.apache.org/licenses/LICENSE-2.0
226
+ *
227
+ * Unless required by applicable law or agreed to in writing, software
228
+ * distributed under the License is distributed on an "AS IS" BASIS,
229
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
230
+ * See the License for the specific language governing permissions and
231
+ * limitations under the License.
232
+ *
233
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
234
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
235
+ * */
236
+ var showPrompt = function showPrompt(event) {
237
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
238
+ // @ts-ignore
239
+ // eslint-disable-next-line no-param-reassign
240
+ event.returnValue = 'Changes that you made may not be saved.'; // changes are your browser have default text to overrule this
241
+ };
242
+ function usePreventBrowserClose(shouldPreventClose) {
243
+ React__namespace.useEffect(function () {
244
+ if (shouldPreventClose) {
245
+ window.addEventListener('beforeunload', showPrompt);
246
+ } else {
247
+ window.removeEventListener('beforeunload', showPrompt);
248
+ }
249
+
250
+ return function () {
251
+ window.removeEventListener('beforeunload', showPrompt);
252
+ };
253
+ }, [shouldPreventClose]);
254
+ }
255
+
256
+ /* *
257
+ * Licensed under the Apache License, Version 2.0 (the "License");
258
+ * you may not use this file except in compliance with the License.
259
+ * You may obtain a copy of the License at
260
+ *
261
+ * http://www.apache.org/licenses/LICENSE-2.0
262
+ *
263
+ * Unless required by applicable law or agreed to in writing, software
264
+ * distributed under the License is distributed on an "AS IS" BASIS,
265
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
266
+ * See the License for the specific language governing permissions and
267
+ * limitations under the License.
268
+ *
269
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
270
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
271
+ * */
272
+ var usePoller = function usePoller(deps, callback, pollingInterval) {
273
+ if (pollingInterval === void 0) {
274
+ pollingInterval = 300000;
275
+ }
276
+
277
+ var interval = React__namespace.useRef(null);
278
+ React__namespace.useEffect(function () {
279
+ if (deps.filter(function (dep) {
280
+ return dep !== null;
281
+ }).length > 0) {
282
+ if (interval.current) {
283
+ clearInterval(interval.current);
284
+ }
285
+
286
+ interval.current = setInterval(function () {
287
+ callback();
288
+ }, pollingInterval);
289
+ }
290
+
291
+ return function () {
292
+ if (interval.current) {
293
+ clearInterval(interval.current);
294
+ }
295
+ }; // eslint-disable-next-line react-hooks/exhaustive-deps
296
+ }, [deps]);
297
+ return interval;
298
+ };
299
+
300
+ /* *
301
+ * Licensed under the Apache License, Version 2.0 (the "License");
302
+ * you may not use this file except in compliance with the License.
303
+ * You may obtain a copy of the License at
304
+ *
305
+ * http://www.apache.org/licenses/LICENSE-2.0
306
+ *
307
+ * Unless required by applicable law or agreed to in writing, software
308
+ * distributed under the License is distributed on an "AS IS" BASIS,
309
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
310
+ * See the License for the specific language governing permissions and
311
+ * limitations under the License.
312
+ *
313
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
314
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
315
+ * */
316
+ function usePrevious(value) {
317
+ var ref = React__namespace.useRef();
318
+ React__namespace.useEffect(function () {
319
+ ref.current = value;
320
+ });
321
+ return ref.current;
322
+ }
323
+
324
+ /* *
325
+ * Licensed under the Apache License, Version 2.0 (the "License");
326
+ * you may not use this file except in compliance with the License.
327
+ * You may obtain a copy of the License at
328
+ *
329
+ * http://www.apache.org/licenses/LICENSE-2.0
330
+ *
331
+ * Unless required by applicable law or agreed to in writing, software
332
+ * distributed under the License is distributed on an "AS IS" BASIS,
333
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
334
+ * See the License for the specific language governing permissions and
335
+ * limitations under the License.
336
+ *
337
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
338
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
339
+ * */
340
+ var useIsMounted = function useIsMounted() {
341
+ var isMounted = React__namespace.useRef(false);
342
+ React__namespace.useEffect(function () {
343
+ isMounted.current = true;
344
+ return function () {
345
+ isMounted.current = false;
346
+ };
347
+ }, []);
348
+ return {
349
+ isMounted: isMounted
350
+ };
351
+ };
352
+
353
+ var HIDDEN_INPUT_HELPER_IS_DRAFT = 'IS_DRAFT';
354
+ var useDraftFormHelpers = function useDraftFormHelpers() {
355
+ var _a = reactHookForm.useFormContext(),
356
+ getValues = _a.getValues,
357
+ setValue = _a.setValue,
358
+ register = _a.register;
359
+
360
+ var isDraft = function isDraft() {
361
+ return getValues(HIDDEN_INPUT_HELPER_IS_DRAFT) === true;
362
+ };
363
+
364
+ var isRequired = function isRequired(value) {
365
+ if (!isDraft() && formFields.isEmpty(value)) {
366
+ return formFields.errorMessages.required;
367
+ }
368
+
369
+ return true;
370
+ };
371
+
372
+ var toggleIsDraft = function toggleIsDraft(isDraft) {
373
+ return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft);
374
+ };
375
+
376
+ var DraftFieldHelper = function DraftFieldHelper() {
377
+ return /*#__PURE__*/React__namespace.createElement("input", __assign({
378
+ defaultValue: "false"
379
+ }, register(HIDDEN_INPUT_HELPER_IS_DRAFT), {
380
+ type: "hidden"
381
+ }));
382
+ };
383
+
384
+ return {
385
+ isRequired: isRequired,
386
+ toggleIsDraft: toggleIsDraft,
387
+ isDraft: isDraft,
388
+ DraftFieldHelper: DraftFieldHelper
389
+ };
390
+ };
391
+
392
+ var ConfirmationServiceContext = /*#__PURE__*/React__namespace.createContext(Promise.reject);
393
+ var useConfirmationDialog = function useConfirmationDialog() {
394
+ return React__namespace.useContext(ConfirmationServiceContext);
395
+ };
396
+ var useDialogActions = function useDialogActions(awaitingPromiseRef, defaultOptions) {
397
+ if (defaultOptions === void 0) {
398
+ defaultOptions = null;
399
+ }
400
+
401
+ var isMounted = useIsMounted().isMounted;
402
+
403
+ var _a = __read(React__namespace.useState(defaultOptions), 2),
404
+ confirmationState = _a[0],
405
+ setConfirmationState = _a[1];
406
+
407
+ var openConfirmation = function openConfirmation(options) {
408
+ setConfirmationState(options);
409
+ return new Promise(function (resolve, reject) {
410
+ // since this is a React.ref it's safe to reassign it, although eslint says no
411
+ // eslint-disable-next-line no-param-reassign
412
+ awaitingPromiseRef.current = {
413
+ resolve: resolve,
414
+ reject: reject
415
+ };
416
+ });
417
+ }; // clears state with timeout delay so optional values provided by the prop 'content' of ConfirmationDialog can be read
418
+
419
+
420
+ var clearState = function clearState() {
421
+ return setTimeout(function () {
422
+ if (isMounted.current) {
423
+ setConfirmationState(null);
424
+ }
425
+ }, 0);
426
+ };
427
+
428
+ var handleClose = function handleClose(reason) {
429
+ if (confirmationState && confirmationState.catchOnCancel && awaitingPromiseRef.current) {
430
+ awaitingPromiseRef.current.reject(reason);
431
+ }
432
+
433
+ clearState();
434
+ };
435
+
436
+ var handleSubmit = function handleSubmit() {
437
+ if (awaitingPromiseRef.current) {
438
+ awaitingPromiseRef.current.resolve();
439
+ }
440
+
441
+ clearState();
442
+ };
443
+
444
+ return {
445
+ openConfirmation: openConfirmation,
446
+ confirmationState: confirmationState,
447
+ handleSubmit: handleSubmit,
448
+ handleClose: handleClose
449
+ };
450
+ };
451
+ var ConfirmationServiceProvider = function ConfirmationServiceProvider(_a) {
452
+ var children = _a.children;
453
+ var awaitingPromiseRef = React__namespace.useRef();
454
+
455
+ var _b = useDialogActions(awaitingPromiseRef),
456
+ openConfirmation = _b.openConfirmation,
457
+ confirmationState = _b.confirmationState,
458
+ handleSubmit = _b.handleSubmit,
459
+ handleClose = _b.handleClose;
460
+
461
+ return /*#__PURE__*/React__namespace.createElement(ConfirmationServiceContext.Provider, {
462
+ value: openConfirmation
463
+ }, children, /*#__PURE__*/React__namespace.createElement(ConfirmationDialog, __assign({
464
+ open: Boolean(confirmationState),
465
+ onSubmit: handleSubmit,
466
+ onClose: handleClose
467
+ }, confirmationState)));
468
+ };
469
+
470
+ /* *
471
+ * Licensed under the Apache License, Version 2.0 (the "License");
472
+ * you may not use this file except in compliance with the License.
473
+ * You may obtain a copy of the License at
474
+ *
475
+ * http://www.apache.org/licenses/LICENSE-2.0
476
+ *
477
+ * Unless required by applicable law or agreed to in writing, software
478
+ * distributed under the License is distributed on an "AS IS" BASIS,
479
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
480
+ * See the License for the specific language governing permissions and
481
+ * limitations under the License.
482
+ *
483
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
484
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
485
+ * */
486
+ var useStyles$c = core.makeStyles(function () {
487
+ return {
488
+ title: {
489
+ fontSize: '14px',
490
+ fontWeight: 'normal',
491
+ marginTop: '0px!important'
492
+ },
493
+ info: {
494
+ fontSize: '16px'
495
+ }
496
+ };
497
+ });
498
+
499
+ var getIcon = function getIcon(severity) {
500
+ switch (severity) {
501
+ case 'info':
502
+ return /*#__PURE__*/React__namespace.createElement(core.SvgIcon, null, /*#__PURE__*/React__namespace.createElement("rect", {
503
+ width: 24,
504
+ height: 24,
505
+ fill: "transparent"
506
+ }), /*#__PURE__*/React__namespace.createElement("path", {
507
+ 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",
508
+ transform: "translate(-946.000000, -368.000000) translate(930.000000, 356.000000) translate(16.000000, 12.000000)",
509
+ fill: "#0062E6"
510
+ }));
511
+
512
+ case 'success':
513
+ return /*#__PURE__*/React__namespace.createElement(core.SvgIcon, null, /*#__PURE__*/React__namespace.createElement("rect", {
514
+ width: 24,
515
+ height: 24,
516
+ fill: "transparent"
517
+ }), /*#__PURE__*/React__namespace.createElement("path", {
518
+ 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",
519
+ transform: "translate(-96.000000, -368.000000) translate(80.000000, 356.000000) translate(16.000000, 12.000000)",
520
+ fill: "#72BB23"
521
+ }));
522
+
523
+ case 'warning':
524
+ return /*#__PURE__*/React__namespace.createElement(core.SvgIcon, null, /*#__PURE__*/React__namespace.createElement("rect", {
525
+ width: 24,
526
+ height: 24,
527
+ fill: "transparent"
528
+ }), /*#__PURE__*/React__namespace.createElement("path", {
529
+ 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",
530
+ transform: "translate(-521.000000, -368.000000) translate(505.000000, 356.000000) translate(16.000000, 12.000000)",
531
+ fill: "#FFA800"
532
+ }));
533
+
534
+ case 'error':
535
+ default:
536
+ return /*#__PURE__*/React__namespace.createElement(core.SvgIcon, null, /*#__PURE__*/React__namespace.createElement("rect", {
537
+ width: 24,
538
+ height: 24,
539
+ fill: "transparent"
540
+ }), /*#__PURE__*/React__namespace.createElement("path", {
541
+ 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",
542
+ transform: "translate(-1371.000000, -368.000000) translate(1355.000000, 356.000000) translate(16.000000, 12.000000)",
543
+ fill: "#C00000"
544
+ }));
545
+ }
546
+ };
547
+
548
+ var AlertBanner = function AlertBanner(_a) {
549
+ var title = _a.title,
550
+ _b = _a.severity,
551
+ severity = _b === void 0 ? 'error' : _b,
552
+ _c = _a.info,
553
+ info = _c === void 0 ? '' : _c,
554
+ _d = _a.dataTestId,
555
+ dataTestId = _d === void 0 ? 'alert-banner' : _d;
556
+ var classes = useStyles$c();
557
+ return /*#__PURE__*/React__namespace.createElement(lab.Alert, {
558
+ "data-testid": dataTestId,
559
+ severity: severity,
560
+ icon: getIcon(severity)
561
+ }, /*#__PURE__*/React__namespace.createElement(lab.AlertTitle, {
562
+ className: classes.title
563
+ }, title), info && /*#__PURE__*/React__namespace.createElement("div", {
564
+ className: classes.info
565
+ }, info));
566
+ };
567
+
568
+ /* *
569
+ * Licensed under the Apache License, Version 2.0 (the "License");
570
+ * you may not use this file except in compliance with the License.
571
+ * You may obtain a copy of the License at
572
+ *
573
+ * http://www.apache.org/licenses/LICENSE-2.0
574
+ *
575
+ * Unless required by applicable law or agreed to in writing, software
576
+ * distributed under the License is distributed on an "AS IS" BASIS,
577
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
578
+ * See the License for the specific language governing permissions and
579
+ * limitations under the License.
580
+ *
581
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
582
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
583
+ * */
584
+ var useStyles$b = core.makeStyles(function () {
585
+ return {
586
+ wrapper: {
587
+ height: '100vh',
588
+ display: 'flex',
589
+ flexDirection: 'column'
590
+ },
591
+ main: {
592
+ flex: 1,
593
+ position: 'relative'
594
+ }
595
+ };
596
+ });
597
+
598
+ var AppLayout = function AppLayout(_a) {
599
+ var header = _a.header,
600
+ children = _a.children;
601
+ var classes = useStyles$b();
602
+ return /*#__PURE__*/React__default["default"].createElement("div", {
603
+ className: classes.wrapper
604
+ }, header, /*#__PURE__*/React__default["default"].createElement("main", {
605
+ className: classes.main
606
+ }, children));
607
+ };
608
+
609
+ 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";
610
+
611
+ /* *
612
+ * Licensed under the Apache License, Version 2.0 (the "License");
613
+ * you may not use this file except in compliance with the License.
614
+ * You may obtain a copy of the License at
615
+ *
616
+ * http://www.apache.org/licenses/LICENSE-2.0
617
+ *
618
+ * Unless required by applicable law or agreed to in writing, software
619
+ * distributed under the License is distributed on an "AS IS" BASIS,
620
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
621
+ * See the License for the specific language governing permissions and
622
+ * limitations under the License.
623
+ *
624
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
625
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
626
+ * */
627
+ var useStyles$a = core.makeStyles(function (theme) {
628
+ var _a;
629
+
630
+ return {
631
+ header: (_a = {
632
+ height: 40,
633
+ background: theme.palette.geowebColors.brand.brand,
634
+ color: theme.palette.common.white,
635
+ boxShadow: theme.shadows[1],
636
+ zIndex: 1000
637
+ }, _a[theme.breakpoints.down('sm')] = {
638
+ padding: '0 8px'
639
+ }, _a[theme.breakpoints.up('sm')] = {
640
+ padding: '0 24px'
641
+ }, _a),
642
+ logo: {
643
+ height: 30
644
+ },
645
+ title: {
646
+ marginLeft: 6,
647
+ fontSize: '1.25rem',
648
+ fontWeight: 400,
649
+ overflow: 'hidden',
650
+ whiteSpace: 'nowrap',
651
+ textOverflow: 'ellipsis'
652
+ },
653
+ container: {
654
+ height: '100%'
655
+ }
656
+ };
657
+ });
658
+
659
+ var AppHeader = function AppHeader(_a) {
660
+ var menu = _a.menu,
661
+ userMenu = _a.userMenu,
662
+ _b = _a.title,
663
+ title = _b === void 0 ? 'GeoWeb' : _b;
664
+ var classes = useStyles$a();
665
+ return /*#__PURE__*/React__default["default"].createElement("header", {
666
+ className: classes.header
667
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
668
+ className: classes.container,
669
+ container: true,
670
+ alignItems: "center"
671
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
672
+ item: true,
673
+ xs: 1,
674
+ sm: 3
675
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
676
+ container: true,
677
+ justify: "flex-start"
678
+ }, menu)), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
679
+ item: true,
680
+ xs: 10,
681
+ sm: 6
682
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
683
+ container: true,
684
+ justify: "center",
685
+ alignItems: "center",
686
+ wrap: "nowrap"
687
+ }, /*#__PURE__*/React__default["default"].createElement("img", {
688
+ alt: title,
689
+ className: classes.logo,
690
+ src: img
691
+ }), /*#__PURE__*/React__default["default"].createElement(core.Typography, {
692
+ variant: "h1",
693
+ className: classes.title
694
+ }, title))), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
695
+ item: true,
696
+ xs: 1,
697
+ sm: 3,
698
+ container: true,
699
+ justify: "flex-end"
700
+ }, userMenu)));
701
+ };
702
+
703
+ /* *
704
+ * Licensed under the Apache License, Version 2.0 (the "License");
705
+ * you may not use this file except in compliance with the License.
706
+ * You may obtain a copy of the License at
707
+ *
708
+ * http://www.apache.org/licenses/LICENSE-2.0
709
+ *
710
+ * Unless required by applicable law or agreed to in writing, software
711
+ * distributed under the License is distributed on an "AS IS" BASIS,
712
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
713
+ * See the License for the specific language governing permissions and
714
+ * limitations under the License.
715
+ *
716
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
717
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
718
+ * */
719
+
720
+ var DraggableComponent$1 = function DraggableComponent(_a) {
721
+ var _b = _a.bounds,
722
+ bounds = _b === void 0 ? 'body' : _b,
723
+ children = _a.children,
724
+ props = __rest(_a, ["bounds", "children"]);
725
+
726
+ return /*#__PURE__*/React__default["default"].createElement(Draggable__default["default"], __assign({
727
+ bounds: bounds
728
+ }, props), children);
729
+ };
730
+
731
+ /* *
732
+ * Licensed under the Apache License, Version 2.0 (the "License");
733
+ * you may not use this file except in compliance with the License.
734
+ * You may obtain a copy of the License at
735
+ *
736
+ * http://www.apache.org/licenses/LICENSE-2.0
737
+ *
738
+ * Unless required by applicable law or agreed to in writing, software
739
+ * distributed under the License is distributed on an "AS IS" BASIS,
740
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
741
+ * See the License for the specific language governing permissions and
742
+ * limitations under the License.
743
+ *
744
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
745
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
746
+ * */
747
+
748
+ var useStyles$9 = function useStyles(isRightAligned) {
749
+ return core.makeStyles(function () {
750
+ return {
751
+ icon: __assign(__assign({
752
+ width: 20,
753
+ height: 20,
754
+ top: -10,
755
+ position: 'relative'
756
+ }, isRightAligned ? {
757
+ left: -10
758
+ } : {
759
+ left: 10,
760
+ transform: 'rotate(90deg)'
761
+ }), {
762
+ zIndex: 100
763
+ })
764
+ };
765
+ });
766
+ };
767
+
768
+ var ResizeHandle = function ResizeHandle(_a) {
769
+ var isRightAligned = _a.isRightAligned;
770
+ var theme = core.useTheme();
771
+ var styles = useStyles$9(isRightAligned)();
772
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
773
+ className: styles.icon,
774
+ "data-testid": "resizeHandle"
775
+ }, /*#__PURE__*/React__default["default"].createElement("rect", {
776
+ fill: "#ffffff"
777
+ }), /*#__PURE__*/React__default["default"].createElement("path", {
778
+ d: "M19.687 18.037v1h-6v-1h6zm3.5-3.5v1h-13v-1h13z",
779
+ fill: "" + theme.palette.geowebColors.greys.accessible,
780
+ transform: "rotate(-45 16.687 16.787)"
781
+ }));
782
+ };
783
+
784
+ var ResizeComponent = function ResizeComponent(_a) {
785
+ var _b = _a.startPosition,
786
+ startPosition = _b === void 0 ? {
787
+ left: null,
788
+ right: null,
789
+ top: null
790
+ } : _b,
791
+ children = _a.children,
792
+ _c = _a.onResizeStart,
793
+ onResizeStart = _c === void 0 ? function () {
794
+ return null;
795
+ } : _c,
796
+ size = _a.size,
797
+ setSize = _a.setSize,
798
+ _d = _a.minHeight,
799
+ minHeight = _d === void 0 ? 50 : _d,
800
+ _e = _a.minWidth,
801
+ minWidth = _e === void 0 ? 50 : _e,
802
+ props = __rest(_a, ["startPosition", "children", "onResizeStart", "size", "setSize", "minHeight", "minWidth"]);
803
+
804
+ var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
805
+ var onStartResize = React__default["default"].useCallback(function (event, _direction, node) {
806
+ event.stopPropagation();
807
+
808
+ var _a = node.getBoundingClientRect(),
809
+ width = _a.width,
810
+ height = _a.height;
811
+
812
+ setSize({
813
+ width: width,
814
+ height: height
815
+ }); // fix for when initial maxHeight gets cleared
816
+ // eslint-disable-next-line no-param-reassign
817
+
818
+ node.style.height = height + "px";
819
+ onResizeStart();
820
+ }, [onResizeStart, setSize]);
821
+ var onResizeStop = React__default["default"].useCallback(function (_event, _direction, _ref, delta) {
822
+ var width = parseInt(size.width, 10) + delta.width;
823
+ var height = parseInt(size.height, 10) + delta.height;
824
+ setSize({
825
+ width: width,
826
+ height: height
827
+ });
828
+ }, [setSize, size]);
829
+ return /*#__PURE__*/React__default["default"].createElement(reResizable.Resizable // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
830
+ , __assign({
831
+ // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
832
+ minHeight: minHeight,
833
+ minWidth: minWidth,
834
+ size: size,
835
+ onResizeStop: onResizeStop,
836
+ handleComponent: {
837
+ bottomRight: /*#__PURE__*/React__default["default"].createElement(ResizeHandle, {
838
+ isRightAligned: true
839
+ }),
840
+ bottomLeft: /*#__PURE__*/React__default["default"].createElement(ResizeHandle, null)
841
+ },
842
+ enable: {
843
+ top: false,
844
+ right: false,
845
+ bottom: false,
846
+ left: false,
847
+ topRight: false,
848
+ bottomRight: !isRightAligned,
849
+ bottomLeft: isRightAligned,
850
+ topLeft: false
851
+ },
852
+ onResizeStart: onStartResize
853
+ }, props), children);
854
+ };
855
+
856
+ /* *
857
+ * Licensed under the Apache License, Version 2.0 (the "License");
858
+ * you may not use this file except in compliance with the License.
859
+ * You may obtain a copy of the License at
860
+ *
861
+ * http://www.apache.org/licenses/LICENSE-2.0
862
+ *
863
+ * Unless required by applicable law or agreed to in writing, software
864
+ * distributed under the License is distributed on an "AS IS" BASIS,
865
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
866
+ * See the License for the specific language governing permissions and
867
+ * limitations under the License.
868
+ *
869
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
870
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
871
+ * */
872
+ var useStyles$8 = core.makeStyles(function (theme) {
873
+ return {
874
+ container: {
875
+ position: 'absolute',
876
+ top: 38,
877
+ right: 20,
878
+ width: 256,
879
+ borderRadius: 0,
880
+ boxShadow: theme.shadows[5],
881
+ background: theme.palette.geowebColors.background.surface
882
+ },
883
+ userMenu: {
884
+ padding: 0,
885
+ '& > li': {
886
+ paddingTop: 24,
887
+ paddingBottom: 24,
888
+ paddingLeft: 16,
889
+ paddingRight: 16
890
+ }
891
+ },
892
+ button: {
893
+ color: theme.palette.common.white,
894
+ padding: 0
895
+ },
896
+ avatar: {
897
+ height: 32,
898
+ width: 32,
899
+ fontSize: '0.938rem',
900
+ fontWeight: 500,
901
+ color: theme.palette.geowebColors.brand.brand,
902
+ backgroundColor: theme.palette.common.white
903
+ }
904
+ };
905
+ });
906
+
907
+ var UserMenu = function UserMenu(_a) {
908
+ var _b = _a.isOpen,
909
+ isOpen = _b === void 0 ? false : _b,
910
+ _c = _a.onToggle,
911
+ onToggle = _c === void 0 ? function () {
912
+ return null;
913
+ } : _c,
914
+ _d = _a.onClose,
915
+ onClose = _d === void 0 ? function () {
916
+ return null;
917
+ } : _d,
918
+ children = _a.children,
919
+ initials = _a.initials;
920
+ var classes = useStyles$8();
921
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(core.IconButton, {
922
+ "data-testid": "userButton",
923
+ onClick: onToggle,
924
+ className: classes.button
925
+ }, /*#__PURE__*/React__default["default"].createElement(core.Avatar, {
926
+ className: classes.avatar
927
+ }, initials)), isOpen && /*#__PURE__*/React__default["default"].createElement(core.Paper, {
928
+ className: classes.container,
929
+ "data-testid": "userMenu"
930
+ }, /*#__PURE__*/React__default["default"].createElement(core.ClickAwayListener, {
931
+ onClickAway: onClose,
932
+ mouseEvent: "onMouseDown"
933
+ }, /*#__PURE__*/React__default["default"].createElement(core.MenuList, {
934
+ className: classes.userMenu,
935
+ variant: "menu"
936
+ }, children))));
937
+ };
938
+
939
+ /* *
940
+ * Licensed under the Apache License, Version 2.0 (the "License");
941
+ * you may not use this file except in compliance with the License.
942
+ * You may obtain a copy of the License at
943
+ *
944
+ * http://www.apache.org/licenses/LICENSE-2.0
945
+ *
946
+ * Unless required by applicable law or agreed to in writing, software
947
+ * distributed under the License is distributed on an "AS IS" BASIS,
948
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
949
+ * See the License for the specific language governing permissions and
950
+ * limitations under the License.
951
+ *
952
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
953
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
954
+ * */
955
+
956
+ var MenuItemTheme = function MenuItemTheme() {
957
+ var _a = theme.useThemeContext(),
958
+ isDark = _a.isDark,
959
+ toggleTheme = _a.toggleTheme;
960
+
961
+ return /*#__PURE__*/React__default["default"].createElement(core.MenuItem, null, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
962
+ container: true
963
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
964
+ item: true
965
+ }, "Choose your default app mode"), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
966
+ item: true
967
+ }, /*#__PURE__*/React__default["default"].createElement(core.RadioGroup, {
968
+ onChange: toggleTheme
969
+ }, /*#__PURE__*/React__default["default"].createElement(core.FormControlLabel, {
970
+ value: true,
971
+ control: /*#__PURE__*/React__default["default"].createElement(core.Radio, {
972
+ checked: !isDark
973
+ }),
974
+ label: "Light"
975
+ }), /*#__PURE__*/React__default["default"].createElement(core.FormControlLabel, {
976
+ value: false,
977
+ control: /*#__PURE__*/React__default["default"].createElement(core.Radio, {
978
+ checked: isDark
979
+ }),
980
+ label: "Dark"
981
+ })))));
982
+ };
983
+
984
+ /* *
985
+ * Licensed under the Apache License, Version 2.0 (the "License");
986
+ * you may not use this file except in compliance with the License.
987
+ * You may obtain a copy of the License at
988
+ *
989
+ * http://www.apache.org/licenses/LICENSE-2.0
990
+ *
991
+ * Unless required by applicable law or agreed to in writing, software
992
+ * distributed under the License is distributed on an "AS IS" BASIS,
993
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
994
+ * See the License for the specific language governing permissions and
995
+ * limitations under the License.
996
+ *
997
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
998
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
999
+ * */
1000
+ var useStyles$7 = core.makeStyles(function (theme) {
1001
+ return {
1002
+ footer: {
1003
+ boxShadow: theme.shadows[1],
1004
+ background: theme.palette.geowebColors.background.surface,
1005
+ textAlign: 'right',
1006
+ height: 18,
1007
+ zIndex: 1
1008
+ }
1009
+ };
1010
+ }); // drag handles will be handled by DraggableResizable/Resizable
1011
+
1012
+ var ToolFooter = function ToolFooter() {
1013
+ var classes = useStyles$7();
1014
+ return /*#__PURE__*/React__default["default"].createElement("footer", {
1015
+ className: classes.footer
1016
+ });
1017
+ };
1018
+
1019
+ /* *
1020
+ * Licensed under the Apache License, Version 2.0 (the "License");
1021
+ * you may not use this file except in compliance with the License.
1022
+ * You may obtain a copy of the License at
1023
+ *
1024
+ * http://www.apache.org/licenses/LICENSE-2.0
1025
+ *
1026
+ * Unless required by applicable law or agreed to in writing, software
1027
+ * distributed under the License is distributed on an "AS IS" BASIS,
1028
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1029
+ * See the License for the specific language governing permissions and
1030
+ * limitations under the License.
1031
+ *
1032
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1033
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1034
+ * */
1035
+
1036
+ var getStyle = function getStyle(size) {
1037
+ switch (size) {
1038
+ case 'xs':
1039
+ {
1040
+ return {
1041
+ fontSize: 10,
1042
+ fontWeight: 500
1043
+ };
1044
+ }
1045
+
1046
+ case 'small':
1047
+ {
1048
+ return {
1049
+ fontSize: 16,
1050
+ fontWeight: 500,
1051
+ padding: 4
1052
+ };
1053
+ }
1054
+
1055
+ case 'medium':
1056
+ {
1057
+ return {
1058
+ fontSize: 20,
1059
+ fontWeight: 400,
1060
+ padding: 8
1061
+ };
1062
+ }
1063
+
1064
+ case 'large':
1065
+ {
1066
+ return {
1067
+ fontSize: 16,
1068
+ fontWeight: 500,
1069
+ padding: 12
1070
+ };
1071
+ }
1072
+
1073
+ default:
1074
+ {
1075
+ return {};
1076
+ }
1077
+ }
1078
+ };
1079
+
1080
+ var useStyles$6 = core.makeStyles(function (theme) {
1081
+ return {
1082
+ header: {
1083
+ boxShadow: theme.shadows[1],
1084
+ background: theme.palette.geowebColors.background.surface,
1085
+ padding: function padding(props) {
1086
+ return props.styles.padding;
1087
+ },
1088
+ zIndex: 1,
1089
+ cursor: function cursor(props) {
1090
+ return props.isDraggable ? 'move' : null;
1091
+ }
1092
+ },
1093
+ title: {
1094
+ fontSize: function fontSize(props) {
1095
+ return props.styles.fontSize;
1096
+ },
1097
+ fontWeight: function fontWeight(props) {
1098
+ return props.styles.fontWeight;
1099
+ }
1100
+ },
1101
+ iconClose: {
1102
+ color: theme.palette.geowebColors.greys.accessible,
1103
+ padding: 0
1104
+ },
1105
+ iconDrag: {
1106
+ color: theme.palette.geowebColors.greys.accessible,
1107
+ padding: 0,
1108
+ pointerEvents: 'none'
1109
+ },
1110
+ iconDragHorizontal: {
1111
+ color: theme.palette.geowebColors.greys.accessible,
1112
+ padding: 0,
1113
+ pointerEvents: 'none',
1114
+ transform: 'rotate(90deg)',
1115
+ height: 12
1116
+ }
1117
+ };
1118
+ });
1119
+
1120
+ var ToolHeader = function ToolHeader(_a) {
1121
+ var size = _a.size,
1122
+ title = _a.title,
1123
+ _b = _a.onClose,
1124
+ onClose = _b === void 0 ? null : _b,
1125
+ _c = _a.isDraggable,
1126
+ isDraggable = _c === void 0 ? false : _c,
1127
+ _d = _a.className,
1128
+ className = _d === void 0 ? '' : _d;
1129
+ var styles = getStyle(size);
1130
+ var classes = useStyles$6({
1131
+ styles: styles,
1132
+ isDraggable: isDraggable
1133
+ });
1134
+
1135
+ var onClickClose = function onClickClose() {
1136
+ return onClose();
1137
+ };
1138
+
1139
+ return /*#__PURE__*/React__default["default"].createElement("header", {
1140
+ className: classes.header + " " + className
1141
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1142
+ container: true,
1143
+ alignItems: "center"
1144
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1145
+ item: true,
1146
+ xs: 1
1147
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1148
+ container: true,
1149
+ justify: "flex-start"
1150
+ }, isDraggable && size !== 'xxs' && /*#__PURE__*/React__default["default"].createElement(core.IconButton, {
1151
+ "data-testid": "dragBtn",
1152
+ className: classes.iconDrag,
1153
+ disableRipple: true
1154
+ }, /*#__PURE__*/React__default["default"].createElement(icons.DragIndicator, null)))), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1155
+ item: true,
1156
+ xs: 10
1157
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1158
+ container: true,
1159
+ justify: "center",
1160
+ alignItems: "center"
1161
+ }, title && /*#__PURE__*/React__default["default"].createElement(core.Typography, {
1162
+ variant: "h2",
1163
+ className: classes.title
1164
+ }, title), size === 'xxs' && /*#__PURE__*/React__default["default"].createElement(core.IconButton, {
1165
+ "data-testid": "dragBtn",
1166
+ className: classes.iconDragHorizontal,
1167
+ disableRipple: true,
1168
+ size: "small"
1169
+ }, /*#__PURE__*/React__default["default"].createElement(icons.DragIndicator, null)))), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1170
+ item: true,
1171
+ xs: 1,
1172
+ container: true,
1173
+ justify: "flex-end"
1174
+ }, onClose && /*#__PURE__*/React__default["default"].createElement(core.IconButton, {
1175
+ "data-testid": "closeBtn",
1176
+ className: classes.iconClose,
1177
+ onClick: onClickClose
1178
+ }, /*#__PURE__*/React__default["default"].createElement(icons.Close, null)))));
1179
+ };
1180
+
1181
+ /* *
1182
+ * Licensed under the Apache License, Version 2.0 (the "License");
1183
+ * you may not use this file except in compliance with the License.
1184
+ * You may obtain a copy of the License at
1185
+ *
1186
+ * http://www.apache.org/licenses/LICENSE-2.0
1187
+ *
1188
+ * Unless required by applicable law or agreed to in writing, software
1189
+ * distributed under the License is distributed on an "AS IS" BASIS,
1190
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1191
+ * See the License for the specific language governing permissions and
1192
+ * limitations under the License.
1193
+ *
1194
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1195
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1196
+ * */
1197
+ var useStyles$5 = core.makeStyles(function () {
1198
+ return {
1199
+ container: {
1200
+ overflow: 'hidden',
1201
+ borderRadius: 0,
1202
+ display: 'flex',
1203
+ flexDirection: 'column',
1204
+ height: '100%'
1205
+ },
1206
+ content: {
1207
+ flex: 1,
1208
+ overflowY: 'auto',
1209
+ zIndex: 2,
1210
+ position: 'relative'
1211
+ }
1212
+ };
1213
+ });
1214
+ var BASE_ELEVATION = 5;
1215
+
1216
+ var ToolContainer = function ToolContainer(_a) {
1217
+ var _b = _a.title,
1218
+ title = _b === void 0 ? '' : _b,
1219
+ _c = _a.size,
1220
+ size = _c === void 0 ? 'medium' : _c,
1221
+ children = _a.children,
1222
+ onClose = _a.onClose,
1223
+ _d = _a.isResizable,
1224
+ isResizable = _d === void 0 ? false : _d,
1225
+ _e = _a.isDraggable,
1226
+ isDraggable = _e === void 0 ? false : _e,
1227
+ _f = _a.maxHeight,
1228
+ maxHeight = _f === void 0 ? 'initial' : _f,
1229
+ _g = _a.elevation,
1230
+ elevation = _g === void 0 ? BASE_ELEVATION : _g,
1231
+ // elevation_06
1232
+ _h = _a.headerClassName,
1233
+ // elevation_06
1234
+ headerClassName = _h === void 0 ? '' : _h,
1235
+ props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName"]);
1236
+
1237
+ var classes = useStyles$5();
1238
+ return /*#__PURE__*/React__default["default"].createElement(core.Paper, __assign({
1239
+ elevation: elevation,
1240
+ className: classes.container
1241
+ }, props), /*#__PURE__*/React__default["default"].createElement(ToolHeader, {
1242
+ title: title,
1243
+ size: size,
1244
+ isDraggable: isDraggable,
1245
+ onClose: onClose,
1246
+ className: headerClassName
1247
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
1248
+ className: classes.content,
1249
+ style: {
1250
+ maxHeight: maxHeight
1251
+ }
1252
+ }, children), isResizable && /*#__PURE__*/React__default["default"].createElement(ToolFooter, null));
1253
+ };
1254
+
1255
+ /* *
1256
+ * Licensed under the Apache License, Version 2.0 (the "License");
1257
+ * you may not use this file except in compliance with the License.
1258
+ * You may obtain a copy of the License at
1259
+ *
1260
+ * http://www.apache.org/licenses/LICENSE-2.0
1261
+ *
1262
+ * Unless required by applicable law or agreed to in writing, software
1263
+ * distributed under the License is distributed on an "AS IS" BASIS,
1264
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1265
+ * See the License for the specific language governing permissions and
1266
+ * limitations under the License.
1267
+ *
1268
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1269
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1270
+ * */
1271
+ var BASE_Z_INDEX = 100;
1272
+
1273
+ var DraggableComponent = function DraggableComponent(_a) {
1274
+ var title = _a.title,
1275
+ _b = _a.bounds,
1276
+ bounds = _b === void 0 ? 'body' : _b,
1277
+ _c = _a.headerSize,
1278
+ headerSize = _c === void 0 ? 'small' : _c,
1279
+ _d = _a.startSize,
1280
+ startSize = _d === void 0 ? {
1281
+ width: 'auto',
1282
+ height: 'auto'
1283
+ } : _d,
1284
+ _e = _a.startPosition,
1285
+ startPosition = _e === void 0 ? {
1286
+ left: null,
1287
+ right: null,
1288
+ top: null
1289
+ } : _e,
1290
+ children = _a.children,
1291
+ _f = _a.isOpen,
1292
+ isOpen = _f === void 0 ? true : _f,
1293
+ _g = _a.onClose,
1294
+ onClose = _g === void 0 ? function () {
1295
+ return null;
1296
+ } : _g,
1297
+ _h = _a.initialMaxHeight,
1298
+ defaultInitialMaxHeight = _h === void 0 ? 'initial' : _h,
1299
+ _j = _a.onChangeSize,
1300
+ onChangeSize = _j === void 0 ? function () {
1301
+ return null;
1302
+ } : _j,
1303
+ _k = _a.onMouseDown,
1304
+ onMouseDown = _k === void 0 ? function () {
1305
+ return null;
1306
+ } : _k,
1307
+ _l = _a.order,
1308
+ order = _l === void 0 ? 1 : _l,
1309
+ _m = _a.source,
1310
+ source = _m === void 0 ? 'app' : _m,
1311
+ props = __rest(_a, ["title", "bounds", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "order", "source"]);
1312
+
1313
+ var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
1314
+ var elevation = BASE_ELEVATION + order;
1315
+ var nodeRef = React__default["default"].useRef(null);
1316
+
1317
+ var _o = __read(React__default["default"].useState({
1318
+ x: 0,
1319
+ y: 0
1320
+ }), 2),
1321
+ position = _o[0],
1322
+ setPosition = _o[1];
1323
+
1324
+ var _p = __read(React__default["default"].useState(startSize), 2),
1325
+ size = _p[0],
1326
+ setSize = _p[1];
1327
+
1328
+ var onStopDrag = React__default["default"].useCallback(function (_event, position) {
1329
+ setPosition(position);
1330
+ }, [setPosition]);
1331
+
1332
+ var _q = __read(React__default["default"].useState(defaultInitialMaxHeight), 2),
1333
+ initialMaxHeight = _q[0],
1334
+ setInitialMaxHeight = _q[1];
1335
+
1336
+ var onStartResize = function onStartResize() {
1337
+ setInitialMaxHeight('initial');
1338
+ };
1339
+
1340
+ var onResize = React__default["default"].useCallback(function (_event, _handle, node) {
1341
+ var _a = node.getBoundingClientRect(),
1342
+ width = _a.width,
1343
+ height = _a.height;
1344
+
1345
+ onChangeSize({
1346
+ width: width,
1347
+ height: height
1348
+ });
1349
+ }, [onChangeSize]);
1350
+ var onResizeWindow = React__default["default"].useCallback(function (event) {
1351
+ if (!nodeRef.current) return;
1352
+ var bbox = nodeRef.current.firstChild.getBoundingClientRect();
1353
+ var windowTarget = event.currentTarget;
1354
+ if (!windowTarget) return;
1355
+ var innerHeight = windowTarget.innerHeight,
1356
+ innerWidth = windowTarget.innerWidth;
1357
+ var isHorizontallyLarger = bbox.width > innerWidth;
1358
+ var isVerticallyLarger = bbox.height > innerHeight; // left screen
1359
+
1360
+ if (bbox.x < 0 || isHorizontallyLarger) {
1361
+ setPosition(__assign(__assign({}, position), {
1362
+ x: position.x - bbox.x
1363
+ }));
1364
+ } // right screen
1365
+ else if (bbox.x + bbox.width >= innerWidth) {
1366
+ var diffX = innerWidth - bbox.x - bbox.width;
1367
+ setPosition(__assign(__assign({}, position), {
1368
+ x: position.x + diffX
1369
+ }));
1370
+ } // top screen
1371
+ else if (bbox.y < 0 || isVerticallyLarger) {
1372
+ setPosition(__assign(__assign({}, position), {
1373
+ y: position.y - bbox.y
1374
+ }));
1375
+ } // bottom screen
1376
+ else if (bbox.y + bbox.height >= innerHeight) {
1377
+ var diffY = innerHeight - bbox.y - bbox.height;
1378
+ setPosition(__assign(__assign({}, position), {
1379
+ y: position.y + diffY
1380
+ }));
1381
+ }
1382
+ }, [position]);
1383
+ React__default["default"].useEffect(function () {
1384
+ var throttledResize = lodash.throttle(onResizeWindow, 100);
1385
+ window.addEventListener('resize', throttledResize);
1386
+ return function () {
1387
+ window.removeEventListener('resize', throttledResize);
1388
+ };
1389
+ }, [onResizeWindow]);
1390
+ var toolcontainerId = React__default["default"].useRef(Date.now().toString()).current;
1391
+ var headerClassName = "header-" + toolcontainerId;
1392
+ return isOpen ? /*#__PURE__*/React__default["default"].createElement(DraggableComponent$1, {
1393
+ nodeRef: nodeRef,
1394
+ bounds: bounds,
1395
+ position: position,
1396
+ onStop: onStopDrag,
1397
+ handle: "." + headerClassName,
1398
+ onMouseDown: onMouseDown
1399
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1400
+ style: __assign({
1401
+ position: 'absolute',
1402
+ zIndex: zIndex
1403
+ }, startPosition),
1404
+ ref: nodeRef
1405
+ }, /*#__PURE__*/React__default["default"].createElement(ResizeComponent, __assign({}, props, {
1406
+ startPosition: startPosition,
1407
+ size: size,
1408
+ setSize: setSize,
1409
+ onResizeStart: onStartResize,
1410
+ onResize: onResize
1411
+ }), /*#__PURE__*/React__default["default"].createElement(ToolContainer, {
1412
+ maxHeight: initialMaxHeight,
1413
+ onClose: onClose,
1414
+ title: title,
1415
+ size: headerSize,
1416
+ isDraggable: true,
1417
+ isResizable: true,
1418
+ elevation: elevation,
1419
+ headerClassName: headerClassName
1420
+ }, children)))) : null;
1421
+ };
1422
+
1423
+ /* *
1424
+ * Licensed under the Apache License, Version 2.0 (the "License");
1425
+ * you may not use this file except in compliance with the License.
1426
+ * You may obtain a copy of the License at
1427
+ *
1428
+ * http://www.apache.org/licenses/LICENSE-2.0
1429
+ *
1430
+ * Unless required by applicable law or agreed to in writing, software
1431
+ * distributed under the License is distributed on an "AS IS" BASIS,
1432
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1433
+ * See the License for the specific language governing permissions and
1434
+ * limitations under the License.
1435
+ *
1436
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1437
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1438
+ * */
1439
+ var useStyles$4 = core.makeStyles(function (theme) {
1440
+ return {
1441
+ icon: {
1442
+ backgroundColor: theme.palette.geowebColors.textInputField["default"].rgba,
1443
+ width: 40,
1444
+ height: 40,
1445
+ display: 'inline-flex',
1446
+ verticalAlign: 'middle',
1447
+ alignItems: 'center',
1448
+ borderRadius: theme.shape.borderRadius,
1449
+ '&>span': {
1450
+ textAlign: 'center',
1451
+ fontSize: 14,
1452
+ fontWeight: 500,
1453
+ display: 'flex',
1454
+ margin: 'auto',
1455
+ letterSpacing: 0.25
1456
+ }
1457
+ },
1458
+ segment: {
1459
+ margin: '0 2px',
1460
+ verticalAlign: 'middle',
1461
+ fontSize: 14,
1462
+ fontWeight: 500,
1463
+ letterSpacing: 0.25
1464
+ },
1465
+ connect: {
1466
+ fontSize: 18
1467
+ },
1468
+ divider: {
1469
+ margin: '0 6px',
1470
+ fontSize: 18
1471
+ }
1472
+ };
1473
+ });
1474
+
1475
+ var ShortCutSegment = function ShortCutSegment(_a) {
1476
+ var _b = _a.type,
1477
+ type = _b === void 0 ? 'text' : _b,
1478
+ children = _a.children;
1479
+ var classes = useStyles$4();
1480
+
1481
+ if (type === 'divider') {
1482
+ return /*#__PURE__*/React__default["default"].createElement(core.Typography, {
1483
+ "data-testid": "segment-divider",
1484
+ className: classes.segment + " " + classes.divider,
1485
+ component: "span"
1486
+ }, children);
1487
+ }
1488
+
1489
+ if (type === 'icon') {
1490
+ return /*#__PURE__*/React__default["default"].createElement("span", {
1491
+ "data-testid": "segment-icon",
1492
+ className: classes.segment + " " + classes.icon
1493
+ }, /*#__PURE__*/React__default["default"].createElement(core.Typography, {
1494
+ component: "span"
1495
+ }, children));
1496
+ }
1497
+
1498
+ if (type === 'connect') {
1499
+ return /*#__PURE__*/React__default["default"].createElement(core.Typography, {
1500
+ className: classes.segment + " " + classes.connect,
1501
+ "data-testid": "segment-connect",
1502
+ component: "span"
1503
+ }, children);
1504
+ }
1505
+
1506
+ return /*#__PURE__*/React__default["default"].createElement(core.Typography, {
1507
+ className: classes.segment,
1508
+ "data-testid": "segment-text",
1509
+ component: "span"
1510
+ }, children);
1511
+ };
1512
+
1513
+ /* *
1514
+ * Licensed under the Apache License, Version 2.0 (the "License");
1515
+ * you may not use this file except in compliance with the License.
1516
+ * You may obtain a copy of the License at
1517
+ *
1518
+ * http://www.apache.org/licenses/LICENSE-2.0
1519
+ *
1520
+ * Unless required by applicable law or agreed to in writing, software
1521
+ * distributed under the License is distributed on an "AS IS" BASIS,
1522
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1523
+ * See the License for the specific language governing permissions and
1524
+ * limitations under the License.
1525
+ *
1526
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1527
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1528
+ * */
1529
+ var useStyles$3 = core.makeStyles(function (theme) {
1530
+ return {
1531
+ icon: {
1532
+ fill: theme.palette.geowebColors.typographyAndIcons.text
1533
+ }
1534
+ };
1535
+ });
1536
+ var OptionIcon = function OptionIcon() {
1537
+ var classes = useStyles$3();
1538
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1539
+ viewBox: "0 0 12 11",
1540
+ style: {
1541
+ width: 12,
1542
+ height: 11
1543
+ }
1544
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Option"), /*#__PURE__*/React__default["default"].createElement("g", {
1545
+ id: "Symbols:-General",
1546
+ stroke: "none",
1547
+ strokeWidth: "1",
1548
+ fill: "none",
1549
+ fillRule: "evenodd"
1550
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1551
+ id: "Shortcut-Option-\"\u2325\"",
1552
+ transform: "translate(-14.000000, -13.000000)",
1553
+ className: classes.icon
1554
+ }, /*#__PURE__*/React__default["default"].createElement("path", {
1555
+ 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",
1556
+ id: "Option"
1557
+ }))));
1558
+ };
1559
+ var CommandIcon = function CommandIcon() {
1560
+ var classes = useStyles$3();
1561
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1562
+ viewBox: "0 0 12 12",
1563
+ style: {
1564
+ width: 12,
1565
+ height: 12
1566
+ }
1567
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Command"), /*#__PURE__*/React__default["default"].createElement("g", {
1568
+ id: "Symbols:-General",
1569
+ stroke: "none",
1570
+ strokeWidth: "1",
1571
+ fill: "none",
1572
+ fillRule: "evenodd"
1573
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1574
+ id: "Shortcut-Command-\"\u2318\"",
1575
+ transform: "translate(-14.000000, -13.000000)",
1576
+ className: classes.icon
1577
+ }, /*#__PURE__*/React__default["default"].createElement("path", {
1578
+ 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",
1579
+ id: "Command"
1580
+ }))));
1581
+ };
1582
+ var ArrowLeftIcon = function ArrowLeftIcon() {
1583
+ var classes = useStyles$3();
1584
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1585
+ viewBox: "0 0 12 6",
1586
+ style: {
1587
+ width: 12,
1588
+ height: 6
1589
+ }
1590
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Arrow left"), /*#__PURE__*/React__default["default"].createElement("g", {
1591
+ id: "Symbols:-General",
1592
+ stroke: "none",
1593
+ strokeWidth: "1",
1594
+ fill: "none",
1595
+ fillRule: "evenodd"
1596
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1597
+ id: "Shortcut-Arrow-left-\"\u2190\"",
1598
+ transform: "translate(-14.000000, -16.000000)",
1599
+ className: classes.icon
1600
+ }, /*#__PURE__*/React__default["default"].createElement("polygon", {
1601
+ id: "Arrow-left",
1602
+ transform: "translate(19.880000, 18.960000) rotate(90.000000) translate(-19.880000, -18.960000) ",
1603
+ 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"
1604
+ }))));
1605
+ };
1606
+ var ArrowRightIcon = function ArrowRightIcon() {
1607
+ var classes = useStyles$3();
1608
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1609
+ viewBox: "0 0 12 6",
1610
+ style: {
1611
+ width: 12,
1612
+ height: 6
1613
+ }
1614
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Arrow right"), /*#__PURE__*/React__default["default"].createElement("g", {
1615
+ id: "Symbols:-General",
1616
+ stroke: "none",
1617
+ strokeWidth: "1",
1618
+ fill: "none",
1619
+ fillRule: "evenodd"
1620
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1621
+ id: "Shortcut-Arrow-right-\"\u2192\"",
1622
+ transform: "translate(-14.000000, -16.000000)",
1623
+ className: classes.icon
1624
+ }, /*#__PURE__*/React__default["default"].createElement("polygon", {
1625
+ id: "Arrow-right",
1626
+ transform: "translate(19.880000, 18.960000) rotate(-90.000000) translate(-19.880000, -18.960000) ",
1627
+ 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"
1628
+ }))));
1629
+ };
1630
+ var ArrowDownIcon = function ArrowDownIcon() {
1631
+ var classes = useStyles$3();
1632
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1633
+ viewBox: "0 0 6 12",
1634
+ style: {
1635
+ width: 6,
1636
+ height: 12
1637
+ }
1638
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Arrow down"), /*#__PURE__*/React__default["default"].createElement("g", {
1639
+ id: "Symbols:-General",
1640
+ stroke: "none",
1641
+ strokeWidth: "1",
1642
+ fill: "none",
1643
+ fillRule: "evenodd"
1644
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1645
+ id: "Shortcut-Arrow-down-\"\u2193\"",
1646
+ transform: "translate(-17.000000, -13.000000)",
1647
+ className: classes.icon
1648
+ }, /*#__PURE__*/React__default["default"].createElement("polygon", {
1649
+ id: "Arrow-down",
1650
+ 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"
1651
+ }))));
1652
+ };
1653
+ var ArrowUpIcon = function ArrowUpIcon() {
1654
+ var classes = useStyles$3();
1655
+ return /*#__PURE__*/React__default["default"].createElement(core.SvgIcon, {
1656
+ viewBox: "0 0 6 11",
1657
+ style: {
1658
+ width: 6,
1659
+ height: 11
1660
+ }
1661
+ }, /*#__PURE__*/React__default["default"].createElement("title", null, "Arrow up"), /*#__PURE__*/React__default["default"].createElement("g", {
1662
+ id: "Symbols:-General",
1663
+ stroke: "none",
1664
+ strokeWidth: "1",
1665
+ fill: "none",
1666
+ fillRule: "evenodd"
1667
+ }, /*#__PURE__*/React__default["default"].createElement("g", {
1668
+ id: "Shortcut-Arrow-up-\"\u2191\"",
1669
+ transform: "translate(-17.000000, -13.000000)",
1670
+ className: classes.icon
1671
+ }, /*#__PURE__*/React__default["default"].createElement("polygon", {
1672
+ id: "Arrow-up",
1673
+ transform: "translate(19.880000, 18.485000) scale(1, -1) translate(-19.880000, -18.485000) ",
1674
+ 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"
1675
+ }))));
1676
+ };
1677
+
1678
+ var shortcuts = [{
1679
+ title: 'Choose a selected time',
1680
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Left click on the time slider rail")
1681
+ }, {
1682
+ title: 'Move backwards/forwards in selected time',
1683
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Mouse scroll over the time slider rail")
1684
+ }, {
1685
+ title: 'Move 1 step backwards/forwards in selected time',
1686
+ description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1687
+ type: "icon"
1688
+ }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1689
+ type: "connect"
1690
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1691
+ type: "icon"
1692
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowLeftIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1693
+ type: "divider"
1694
+ }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1695
+ type: "icon"
1696
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowRightIcon, null))),
1697
+ descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1698
+ type: "icon"
1699
+ }, /*#__PURE__*/React__default["default"].createElement(OptionIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1700
+ type: "connect"
1701
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1702
+ type: "icon"
1703
+ }, /*#__PURE__*/React__default["default"].createElement(CommandIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1704
+ type: "connect"
1705
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1706
+ type: "icon"
1707
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowLeftIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1708
+ type: "divider"
1709
+ }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1710
+ type: "icon"
1711
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowRightIcon, null)))
1712
+ }, {
1713
+ title: 'Toggle hide/show time slider',
1714
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1715
+ type: "icon"
1716
+ }, "t")
1717
+ }, {
1718
+ title: 'Change time slider scale (visible timespan)',
1719
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Hold left click over Time Slider legend + drag left or right")
1720
+ }, {
1721
+ title: 'Expand/shrink time slider scale (visible timespan)',
1722
+ description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1723
+ type: "icon"
1724
+ }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "+ Scroll the slider rail"))
1725
+ }, {
1726
+ title: 'Mouseover to change selected time',
1727
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Hover over Time Slider rail or time indicator")
1728
+ }, {
1729
+ title: 'Mouseover switch on/off',
1730
+ description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1731
+ type: "icon"
1732
+ }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1733
+ type: "connect"
1734
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1735
+ type: "icon"
1736
+ }, "Alt"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1737
+ type: "connect"
1738
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1739
+ type: "icon"
1740
+ }, "h")),
1741
+ descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1742
+ type: "icon"
1743
+ }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1744
+ type: "connect"
1745
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1746
+ type: "icon"
1747
+ }, /*#__PURE__*/React__default["default"].createElement(OptionIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1748
+ type: "connect"
1749
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1750
+ type: "icon"
1751
+ }, "h"))
1752
+ }, {
1753
+ title: 'Change time step or animation speed',
1754
+ description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1755
+ type: "icon"
1756
+ }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1757
+ type: "connect"
1758
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1759
+ type: "icon"
1760
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowUpIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1761
+ type: "divider"
1762
+ }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1763
+ type: "icon"
1764
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowDownIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "(when slider active)")),
1765
+ descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1766
+ type: "icon"
1767
+ }, /*#__PURE__*/React__default["default"].createElement(CommandIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1768
+ type: "connect"
1769
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1770
+ type: "icon"
1771
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowUpIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1772
+ type: "divider"
1773
+ }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1774
+ type: "icon"
1775
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowDownIcon, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "(when slider active)"))
1776
+ }, {
1777
+ title: 'Return to current time',
1778
+ description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1779
+ type: "icon"
1780
+ }, "Home"),
1781
+ descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1782
+ type: "icon"
1783
+ }, "fn"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1784
+ type: "connect"
1785
+ }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
1786
+ type: "icon"
1787
+ }, /*#__PURE__*/React__default["default"].createElement(ArrowLeftIcon, null)))
1788
+ }];
1789
+ var getShortcutList = function getShortcutList(shortcutList, platform) {
1790
+ if (platform === void 0) {
1791
+ platform = 'windows';
1792
+ }
1793
+
1794
+ return shortcutList.map(function (_a) {
1795
+ var title = _a.title,
1796
+ description = _a.description,
1797
+ descriptionMac = _a.descriptionMac;
1798
+ return __assign({
1799
+ title: title,
1800
+ description: description
1801
+ }, platform === 'windows' ? {
1802
+ description: description
1803
+ } : {
1804
+ description: descriptionMac || description
1805
+ });
1806
+ });
1807
+ };
1808
+ var useStyles$2 = core.makeStyles(function () {
1809
+ return {
1810
+ row: {
1811
+ minHeight: 56
1812
+ },
1813
+ title: {
1814
+ fontSize: 12,
1815
+ fontWeight: 300,
1816
+ letterSpacing: 0.4,
1817
+ opacity: 0.67
1818
+ },
1819
+ description: {
1820
+ alignItems: 'center'
1821
+ }
1822
+ };
1823
+ });
1824
+
1825
+ var ShortcutList = function ShortcutList(_a) {
1826
+ var _b = _a.platform,
1827
+ platform = _b === void 0 ? 'windows' : _b;
1828
+ var classes = useStyles$2();
1829
+ var rows = getShortcutList(shortcuts, platform);
1830
+ return /*#__PURE__*/React__default["default"].createElement(core.List, {
1831
+ "data-testid": "list-" + platform
1832
+ }, rows.map(function (row, index) {
1833
+ return /*#__PURE__*/React__default["default"].createElement(core.ListItem, {
1834
+ className: classes.row,
1835
+ divider: index !== rows.length - 1,
1836
+ key: row.title
1837
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1838
+ container: true,
1839
+ direction: "row",
1840
+ justify: "space-between",
1841
+ alignItems: "center"
1842
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1843
+ item: true,
1844
+ className: classes.title
1845
+ }, row.title), /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1846
+ item: true
1847
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1848
+ className: classes.description
1849
+ }, row.description))));
1850
+ }));
1851
+ };
1852
+
1853
+ var TabPanel = function TabPanel(_a) {
1854
+ var children = _a.children,
1855
+ value = _a.value,
1856
+ index = _a.index;
1857
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1858
+ role: "tabpanel",
1859
+ hidden: value !== index,
1860
+ id: "tabpanel-" + index,
1861
+ "aria-labelledby": "tab-" + index
1862
+ }, value === index && children);
1863
+ };
1864
+
1865
+ var useStyles$1 = core.makeStyles(function () {
1866
+ return {
1867
+ container: {
1868
+ margin: '0px 20px'
1869
+ },
1870
+ tab: {
1871
+ fontSize: 12
1872
+ }
1873
+ };
1874
+ });
1875
+
1876
+ var CheatSheet = function CheatSheet() {
1877
+ var classes = useStyles$1();
1878
+
1879
+ var _a = __read(React__default["default"].useState(0), 2),
1880
+ activeTab = _a[0],
1881
+ onChangeActiveTab = _a[1];
1882
+
1883
+ var onChangeTab = function onChangeTab(_event, newValue) {
1884
+ onChangeActiveTab(newValue);
1885
+ };
1886
+
1887
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1888
+ className: classes.container
1889
+ }, /*#__PURE__*/React__default["default"].createElement(core.Tabs, {
1890
+ value: activeTab,
1891
+ onChange: onChangeTab,
1892
+ "aria-label": "platform"
1893
+ }, /*#__PURE__*/React__default["default"].createElement(core.Tab, {
1894
+ className: classes.tab,
1895
+ label: "Windows"
1896
+ }), /*#__PURE__*/React__default["default"].createElement(core.Tab, {
1897
+ className: classes.tab,
1898
+ label: "Mac"
1899
+ })), /*#__PURE__*/React__default["default"].createElement(TabPanel, {
1900
+ value: activeTab,
1901
+ index: 0
1902
+ }, /*#__PURE__*/React__default["default"].createElement(ShortcutList, null)), /*#__PURE__*/React__default["default"].createElement(TabPanel, {
1903
+ value: activeTab,
1904
+ index: 1
1905
+ }, /*#__PURE__*/React__default["default"].createElement(ShortcutList, {
1906
+ platform: "mac"
1907
+ })));
1908
+ };
1909
+
1910
+ var useStyles = core.makeStyles(function () {
1911
+ return {
1912
+ backdrop: {
1913
+ zIndex: 1
1914
+ }
1915
+ };
1916
+ });
1917
+
1918
+ var UserMenuItemCheatSheet = function UserMenuItemCheatSheet() {
1919
+ var classes = useStyles();
1920
+
1921
+ var _a = __read(React__default["default"].useState(false), 2),
1922
+ open = _a[0],
1923
+ setOpen = _a[1];
1924
+
1925
+ var onClose = function onClose() {
1926
+ setOpen(false);
1927
+ };
1928
+
1929
+ var onOpen = function onOpen() {
1930
+ setOpen(true);
1931
+ };
1932
+
1933
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(core.MenuItem, {
1934
+ "data-testid": "cheatsheet-btn",
1935
+ onClick: onOpen
1936
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1937
+ container: true
1938
+ }, /*#__PURE__*/React__default["default"].createElement(core.Grid, {
1939
+ item: true
1940
+ }, "Cheat sheet"))), /*#__PURE__*/React__default["default"].createElement(core.Backdrop, {
1941
+ "data-testid": "cheatsheet-content",
1942
+ open: open,
1943
+ className: classes.backdrop
1944
+ }, /*#__PURE__*/React__default["default"].createElement(DraggableComponent, {
1945
+ startSize: {
1946
+ width: 700
1947
+ },
1948
+ minHeight: 300,
1949
+ minWidth: 500,
1950
+ title: "Cheat sheet",
1951
+ headerSize: "small",
1952
+ isOpen: true,
1953
+ onClose: onClose,
1954
+ bounds: "parent"
1955
+ }, /*#__PURE__*/React__default["default"].createElement(CheatSheet, null))));
1956
+ };
1957
+
1958
+ /* *
1959
+ * Licensed under the Apache License, Version 2.0 (the "License");
1960
+ * you may not use this file except in compliance with the License.
1961
+ * You may obtain a copy of the License at
1962
+ *
1963
+ * http://www.apache.org/licenses/LICENSE-2.0
1964
+ *
1965
+ * Unless required by applicable law or agreed to in writing, software
1966
+ * distributed under the License is distributed on an "AS IS" BASIS,
1967
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1968
+ * See the License for the specific language governing permissions and
1969
+ * limitations under the License.
1970
+ *
1971
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1972
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1973
+ * */
1974
+ var useUserMenu = function useUserMenu(open) {
1975
+ if (open === void 0) {
1976
+ open = false;
1977
+ }
1978
+
1979
+ var _a = __read(React__default["default"].useState(open), 2),
1980
+ isOpen = _a[0],
1981
+ setOpen = _a[1];
1982
+
1983
+ var onClose = function onClose() {
1984
+ return setOpen(false);
1985
+ };
1986
+
1987
+ var onToggle = function onToggle() {
1988
+ return setOpen(!isOpen);
1989
+ };
1990
+
1991
+ return {
1992
+ isOpen: isOpen,
1993
+ onClose: onClose,
1994
+ onToggle: onToggle
1995
+ };
1996
+ };
1997
+
1998
+ /* *
1999
+ * Licensed under the Apache License, Version 2.0 (the "License");
2000
+ * you may not use this file except in compliance with the License.
2001
+ * You may obtain a copy of the License at
2002
+ *
2003
+ * http://www.apache.org/licenses/LICENSE-2.0
2004
+ *
2005
+ * Unless required by applicable law or agreed to in writing, software
2006
+ * distributed under the License is distributed on an "AS IS" BASIS,
2007
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2008
+ * See the License for the specific language governing permissions and
2009
+ * limitations under the License.
2010
+ *
2011
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2012
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
2013
+ * */
2014
+ var getInitials = function getInitials(name) {
2015
+ if (!name) return '';
2016
+ var nameWithoutEmail = name.split('@')[0];
2017
+ var array = nameWithoutEmail.split('.');
2018
+
2019
+ switch (array.length) {
2020
+ case 1:
2021
+ return array[0].charAt(0).toUpperCase();
2022
+
2023
+ default:
2024
+ return array[0].charAt(0).toUpperCase() + array[array.length - 1].charAt(0).toUpperCase();
2025
+ }
2026
+ };
2027
+
2028
+ /* *
2029
+ * Licensed under the Apache License, Version 2.0 (the "License");
2030
+ * you may not use this file except in compliance with the License.
2031
+ * You may obtain a copy of the License at
2032
+ *
2033
+ * http://www.apache.org/licenses/LICENSE-2.0
2034
+ *
2035
+ * Unless required by applicable law or agreed to in writing, software
2036
+ * distributed under the License is distributed on an "AS IS" BASIS,
2037
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2038
+ * See the License for the specific language governing permissions and
2039
+ * limitations under the License.
2040
+ *
2041
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2042
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
2043
+ * */
2044
+ var sliderStyles = core.makeStyles(function (theme) {
2045
+ return {
2046
+ sliderHeader: {
2047
+ fontFamily: 'Roboto-Black, Roboto',
2048
+ fontSize: 12,
2049
+ color: theme.palette.geowebColors.typographyAndIcons.text,
2050
+ padding: '11px 0 11px 16px'
2051
+ }
2052
+ };
2053
+ });
2054
+ var CustomSliderComponent = core.withStyles(function (theme) {
2055
+ return {
2056
+ root: {
2057
+ marginLeft: '16px',
2058
+ // highlight selected label
2059
+ '& span.selectedLabel': {
2060
+ fontWeight: 'bold'
2061
+ }
2062
+ },
2063
+ thumb: {
2064
+ width: 20,
2065
+ height: 20,
2066
+ marginLeft: '-7px !important',
2067
+ marginBottom: '-10px !important',
2068
+ backgroundColor: theme.palette.geowebColors.customSlider.thumb,
2069
+ '$disabled &': {
2070
+ width: 20,
2071
+ height: 20,
2072
+ backgroundColor: theme.palette.geowebColors.customSlider.thumbDisabled
2073
+ },
2074
+ boxShadow: '0px 3px 5px 1px rgba(0,0,0,0.3)',
2075
+ '&:focus, &:hover, &:active': {
2076
+ boxShadow: '0px 3px 5px 2px rgba(0,0,0,0.4)'
2077
+ }
2078
+ },
2079
+ mark: {
2080
+ height: '2px',
2081
+ width: '2px',
2082
+ marginLeft: '2px',
2083
+ backgroundColor: theme.palette.geowebColors.customSlider.mark,
2084
+ '$disabled &': {
2085
+ backgroundColor: theme.palette.geowebColors.customSlider.markDisabled
2086
+ }
2087
+ },
2088
+ markLabel: {
2089
+ fontFamily: 'Roboto-Black, Roboto',
2090
+ fontSize: 12,
2091
+ color: theme.palette.geowebColors.typographyAndIcons.text
2092
+ },
2093
+ track: {
2094
+ borderRadius: '0 0 4.5px 4.5px',
2095
+ width: '6px !important',
2096
+ backgroundColor: theme.palette.geowebColors.customSlider.track,
2097
+ '$disabled &': {
2098
+ backgroundColor: theme.palette.geowebColors.customSlider.trackDisabled
2099
+ }
2100
+ },
2101
+ rail: {
2102
+ width: '4px !important',
2103
+ borderRadius: 4.5,
2104
+ backgroundColor: theme.palette.geowebColors.customSlider.rail,
2105
+ marginLeft: '1px',
2106
+ opacity: 1,
2107
+ '$disabled &': {
2108
+ backgroundColor: theme.palette.geowebColors.customSlider.railDisabled,
2109
+ opacity: 1
2110
+ }
2111
+ },
2112
+ disabled: {// this has to exist, because otherwise '$disabled &' rules above has no effect ???
2113
+ }
2114
+ };
2115
+ })(core.Slider);
2116
+ var CustomSlider = function CustomSlider(_a) {
2117
+ var value = _a.value,
2118
+ onChange = _a.onChange,
2119
+ onKeyDown = _a.onKeyDown,
2120
+ _b = _a.dataTestId,
2121
+ dataTestId = _b === void 0 ? 'customSlider' : _b,
2122
+ _c = _a.orientation,
2123
+ orientation = _c === void 0 ? 'vertical' : _c,
2124
+ max = _a.max,
2125
+ min = _a.min,
2126
+ step = _a.step,
2127
+ _d = _a.marks,
2128
+ marks = _d === void 0 ? [] : _d,
2129
+ _e = _a.disabled,
2130
+ disabled = _e === void 0 ? false : _e,
2131
+ ThumbComponent = _a.ThumbComponent; // Add custom class (for bold text) to label adjacent to thumb component.
2132
+ // Material UI doesn't support highlighing only adjacent label
2133
+ // when track is highlighted everywhere below selected value.
2134
+
2135
+ var element = React__namespace.useRef(null);
2136
+ var themeContext = theme.useThemeContext();
2137
+ React__namespace.useEffect(function () {
2138
+ var activeMarkLabelElements = element.current.getElementsByClassName('MuiSlider-markLabelActive');
2139
+
2140
+ var _a = __read(__spreadArray([], __read(activeMarkLabelElements)).reverse()),
2141
+ first = _a[0],
2142
+ rest = _a.slice(1);
2143
+
2144
+ if (first) first.classList.add('selectedLabel');
2145
+ rest.forEach(function (element) {
2146
+ return element.classList.remove('selectedLabel');
2147
+ });
2148
+ }, [value, themeContext.isDark]);
2149
+ return /*#__PURE__*/React__namespace.createElement(CustomSliderComponent, {
2150
+ ref: element,
2151
+ "data-testid": dataTestId,
2152
+ orientation: orientation,
2153
+ value: value,
2154
+ step: step,
2155
+ max: max,
2156
+ min: min,
2157
+ marks: marks,
2158
+ onChange: onChange,
2159
+ onKeyDown: onKeyDown,
2160
+ disabled: disabled,
2161
+ ThumbComponent: ThumbComponent
2162
+ });
2163
+ };
2164
+
2165
+ /* *
2166
+ * Licensed under the Apache License, Version 2.0 (the "License");
2167
+ * you may not use this file except in compliance with the License.
2168
+ * You may obtain a copy of the License at
2169
+ *
2170
+ * http://www.apache.org/licenses/LICENSE-2.0
2171
+ *
2172
+ * Unless required by applicable law or agreed to in writing, software
2173
+ * distributed under the License is distributed on an "AS IS" BASIS,
2174
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2175
+ * See the License for the specific language governing permissions and
2176
+ * limitations under the License.
2177
+ *
2178
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2179
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
2180
+ * */
2181
+ // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
2182
+ var isAxiosError = function isAxiosError(error) {
2183
+ return error.isAxiosError !== undefined;
2184
+ };
2185
+ var getAxiosErrorMessage = function getAxiosErrorMessage(error) {
2186
+ var data = error.response && error.response.data;
2187
+
2188
+ if (data && typeof data === 'string') {
2189
+ return data;
2190
+ }
2191
+
2192
+ if (data && data.message && typeof data.message === 'string') {
2193
+ return data.message;
2194
+ }
2195
+
2196
+ return 'An error has occurred';
2197
+ };
2198
+
2199
+ exports.AlertBanner = AlertBanner;
2200
+ exports.AppHeader = AppHeader;
2201
+ exports.AppLayout = AppLayout;
2202
+ exports.ConfirmationDialog = ConfirmationDialog;
2203
+ exports.ConfirmationServiceProvider = ConfirmationServiceProvider;
2204
+ exports.CustomSlider = CustomSlider;
2205
+ exports.Draggable = DraggableComponent$1;
2206
+ exports.HIDDEN_INPUT_HELPER_IS_DRAFT = HIDDEN_INPUT_HELPER_IS_DRAFT;
2207
+ exports.Resizable = ResizeComponent;
2208
+ exports.StatusTag = StatusTag;
2209
+ exports.ToolContainer = ToolContainer;
2210
+ exports.ToolContainerDraggable = DraggableComponent;
2211
+ exports.ToolFooter = ToolFooter;
2212
+ exports.ToolHeader = ToolHeader;
2213
+ exports.UserMenu = UserMenu;
2214
+ exports.UserMenuItemCheatSheet = UserMenuItemCheatSheet;
2215
+ exports.UserMenuItemTheme = MenuItemTheme;
2216
+ exports.getAxiosErrorMessage = getAxiosErrorMessage;
2217
+ exports.getInitials = getInitials;
2218
+ exports.isAxiosError = isAxiosError;
2219
+ exports.showPrompt = showPrompt;
2220
+ exports.sliderStyles = sliderStyles;
2221
+ exports.useConfirmationDialog = useConfirmationDialog;
2222
+ exports.useDialogActions = useDialogActions;
2223
+ exports.useDraftFormHelpers = useDraftFormHelpers;
2224
+ exports.useIsMounted = useIsMounted;
2225
+ exports.usePoller = usePoller;
2226
+ exports.usePreventBrowserClose = usePreventBrowserClose;
2227
+ exports.usePrevious = usePrevious;
2228
+ exports.useUserMenu = useUserMenu;
2229
+
2230
+ Object.defineProperty(exports, '__esModule', { value: true });
2231
+
2232
+ }));