@opengeoweb/shared 4.21.0 → 4.22.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 (141) hide show
  1. package/index.js +25306 -0
  2. package/package.json +15 -16
  3. package/{lib → src/lib}/components/ConfirmationDialog/ConfirmationDialog.d.ts +5 -2
  4. package/{lib → src/lib}/utils/axiosErrorUtils/axiosErrorUtils.d.ts +1 -1
  5. package/{lib → src/lib}/utils/dateUtils/dateUtils.d.ts +28 -0
  6. package/index.esm.js +0 -3538
  7. package/index.umd.js +0 -3537
  8. /package/{index.d.ts → src/index.d.ts} +0 -0
  9. /package/{lib → src/lib}/components/AlertBanner/AlertBanner.d.ts +0 -0
  10. /package/{lib → src/lib}/components/AlertBanner/AlertBanner.spec.d.ts +0 -0
  11. /package/{lib → src/lib}/components/AlertBanner/AlertBanner.stories.d.ts +0 -0
  12. /package/{lib → src/lib}/components/AlertBanner/index.d.ts +0 -0
  13. /package/{lib → src/lib}/components/AlertIcon/AlertIcon.d.ts +0 -0
  14. /package/{lib → src/lib}/components/AlertIcon/index.d.ts +0 -0
  15. /package/{lib → src/lib}/components/AppHeader/AppHeader.d.ts +0 -0
  16. /package/{lib → src/lib}/components/AppHeader/AppHeader.spec.d.ts +0 -0
  17. /package/{lib → src/lib}/components/AppHeader/AppHeader.stories.d.ts +0 -0
  18. /package/{lib → src/lib}/components/AppHeader/index.d.ts +0 -0
  19. /package/{lib → src/lib}/components/AppLayout/AppLayout.d.ts +0 -0
  20. /package/{lib → src/lib}/components/AppLayout/AppLayout.spec.d.ts +0 -0
  21. /package/{lib → src/lib}/components/AppLayout/AppLayout.stories.d.ts +0 -0
  22. /package/{lib → src/lib}/components/AppLayout/index.d.ts +0 -0
  23. /package/{lib → src/lib}/components/Avatar/Avatar.d.ts +0 -0
  24. /package/{lib → src/lib}/components/Avatar/Avatar.stories.d.ts +0 -0
  25. /package/{lib → src/lib}/components/Avatar/index.d.ts +0 -0
  26. /package/{lib → src/lib}/components/ConfirmationDialog/ConfirmationDialog.spec.d.ts +0 -0
  27. /package/{lib → src/lib}/components/ConfirmationDialog/ConfirmationDialog.stories.d.ts +0 -0
  28. /package/{lib → src/lib}/components/ConfirmationDialog/ConfirmationService.d.ts +0 -0
  29. /package/{lib → src/lib}/components/ConfirmationDialog/ConfirmationService.spec.d.ts +0 -0
  30. /package/{lib → src/lib}/components/ConfirmationDialog/index.d.ts +0 -0
  31. /package/{lib → src/lib}/components/CustomAccordion/CustomAccordion.d.ts +0 -0
  32. /package/{lib → src/lib}/components/CustomAccordion/CustomAccordion.spec.d.ts +0 -0
  33. /package/{lib → src/lib}/components/CustomAccordion/CustomAccordion.stories.d.ts +0 -0
  34. /package/{lib → src/lib}/components/CustomAccordion/index.d.ts +0 -0
  35. /package/{lib → src/lib}/components/CustomDialog/CustomDialog.d.ts +0 -0
  36. /package/{lib → src/lib}/components/CustomDialog/CustomDialog.spec.d.ts +0 -0
  37. /package/{lib → src/lib}/components/CustomDialog/CustomDialog.stories.d.ts +0 -0
  38. /package/{lib → src/lib}/components/CustomDialog/index.d.ts +0 -0
  39. /package/{lib → src/lib}/components/CustomIconButton/CustomIconButton.d.ts +0 -0
  40. /package/{lib → src/lib}/components/CustomIconButton/CustomIconButton.spec.d.ts +0 -0
  41. /package/{lib → src/lib}/components/CustomIconButton/CustomIconButton.stories.d.ts +0 -0
  42. /package/{lib → src/lib}/components/CustomIconButton/index.d.ts +0 -0
  43. /package/{lib → src/lib}/components/CustomSlider/CustomSlider.d.ts +0 -0
  44. /package/{lib → src/lib}/components/CustomSlider/CustomSlider.spec.d.ts +0 -0
  45. /package/{lib → src/lib}/components/CustomSlider/CustomSlider.stories.d.ts +0 -0
  46. /package/{lib → src/lib}/components/CustomSlider/index.d.ts +0 -0
  47. /package/{lib → src/lib}/components/CustomToggleButton/CustomToggleButton.d.ts +0 -0
  48. /package/{lib → src/lib}/components/CustomToggleButton/CustomToggleButton.spec.d.ts +0 -0
  49. /package/{lib → src/lib}/components/CustomToggleButton/CustomToggleButton.stories.d.ts +0 -0
  50. /package/{lib → src/lib}/components/CustomToggleButton/index.d.ts +0 -0
  51. /package/{lib → src/lib}/components/CustomTooltip/CustomTooltip.d.ts +0 -0
  52. /package/{lib → src/lib}/components/CustomTooltip/CustomTooltip.spec.d.ts +0 -0
  53. /package/{lib → src/lib}/components/CustomTooltip/index.d.ts +0 -0
  54. /package/{lib → src/lib}/components/DraggableResizable/Draggable.d.ts +0 -0
  55. /package/{lib → src/lib}/components/DraggableResizable/Draggable.spec.d.ts +0 -0
  56. /package/{lib → src/lib}/components/DraggableResizable/Resizable.d.ts +0 -0
  57. /package/{lib → src/lib}/components/DraggableResizable/Resizable.spec.d.ts +0 -0
  58. /package/{lib → src/lib}/components/DraggableResizable/index.d.ts +0 -0
  59. /package/{lib → src/lib}/components/DraggableResizable/types.d.ts +0 -0
  60. /package/{lib → src/lib}/components/ErrorBoundary/ErrorBoundary.d.ts +0 -0
  61. /package/{lib → src/lib}/components/ErrorBoundary/ErrorBoundary.spec.d.ts +0 -0
  62. /package/{lib → src/lib}/components/ErrorBoundary/ErrorBoundary.stories.d.ts +0 -0
  63. /package/{lib → src/lib}/components/ErrorBoundary/index.d.ts +0 -0
  64. /package/{lib → src/lib}/components/Providers/Providers.d.ts +0 -0
  65. /package/{lib → src/lib}/components/Providers/index.d.ts +0 -0
  66. /package/{lib → src/lib}/components/SearchHighlight/SearchHighlight.d.ts +0 -0
  67. /package/{lib → src/lib}/components/SearchHighlight/SearchHighlight.spec.d.ts +0 -0
  68. /package/{lib → src/lib}/components/SearchHighlight/SearchHighlight.stories.d.ts +0 -0
  69. /package/{lib → src/lib}/components/SearchHighlight/index.d.ts +0 -0
  70. /package/{lib → src/lib}/components/StatusTag/StatusTag.d.ts +0 -0
  71. /package/{lib → src/lib}/components/StatusTag/StatusTag.spec.d.ts +0 -0
  72. /package/{lib → src/lib}/components/StatusTag/StatusTag.stories.d.ts +0 -0
  73. /package/{lib → src/lib}/components/StatusTag/index.d.ts +0 -0
  74. /package/{lib → src/lib}/components/ToggleMenu/ToggleMenu.d.ts +0 -0
  75. /package/{lib → src/lib}/components/ToggleMenu/ToggleMenu.spec.d.ts +0 -0
  76. /package/{lib → src/lib}/components/ToggleMenu/ToggleMenu.stories.d.ts +0 -0
  77. /package/{lib → src/lib}/components/ToggleMenu/index.d.ts +0 -0
  78. /package/{lib → src/lib}/components/ToolContainer/ToolContainer.d.ts +0 -0
  79. /package/{lib → src/lib}/components/ToolContainer/ToolContainer.spec.d.ts +0 -0
  80. /package/{lib → src/lib}/components/ToolContainer/ToolContainer.stories.d.ts +0 -0
  81. /package/{lib → src/lib}/components/ToolContainer/ToolContainerDraggable.d.ts +0 -0
  82. /package/{lib → src/lib}/components/ToolContainer/ToolContainerDraggable.spec.d.ts +0 -0
  83. /package/{lib → src/lib}/components/ToolContainer/ToolContainerDraggable.stories.d.ts +0 -0
  84. /package/{lib → src/lib}/components/ToolContainer/ToolContainerSnapShots.stories.d.ts +0 -0
  85. /package/{lib → src/lib}/components/ToolContainer/ToolFooter.d.ts +0 -0
  86. /package/{lib → src/lib}/components/ToolContainer/ToolFooter.spec.d.ts +0 -0
  87. /package/{lib → src/lib}/components/ToolContainer/ToolHeader.d.ts +0 -0
  88. /package/{lib → src/lib}/components/ToolContainer/ToolHeader.spec.d.ts +0 -0
  89. /package/{lib → src/lib}/components/ToolContainer/ToolHeader.stories.d.ts +0 -0
  90. /package/{lib → src/lib}/components/ToolContainer/index.d.ts +0 -0
  91. /package/{lib → src/lib}/components/ToolContainer/types.d.ts +0 -0
  92. /package/{lib → src/lib}/components/ToolContainer/useHandleSizeFromOutsideComponent.d.ts +0 -0
  93. /package/{lib → src/lib}/components/ToolContainer/useHandleSizeFromOutsideComponent.spec.d.ts +0 -0
  94. /package/{lib → src/lib}/components/TooltipSelect/TooltipSelect.d.ts +0 -0
  95. /package/{lib → src/lib}/components/TooltipSelect/TooltipSelect.spec.d.ts +0 -0
  96. /package/{lib → src/lib}/components/TooltipSelect/TooltipSelect.stories.d.ts +0 -0
  97. /package/{lib → src/lib}/components/TooltipSelect/index.d.ts +0 -0
  98. /package/{lib → src/lib}/components/TooltipSelect/tooltipContainerStyles.d.ts +0 -0
  99. /package/{lib → src/lib}/components/UserMenu/CheatSheet/CheatSheet.d.ts +0 -0
  100. /package/{lib → src/lib}/components/UserMenu/CheatSheet/CheatSheet.spec.d.ts +0 -0
  101. /package/{lib → src/lib}/components/UserMenu/CheatSheet/CheatSheet.stories.d.ts +0 -0
  102. /package/{lib → src/lib}/components/UserMenu/CheatSheet/ShortcutList.d.ts +0 -0
  103. /package/{lib → src/lib}/components/UserMenu/CheatSheet/ShortcutList.spec.d.ts +0 -0
  104. /package/{lib → src/lib}/components/UserMenu/CheatSheet/ShortcutSegment.d.ts +0 -0
  105. /package/{lib → src/lib}/components/UserMenu/CheatSheet/ShortcutSegment.spec.d.ts +0 -0
  106. /package/{lib → src/lib}/components/UserMenu/UserMenu.d.ts +0 -0
  107. /package/{lib → src/lib}/components/UserMenu/UserMenu.spec.d.ts +0 -0
  108. /package/{lib → src/lib}/components/UserMenu/UserMenu.stories.d.ts +0 -0
  109. /package/{lib → src/lib}/components/UserMenu/UserMenuItemCheatSheet.d.ts +0 -0
  110. /package/{lib → src/lib}/components/UserMenu/UserMenuItemCheatSheet.spec.d.ts +0 -0
  111. /package/{lib → src/lib}/components/UserMenu/UserMenuItemTheme.d.ts +0 -0
  112. /package/{lib → src/lib}/components/UserMenu/UserMenuItemTheme.spec.d.ts +0 -0
  113. /package/{lib → src/lib}/components/UserMenu/index.d.ts +0 -0
  114. /package/{lib → src/lib}/components/UserMenu/useUserMenu.d.ts +0 -0
  115. /package/{lib → src/lib}/components/UserMenu/useUserMenu.spec.d.ts +0 -0
  116. /package/{lib → src/lib}/components/UserMenu/utils.d.ts +0 -0
  117. /package/{lib → src/lib}/components/WithEggs/WithEggs.d.ts +0 -0
  118. /package/{lib → src/lib}/components/WithEggs/WithEggs.spec.d.ts +0 -0
  119. /package/{lib → src/lib}/components/WithEggs/index.d.ts +0 -0
  120. /package/{lib → src/lib}/components/components.stories.d.ts +0 -0
  121. /package/{lib → src/lib}/components/index.d.ts +0 -0
  122. /package/{lib → src/lib}/hooks/index.d.ts +0 -0
  123. /package/{lib → src/lib}/hooks/useIsMounted/useIsMounted.d.ts +0 -0
  124. /package/{lib → src/lib}/hooks/useIsMounted/useIsMounted.spec.d.ts +0 -0
  125. /package/{lib → src/lib}/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.d.ts +0 -0
  126. /package/{lib → src/lib}/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.spec.d.ts +0 -0
  127. /package/{lib → src/lib}/hooks/usePoller/usePoller.d.ts +0 -0
  128. /package/{lib → src/lib}/hooks/usePoller/usePoller.spec.d.ts +0 -0
  129. /package/{lib → src/lib}/hooks/usePoller/usePoller.stories.d.ts +0 -0
  130. /package/{lib → src/lib}/hooks/usePreventBrowserClose/usePreventBrowserClose.d.ts +0 -0
  131. /package/{lib → src/lib}/hooks/usePreventBrowserClose/usePreventBrowserClose.spec.d.ts +0 -0
  132. /package/{lib → src/lib}/hooks/usePreventBrowserClose/usePreventBrowserClose.stories.d.ts +0 -0
  133. /package/{lib → src/lib}/hooks/usePrevious/usePrevious.d.ts +0 -0
  134. /package/{lib → src/lib}/hooks/usePrevious/usePrevious.spec.d.ts +0 -0
  135. /package/{lib → src/lib}/hooks/usePrevious/usePrevious.stories.d.ts +0 -0
  136. /package/{lib → src/lib}/storyshots/Storyshots.spec.d.ts +0 -0
  137. /package/{lib → src/lib}/utils/axiosErrorUtils/axiosErrorUtils.spec.d.ts +0 -0
  138. /package/{lib → src/lib}/utils/axiosErrorUtils/index.d.ts +0 -0
  139. /package/{lib → src/lib}/utils/dateUtils/dateUtils.spec.d.ts +0 -0
  140. /package/{lib → src/lib}/utils/dateUtils/index.d.ts +0 -0
  141. /package/{lib → src/lib}/utils/index.d.ts +0 -0
package/index.umd.js DELETED
@@ -1,3537 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('@opengeoweb/theme'), require('lodash'), require('react-draggable'), require('re-resizable'), require('react-redux'), require('date-fns')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', '@opengeoweb/theme', 'lodash', 'react-draggable', 're-resizable', 'react-redux', 'date-fns'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Shared = {}, global.React, global.material, global.theme, global.lodash, global.Draggable, global.reResizable, global.reactRedux, global.dateFns));
5
- })(this, (function (exports, React, material, theme, lodash, Draggable, reResizable, reactRedux, dateFns) { '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
- /* global Reflect, Promise */
46
-
47
- var extendStatics = function(d, b) {
48
- extendStatics = Object.setPrototypeOf ||
49
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
51
- return extendStatics(d, b);
52
- };
53
-
54
- function __extends(d, b) {
55
- if (typeof b !== "function" && b !== null)
56
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
57
- extendStatics(d, b);
58
- function __() { this.constructor = d; }
59
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
60
- }
61
-
62
- var __assign = function() {
63
- __assign = Object.assign || function __assign(t) {
64
- for (var s, i = 1, n = arguments.length; i < n; i++) {
65
- s = arguments[i];
66
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
67
- }
68
- return t;
69
- };
70
- return __assign.apply(this, arguments);
71
- };
72
-
73
- function __rest(s, e) {
74
- var t = {};
75
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
76
- t[p] = s[p];
77
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
78
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
79
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
80
- t[p[i]] = s[p[i]];
81
- }
82
- return t;
83
- }
84
-
85
- function __read(o, n) {
86
- var m = typeof Symbol === "function" && o[Symbol.iterator];
87
- if (!m) return o;
88
- var i = m.call(o), r, ar = [], e;
89
- try {
90
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
91
- }
92
- catch (error) { e = { error: error }; }
93
- finally {
94
- try {
95
- if (r && !r.done && (m = i["return"])) m.call(i);
96
- }
97
- finally { if (e) throw e.error; }
98
- }
99
- return ar;
100
- }
101
-
102
- function __spreadArray(to, from, pack) {
103
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
104
- if (ar || !(i in from)) {
105
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
106
- ar[i] = from[i];
107
- }
108
- }
109
- return to.concat(ar || Array.prototype.slice.call(from));
110
- }
111
-
112
- var bgColors = {
113
- green: 'geowebColors.functional.successOutline.fill',
114
- grey: 'geowebColors.functional.disabledOutline.fill',
115
- purple: 'geowebColors.functional.summaryOutline.fill',
116
- red: 'geowebColors.functional.errorOutline.fill',
117
- yellow: 'geowebColors.functional.warningOutline.fill',
118
- blue: 'geowebColors.functional.notificationOutline.fill'
119
- };
120
- var borderColors = {
121
- green: 'geowebColors.functional.successOutline.borderColor',
122
- grey: 'geowebColors.functional.disabledOutline.borderColor',
123
- purple: 'geowebColors.functional.summaryOutline.borderColor',
124
- red: 'geowebColors.functional.errorOutline.borderColor',
125
- yellow: 'geowebColors.functional.warningOutline.borderColor',
126
- blue: 'geowebColors.functional.notificationOutline.borderColor'
127
- };
128
-
129
- var tagStyle = function tagStyle(color) {
130
- // Set color to grey for summary
131
- var backgroundColor = __assign({}, bgColors)[color];
132
-
133
- var borderColor = __assign({}, borderColors)[color];
134
-
135
- return {
136
- backgroundColor: backgroundColor,
137
- m: 0,
138
- p: 0,
139
- border: '1px solid',
140
- borderColor: borderColor,
141
- borderRadius: '4px',
142
- width: '120px',
143
- height: '18px',
144
- lineHeight: '16px',
145
- color: 'geowebColors.captions.captionStatus.rgba'
146
- };
147
- };
148
-
149
- var StatusTag = function StatusTag(_a) {
150
- var content = _a.content,
151
- color = _a.color,
152
- props = __rest(_a, ["content", "color"]);
153
-
154
- return /*#__PURE__*/React__namespace.createElement(material.Box, {
155
- display: "flex",
156
- alignItems: "center",
157
- justifyContent: "center",
158
- "data-testid": "statusTag",
159
- className: "statusTag",
160
- sx: __assign(__assign({}, tagStyle(color)), props.sx)
161
- }, /*#__PURE__*/React__namespace.createElement(material.Typography, {
162
- variant: "caption"
163
- }, content));
164
- };
165
-
166
- /* *
167
- * Licensed under the Apache License, Version 2.0 (the "License");
168
- * you may not use this file except in compliance with the License.
169
- * You may obtain a copy of the License at
170
- *
171
- * http://www.apache.org/licenses/LICENSE-2.0
172
- *
173
- * Unless required by applicable law or agreed to in writing, software
174
- * distributed under the License is distributed on an "AS IS" BASIS,
175
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
176
- * See the License for the specific language governing permissions and
177
- * limitations under the License.
178
- *
179
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
180
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
181
- * */
182
- var defaultDelay = 1000;
183
- var useControlledTooltip = function useControlledTooltip() {
184
- var _a = __read(React__namespace.useState(false), 2),
185
- tooltipOpen = _a[0],
186
- setTooltipOpen = _a[1];
187
-
188
- var _b = __read(React__namespace.useState(false), 2),
189
- delayedTooltip = _b[0],
190
- setDelayedTooltip = _b[1];
191
-
192
- React__namespace.useEffect(function () {
193
- if (tooltipOpen === true) {
194
- var timer_1 = setTimeout(function () {
195
- return setDelayedTooltip(true);
196
- }, defaultDelay);
197
- return function () {
198
- clearTimeout(timer_1);
199
- };
200
- }
201
-
202
- setDelayedTooltip(false);
203
- return function () {};
204
- }, [tooltipOpen]);
205
- return [delayedTooltip, setTooltipOpen];
206
- };
207
- var CustomTooltip = function CustomTooltip(props) {
208
- return /*#__PURE__*/React__namespace.createElement(material.Tooltip, __assign({}, props, {
209
- enterDelay: defaultDelay,
210
- enterNextDelay: defaultDelay,
211
- disableInteractive: true
212
- }));
213
- };
214
-
215
- /* *
216
- * Licensed under the Apache License, Version 2.0 (the "License");
217
- * you may not use this file except in compliance with the License.
218
- * You may obtain a copy of the License at
219
- *
220
- * http://www.apache.org/licenses/LICENSE-2.0
221
- *
222
- * Unless required by applicable law or agreed to in writing, software
223
- * distributed under the License is distributed on an "AS IS" BASIS,
224
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
225
- * See the License for the specific language governing permissions and
226
- * limitations under the License.
227
- *
228
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
229
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
230
- * */
231
- var CustomIconButton = /*#__PURE__*/React__namespace.forwardRef(function (_a, ref) {
232
- var _b = _a.tooltipTitle,
233
- defaultTooltipTitle = _b === void 0 ? '' : _b,
234
- _c = _a.variant,
235
- variant = _c === void 0 ? 'flat' : _c,
236
- _d = _a.isSelected,
237
- isSelected = _d === void 0 ? false : _d,
238
- _e = _a.shouldShowAsDisabled,
239
- shouldShowAsDisabled = _e === void 0 ? false : _e,
240
- _f = _a.size,
241
- size = _f === void 0 ? 'small' : _f,
242
- children = _a.children,
243
- className = _a.className,
244
- defaultTooltipProps = _a.tooltipProps,
245
- props = __rest(_a, ["tooltipTitle", "variant", "isSelected", "shouldShowAsDisabled", "size", "children", "className", "tooltipProps"]);
246
-
247
- var classNames = __spreadArray(__spreadArray(__spreadArray([], __read(className ? [className] : [])), __read(isSelected ? ['Mui-selected'] : [])), [variant]).join(' ');
248
-
249
- var tooltipTitle = (defaultTooltipProps === null || defaultTooltipProps === void 0 ? void 0 : defaultTooltipProps.title) || defaultTooltipTitle;
250
-
251
- var tooltipProps = __assign(__assign({}, defaultTooltipProps), {
252
- title: tooltipTitle,
253
- placement: (defaultTooltipProps === null || defaultTooltipProps === void 0 ? void 0 : defaultTooltipProps.placement) || 'top',
254
- sx: {
255
- pointerEvents: 'none'
256
- }
257
- });
258
-
259
- var renderIconButton = function renderIconButton() {
260
- return /*#__PURE__*/React__namespace.createElement(material.IconButton, __assign({
261
- "aria-label": tooltipTitle
262
- }, props, {
263
- size: size,
264
- className: classNames,
265
- ref: ref,
266
- sx: __assign(__assign({}, props.sx), shouldShowAsDisabled && {
267
- '&.MuiIconButton-root': {
268
- color: "geowebColors.iconButtons." + variant + ".disabled.color"
269
- },
270
- '&.Mui-focusVisible': {
271
- color: "geowebColors.iconButtons." + variant + ".default.color"
272
- }
273
- })
274
- }), children);
275
- };
276
-
277
- return tooltipTitle && !props.disabled ? /*#__PURE__*/React__namespace.createElement(CustomTooltip, __assign({}, tooltipProps), renderIconButton()) : renderIconButton();
278
- });
279
-
280
- var CustomDialog = function CustomDialog(_a) {
281
- var title = _a.title,
282
- _onClose = _a.onClose,
283
- _b = _a.description,
284
- description = _b === void 0 ? '' : _b,
285
- _c = _a.actions,
286
- actions = _c === void 0 ? null : _c,
287
- children = _a.children,
288
- sx = _a.sx,
289
- other = __rest(_a, ["title", "onClose", "description", "actions", "children", "sx"]);
290
-
291
- return /*#__PURE__*/React__namespace.createElement(material.Dialog, __assign({
292
- "data-testid": "customDialog",
293
- PaperProps: {
294
- sx: __assign({
295
- width: '560px',
296
- margin: 2.5
297
- }, sx)
298
- },
299
- // fix for briefly showing default options when closing dialog
300
- transitionDuration: 0,
301
- onClose: function onClose() {
302
- _onClose('CLOSED');
303
- },
304
- "aria-labelledby": "dialog-title"
305
- }, other), /*#__PURE__*/React__namespace.createElement(material.DialogTitle, {
306
- id: "dialog-title",
307
- sx: {
308
- zIndex: 1,
309
- padding: 2,
310
- display: 'flex',
311
- justifyContent: 'space-between',
312
- alignItems: 'center'
313
- }
314
- }, /*#__PURE__*/React__namespace.createElement(material.Typography, {
315
- sx: {
316
- fontSize: '16px',
317
- fontWeight: 500
318
- },
319
- "data-testid": "customDialog-title",
320
- component: "span"
321
- }, title), /*#__PURE__*/React__namespace.createElement(CustomIconButton, {
322
- "data-testid": "customDialog-close",
323
- "aria-label": "close",
324
- onClick: function onClick() {
325
- return _onClose('CLOSED');
326
- },
327
- sx: {
328
- '&.MuiIconButton-root': {
329
- color: 'geowebColors.greys.accessible'
330
- }
331
- }
332
- }, /*#__PURE__*/React__namespace.createElement(theme.Close, {
333
- "data-testid": "CloseIcon"
334
- }))), /*#__PURE__*/React__namespace.createElement(material.DialogContent, {
335
- sx: {
336
- padding: '8px 16px'
337
- }
338
- }, description && /*#__PURE__*/React__namespace.createElement(material.Typography, {
339
- variant: "body1"
340
- }, description), children), /*#__PURE__*/React__namespace.createElement(material.DialogActions, {
341
- sx: {
342
- padding: 2,
343
- flexDirection: {
344
- xs: 'column',
345
- sm: 'row'
346
- }
347
- }
348
- }, actions));
349
- };
350
-
351
- var confirmStyle = {
352
- width: {
353
- xs: '100%',
354
- sm: '150px'
355
- },
356
- marginLeft: {
357
- xs: '0px!important',
358
- sm: '8px!important'
359
- },
360
- marginTop: {
361
- xs: 2,
362
- sm: 0
363
- }
364
- };
365
- var ConfirmationDialog = function ConfirmationDialog(_a) {
366
- var open = _a.open,
367
- title = _a.title,
368
- _b = _a.description,
369
- description = _b === void 0 ? 'Are you sure?' : _b,
370
- _c = _a.confirmLabel,
371
- confirmLabel = _c === void 0 ? 'Submit' : _c,
372
- _d = _a.cancelLabel,
373
- cancelLabel = _d === void 0 ? 'Go back' : _d,
374
- onSubmit = _a.onSubmit,
375
- onClose = _a.onClose,
376
- _e = _a.content,
377
- content = _e === void 0 ? null : _e,
378
- _f = _a.disableAutoFocus,
379
- disableAutoFocus = _f === void 0 ? false : _f,
380
- _g = _a.isLoading,
381
- isLoading = _g === void 0 ? false : _g,
382
- other = __rest(_a, ["open", "title", "description", "confirmLabel", "cancelLabel", "onSubmit", "onClose", "content", "disableAutoFocus", "isLoading"]);
383
-
384
- other.catchOnCancel;
385
- var rest = __rest(other, ["catchOnCancel"]); // remove unwanted props
386
-
387
-
388
- return /*#__PURE__*/React__namespace.createElement(CustomDialog, __assign({
389
- "data-testid": "confirmationDialog",
390
- open: open,
391
- title: title,
392
- description: description,
393
- onClose: onClose,
394
- actions: /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(material.Button, {
395
- "data-testid": "confirmationDialog-cancel",
396
- variant: "tertiary",
397
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
398
- sx: function sx(theme) {
399
- return {
400
- width: {
401
- xs: '100%',
402
- sm: '150px'
403
- },
404
- '&:focus': {
405
- outline: theme.palette.geowebColors.buttons.primary.focus.outline,
406
- borderColor: 'transparent'
407
- }
408
- };
409
- },
410
- onClick: function onClick() {
411
- return onClose('CANCELLED');
412
- }
413
- }, cancelLabel), isLoading ? /*#__PURE__*/React__namespace.createElement(material.Box, {
414
- "data-testid": "confirm-dialog-spinner",
415
- sx: __assign(__assign({}, confirmStyle), {
416
- height: '40px',
417
- display: 'flex',
418
- justifyContent: 'center',
419
- alignItems: 'center'
420
- })
421
- }, /*#__PURE__*/React__namespace.createElement(material.CircularProgress, {
422
- size: 40,
423
- color: "secondary"
424
- })) : /*#__PURE__*/React__namespace.createElement(material.Button, {
425
- "data-testid": "confirmationDialog-confirm",
426
- variant: "primary",
427
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
428
- sx: function sx(theme) {
429
- return __assign(__assign({}, confirmStyle), {
430
- '&:focus': {
431
- outline: theme.palette.geowebColors.buttons.primary.focus.outline,
432
- borderColor: 'transparent'
433
- }
434
- });
435
- },
436
- onClick: onSubmit,
437
- autoFocus: !disableAutoFocus
438
- }, confirmLabel))
439
- }, rest), content);
440
- };
441
-
442
- /* *
443
- * Licensed under the Apache License, Version 2.0 (the "License");
444
- * you may not use this file except in compliance with the License.
445
- * You may obtain a copy of the License at
446
- *
447
- * http://www.apache.org/licenses/LICENSE-2.0
448
- *
449
- * Unless required by applicable law or agreed to in writing, software
450
- * distributed under the License is distributed on an "AS IS" BASIS,
451
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
452
- * See the License for the specific language governing permissions and
453
- * limitations under the License.
454
- *
455
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
456
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
457
- * */
458
- var showPrompt = function showPrompt(event) {
459
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
460
- // @ts-ignore
461
- // eslint-disable-next-line no-param-reassign
462
- event.returnValue = 'Changes that you made may not be saved.'; // changes are your browser have default text to overrule this
463
- };
464
- function usePreventBrowserClose(shouldPreventClose) {
465
- React__namespace.useEffect(function () {
466
- if (shouldPreventClose) {
467
- window.addEventListener('beforeunload', showPrompt);
468
- } else {
469
- window.removeEventListener('beforeunload', showPrompt);
470
- }
471
-
472
- return function () {
473
- window.removeEventListener('beforeunload', showPrompt);
474
- };
475
- }, [shouldPreventClose]);
476
- }
477
-
478
- /* *
479
- * Licensed under the Apache License, Version 2.0 (the "License");
480
- * you may not use this file except in compliance with the License.
481
- * You may obtain a copy of the License at
482
- *
483
- * http://www.apache.org/licenses/LICENSE-2.0
484
- *
485
- * Unless required by applicable law or agreed to in writing, software
486
- * distributed under the License is distributed on an "AS IS" BASIS,
487
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
488
- * See the License for the specific language governing permissions and
489
- * limitations under the License.
490
- *
491
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
492
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
493
- * */
494
- var usePoller = function usePoller(deps, callback, pollingInterval) {
495
- if (pollingInterval === void 0) {
496
- pollingInterval = 300000;
497
- }
498
-
499
- var interval = React.useRef(null);
500
- React__namespace.useEffect(function () {
501
- if (deps.filter(function (dep) {
502
- return dep !== null;
503
- }).length > 0) {
504
- if (interval.current) {
505
- clearInterval(interval.current);
506
- }
507
-
508
- interval.current = setInterval(function () {
509
- callback();
510
- }, pollingInterval);
511
- }
512
-
513
- return function () {
514
- if (interval.current) {
515
- clearInterval(interval.current);
516
- }
517
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
518
- }, [deps]);
519
- return interval;
520
- };
521
-
522
- /* *
523
- * Licensed under the Apache License, Version 2.0 (the "License");
524
- * you may not use this file except in compliance with the License.
525
- * You may obtain a copy of the License at
526
- *
527
- * http://www.apache.org/licenses/LICENSE-2.0
528
- *
529
- * Unless required by applicable law or agreed to in writing, software
530
- * distributed under the License is distributed on an "AS IS" BASIS,
531
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
532
- * See the License for the specific language governing permissions and
533
- * limitations under the License.
534
- *
535
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
536
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
537
- * */
538
- function usePrevious(value) {
539
- var ref = React__namespace.useRef();
540
- React__namespace.useEffect(function () {
541
- ref.current = value;
542
- });
543
- return ref.current;
544
- }
545
-
546
- /* *
547
- * Licensed under the Apache License, Version 2.0 (the "License");
548
- * you may not use this file except in compliance with the License.
549
- * You may obtain a copy of the License at
550
- *
551
- * http://www.apache.org/licenses/LICENSE-2.0
552
- *
553
- * Unless required by applicable law or agreed to in writing, software
554
- * distributed under the License is distributed on an "AS IS" BASIS,
555
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
556
- * See the License for the specific language governing permissions and
557
- * limitations under the License.
558
- *
559
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
560
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
561
- * */
562
- var useIsMounted = function useIsMounted() {
563
- var isMounted = React__namespace.useRef(false);
564
- React__namespace.useEffect(function () {
565
- isMounted.current = true;
566
- return function () {
567
- isMounted.current = false;
568
- };
569
- }, []);
570
- return {
571
- isMounted: isMounted
572
- };
573
- };
574
-
575
- var adjustPosition = function adjustPosition(bbox, containingView, position, setPosition) {
576
- var isHorizontallyLarger = bbox.width > containingView.width;
577
- var isVerticallyLarger = bbox.height > containingView.height; // Check corner cases first
578
- // bottom left
579
-
580
- if (bbox.x < containingView.x && bbox.bottom >= containingView.bottom) {
581
- var diffX = containingView.x - bbox.x;
582
- var diffY = containingView.bottom - bbox.bottom;
583
- setPosition({
584
- x: position.x + diffX,
585
- y: position.y + diffY
586
- });
587
- } else if ( // bottom right
588
- bbox.right >= containingView.right && bbox.bottom >= containingView.bottom) {
589
- var diffX = containingView.right - bbox.right;
590
- var diffY = containingView.bottom - bbox.bottom;
591
- setPosition({
592
- x: position.x + diffX,
593
- y: position.y + diffY
594
- });
595
- } else if (bbox.x < containingView.x || isHorizontallyLarger) {
596
- // left screen
597
- var diffX = containingView.x - bbox.x;
598
- setPosition(__assign(__assign({}, position), {
599
- x: position.x + diffX
600
- }));
601
- } else if (bbox.right >= containingView.right) {
602
- // right screen
603
- var diffX = containingView.right - bbox.right;
604
- setPosition(__assign(__assign({}, position), {
605
- x: position.x + diffX
606
- }));
607
- } else if (bbox.y < containingView.y || isVerticallyLarger) {
608
- // top screen
609
- var diffY = containingView.y - bbox.y;
610
- setPosition(__assign(__assign({}, position), {
611
- y: position.y + diffY
612
- }));
613
- } else if (bbox.bottom >= containingView.bottom) {
614
- // bottom screen
615
- var diffY = containingView.bottom - bbox.bottom;
616
- setPosition(__assign(__assign({}, position), {
617
- y: position.y + diffY
618
- }));
619
- }
620
- };
621
- var useMakeSureContainerStaysInsideWindow = function useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition) {
622
- var onResizeWindow = React__default["default"].useCallback(function () {
623
- if (!nodeRef.current) {
624
- return;
625
- }
626
-
627
- var bbox = nodeRef.current.firstChild.getBoundingClientRect();
628
- var containingView = nodeRef.current.parentElement.getBoundingClientRect();
629
- adjustPosition(bbox, containingView, position, setPosition);
630
- }, [nodeRef, position, setPosition]);
631
- React__default["default"].useEffect(function () {
632
- var throttledResize = lodash.throttle(onResizeWindow, 100);
633
- window.addEventListener('resize', throttledResize);
634
- return function () {
635
- window.removeEventListener('resize', throttledResize);
636
- };
637
- }, [onResizeWindow]);
638
- };
639
-
640
- var ConfirmationServiceContext = /*#__PURE__*/React__namespace.createContext(Promise.reject);
641
- var useConfirmationDialog = function useConfirmationDialog() {
642
- return React__namespace.useContext(ConfirmationServiceContext);
643
- };
644
- var useDialogActions = function useDialogActions(awaitingPromiseRef, defaultOptions) {
645
- if (defaultOptions === void 0) {
646
- defaultOptions = null;
647
- }
648
-
649
- var isMounted = useIsMounted().isMounted;
650
-
651
- var _a = __read(React__namespace.useState(defaultOptions), 2),
652
- confirmationState = _a[0],
653
- setConfirmationState = _a[1];
654
-
655
- var openConfirmation = function openConfirmation(options) {
656
- setConfirmationState(options);
657
- return new Promise(function (resolve, reject) {
658
- // since this is a React.ref it's safe to reassign it, although eslint says no
659
- // eslint-disable-next-line no-param-reassign
660
- awaitingPromiseRef.current = {
661
- resolve: resolve,
662
- reject: reject
663
- };
664
- });
665
- }; // clears state with timeout delay so optional values provided by the prop 'content' of ConfirmationDialog can be read
666
-
667
-
668
- var clearState = function clearState() {
669
- return setTimeout(function () {
670
- if (isMounted.current) {
671
- setConfirmationState(null);
672
- }
673
- }, 0);
674
- };
675
-
676
- var handleClose = function handleClose(reason) {
677
- if (confirmationState && confirmationState.catchOnCancel && awaitingPromiseRef.current) {
678
- awaitingPromiseRef.current.reject(reason);
679
- }
680
-
681
- clearState();
682
- };
683
-
684
- var handleSubmit = function handleSubmit() {
685
- if (awaitingPromiseRef.current) {
686
- awaitingPromiseRef.current.resolve();
687
- }
688
-
689
- clearState();
690
- };
691
-
692
- return {
693
- openConfirmation: openConfirmation,
694
- confirmationState: confirmationState,
695
- handleSubmit: handleSubmit,
696
- handleClose: handleClose
697
- };
698
- };
699
- var ConfirmationServiceProvider = function ConfirmationServiceProvider(_a) {
700
- var children = _a.children;
701
- var awaitingPromiseRef = React__namespace.useRef({
702
- resolve: function resolve() {
703
- return Promise.resolve();
704
- },
705
- reject: function reject() {
706
- return Promise.reject();
707
- }
708
- });
709
-
710
- var _b = useDialogActions(awaitingPromiseRef),
711
- openConfirmation = _b.openConfirmation,
712
- confirmationState = _b.confirmationState,
713
- handleSubmit = _b.handleSubmit,
714
- handleClose = _b.handleClose;
715
-
716
- return /*#__PURE__*/React__namespace.createElement(ConfirmationServiceContext.Provider, {
717
- value: openConfirmation
718
- }, children, /*#__PURE__*/React__namespace.createElement(ConfirmationDialog, __assign({
719
- open: Boolean(confirmationState),
720
- onSubmit: handleSubmit,
721
- onClose: handleClose
722
- }, confirmationState)));
723
- };
724
-
725
- /* *
726
- * Licensed under the Apache License, Version 2.0 (the "License");
727
- * you may not use this file except in compliance with the License.
728
- * You may obtain a copy of the License at
729
- *
730
- * http://www.apache.org/licenses/LICENSE-2.0
731
- *
732
- * Unless required by applicable law or agreed to in writing, software
733
- * distributed under the License is distributed on an "AS IS" BASIS,
734
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
735
- * See the License for the specific language governing permissions and
736
- * limitations under the License.
737
- *
738
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
739
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
740
- * */
741
-
742
- var AlertIcon = function AlertIcon(_a) {
743
- var _b = _a.severity,
744
- severity = _b === void 0 ? 'error' : _b,
745
- _c = _a.dataTestId,
746
- dataTestId = _c === void 0 ? 'alert-icon' : _c;
747
-
748
- switch (severity) {
749
- case 'info':
750
- return /*#__PURE__*/React__namespace.createElement(theme.Info, {
751
- sx: {
752
- color: 'geowebColors.functional.notification'
753
- },
754
- "data-testid": dataTestId
755
- });
756
-
757
- case 'success':
758
- return /*#__PURE__*/React__namespace.createElement(theme.Success, {
759
- sx: {
760
- color: 'geowebColors.functional.success'
761
- },
762
- "data-testid": dataTestId
763
- });
764
-
765
- case 'warning':
766
- return /*#__PURE__*/React__namespace.createElement(theme.Exclamation, {
767
- sx: {
768
- color: 'geowebColors.functional.warning'
769
- },
770
- "data-testid": dataTestId
771
- });
772
-
773
- case 'error':
774
- default:
775
- return /*#__PURE__*/React__namespace.createElement(theme.Exclamation, {
776
- sx: {
777
- color: 'geowebColors.functional.error'
778
- },
779
- "data-testid": dataTestId
780
- });
781
- }
782
- };
783
-
784
- var AlertBanner = function AlertBanner(_a) {
785
- var title = _a.title,
786
- _b = _a.severity,
787
- severity = _b === void 0 ? 'error' : _b,
788
- _c = _a.info,
789
- info = _c === void 0 ? '' : _c,
790
- _d = _a.dataTestId,
791
- dataTestId = _d === void 0 ? 'alert-banner' : _d,
792
- _e = _a.isCompact,
793
- isCompact = _e === void 0 ? false : _e,
794
- _f = _a.shouldClose,
795
- shouldClose = _f === void 0 ? false : _f,
796
- _g = _a.actionButtonProps,
797
- actionButtonProps = _g === void 0 ? undefined : _g;
798
-
799
- var _h = __read(React__namespace.useState(true), 2),
800
- isOpen = _h[0],
801
- setIsOpen = _h[1];
802
-
803
- if (!isOpen) {
804
- return null;
805
- }
806
-
807
- return /*#__PURE__*/React__namespace.createElement(material.Alert, {
808
- "data-testid": dataTestId,
809
- severity: severity,
810
- icon: /*#__PURE__*/React__namespace.createElement(AlertIcon, {
811
- severity: severity
812
- }),
813
- action: shouldClose ? /*#__PURE__*/React__namespace.createElement(material.Button, {
814
- variant: "flat",
815
- onClick: function onClick() {
816
- return setIsOpen(false);
817
- },
818
- sx: {
819
- backgroundColor: 'transparent!important'
820
- }
821
- }, "CLOSE") : undefined,
822
- sx: isCompact ? {
823
- height: '32px',
824
- boxSizing: 'border-box',
825
- '& .MuiAlert-message': {
826
- padding: '0px',
827
- whiteSpace: 'nowrap',
828
- overflow: 'hidden',
829
- textOverflow: 'ellipsis',
830
- '& .MuiTypography-root': {
831
- display: 'inline'
832
- }
833
- },
834
- '& .MuiAlert-icon': {
835
- marginTop: '-3px',
836
- padding: '0px'
837
- }
838
- } : {
839
- padding: '3px 16px',
840
- '& .MuiAlert-message': {
841
- padding: '8px 0'
842
- },
843
- '& .MuiAlert-icon': {
844
- padding: '8px 0'
845
- },
846
- '& .MuiAlert-action': {
847
- padding: 0
848
- }
849
- }
850
- }, /*#__PURE__*/React__namespace.createElement(material.AlertTitle, {
851
- sx: {
852
- fontSize: '14px',
853
- fontWeight: 'normal',
854
- marginTop: '0px!important',
855
- paddingTop: '0px!important',
856
- marginBottom: '0px!important',
857
- lineHeight: isCompact ? '18px' : '24px'
858
- }
859
- }, title), info && /*#__PURE__*/React__namespace.createElement(material.Box, {
860
- sx: {
861
- fontSize: '16px',
862
- marginTop: 1,
863
- wordBreak: 'break-word',
864
- lineHeight: '22px'
865
- }
866
- }, info), actionButtonProps && /*#__PURE__*/React__namespace.createElement(material.Button, {
867
- variant: "flat",
868
- onClick: function onClick(event) {
869
- setIsOpen(false);
870
- actionButtonProps.onClick(event);
871
- },
872
- sx: {
873
- backgroundColor: 'transparent!important'
874
- },
875
- startIcon: /*#__PURE__*/React__namespace.createElement(theme.ChevronRight, null)
876
- }, actionButtonProps.title.toUpperCase()));
877
- };
878
-
879
- /* *
880
- * Licensed under the Apache License, Version 2.0 (the "License");
881
- * you may not use this file except in compliance with the License.
882
- * You may obtain a copy of the License at
883
- *
884
- * http://www.apache.org/licenses/LICENSE-2.0
885
- *
886
- * Unless required by applicable law or agreed to in writing, software
887
- * distributed under the License is distributed on an "AS IS" BASIS,
888
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
889
- * See the License for the specific language governing permissions and
890
- * limitations under the License.
891
- *
892
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
893
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
894
- * */
895
-
896
- var AppLayout = function AppLayout(_a) {
897
- var header = _a.header,
898
- children = _a.children;
899
- return /*#__PURE__*/React__default["default"].createElement(material.Box, {
900
- sx: {
901
- height: '100vh',
902
- display: 'flex',
903
- flexDirection: 'column'
904
- },
905
- "data-testid": "appLayout"
906
- }, header, /*#__PURE__*/React__default["default"].createElement(material.Box, {
907
- component: "main",
908
- sx: {
909
- flex: 1,
910
- position: 'relative'
911
- }
912
- }, children));
913
- };
914
-
915
- /* *
916
- * Licensed under the Apache License, Version 2.0 (the "License");
917
- * you may not use this file except in compliance with the License.
918
- * You may obtain a copy of the License at
919
- *
920
- * http://www.apache.org/licenses/LICENSE-2.0
921
- *
922
- * Unless required by applicable law or agreed to in writing, software
923
- * distributed under the License is distributed on an "AS IS" BASIS,
924
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
925
- * See the License for the specific language governing permissions and
926
- * limitations under the License.
927
- *
928
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
929
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
930
- * */
931
-
932
- var AppHeader = function AppHeader(_a) {
933
- var _b;
934
-
935
- var menu = _a.menu,
936
- userMenu = _a.userMenu,
937
- workspaceTopBar = _a.workspaceTopBar,
938
- _c = _a.title,
939
- title = _c === void 0 ? 'GeoWeb' : _c,
940
- onClick = _a.onClick;
941
- var theme$1 = material.useTheme();
942
-
943
- var _d = __read(React__default["default"].useState(false), 2),
944
- isDrawerOpen = _d[0],
945
- toggleDrawer = _d[1];
946
-
947
- var onToggleDrawer = function onToggleDrawer(isOpen) {
948
- return toggleDrawer(isOpen);
949
- };
950
-
951
- var onKeyDown = function onKeyDown(event) {
952
- if (event.key === 'Tab' || event.key === 'Shift') {
953
- return;
954
- }
955
-
956
- toggleDrawer(false);
957
- };
958
-
959
- return /*#__PURE__*/React__default["default"].createElement(material.Box, {
960
- component: "header",
961
- role: "heading",
962
- sx: (_b = {
963
- height: 40,
964
- backgroundColor: theme$1.palette.geowebColors.brand.brand,
965
- color: theme$1.palette.common.white,
966
- boxShadow: theme$1.shadows[1],
967
- zIndex: 1000,
968
- display: 'flex',
969
- padding: '0 16px'
970
- }, _b[theme$1.breakpoints.up('md')] = {
971
- padding: '0 24px'
972
- }, _b[theme$1.breakpoints.up('sm')] = {
973
- '.workspace-topbar': {
974
- marginLeft: 3,
975
- maxWidth: 260
976
- },
977
- '.hamburger-btn': {
978
- marginLeft: 4
979
- },
980
- h1: {
981
- maxWidth: 'initial',
982
- display: 'block'
983
- }
984
- }, _b)
985
- }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
986
- onClick: onClick,
987
- sx: {
988
- display: 'inherit',
989
- alignItems: 'center',
990
- cursor: onClick ? 'pointer' : 'auto'
991
- }
992
- }, /*#__PURE__*/React__default["default"].createElement(theme.GeoWebLogo, {
993
- style: {
994
- position: 'relative',
995
- top: '-1px',
996
- right: '-1px'
997
- }
998
- }), /*#__PURE__*/React__default["default"].createElement(material.Typography, {
999
- variant: "h1",
1000
- sx: {
1001
- display: 'none',
1002
- fontSize: '20px',
1003
- fontWeight: 500,
1004
- fontStretch: 'normal',
1005
- fontStyle: 'normal',
1006
- lineHeight: 'normal',
1007
- letterSpacing: '0.15px',
1008
- overflow: 'hidden',
1009
- whiteSpace: 'nowrap',
1010
- textOverflow: 'ellipsis',
1011
- color: 'geowebColors.typographyAndIcons.text',
1012
- marginLeft: 1,
1013
- maxWidth: 130
1014
- }
1015
- }, title)), menu && /*#__PURE__*/React__default["default"].createElement(material.Box, {
1016
- className: "hamburger-btn",
1017
- sx: {
1018
- display: 'flex',
1019
- alignItems: 'center',
1020
- marginLeft: 1
1021
- }
1022
- }, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1023
- "data-testid": "menuButton",
1024
- onClick: function onClick() {
1025
- return onToggleDrawer(true);
1026
- },
1027
- isSelected: isDrawerOpen
1028
- }, /*#__PURE__*/React__default["default"].createElement(theme.HamburgerMenu, null)), /*#__PURE__*/React__default["default"].createElement(material.Drawer, {
1029
- "data-testid": "app-drawer",
1030
- anchor: "left",
1031
- open: isDrawerOpen,
1032
- onClose: function onClose() {
1033
- return onToggleDrawer(false);
1034
- },
1035
- onClick: function onClick() {
1036
- return onToggleDrawer(false);
1037
- },
1038
- onKeyDown: onKeyDown,
1039
- sx: {
1040
- '& .MuiDrawer-paper': {
1041
- top: '40px'
1042
- }
1043
- }
1044
- }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
1045
- role: "presentation",
1046
- sx: {
1047
- width: '250px',
1048
- overflowY: 'auto'
1049
- }
1050
- }, menu))), /*#__PURE__*/React__default["default"].createElement(material.Box, {
1051
- className: "workspace-topbar",
1052
- sx: {
1053
- flexGrow: 1,
1054
- display: 'flex',
1055
- marginLeft: 1,
1056
- alignItems: 'center',
1057
- maxWidth: 168
1058
- }
1059
- }, workspaceTopBar), /*#__PURE__*/React__default["default"].createElement(material.Box, {
1060
- sx: {
1061
- display: 'flex',
1062
- alignItems: 'center',
1063
- flexGrow: 1,
1064
- justifyContent: 'flex-end'
1065
- }
1066
- }, userMenu));
1067
- };
1068
-
1069
- /* *
1070
- * Licensed under the Apache License, Version 2.0 (the "License");
1071
- * you may not use this file except in compliance with the License.
1072
- * You may obtain a copy of the License at
1073
- *
1074
- * http://www.apache.org/licenses/LICENSE-2.0
1075
- *
1076
- * Unless required by applicable law or agreed to in writing, software
1077
- * distributed under the License is distributed on an "AS IS" BASIS,
1078
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079
- * See the License for the specific language governing permissions and
1080
- * limitations under the License.
1081
- *
1082
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1083
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1084
- * */
1085
-
1086
- var DraggableComponent$1 = function DraggableComponent(_a) {
1087
- var _b = _a.bounds,
1088
- bounds = _b === void 0 ? 'body' : _b,
1089
- children = _a.children,
1090
- props = __rest(_a, ["bounds", "children"]);
1091
-
1092
- return /*#__PURE__*/React__default["default"].createElement(Draggable__default["default"], __assign({
1093
- bounds: bounds
1094
- }, props), children);
1095
- };
1096
-
1097
- /* *
1098
- * Licensed under the Apache License, Version 2.0 (the "License");
1099
- * you may not use this file except in compliance with the License.
1100
- * You may obtain a copy of the License at
1101
- *
1102
- * http://www.apache.org/licenses/LICENSE-2.0
1103
- *
1104
- * Unless required by applicable law or agreed to in writing, software
1105
- * distributed under the License is distributed on an "AS IS" BASIS,
1106
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1107
- * See the License for the specific language governing permissions and
1108
- * limitations under the License.
1109
- *
1110
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1111
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1112
- * */
1113
- var isDraggingClassName = 'is-dragging';
1114
-
1115
- var ResizeComponent = function ResizeComponent(_a) {
1116
- var children = _a.children,
1117
- _b = _a.onResizeStart,
1118
- onResizeStart = _b === void 0 ? function () {} : _b,
1119
- _c = _a.onResizeStop,
1120
- onResizeStop = _c === void 0 ? function () {} : _c,
1121
- size = _a.size,
1122
- setSize = _a.setSize,
1123
- _d = _a.minHeight,
1124
- minHeight = _d === void 0 ? 50 : _d,
1125
- _e = _a.minWidth,
1126
- minWidth = _e === void 0 ? 50 : _e,
1127
- props = __rest(_a, ["children", "onResizeStart", "onResizeStop", "size", "setSize", "minHeight", "minWidth"]);
1128
-
1129
- var theme$1 = material.useTheme();
1130
- var onStartResize = React__default["default"].useCallback(function (event, _direction, node) {
1131
- event.stopPropagation();
1132
- node.classList.add(isDraggingClassName);
1133
-
1134
- var _a = node.getBoundingClientRect(),
1135
- width = _a.width,
1136
- height = _a.height;
1137
-
1138
- setSize({
1139
- width: width,
1140
- height: height
1141
- }); // fix for when initial maxHeight gets cleared
1142
- // eslint-disable-next-line no-param-reassign
1143
-
1144
- node.style.height = height + "px";
1145
- onResizeStart();
1146
- }, [onResizeStart, setSize]);
1147
- var onStopResize = React__default["default"].useCallback(function (event, direction, node, delta) {
1148
- node.classList.remove(isDraggingClassName);
1149
- var width = parseInt(size.width, 10) + delta.width;
1150
- var height = parseInt(size.height, 10) + delta.height;
1151
- setSize({
1152
- width: width,
1153
- height: height
1154
- });
1155
- onResizeStop(event, direction, node, delta);
1156
- }, [setSize, onResizeStop, size]);
1157
- return /*#__PURE__*/React__default["default"].createElement(reResizable.Resizable // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
1158
- , __assign({
1159
- // TODO: implement bounds https://gitlab.com/opengeoweb/opengeoweb/-/issues/1035
1160
- minHeight: minHeight,
1161
- minWidth: minWidth,
1162
- size: size,
1163
- onResizeStop: onStopResize,
1164
- handleComponent: {
1165
- bottomRight: /*#__PURE__*/React__default["default"].createElement(theme.Resize, {
1166
- style: {
1167
- fill: "" + theme$1.palette.geowebColors.buttons.flat["default"].color
1168
- },
1169
- sx: {
1170
- display: 'none'
1171
- },
1172
- className: "resizableHandle"
1173
- }),
1174
- bottomLeft: /*#__PURE__*/React__default["default"].createElement(theme.Resize, {
1175
- isRightAligned: true,
1176
- style: {
1177
- fill: "" + theme$1.palette.geowebColors.buttons.flat["default"].color
1178
- },
1179
- sx: {
1180
- display: 'none'
1181
- },
1182
- className: "resizableHandle"
1183
- })
1184
- },
1185
- enable: {
1186
- top: false,
1187
- right: false,
1188
- bottom: false,
1189
- left: false,
1190
- topRight: true,
1191
- bottomRight: true,
1192
- bottomLeft: true,
1193
- topLeft: true
1194
- },
1195
- onResizeStart: onStartResize
1196
- }, props), children);
1197
- };
1198
-
1199
- /**
1200
- * ErrorBoundary
1201
- * Wrap this component around parts of your application. It will catch any uncaught errors and display an alert, and allows you to continue using the rest of your application.
1202
- *
1203
- * @example
1204
- * ``` <ErrorBoundary><ExampleComponent /></ErrorBoundary> ```
1205
- */
1206
-
1207
- var ErrorBoundary =
1208
- /** @class */
1209
- function (_super) {
1210
- __extends(ErrorBoundary, _super);
1211
-
1212
- function ErrorBoundary(props) {
1213
- var _this = _super.call(this, props) || this;
1214
-
1215
- _this.state = {
1216
- error: undefined,
1217
- errorInfo: undefined
1218
- };
1219
- return _this;
1220
- }
1221
-
1222
- ErrorBoundary.getDerivedStateFromError = function (error) {
1223
- return {
1224
- error: error
1225
- };
1226
- };
1227
-
1228
- ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
1229
- var onError = this.props.onError;
1230
- this.setState({
1231
- error: error,
1232
- errorInfo: errorInfo
1233
- });
1234
- onError(error, errorInfo);
1235
- };
1236
-
1237
- ErrorBoundary.prototype.render = function () {
1238
- var _a = this.state,
1239
- error = _a.error,
1240
- errorInfo = _a.errorInfo;
1241
- var children = this.props.children;
1242
-
1243
- if (error) {
1244
- return /*#__PURE__*/React__namespace.createElement(material.Box, {
1245
- sx: {
1246
- whiteSpace: 'pre-wrap',
1247
- width: '100%',
1248
- height: '100%',
1249
- overflowY: 'scroll'
1250
- }
1251
- }, /*#__PURE__*/React__namespace.createElement(AlertBanner, {
1252
- severity: "error",
1253
- title: "Woops, an error has occurred. Please report the error shown below and reload the page if needed.",
1254
- info: /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("br", null), error.toString(), /*#__PURE__*/React__namespace.createElement("br", null), errorInfo && errorInfo.componentStack, /*#__PURE__*/React__namespace.createElement("br", null), /*#__PURE__*/React__namespace.createElement("br", null), /*#__PURE__*/React__namespace.createElement(material.Link, {
1255
- underline: "always",
1256
- style: {
1257
- cursor: 'pointer'
1258
- },
1259
- onClick: function onClick() {
1260
- return window.location.reload();
1261
- }
1262
- }, "Reload page"))
1263
- }));
1264
- }
1265
-
1266
- return children;
1267
- };
1268
-
1269
- ErrorBoundary.defaultProps = {
1270
- onError: function onError() {}
1271
- };
1272
- return ErrorBoundary;
1273
- }(React__namespace.Component);
1274
-
1275
- var styles$4 = {
1276
- small: {
1277
- height: 16,
1278
- width: 16,
1279
- fontSize: '0.5rem'
1280
- },
1281
- large: {}
1282
- };
1283
-
1284
- var Avatar = function Avatar(_a) {
1285
- var children = _a.children,
1286
- _b = _a.size,
1287
- size = _b === void 0 ? 'large' : _b;
1288
- return /*#__PURE__*/React__namespace.createElement(material.Avatar, {
1289
- "data-testid": "avatar",
1290
- sx: __assign({}, styles$4[size])
1291
- }, children);
1292
- };
1293
-
1294
- /* *
1295
- * Licensed under the Apache License, Version 2.0 (the "License");
1296
- * you may not use this file except in compliance with the License.
1297
- * You may obtain a copy of the License at
1298
- *
1299
- * http://www.apache.org/licenses/LICENSE-2.0
1300
- *
1301
- * Unless required by applicable law or agreed to in writing, software
1302
- * distributed under the License is distributed on an "AS IS" BASIS,
1303
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304
- * See the License for the specific language governing permissions and
1305
- * limitations under the License.
1306
- *
1307
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1308
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1309
- * */
1310
- var styles$3 = {
1311
- container: {
1312
- position: 'absolute',
1313
- top: 38,
1314
- right: 20,
1315
- width: 256,
1316
- borderRadius: 0,
1317
- boxShadow: 5,
1318
- backgroundColor: 'geowebColors.background.surface'
1319
- },
1320
- userMenu: {
1321
- padding: 0,
1322
- '& > li': {
1323
- paddingTop: 3,
1324
- paddingBottom: 3,
1325
- paddingLeft: 2,
1326
- paddingRight: 2
1327
- }
1328
- }
1329
- };
1330
-
1331
- var UserMenu = function UserMenu(_a) {
1332
- var _b = _a.isOpen,
1333
- isOpen = _b === void 0 ? false : _b,
1334
- _c = _a.onToggle,
1335
- onToggle = _c === void 0 ? function () {} : _c,
1336
- _d = _a.onClose,
1337
- onClose = _d === void 0 ? function () {} : _d,
1338
- children = _a.children,
1339
- initials = _a.initials;
1340
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1341
- "data-testid": "userButton",
1342
- onClick: onToggle,
1343
- sx: {
1344
- '&.MuiButtonBase-root': {
1345
- background: 'transparent',
1346
- '&:hover': {
1347
- border: 'none',
1348
- background: 'transparent'
1349
- }
1350
- }
1351
- },
1352
- size: "medium"
1353
- }, /*#__PURE__*/React__default["default"].createElement(Avatar, null, initials)), isOpen && /*#__PURE__*/React__default["default"].createElement(material.Paper, {
1354
- sx: styles$3.container,
1355
- "data-testid": "userMenu"
1356
- }, /*#__PURE__*/React__default["default"].createElement(material.ClickAwayListener, {
1357
- onClickAway: onClose,
1358
- mouseEvent: "onMouseDown"
1359
- }, /*#__PURE__*/React__default["default"].createElement(material.MenuList, {
1360
- sx: styles$3.userMenu,
1361
- variant: "menu"
1362
- }, children))));
1363
- };
1364
-
1365
- /* *
1366
- * Licensed under the Apache License, Version 2.0 (the "License");
1367
- * you may not use this file except in compliance with the License.
1368
- * You may obtain a copy of the License at
1369
- *
1370
- * http://www.apache.org/licenses/LICENSE-2.0
1371
- *
1372
- * Unless required by applicable law or agreed to in writing, software
1373
- * distributed under the License is distributed on an "AS IS" BASIS,
1374
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1375
- * See the License for the specific language governing permissions and
1376
- * limitations under the License.
1377
- *
1378
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1379
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1380
- * */
1381
-
1382
- var MenuItemTheme = function MenuItemTheme() {
1383
- var _a = theme.useThemeContext(),
1384
- isDark = _a.isDark,
1385
- toggleTheme = _a.toggleTheme;
1386
-
1387
- return /*#__PURE__*/React__default["default"].createElement(material.MenuItem, {
1388
- divider: true
1389
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1390
- container: true
1391
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1392
- item: true
1393
- }, "Choose your default app mode"), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1394
- item: true
1395
- }, /*#__PURE__*/React__default["default"].createElement(material.RadioGroup, {
1396
- onChange: toggleTheme
1397
- }, /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
1398
- value: true,
1399
- control: /*#__PURE__*/React__default["default"].createElement(material.Radio, {
1400
- checked: !isDark
1401
- }),
1402
- label: "Light"
1403
- }), /*#__PURE__*/React__default["default"].createElement(material.FormControlLabel, {
1404
- value: false,
1405
- control: /*#__PURE__*/React__default["default"].createElement(material.Radio, {
1406
- checked: isDark
1407
- }),
1408
- label: "Dark"
1409
- })))));
1410
- };
1411
-
1412
- /* *
1413
- * Licensed under the Apache License, Version 2.0 (the "License");
1414
- * you may not use this file except in compliance with the License.
1415
- * You may obtain a copy of the License at
1416
- *
1417
- * http://www.apache.org/licenses/LICENSE-2.0
1418
- *
1419
- * Unless required by applicable law or agreed to in writing, software
1420
- * distributed under the License is distributed on an "AS IS" BASIS,
1421
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1422
- * See the License for the specific language governing permissions and
1423
- * limitations under the License.
1424
- *
1425
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1426
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1427
- * */
1428
-
1429
- var ToolFooter = function ToolFooter() {
1430
- return /*#__PURE__*/React__default["default"].createElement(material.Box, {
1431
- component: "footer",
1432
- sx: {
1433
- boxShadow: 1,
1434
- backgroundColor: 'geowebColors.background.surface',
1435
- textAlign: 'right',
1436
- height: 18,
1437
- zIndex: 1
1438
- }
1439
- });
1440
- };
1441
-
1442
- /* *
1443
- * Licensed under the Apache License, Version 2.0 (the "License");
1444
- * you may not use this file except in compliance with the License.
1445
- * You may obtain a copy of the License at
1446
- *
1447
- * http://www.apache.org/licenses/LICENSE-2.0
1448
- *
1449
- * Unless required by applicable law or agreed to in writing, software
1450
- * distributed under the License is distributed on an "AS IS" BASIS,
1451
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1452
- * See the License for the specific language governing permissions and
1453
- * limitations under the License.
1454
- *
1455
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1456
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1457
- * */
1458
-
1459
- var getStyle = function getStyle(size) {
1460
- switch (size) {
1461
- case 'xs':
1462
- {
1463
- return {
1464
- fontSize: 10,
1465
- fontWeight: 500
1466
- };
1467
- }
1468
-
1469
- case 'small':
1470
- {
1471
- return {
1472
- fontSize: 16,
1473
- fontWeight: 500,
1474
- padding: '4px'
1475
- };
1476
- }
1477
-
1478
- case 'medium':
1479
- {
1480
- return {
1481
- fontSize: 20,
1482
- fontWeight: 400,
1483
- padding: '4px 8px',
1484
- height: 40
1485
- };
1486
- }
1487
-
1488
- case 'large':
1489
- {
1490
- return {
1491
- fontSize: 16,
1492
- fontWeight: 500,
1493
- padding: '12px'
1494
- };
1495
- }
1496
-
1497
- default:
1498
- {
1499
- return {};
1500
- }
1501
- }
1502
- };
1503
-
1504
- var iconStyle = {
1505
- color: 'geowebColors.greys.accessible',
1506
- padding: 0,
1507
- '&:hover': {
1508
- background: 'action.hover'
1509
- }
1510
- };
1511
-
1512
- var ToolHeader = function ToolHeader(_a) {
1513
- var size = _a.size,
1514
- title = _a.title,
1515
- _b = _a.onClose,
1516
- onClose = _b === void 0 ? null : _b,
1517
- _c = _a.isDraggable,
1518
- isDraggable = _c === void 0 ? false : _c,
1519
- _d = _a.className,
1520
- className = _d === void 0 ? '' : _d,
1521
- _e = _a.leftHeaderComponent,
1522
- leftHeaderComponent = _e === void 0 ? null : _e,
1523
- _f = _a.rightHeaderComponent,
1524
- rightHeaderComponent = _f === void 0 ? null : _f,
1525
- _g = _a.dragHandleIcon,
1526
- dragHandleIcon = _g === void 0 ? /*#__PURE__*/React__default["default"].createElement(theme.DragHandle, null) : _g,
1527
- _h = _a.closeIcon,
1528
- closeIcon = _h === void 0 ? /*#__PURE__*/React__default["default"].createElement(theme.Close, {
1529
- "data-testid": "CloseIcon"
1530
- }) : _h;
1531
- var styles = getStyle(size);
1532
- var columnSizeIcon = leftHeaderComponent || rightHeaderComponent ? 4 : 1;
1533
- var columnSizeTitle = leftHeaderComponent || rightHeaderComponent ? 4 : 10;
1534
- return /*#__PURE__*/React__default["default"].createElement(material.Box, {
1535
- component: "header",
1536
- className: className,
1537
- sx: {
1538
- boxShadow: 1,
1539
- backgroundColor: 'geowebColors.background.surface',
1540
- zIndex: 2,
1541
- cursor: isDraggable ? 'move' : null
1542
- }
1543
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1544
- container: true,
1545
- alignItems: "center",
1546
- sx: {
1547
- padding: styles.padding,
1548
- height: styles.height
1549
- }
1550
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1551
- className: "header-left",
1552
- item: true,
1553
- xs: columnSizeIcon,
1554
- sx: {
1555
- paddingRight: 1
1556
- }
1557
- }, isDraggable && size !== 'xxs' && !leftHeaderComponent && /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1558
- container: true,
1559
- justifyContent: "flex-start"
1560
- }, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1561
- "data-testid": "dragBtn",
1562
- disableRipple: true,
1563
- sx: {
1564
- pointerEvents: 'none',
1565
- '&.MuiIconButton-root': iconStyle
1566
- }
1567
- }, dragHandleIcon)), leftHeaderComponent && leftHeaderComponent), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1568
- className: "header-title",
1569
- item: true,
1570
- xs: columnSizeTitle
1571
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1572
- container: true,
1573
- justifyContent: "center",
1574
- alignItems: "center"
1575
- }, title && /*#__PURE__*/React__default["default"].createElement(material.Typography, {
1576
- variant: "h2",
1577
- noWrap: true,
1578
- sx: {
1579
- fontSize: styles.fontSize,
1580
- fontWeight: styles.fontWeight
1581
- }
1582
- }, title), size === 'xxs' && /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1583
- "data-testid": "dragBtn-xxs",
1584
- disableRipple: true,
1585
- sx: {
1586
- pointerEvents: 'none',
1587
- transform: 'rotate(90deg)',
1588
- '&.MuiButtonBase-root.MuiIconButton-root': __assign(__assign({}, iconStyle), {
1589
- height: 12
1590
- })
1591
- }
1592
- }, dragHandleIcon))), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
1593
- className: "header-right",
1594
- item: true,
1595
- xs: columnSizeIcon,
1596
- container: true,
1597
- justifyContent: "flex-end"
1598
- }, rightHeaderComponent && rightHeaderComponent, onClose && /*#__PURE__*/React__default["default"].createElement(CustomTooltip, {
1599
- title: "Close",
1600
- placement: "bottom",
1601
- sx: {
1602
- pointerEvents: 'none'
1603
- }
1604
- }, /*#__PURE__*/React__default["default"].createElement(CustomIconButton, {
1605
- "data-testid": "closeBtn",
1606
- onClick: onClose,
1607
- onTouchEnd: onClose,
1608
- sx: {
1609
- '&.MuiButtonBase-root.MuiIconButton-root': iconStyle
1610
- }
1611
- }, closeIcon)))));
1612
- };
1613
-
1614
- /* *
1615
- * Licensed under the Apache License, Version 2.0 (the "License");
1616
- * you may not use this file except in compliance with the License.
1617
- * You may obtain a copy of the License at
1618
- *
1619
- * http://www.apache.org/licenses/LICENSE-2.0
1620
- *
1621
- * Unless required by applicable law or agreed to in writing, software
1622
- * distributed under the License is distributed on an "AS IS" BASIS,
1623
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1624
- * See the License for the specific language governing permissions and
1625
- * limitations under the License.
1626
- *
1627
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1628
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
1629
- * */
1630
- var styles$2 = {
1631
- container: {
1632
- overflow: 'hidden',
1633
- borderRadius: 0,
1634
- display: 'flex',
1635
- flexDirection: 'column',
1636
- height: '100%'
1637
- },
1638
- content: {
1639
- flex: 1,
1640
- overflowY: 'auto',
1641
- position: 'relative'
1642
- }
1643
- };
1644
- var BASE_ELEVATION = 5;
1645
-
1646
- var ToolContainer = function ToolContainer(_a) {
1647
- var _b = _a.title,
1648
- title = _b === void 0 ? '' : _b,
1649
- _c = _a.size,
1650
- size = _c === void 0 ? 'medium' : _c,
1651
- children = _a.children,
1652
- onClose = _a.onClose,
1653
- _d = _a.isResizable,
1654
- isResizable = _d === void 0 ? false : _d,
1655
- _e = _a.isDraggable,
1656
- isDraggable = _e === void 0 ? false : _e,
1657
- _f = _a.maxHeight,
1658
- maxHeight = _f === void 0 ? 'initial' : _f,
1659
- _g = _a.elevation,
1660
- elevation = _g === void 0 ? BASE_ELEVATION : _g,
1661
- // elevation_06
1662
- _h = _a.headerClassName,
1663
- // elevation_06
1664
- headerClassName = _h === void 0 ? '' : _h,
1665
- _j = _a.leftHeaderComponent,
1666
- leftHeaderComponent = _j === void 0 ? null : _j,
1667
- _k = _a.rightHeaderComponent,
1668
- rightHeaderComponent = _k === void 0 ? null : _k,
1669
- dragHandleIcon = _a.dragHandleIcon,
1670
- closeIcon = _a.closeIcon,
1671
- props = __rest(_a, ["title", "size", "children", "onClose", "isResizable", "isDraggable", "maxHeight", "elevation", "headerClassName", "leftHeaderComponent", "rightHeaderComponent", "dragHandleIcon", "closeIcon"]);
1672
-
1673
- return /*#__PURE__*/React__default["default"].createElement(material.Paper, __assign({
1674
- elevation: elevation,
1675
- sx: styles$2.container
1676
- }, props), /*#__PURE__*/React__default["default"].createElement(ErrorBoundary, null, /*#__PURE__*/React__default["default"].createElement(ToolHeader, {
1677
- title: title,
1678
- size: size,
1679
- isDraggable: isDraggable,
1680
- onClose: onClose,
1681
- className: headerClassName,
1682
- leftHeaderComponent: leftHeaderComponent,
1683
- rightHeaderComponent: rightHeaderComponent,
1684
- dragHandleIcon: dragHandleIcon,
1685
- closeIcon: closeIcon
1686
- })), /*#__PURE__*/React__default["default"].createElement(material.Box, {
1687
- sx: styles$2.content,
1688
- style: {
1689
- maxHeight: maxHeight
1690
- }
1691
- }, children), isResizable && /*#__PURE__*/React__default["default"].createElement(ToolFooter, null));
1692
- };
1693
-
1694
- var getRightPositionAndSize = function getRightPositionAndSize(_a) {
1695
- var currentX = _a.currentX,
1696
- currentWidth = _a.currentWidth,
1697
- newWidth = _a.newWidth,
1698
- maxWidth = _a.maxWidth,
1699
- position = _a.position,
1700
- startSize = _a.startSize;
1701
-
1702
- var newSize = __assign(__assign({}, startSize), {
1703
- width: newWidth
1704
- }); // if new size is bigger than the window
1705
-
1706
-
1707
- if (newWidth >= maxWidth) {
1708
- return {
1709
- size: __assign(__assign({}, newSize), {
1710
- width: maxWidth
1711
- }),
1712
- position: __assign(__assign({}, position), {
1713
- x: position.x + (maxWidth - (currentX + currentWidth))
1714
- })
1715
- };
1716
- } // if new size overlaps left side of screen
1717
-
1718
-
1719
- var newStartX = currentX - (newWidth - currentWidth);
1720
-
1721
- if (newStartX <= 0) {
1722
- return {
1723
- size: newSize,
1724
- position: __assign(__assign({}, position), {
1725
- x: position.x - newStartX
1726
- })
1727
- };
1728
- } // there is room to grow
1729
-
1730
-
1731
- return {
1732
- size: newSize,
1733
- position: position
1734
- };
1735
- };
1736
- var getLeftPositionAndSize = function getLeftPositionAndSize(_a) {
1737
- var currentX = _a.currentX,
1738
- newWidth = _a.newWidth,
1739
- maxWidth = _a.maxWidth,
1740
- position = _a.position,
1741
- startSize = _a.startSize;
1742
-
1743
- var newSize = __assign(__assign({}, startSize), {
1744
- width: newWidth
1745
- }); // if new size is bigger than the window
1746
-
1747
-
1748
- if (newWidth >= maxWidth) {
1749
- return {
1750
- size: __assign(__assign({}, newSize), {
1751
- width: maxWidth
1752
- }),
1753
- position: __assign(__assign({}, position), {
1754
- x: position.x - currentX
1755
- })
1756
- };
1757
- } // if new size overlaps right side of screen
1758
-
1759
-
1760
- var newEndX = currentX + newWidth;
1761
-
1762
- if (newEndX >= maxWidth) {
1763
- return {
1764
- size: newSize,
1765
- position: __assign(__assign({}, position), {
1766
- x: position.x + (maxWidth - newEndX)
1767
- })
1768
- };
1769
- } // there is room to grow
1770
-
1771
-
1772
- return {
1773
- size: newSize,
1774
- position: position
1775
- };
1776
- };
1777
- var useHandleSizeFromOutsideComponent = function useHandleSizeFromOutsideComponent(_a) {
1778
- var nodeRef = _a.nodeRef,
1779
- startSize = _a.startSize,
1780
- bounds = _a.bounds,
1781
- isRightAligned = _a.isRightAligned,
1782
- size = _a.size,
1783
- setSize = _a.setSize,
1784
- position = _a.position,
1785
- setPosition = _a.setPosition;
1786
- React__default["default"].useEffect(function () {
1787
- var _a, _b; // update size when startSize has changed outside the component
1788
-
1789
-
1790
- if (startSize !== size) {
1791
- var node = (_a = nodeRef.current) === null || _a === void 0 ? void 0 : _a.firstChild;
1792
- var boundsNode = bounds === 'parent' ? (_b = nodeRef.current) === null || _b === void 0 ? void 0 : _b.parentNode : document.querySelector(bounds);
1793
- var maxWidth = boundsNode.getBoundingClientRect().width;
1794
- var newWidth = Number(startSize.width);
1795
-
1796
- var _c = node.getBoundingClientRect(),
1797
- currentX = _c.x,
1798
- currentWidth = _c.width;
1799
-
1800
- var _d = isRightAligned ? getRightPositionAndSize({
1801
- currentX: currentX,
1802
- currentWidth: currentWidth,
1803
- newWidth: newWidth,
1804
- maxWidth: maxWidth,
1805
- position: position,
1806
- startSize: startSize
1807
- }) : getLeftPositionAndSize({
1808
- currentX: currentX,
1809
- newWidth: newWidth,
1810
- maxWidth: maxWidth,
1811
- position: position,
1812
- startSize: startSize
1813
- }),
1814
- newPosition = _d.position,
1815
- newSize = _d.size;
1816
-
1817
- setSize(newSize);
1818
- setPosition(newPosition);
1819
- } // eslint-disable-next-line react-hooks/exhaustive-deps
1820
-
1821
- }, [startSize.width, startSize.height]);
1822
- };
1823
-
1824
- /* *
1825
- * Licensed under the Apache License, Version 2.0 (the "License");
1826
- * you may not use this file except in compliance with the License.
1827
- * You may obtain a copy of the License at
1828
- *
1829
- * http://www.apache.org/licenses/LICENSE-2.0
1830
- *
1831
- * Unless required by applicable law or agreed to in writing, software
1832
- * distributed under the License is distributed on an "AS IS" BASIS,
1833
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1834
- * See the License for the specific language governing permissions and
1835
- * limitations under the License.
1836
- *
1837
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1838
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
1839
- * */
1840
-
1841
- var calculateDialogSizeAndPosition = function calculateDialogSizeAndPosition() {
1842
- var width = window.innerWidth * 0.85;
1843
- var height = window.innerHeight * 0.85;
1844
- var top = window.innerHeight * 0.15 / 2;
1845
- var left = window.innerWidth * 0.15 / 2;
1846
- return {
1847
- width: width,
1848
- height: height,
1849
- top: top,
1850
- left: left
1851
- };
1852
- };
1853
- var BASE_Z_INDEX = 100;
1854
- var calculateNewPosition = function calculateNewPosition(position, isRightAligned, handle, delta) {
1855
- var x = position.x,
1856
- y = position.y; // If dragging the same side as alignment, adjust position
1857
-
1858
- if (isRightAligned && handle === 'bottomRight') {
1859
- x = position.x + delta.width;
1860
- } else if (!isRightAligned && handle === 'bottomLeft') {
1861
- x = position.x - delta.width;
1862
- } else if (isRightAligned && handle === 'topRight') {
1863
- x = position.x + delta.width;
1864
- y = position.y - delta.height;
1865
- } else if (isRightAligned && handle === 'topLeft') {
1866
- y = position.y - delta.height;
1867
- } else if (!isRightAligned && handle === 'topRight') {
1868
- y = position.y - delta.height;
1869
- } else if (!isRightAligned && handle === 'topLeft') {
1870
- x = position.x - delta.width;
1871
- y = position.y - delta.height;
1872
- }
1873
-
1874
- return {
1875
- x: x,
1876
- y: y
1877
- };
1878
- };
1879
-
1880
- var DraggableComponent = function DraggableComponent(_a) {
1881
- var title = _a.title,
1882
- _b = _a.bounds,
1883
- bounds = _b === void 0 ? 'body' : _b,
1884
- _c = _a.cancel,
1885
- cancel = _c === void 0 ? '.MuiButtonBase-root' : _c,
1886
- _d = _a.headerSize,
1887
- headerSize = _d === void 0 ? 'small' : _d,
1888
- _e = _a.startSize,
1889
- startSize = _e === void 0 ? {
1890
- width: 'auto',
1891
- height: 'auto'
1892
- } : _e,
1893
- _f = _a.startPosition,
1894
- startPosition = _f === void 0 ? {
1895
- left: undefined,
1896
- right: undefined,
1897
- top: undefined
1898
- } : _f,
1899
- children = _a.children,
1900
- _g = _a.isOpen,
1901
- isOpen = _g === void 0 ? true : _g,
1902
- _h = _a.onClose,
1903
- onClose = _h === void 0 ? function () {} : _h,
1904
- _j = _a.initialMaxHeight,
1905
- defaultInitialMaxHeight = _j === void 0 ? 'initial' : _j,
1906
- _k = _a.onChangeSize,
1907
- onChangeSize = _k === void 0 ? function () {} : _k,
1908
- _l = _a.onMouseDown,
1909
- onMouseDown = _l === void 0 ? function () {} : _l,
1910
- _m = _a.onResizeStop,
1911
- onResizeStop = _m === void 0 ? function () {} : _m,
1912
- _o = _a.onDragEnd,
1913
- onDragEnd = _o === void 0 ? function () {} : _o,
1914
- _p = _a.onFocus,
1915
- onFocus = _p === void 0 ? function () {} : _p,
1916
- _q = _a.onBlur,
1917
- onBlur = _q === void 0 ? function () {} : _q,
1918
- _r = _a.order,
1919
- order = _r === void 0 ? 1 : _r,
1920
- _s = _a.source,
1921
- source = _s === void 0 ? 'app' : _s,
1922
- _t = _a.leftHeaderComponent,
1923
- leftHeaderComponent = _t === void 0 ? null : _t,
1924
- _u = _a.rightHeaderComponent,
1925
- rightHeaderComponent = _u === void 0 ? null : _u,
1926
- dragHandleIcon = _a.dragHandleIcon,
1927
- closeIcon = _a.closeIcon,
1928
- className = _a.className,
1929
- _v = _a.sx,
1930
- sx = _v === void 0 ? {} : _v,
1931
- props = __rest(_a, ["title", "bounds", "cancel", "headerSize", "startSize", "startPosition", "children", "isOpen", "onClose", "initialMaxHeight", "onChangeSize", "onMouseDown", "onResizeStop", "onDragEnd", "onFocus", "onBlur", "order", "source", "leftHeaderComponent", "rightHeaderComponent", "dragHandleIcon", "closeIcon", "className", "sx"]);
1932
-
1933
- var zIndex = (source === 'app' ? BASE_Z_INDEX : 1000) + order;
1934
- var elevation = BASE_ELEVATION + order;
1935
- var nodeRef = React__default["default"].useRef(null);
1936
-
1937
- var _w = __read(React__default["default"].useState({
1938
- x: 0,
1939
- y: 0
1940
- }), 2),
1941
- position = _w[0],
1942
- setPosition = _w[1];
1943
-
1944
- var _x = __read(React__default["default"].useState(startSize), 2),
1945
- size = _x[0],
1946
- setSize = _x[1];
1947
-
1948
- var isRightAligned = startPosition && startPosition.right !== null && startPosition.right !== undefined;
1949
- var onStopDrag = React__default["default"].useCallback(function (_event, position) {
1950
- setPosition(position);
1951
- onDragEnd(position, size);
1952
- }, [setPosition, onDragEnd, size]);
1953
-
1954
- var _y = __read(React__default["default"].useState(defaultInitialMaxHeight), 2),
1955
- initialMaxHeight = _y[0],
1956
- setInitialMaxHeight = _y[1];
1957
-
1958
- var onStartResize = function onStartResize() {
1959
- setInitialMaxHeight('initial');
1960
- };
1961
-
1962
- var onResize = React__default["default"].useCallback(function (_event, handle, node, delta) {
1963
- var _a = node.getBoundingClientRect(),
1964
- width = _a.width,
1965
- height = _a.height;
1966
-
1967
- onChangeSize({
1968
- width: width,
1969
- height: height
1970
- });
1971
- var newPos = calculateNewPosition(position, isRightAligned, handle, delta); // eslint-disable-next-line no-param-reassign
1972
-
1973
- var parent = node.parentNode;
1974
- parent.style.transform = "translate(" + newPos.x + "px, " + newPos.y + "px)";
1975
- }, [onChangeSize, position, isRightAligned]);
1976
-
1977
- var onStopResize = function onStopResize(_event, direction, node, delta) {
1978
- setPosition(calculateNewPosition(position, isRightAligned, direction, delta));
1979
- onResizeStop(_event, direction, node, delta);
1980
- };
1981
-
1982
- useMakeSureContainerStaysInsideWindow(nodeRef, position, setPosition);
1983
- useHandleSizeFromOutsideComponent({
1984
- nodeRef: nodeRef,
1985
- startSize: startSize,
1986
- bounds: bounds,
1987
- isRightAligned: isRightAligned,
1988
- size: size,
1989
- setSize: setSize,
1990
- position: position,
1991
- setPosition: setPosition
1992
- });
1993
- var toolcontainerId = React__default["default"].useRef(Date.now().toString()).current;
1994
- var headerClassName = "header-" + (className || toolcontainerId);
1995
- return isOpen ? /*#__PURE__*/React__default["default"].createElement(DraggableComponent$1, {
1996
- nodeRef: nodeRef,
1997
- bounds: bounds,
1998
- cancel: cancel,
1999
- position: position,
2000
- onStop: onStopDrag,
2001
- handle: "." + headerClassName,
2002
- onMouseDown: onMouseDown
2003
- }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
2004
- tabIndex: -1,
2005
- onFocus: onFocus,
2006
- onBlur: onBlur,
2007
- sx: __assign(__assign(__assign({
2008
- position: 'absolute',
2009
- pointerEvents: 'all',
2010
- zIndex: zIndex
2011
- }, startPosition), sx), {
2012
- '&:hover .resizableHandle': {
2013
- display: 'inline'
2014
- }
2015
- }),
2016
- ref: nodeRef,
2017
- className: "toolContainerDraggable"
2018
- }, /*#__PURE__*/React__default["default"].createElement(ResizeComponent, __assign({}, props, {
2019
- size: size,
2020
- setSize: setSize,
2021
- onResizeStart: onStartResize,
2022
- onResizeStop: onStopResize,
2023
- onResize: onResize
2024
- }), /*#__PURE__*/React__default["default"].createElement(ToolContainer, {
2025
- maxHeight: initialMaxHeight,
2026
- onClose: onClose,
2027
- title: title,
2028
- size: headerSize,
2029
- isDraggable: true,
2030
- isResizable: true,
2031
- elevation: elevation,
2032
- headerClassName: headerClassName,
2033
- leftHeaderComponent: leftHeaderComponent,
2034
- rightHeaderComponent: rightHeaderComponent,
2035
- dragHandleIcon: dragHandleIcon,
2036
- closeIcon: closeIcon,
2037
- className: className
2038
- }, children)))) : null;
2039
- };
2040
-
2041
- var segmentStyle = {
2042
- margin: '0 2px',
2043
- verticalAlign: 'middle',
2044
- fontSize: 14,
2045
- fontWeight: 500,
2046
- letterSpacing: 0.25,
2047
- justifyContent: 'center'
2048
- };
2049
- var styles$1 = {
2050
- icon: __assign(__assign({}, segmentStyle), {
2051
- backgroundColor: 'geowebColors.textInputField.default.rgba',
2052
- width: 40,
2053
- height: 40,
2054
- display: 'inline-flex',
2055
- alignItems: 'center',
2056
- borderRadius: 1
2057
- }),
2058
- connect: __assign(__assign({}, segmentStyle), {
2059
- fontSize: 18
2060
- }),
2061
- divider: __assign(__assign({}, segmentStyle), {
2062
- margin: '0 6px',
2063
- fontSize: 18
2064
- })
2065
- };
2066
-
2067
- var ShortCutSegment = function ShortCutSegment(_a) {
2068
- var _b = _a.type,
2069
- type = _b === void 0 ? 'text' : _b,
2070
- children = _a.children;
2071
-
2072
- if (type === 'divider') {
2073
- return /*#__PURE__*/React__default["default"].createElement(material.Typography, {
2074
- sx: styles$1.divider,
2075
- "data-testid": "segment-divider",
2076
- component: "span"
2077
- }, children);
2078
- }
2079
-
2080
- if (type === 'icon') {
2081
- return /*#__PURE__*/React__default["default"].createElement(material.Typography, {
2082
- sx: styles$1.icon,
2083
- "data-testid": "segment-icon",
2084
- component: "span"
2085
- }, children);
2086
- }
2087
-
2088
- if (type === 'connect') {
2089
- return /*#__PURE__*/React__default["default"].createElement(material.Typography, {
2090
- sx: styles$1.connect,
2091
- "data-testid": "segment-connect",
2092
- component: "span"
2093
- }, children);
2094
- }
2095
-
2096
- return /*#__PURE__*/React__default["default"].createElement(material.Typography, {
2097
- sx: segmentStyle,
2098
- "data-testid": "segment-text",
2099
- component: "span"
2100
- }, children);
2101
- };
2102
-
2103
- var shortcuts = [{
2104
- title: 'Choose a selected time',
2105
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Left click on the time slider rail")
2106
- }, {
2107
- title: 'Move backwards/forwards in selected time',
2108
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Mouse scroll over the time slider rail")
2109
- }, {
2110
- title: 'Move 1 step backwards/forwards in selected time',
2111
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2112
- type: "icon"
2113
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2114
- type: "connect"
2115
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2116
- type: "icon"
2117
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowLeft, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2118
- type: "divider"
2119
- }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2120
- type: "icon"
2121
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowRight, null))),
2122
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2123
- type: "icon"
2124
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2125
- type: "connect"
2126
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2127
- type: "icon"
2128
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyOption, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2129
- type: "connect"
2130
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2131
- type: "icon"
2132
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowLeft, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2133
- type: "divider"
2134
- }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2135
- type: "icon"
2136
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowRight, null)))
2137
- }, {
2138
- title: 'Toggle hide/show time slider',
2139
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2140
- type: "icon"
2141
- }, "t")
2142
- }, {
2143
- title: 'Change time slider scale (visible timespan)',
2144
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Hold left click over Time Slider legend + drag left or right")
2145
- }, {
2146
- title: 'Expand/shrink time slider scale (visible timespan)',
2147
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2148
- type: "icon"
2149
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "+ Scroll the slider rail"))
2150
- }, {
2151
- title: 'Mouseover to change selected time',
2152
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "Hover over Time Slider rail or time indicator")
2153
- }, {
2154
- title: 'Mouseover switch on/off',
2155
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2156
- type: "icon"
2157
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2158
- type: "connect"
2159
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2160
- type: "icon"
2161
- }, "Alt"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2162
- type: "connect"
2163
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2164
- type: "icon"
2165
- }, "h")),
2166
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2167
- type: "icon"
2168
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2169
- type: "connect"
2170
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2171
- type: "icon"
2172
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyOption, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2173
- type: "connect"
2174
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2175
- type: "icon"
2176
- }, "h"))
2177
- }, {
2178
- title: 'Change time step or animation speed',
2179
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2180
- type: "icon"
2181
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2182
- type: "connect"
2183
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2184
- type: "icon"
2185
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowUp, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2186
- type: "divider"
2187
- }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2188
- type: "icon"
2189
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowDown, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "(when slider active)")),
2190
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2191
- type: "icon"
2192
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyCommand, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2193
- type: "connect"
2194
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2195
- type: "icon"
2196
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowUp, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2197
- type: "divider"
2198
- }, "or"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2199
- type: "icon"
2200
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowDown, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, "(when slider active)"))
2201
- }, {
2202
- title: 'Return to current time',
2203
- description: /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2204
- type: "icon"
2205
- }, "Home"),
2206
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2207
- type: "icon"
2208
- }, "fn"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2209
- type: "connect"
2210
- }, "+"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2211
- type: "icon"
2212
- }, /*#__PURE__*/React__default["default"].createElement(theme.ArrowLeft, null)))
2213
- }, {
2214
- title: 'Change layer manager values by scrolling',
2215
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2216
- type: "icon"
2217
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + Mouse scroll")),
2218
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2219
- type: "icon"
2220
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyCommand, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + Mouse scroll"))
2221
- }, {
2222
- title: 'Change size of layer manager to small',
2223
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2224
- type: "icon"
2225
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2226
- type: "icon"
2227
- }, "Alt"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2228
- type: "icon"
2229
- }, "s")),
2230
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2231
- type: "icon"
2232
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2233
- type: "icon"
2234
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyOption, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2235
- type: "icon"
2236
- }, "s"))
2237
- }, {
2238
- title: 'Change size of layer manager to medium',
2239
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2240
- type: "icon"
2241
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2242
- type: "icon"
2243
- }, "Alt"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2244
- type: "icon"
2245
- }, "m")),
2246
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2247
- type: "icon"
2248
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2249
- type: "icon"
2250
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyOption, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2251
- type: "icon"
2252
- }, "m"))
2253
- }, {
2254
- title: 'Change size of layer manager to large',
2255
- description: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2256
- type: "icon"
2257
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2258
- type: "icon"
2259
- }, "Alt"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2260
- type: "icon"
2261
- }, "l")),
2262
- descriptionMac: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2263
- type: "icon"
2264
- }, "Ctrl"), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2265
- type: "icon"
2266
- }, /*#__PURE__*/React__default["default"].createElement(theme.KeyOption, null)), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, null, " + "), /*#__PURE__*/React__default["default"].createElement(ShortCutSegment, {
2267
- type: "icon"
2268
- }, "l"))
2269
- }];
2270
- var getShortcutList = function getShortcutList(shortcutList, platform) {
2271
- if (platform === void 0) {
2272
- platform = 'windows';
2273
- }
2274
-
2275
- return shortcutList.map(function (_a) {
2276
- var title = _a.title,
2277
- description = _a.description,
2278
- descriptionMac = _a.descriptionMac;
2279
- return __assign({
2280
- title: title,
2281
- description: description
2282
- }, platform === 'windows' ? {
2283
- description: description
2284
- } : {
2285
- description: descriptionMac || description
2286
- });
2287
- });
2288
- };
2289
-
2290
- var ShortcutList = function ShortcutList(_a) {
2291
- var _b = _a.platform,
2292
- platform = _b === void 0 ? 'windows' : _b;
2293
- var rows = getShortcutList(shortcuts, platform);
2294
- return /*#__PURE__*/React__default["default"].createElement(material.List, {
2295
- "data-testid": "list-" + platform
2296
- }, rows.map(function (row, index) {
2297
- return /*#__PURE__*/React__default["default"].createElement(material.ListItem, {
2298
- sx: {
2299
- minHeight: 56
2300
- },
2301
- divider: index !== rows.length - 1,
2302
- key: row.title
2303
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
2304
- container: true,
2305
- direction: "row",
2306
- justifyContent: "space-between",
2307
- alignItems: "center"
2308
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
2309
- item: true,
2310
- sx: {
2311
- fontSize: 12,
2312
- fontWeight: 300,
2313
- letterSpacing: 0.4,
2314
- opacity: 0.67
2315
- }
2316
- }, row.title), /*#__PURE__*/React__default["default"].createElement(material.Grid, {
2317
- item: true
2318
- }, /*#__PURE__*/React__default["default"].createElement(material.Box, {
2319
- sx: {
2320
- alignItems: 'center'
2321
- }
2322
- }, row.description))));
2323
- }));
2324
- };
2325
-
2326
- var TabPanel = function TabPanel(_a) {
2327
- var children = _a.children,
2328
- value = _a.value,
2329
- index = _a.index;
2330
- return /*#__PURE__*/React__default["default"].createElement("div", {
2331
- role: "tabpanel",
2332
- hidden: value !== index,
2333
- id: "tabpanel-" + index,
2334
- "aria-labelledby": "tab-" + index
2335
- }, value === index && children);
2336
- };
2337
-
2338
- var styles = {
2339
- container: {
2340
- margin: '0px 20px',
2341
- maxHeight: '90vh'
2342
- },
2343
- tab: {
2344
- fontSize: 12
2345
- }
2346
- };
2347
-
2348
- var CheatSheet = function CheatSheet() {
2349
- var _a = __read(React__default["default"].useState(0), 2),
2350
- activeTab = _a[0],
2351
- onChangeActiveTab = _a[1];
2352
-
2353
- var onChangeTab = function onChangeTab(_event, newValue) {
2354
- onChangeActiveTab(newValue);
2355
- };
2356
-
2357
- return /*#__PURE__*/React__default["default"].createElement(material.Box, {
2358
- sx: styles.container
2359
- }, /*#__PURE__*/React__default["default"].createElement(material.Tabs, {
2360
- value: activeTab,
2361
- onChange: onChangeTab,
2362
- "aria-label": "platform"
2363
- }, /*#__PURE__*/React__default["default"].createElement(material.Tab, {
2364
- sx: styles.tab,
2365
- label: "Windows"
2366
- }), /*#__PURE__*/React__default["default"].createElement(material.Tab, {
2367
- sx: styles.tab,
2368
- label: "Mac"
2369
- })), /*#__PURE__*/React__default["default"].createElement(TabPanel, {
2370
- value: activeTab,
2371
- index: 0
2372
- }, /*#__PURE__*/React__default["default"].createElement(ShortcutList, null)), /*#__PURE__*/React__default["default"].createElement(TabPanel, {
2373
- value: activeTab,
2374
- index: 1
2375
- }, /*#__PURE__*/React__default["default"].createElement(ShortcutList, {
2376
- platform: "mac"
2377
- })));
2378
- };
2379
-
2380
- var UserMenuItemCheatSheet = function UserMenuItemCheatSheet() {
2381
- var _a = __read(React__default["default"].useState(false), 2),
2382
- open = _a[0],
2383
- setOpen = _a[1];
2384
-
2385
- var onClose = function onClose() {
2386
- setOpen(false);
2387
- };
2388
-
2389
- var onOpen = function onOpen() {
2390
- setOpen(true);
2391
- };
2392
-
2393
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(material.MenuItem, {
2394
- "data-testid": "cheatsheet-btn",
2395
- onClick: onOpen,
2396
- divider: true
2397
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
2398
- container: true
2399
- }, /*#__PURE__*/React__default["default"].createElement(material.Grid, {
2400
- item: true
2401
- }, "Cheat sheet"))), /*#__PURE__*/React__default["default"].createElement(material.Backdrop, {
2402
- "data-testid": "cheatsheet-content",
2403
- open: open,
2404
- sx: {
2405
- zIndex: 1
2406
- }
2407
- }, /*#__PURE__*/React__default["default"].createElement(DraggableComponent, {
2408
- startSize: {
2409
- width: 700
2410
- },
2411
- minHeight: 300,
2412
- minWidth: 500,
2413
- title: "Cheat sheet",
2414
- headerSize: "small",
2415
- isOpen: true,
2416
- onClose: onClose,
2417
- bounds: "parent"
2418
- }, /*#__PURE__*/React__default["default"].createElement(CheatSheet, null))));
2419
- };
2420
-
2421
- /* *
2422
- * Licensed under the Apache License, Version 2.0 (the "License");
2423
- * you may not use this file except in compliance with the License.
2424
- * You may obtain a copy of the License at
2425
- *
2426
- * http://www.apache.org/licenses/LICENSE-2.0
2427
- *
2428
- * Unless required by applicable law or agreed to in writing, software
2429
- * distributed under the License is distributed on an "AS IS" BASIS,
2430
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2431
- * See the License for the specific language governing permissions and
2432
- * limitations under the License.
2433
- *
2434
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2435
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2436
- * */
2437
- var useUserMenu = function useUserMenu(open) {
2438
- if (open === void 0) {
2439
- open = false;
2440
- }
2441
-
2442
- var _a = __read(React__default["default"].useState(open), 2),
2443
- isOpen = _a[0],
2444
- setOpen = _a[1];
2445
-
2446
- var onClose = function onClose() {
2447
- return setOpen(false);
2448
- };
2449
-
2450
- var onToggle = function onToggle() {
2451
- return setOpen(!isOpen);
2452
- };
2453
-
2454
- return {
2455
- isOpen: isOpen,
2456
- onClose: onClose,
2457
- onToggle: onToggle
2458
- };
2459
- };
2460
-
2461
- /* *
2462
- * Licensed under the Apache License, Version 2.0 (the "License");
2463
- * you may not use this file except in compliance with the License.
2464
- * You may obtain a copy of the License at
2465
- *
2466
- * http://www.apache.org/licenses/LICENSE-2.0
2467
- *
2468
- * Unless required by applicable law or agreed to in writing, software
2469
- * distributed under the License is distributed on an "AS IS" BASIS,
2470
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2471
- * See the License for the specific language governing permissions and
2472
- * limitations under the License.
2473
- *
2474
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2475
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2476
- * */
2477
- var getInitials = function getInitials(name) {
2478
- if (!name) {
2479
- return '';
2480
- }
2481
-
2482
- var nameWithoutEmail = name.split('@')[0];
2483
- var array = nameWithoutEmail.split('.');
2484
-
2485
- switch (array.length) {
2486
- case 1:
2487
- return array[0].charAt(0).toUpperCase();
2488
-
2489
- default:
2490
- return array[0].charAt(0).toUpperCase() + array[array.length - 1].charAt(0).toUpperCase();
2491
- }
2492
- };
2493
-
2494
- /* *
2495
- * Licensed under the Apache License, Version 2.0 (the "License");
2496
- * you may not use this file except in compliance with the License.
2497
- * You may obtain a copy of the License at
2498
- *
2499
- * http://www.apache.org/licenses/LICENSE-2.0
2500
- *
2501
- * Unless required by applicable law or agreed to in writing, software
2502
- * distributed under the License is distributed on an "AS IS" BASIS,
2503
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2504
- * See the License for the specific language governing permissions and
2505
- * limitations under the License.
2506
- *
2507
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2508
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2509
- * */
2510
- var sliderHeaderStyle = {
2511
- fontFamily: 'Roboto-Black, Roboto',
2512
- fontSize: 12,
2513
- color: 'geowebColors.typographyAndIcons.text',
2514
- padding: '11px 0 11px 16px'
2515
- };
2516
- var sliderStyle = {
2517
- '& span.selectedLabel': {
2518
- fontWeight: 'bold'
2519
- },
2520
- '& .MuiSlider-thumb': {
2521
- backgroundColor: 'geowebColors.customSlider.thumb',
2522
- boxShadow: '0px 3px 5px 1px rgba(0,0,0,0.3)',
2523
- '&.Mui-focusVisible, &:hover, &:active': {
2524
- boxShadow: '0px 3px 5px 2px rgba(0,0,0,0.4)'
2525
- }
2526
- },
2527
- '& .MuiSlider-mark': {
2528
- backgroundColor: 'geowebColors.customSlider.mark'
2529
- },
2530
- '& .MuiSlider-markLabel': {
2531
- fontFamily: 'Roboto-Black, Roboto',
2532
- fontSize: 12,
2533
- color: 'geowebColors.typographyAndIcons.text'
2534
- },
2535
- '& .MuiSlider-track': {
2536
- color: 'geowebColors.customSlider.track',
2537
- backgroundColor: 'geowebColors.customSlider.track'
2538
- },
2539
- '& .MuiSlider-rail': {
2540
- backgroundColor: 'geowebColors.customSlider.rail',
2541
- opacity: 1
2542
- },
2543
- '&.Mui-disabled': {
2544
- '& .MuiSlider-thumb': {
2545
- backgroundColor: 'geowebColors.customSlider.thumbDisabled'
2546
- },
2547
- '& .MuiSlider-mark': {
2548
- backgroundColor: 'geowebColors.customSlider.markDisabled'
2549
- },
2550
- '& .MuiSlider-track': {
2551
- backgroundColor: 'geowebColors.customSlider.trackDisabled',
2552
- color: 'geowebColors.customSlider.trackDisabled'
2553
- },
2554
- '& .MuiSlider-rail': {
2555
- backgroundColor: 'geowebColors.customSlider.railDisabled',
2556
- opacity: 1
2557
- }
2558
- }
2559
- };
2560
- var CustomSlider = function CustomSlider(_a) {
2561
- var value = _a.value,
2562
- _b = _a.orientation,
2563
- orientation = _b === void 0 ? 'vertical' : _b,
2564
- _c = _a.shouldAutoFocus,
2565
- shouldAutoFocus = _c === void 0 ? false : _c,
2566
- props = __rest(_a, ["value", "orientation", "shouldAutoFocus"]); // Add custom class (for bold text) to label adjacent to thumb component.
2567
- // Material UI doesn't support highlighing only adjacent label
2568
- // when track is highlighted everywhere below selected value.
2569
-
2570
-
2571
- var element = React__namespace.useRef(null);
2572
- var themeContext = theme.useThemeContext();
2573
- React__namespace.useEffect(function () {
2574
- var activeMarkLabelElements = element.current.getElementsByClassName('MuiSlider-markLabelActive');
2575
-
2576
- var _a = __read(__spreadArray([], __read(activeMarkLabelElements)).reverse()),
2577
- first = _a[0],
2578
- rest = _a.slice(1);
2579
-
2580
- if (first) {
2581
- first.classList.add('selectedLabel');
2582
- }
2583
-
2584
- rest.forEach(function (element) {
2585
- return element.classList.remove('selectedLabel');
2586
- });
2587
- }, [value, themeContext.isDark]); // autofocus
2588
-
2589
- React__namespace.useEffect(function () {
2590
- if (shouldAutoFocus && element.current) {
2591
- var thumb = element.current.querySelector('.MuiSlider-thumb input');
2592
- thumb.focus();
2593
- } // eslint-disable-next-line react-hooks/exhaustive-deps
2594
-
2595
- }, []);
2596
- return /*#__PURE__*/React__namespace.createElement(material.Slider, __assign({
2597
- sx: sliderStyle,
2598
- ref: element,
2599
- value: value,
2600
- orientation: orientation
2601
- }, props));
2602
- };
2603
-
2604
- /* *
2605
- * Licensed under the Apache License, Version 2.0 (the "License");
2606
- * you may not use this file except in compliance with the License.
2607
- * You may obtain a copy of the License at
2608
- *
2609
- * http://www.apache.org/licenses/LICENSE-2.0
2610
- *
2611
- * Unless required by applicable law or agreed to in writing, software
2612
- * distributed under the License is distributed on an "AS IS" BASIS,
2613
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2614
- * See the License for the specific language governing permissions and
2615
- * limitations under the License.
2616
- *
2617
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2618
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2619
- * */
2620
-
2621
- var CustomToggleButton = /*#__PURE__*/React__namespace.forwardRef(function (_a, ref) {
2622
- var _b = _a.variant,
2623
- variant = _b === void 0 ? 'primary' : _b,
2624
- className = _a.className,
2625
- _c = _a.value,
2626
- value = _c === void 0 ? 0 : _c,
2627
- props = __rest(_a, ["variant", "className", "value"]);
2628
-
2629
- return /*#__PURE__*/React__namespace.createElement(material.ToggleButton, __assign({
2630
- ref: ref,
2631
- className: variant + " " + className,
2632
- value: value
2633
- }, props));
2634
- });
2635
-
2636
- var getPosition = function getPosition(menuPosition) {
2637
- switch (menuPosition) {
2638
- case 'bottom':
2639
- return {
2640
- anchorOrigin: {
2641
- vertical: 'bottom',
2642
- horizontal: 'center'
2643
- },
2644
- transformOrigin: {
2645
- vertical: 'top',
2646
- horizontal: 'center'
2647
- }
2648
- };
2649
-
2650
- default:
2651
- case 'left':
2652
- return {
2653
- anchorOrigin: {
2654
- vertical: 'center',
2655
- horizontal: 'left'
2656
- },
2657
- transformOrigin: {
2658
- vertical: 'center',
2659
- horizontal: 'right'
2660
- }
2661
- };
2662
-
2663
- case 'right':
2664
- return {
2665
- anchorOrigin: {
2666
- vertical: 'center',
2667
- horizontal: 'right'
2668
- },
2669
- transformOrigin: {
2670
- vertical: 'center',
2671
- horizontal: 'left'
2672
- }
2673
- };
2674
- }
2675
- };
2676
- var ToggleMenu = function ToggleMenu(_a) {
2677
- var _b = _a.buttonTestId,
2678
- buttonTestId = _b === void 0 ? 'toggleMenuButton' : _b,
2679
- _c = _a.menuPosition,
2680
- menuPosition = _c === void 0 ? 'left' : _c,
2681
- menuItems = _a.menuItems,
2682
- children = _a.children,
2683
- buttonSx = _a.buttonSx,
2684
- _d = _a.tooltipTitle,
2685
- tooltipTitle = _d === void 0 ? '' : _d,
2686
- _e = _a.menuTitle,
2687
- menuTitle = _e === void 0 ? '' : _e,
2688
- _f = _a.variant,
2689
- variant = _f === void 0 ? 'tool' : _f,
2690
- _g = _a.isDefaultOpen,
2691
- isDefaultOpen = _g === void 0 ? false : _g,
2692
- _h = _a.buttonIcon,
2693
- buttonIcon = _h === void 0 ? /*#__PURE__*/React__namespace.createElement(theme.Options, null) : _h;
2694
-
2695
- var _j = __read(React__namespace.useState(null), 2),
2696
- anchorEl = _j[0],
2697
- setAnchorEl = _j[1];
2698
-
2699
- var isOpen = Boolean(anchorEl);
2700
-
2701
- var _k = getPosition(menuPosition),
2702
- anchorOrigin = _k.anchorOrigin,
2703
- transformOrigin = _k.transformOrigin;
2704
-
2705
- var handleClick = function handleClick(event) {
2706
- event.stopPropagation();
2707
- setAnchorEl(event.currentTarget);
2708
- };
2709
-
2710
- var handleClose = function handleClose(event) {
2711
- event.stopPropagation();
2712
- setAnchorEl(null);
2713
- };
2714
-
2715
- React__namespace.useEffect(function () {
2716
- if (isDefaultOpen) {
2717
- setAnchorEl(document.getElementById(buttonTestId));
2718
- }
2719
- }, [isDefaultOpen, buttonTestId]);
2720
- return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(CustomIconButton, {
2721
- tooltipProps: {
2722
- placement: 'top',
2723
- title: tooltipTitle
2724
- },
2725
- isSelected: isOpen,
2726
- sx: buttonSx,
2727
- onClick: handleClick,
2728
- "data-testid": buttonTestId,
2729
- variant: variant,
2730
- id: buttonTestId
2731
- }, buttonIcon), /*#__PURE__*/React__namespace.createElement(material.Menu, {
2732
- anchorEl: anchorEl,
2733
- open: isOpen,
2734
- onClose: function onClose(event, reason) {
2735
- if (reason === 'tabKeyDown') {
2736
- return;
2737
- }
2738
-
2739
- handleClose(event);
2740
- },
2741
- anchorOrigin: anchorOrigin,
2742
- transformOrigin: transformOrigin,
2743
- BackdropProps: {
2744
- style: {
2745
- opacity: 0,
2746
- transition: 'none'
2747
- }
2748
- },
2749
- MenuListProps: __assign({}, children && {
2750
- style: {
2751
- padding: '0px'
2752
- }
2753
- })
2754
- }, menuTitle && /*#__PURE__*/React__namespace.createElement(material.ListSubheader, {
2755
- "data-testid": "toggleMenuTitle"
2756
- }, /*#__PURE__*/React__namespace.createElement(material.Typography, {
2757
- sx: {
2758
- fontSize: '12px'
2759
- }
2760
- }, menuTitle)), menuItems && menuItems.length ? menuItems.map(function (menuItem) {
2761
- var text = menuItem.text,
2762
- icon = menuItem.icon,
2763
- action = menuItem.action;
2764
- return /*#__PURE__*/React__namespace.createElement(material.MenuItem, {
2765
- key: text,
2766
- onClick: function onClick(event) {
2767
- action(event);
2768
- handleClose(event);
2769
- }
2770
- }, icon && /*#__PURE__*/React__namespace.createElement(material.ListItemIcon, null, icon), /*#__PURE__*/React__namespace.createElement(material.Typography, null, text));
2771
- }) : /*#__PURE__*/React__namespace.createElement("div", null) // Needed to make the menu work without any menuItems
2772
- , children));
2773
- };
2774
-
2775
- /* *
2776
- * Licensed under the Apache License, Version 2.0 (the "License");
2777
- * you may not use this file except in compliance with the License.
2778
- * You may obtain a copy of the License at
2779
- *
2780
- * http://www.apache.org/licenses/LICENSE-2.0
2781
- *
2782
- * Unless required by applicable law or agreed to in writing, software
2783
- * distributed under the License is distributed on an "AS IS" BASIS,
2784
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2785
- * See the License for the specific language governing permissions and
2786
- * limitations under the License.
2787
- *
2788
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2789
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
2790
- * */
2791
- var tooltipContainerStyles = function tooltipContainerStyles(isEnabled, hasBackgroundColor) {
2792
- if (hasBackgroundColor === void 0) {
2793
- hasBackgroundColor = true;
2794
- }
2795
-
2796
- return __assign({
2797
- width: '100%',
2798
- height: 32,
2799
- fontWeight: 500,
2800
- fontSize: function fontSize(theme) {
2801
- return theme.palette.geowebColors.layerManager.tableRowDefaultText.fontSize;
2802
- },
2803
- color: isEnabled ? 'geowebColors.layerManager.tableRowDefaultText.rgba' : 'geowebColors.layerManager.tableRowDisabledText.rgba',
2804
- '& .MuiOutlinedInput-input': {
2805
- padding: '6px 24px 6px 8px'
2806
- },
2807
- '& .MuiOutlinedInput-notchedOutline': {
2808
- borderColor: 'transparent!important'
2809
- },
2810
- '&:hover': {
2811
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2812
- borderRadius: 0
2813
- },
2814
- '&.Mui-focused .MuiSelect-select': {
2815
- outline: function outline(theme) {
2816
- return theme.palette.geowebColors.buttons.tool.focus.outline;
2817
- },
2818
- borderRadius: 0
2819
- },
2820
- '& .MuiSvgIcon-root': {
2821
- transition: 'none',
2822
- fill: function fill(theme) {
2823
- return isEnabled ? theme.palette.geowebColors.buttons.flat["default"].color : theme.palette.geowebColors.buttons.flat.disabled.color;
2824
- }
2825
- },
2826
- '&>div': {
2827
- paddingLeft: '8px!important'
2828
- }
2829
- }, hasBackgroundColor && backgroundColor);
2830
- };
2831
- var backgroundColor = {
2832
- '&:hover .MuiSelect-select': {
2833
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2834
- borderRadius: 0
2835
- },
2836
- '&.Mui-focused .MuiSelect-select': {
2837
- outline: function outline(theme) {
2838
- return theme.palette.geowebColors.buttons.tool.focus.outline;
2839
- },
2840
- borderRadius: 0,
2841
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2842
- },
2843
- '&:hover&.MuiButton-root': {
2844
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2845
- },
2846
- '&:focus&.MuiButton-root': {
2847
- border: function border(theme) {
2848
- return theme.palette.geowebColors.buttons.tool.focus.outline;
2849
- },
2850
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill',
2851
- transition: 'border'
2852
- }
2853
- };
2854
-
2855
- /* *
2856
- * Licensed under the Apache License, Version 2.0 (the "License");
2857
- * you may not use this file except in compliance with the License.
2858
- * You may obtain a copy of the License at
2859
- *
2860
- * http://www.apache.org/licenses/LICENSE-2.0
2861
- *
2862
- * Unless required by applicable law or agreed to in writing, software
2863
- * distributed under the License is distributed on an "AS IS" BASIS,
2864
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2865
- * See the License for the specific language governing permissions and
2866
- * limitations under the License.
2867
- *
2868
- * Copyright 2020 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
2869
- * Copyright 2020 - Finnish Meteorological Institute (FMI)
2870
- * */
2871
- var TooltipSelect = function TooltipSelect(_a) {
2872
- var tooltip = _a.tooltip,
2873
- _b = _a.list,
2874
- list = _b === void 0 ? [] : _b,
2875
- _c = _a.currentIndex,
2876
- currentIndex = _c === void 0 ? -1 : _c,
2877
- _d = _a.onChangeMouseWheel,
2878
- onChangeMouseWheel = _d === void 0 ? function () {} : _d,
2879
- _e = _a.requiresCtrlToChange,
2880
- requiresCtrlToChange = _e === void 0 ? false : _e,
2881
- isEnabled = _a.isEnabled,
2882
- noStyling = _a.noStyling,
2883
- hasBackgroundColor = _a.hasBackgroundColor,
2884
- props = __rest(_a, ["tooltip", "list", "currentIndex", "onChangeMouseWheel", "requiresCtrlToChange", "isEnabled", "noStyling", "hasBackgroundColor"]);
2885
-
2886
- var _f = __read(React__namespace.useState(false), 2),
2887
- selectOpen = _f[0],
2888
- setSelectOpen = _f[1];
2889
-
2890
- var _g = __read(useControlledTooltip(), 2),
2891
- tooltipOpen = _g[0],
2892
- setTooltipOpen = _g[1];
2893
-
2894
- var theme = material.useTheme();
2895
- var onWheel = React__namespace.useCallback(function (event) {
2896
- if (requiresCtrlToChange && (event.ctrlKey || event.metaKey) || !requiresCtrlToChange) {
2897
- if (selectOpen) {
2898
- return;
2899
- }
2900
-
2901
- var direction = event.deltaY < 0 ? 1 : -1;
2902
- var newIndex = currentIndex - direction;
2903
-
2904
- if (newIndex < 0 || newIndex >= list.length) {
2905
- return;
2906
- }
2907
-
2908
- onChangeMouseWheel(list[newIndex]);
2909
- }
2910
- }, [selectOpen, currentIndex, list, onChangeMouseWheel, requiresCtrlToChange]);
2911
- var onOpen = React__namespace.useCallback(function () {
2912
- setSelectOpen(true);
2913
- setTooltipOpen(false);
2914
- }, [setTooltipOpen]);
2915
- var onClose = React__namespace.useCallback(function () {
2916
- setSelectOpen(false);
2917
- }, []);
2918
- var onMouseEnter = React__namespace.useCallback(function () {
2919
- if (!selectOpen) {
2920
- setTooltipOpen(true);
2921
- }
2922
- }, [selectOpen, setTooltipOpen]);
2923
- var onMouseLeave = React__namespace.useCallback(function () {
2924
- setTooltipOpen(false);
2925
- }, [setTooltipOpen]);
2926
- var onFocus = React__namespace.useCallback(function () {
2927
- setTooltipOpen(true);
2928
- }, [setTooltipOpen]);
2929
- var onBlur = React__namespace.useCallback(function () {
2930
- setTooltipOpen(false);
2931
- }, [setTooltipOpen]);
2932
- var selectStyles = noStyling ? {} : tooltipContainerStyles(!!isEnabled, hasBackgroundColor);
2933
- return /*#__PURE__*/React__namespace.createElement(CustomTooltip, {
2934
- title: tooltip,
2935
- placement: "top",
2936
- open: tooltipOpen
2937
- }, /*#__PURE__*/React__namespace.createElement(material.Select, __assign({
2938
- variant: "standard",
2939
- disableUnderline: true,
2940
- onOpen: onOpen,
2941
- onClose: onClose,
2942
- onMouseEnter: onMouseEnter,
2943
- onMouseLeave: onMouseLeave,
2944
- onFocus: onFocus,
2945
- onBlur: onBlur,
2946
- onWheel: onWheel,
2947
- MenuProps: {
2948
- BackdropProps: {
2949
- sx: {
2950
- '&.MuiBackdrop-root': {
2951
- backgroundColor: 'transparent'
2952
- }
2953
- }
2954
- },
2955
- sx: __assign({
2956
- '& ul': {
2957
- backgroundColor: 'geowebColors.background.surface'
2958
- },
2959
- '& li': {
2960
- fontSize: '16px',
2961
- padding: '12px',
2962
- '&:hover': {
2963
- backgroundColor: 'geowebColors.buttons.tool.mouseOver.fill'
2964
- },
2965
- '&.Mui-selected': {
2966
- color: 'geowebColors.buttons.tool.active.color',
2967
- backgroundColor: 'geowebColors.buttons.tool.active.fill',
2968
- boxShadow: "none",
2969
- '&:hover': {
2970
- backgroundColor: 'geowebColors.buttons.tool.activeMouseOver.fill'
2971
- },
2972
- '&:focus': {
2973
- backgroundColor: 'geowebColors.buttons.tool.activeMouseOver.fill'
2974
- },
2975
- '.MuiListItemIcon-root': {
2976
- color: 'geowebColors.buttons.tool.active.color'
2977
- }
2978
- },
2979
- '&:after': {
2980
- background: 'none!important'
2981
- },
2982
- '&.Mui-disabled': {
2983
- fontSize: '12px',
2984
- opacity: 0.67,
2985
- padding: '0px 12px',
2986
- '&.MuiMenuItem-root': {
2987
- minHeight: '30px!important'
2988
- }
2989
- }
2990
- }
2991
- }, theme.palette.geowebColors.tooltips.tooltipSelect.menu)
2992
- },
2993
- sx: __assign(__assign({}, selectStyles), theme.palette.geowebColors.tooltips.tooltipSelect.select)
2994
- }, props)));
2995
- };
2996
-
2997
- function withEggs(eggs) {
2998
- return function (Component) {
2999
- var WithEggs = function WithEggs(props) {
3000
- var store = reactRedux.useStore();
3001
-
3002
- var _a = __read(React__namespace.useState(function () {
3003
- return store.addEggs(eggs);
3004
- }), 1),
3005
- remover = _a[0];
3006
-
3007
- React__namespace.useEffect(function () {
3008
- return remover;
3009
- }, [remover]);
3010
- return /*#__PURE__*/React__namespace.createElement(Component, __assign({}, props));
3011
- };
3012
-
3013
- WithEggs.displayName = "withEggs(" + (Component.displayName || Component.name || 'Component') + ")";
3014
- return WithEggs;
3015
- };
3016
- }
3017
-
3018
- var CustomAccordion = function CustomAccordion(_a) {
3019
- var title = _a.title,
3020
- _b = _a.defaultExpanded,
3021
- defaultExpanded = _b === void 0 ? true : _b,
3022
- _c = _a.disableGutters,
3023
- disableGutters = _c === void 0 ? true : _c,
3024
- _d = _a.expandedElevation,
3025
- expandedElevation = _d === void 0 ? 3 : _d,
3026
- _e = _a.collapsedElevation,
3027
- collapsedElevation = _e === void 0 ? 0 : _e,
3028
- _f = _a.transitionDuration,
3029
- transitionDuration = _f === void 0 ? 150 : _f,
3030
- detailsSx = _a.detailsSx,
3031
- children = _a.children,
3032
- props = __rest(_a, ["title", "defaultExpanded", "disableGutters", "expandedElevation", "collapsedElevation", "transitionDuration", "detailsSx", "children"]);
3033
-
3034
- var _g = __read(React__namespace.useState(defaultExpanded), 2),
3035
- expanded = _g[0],
3036
- setExpanded = _g[1];
3037
-
3038
- return /*#__PURE__*/React__namespace.createElement(material.Accordion, __assign({}, props, {
3039
- defaultExpanded: defaultExpanded,
3040
- elevation: expanded ? expandedElevation : collapsedElevation,
3041
- onChange: function onChange(_event, expanded) {
3042
- return setExpanded(expanded);
3043
- },
3044
- disableGutters: disableGutters,
3045
- TransitionProps: {
3046
- timeout: transitionDuration
3047
- }
3048
- }), /*#__PURE__*/React__namespace.createElement(material.AccordionSummary, {
3049
- expandIcon: /*#__PURE__*/React__namespace.createElement(theme.ChevronDown, null)
3050
- }, title), /*#__PURE__*/React__namespace.createElement(material.AccordionDetails, {
3051
- sx: detailsSx
3052
- }, children));
3053
- };
3054
-
3055
- /* *
3056
- * Licensed under the Apache License, Version 2.0 (the "License");
3057
- * you may not use this file except in compliance with the License.
3058
- * You may obtain a copy of the License at
3059
- *
3060
- * http://www.apache.org/licenses/LICENSE-2.0
3061
- *
3062
- * Unless required by applicable law or agreed to in writing, software
3063
- * distributed under the License is distributed on an "AS IS" BASIS,
3064
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3065
- * See the License for the specific language governing permissions and
3066
- * limitations under the License.
3067
- *
3068
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3069
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
3070
- * */
3071
- var highlightStyle = {
3072
- background: '#ffeecc'
3073
- };
3074
-
3075
- var SearchHighlight = function SearchHighlight(_a) {
3076
- var _b = _a.text,
3077
- text = _b === void 0 ? '' : _b,
3078
- search = _a.search;
3079
-
3080
- if (search === '') {
3081
- return /*#__PURE__*/React__default["default"].createElement("span", null, text);
3082
- }
3083
-
3084
- var searchWords = search.split(' ').reduce(function (words, word) {
3085
- return word ? __spreadArray(__spreadArray([], __read(words)), [word.toLocaleLowerCase()]) : words;
3086
- }, []);
3087
- var searchRegex = searchWords.map(function (word) {
3088
- return lodash.escapeRegExp(word);
3089
- }).join('|');
3090
- var textParts = text.split(new RegExp("(" + searchRegex + ")", 'gi'));
3091
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, textParts.map(function (part, index) {
3092
- var key = part + "-" + index;
3093
-
3094
- if (searchWords.some(function (search) {
3095
- return part.toLocaleLowerCase().includes(search);
3096
- })) {
3097
- return /*#__PURE__*/React__default["default"].createElement("mark", {
3098
- key: key,
3099
- style: highlightStyle
3100
- }, part);
3101
- }
3102
-
3103
- return /*#__PURE__*/React__default["default"].createElement("span", {
3104
- key: key
3105
- }, part);
3106
- }));
3107
- };
3108
-
3109
- /* *
3110
- * Licensed under the Apache License, Version 2.0 (the "License");
3111
- * you may not use this file except in compliance with the License.
3112
- * You may obtain a copy of the License at
3113
- *
3114
- * http://www.apache.org/licenses/LICENSE-2.0
3115
- *
3116
- * Unless required by applicable law or agreed to in writing, software
3117
- * distributed under the License is distributed on an "AS IS" BASIS,
3118
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3119
- * See the License for the specific language governing permissions and
3120
- * limitations under the License.
3121
- *
3122
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3123
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
3124
- * */
3125
- var DEFAULT_ERROR_MESSAGE = 'An error has occurred'; // Guard function for detecting an AxiosError (typically the kind of error returned by the backend)
3126
-
3127
- var isAxiosError = function isAxiosError(error) {
3128
- return error.isAxiosError !== undefined;
3129
- };
3130
- var getAxiosErrorMessage = function getAxiosErrorMessage(error) {
3131
- var data = error.response && error.response.data;
3132
-
3133
- if (data && typeof data === 'string') {
3134
- return data;
3135
- }
3136
-
3137
- if (data && data.message && typeof data.message === 'string') {
3138
- return data.message;
3139
- }
3140
-
3141
- if (error.message) {
3142
- return error.message;
3143
- }
3144
-
3145
- return DEFAULT_ERROR_MESSAGE;
3146
- };
3147
- var getErrorMessage = function getErrorMessage(error) {
3148
- if (isAxiosError(error)) {
3149
- return getAxiosErrorMessage(error);
3150
- }
3151
-
3152
- return error.message || DEFAULT_ERROR_MESSAGE;
3153
- };
3154
- var getAxiosWarningMessage = function getAxiosWarningMessage(error) {
3155
- var data = error.response && error.response.data;
3156
-
3157
- if (data && data.WarningMessage && typeof data.WarningMessage === 'string') {
3158
- return data.WarningMessage;
3159
- }
3160
-
3161
- return '';
3162
- };
3163
- var getWarningMessage = function getWarningMessage(error) {
3164
- if (isAxiosError(error)) {
3165
- return getAxiosWarningMessage(error);
3166
- }
3167
-
3168
- return '';
3169
- };
3170
-
3171
- /* *
3172
- * Licensed under the Apache License, Version 2.0 (the "License");
3173
- * you may not use this file except in compliance with the License.
3174
- * You may obtain a copy of the License at
3175
- *
3176
- * http://www.apache.org/licenses/LICENSE-2.0
3177
- *
3178
- * Unless required by applicable law or agreed to in writing, software
3179
- * distributed under the License is distributed on an "AS IS" BASIS,
3180
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3181
- * See the License for the specific language governing permissions and
3182
- * limitations under the License.
3183
- *
3184
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3185
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
3186
- * */
3187
- /**
3188
- * Parsing date strings with geoweb dateUtils:
3189
- *
3190
- * An ISO String *with timezone* can safely be parsed directly to a date:
3191
- *
3192
- * date = new Date('2022-10-10T15:30:00Z')
3193
- * date = new Date('2022-10-10T15:30:00+00:00')
3194
- * date = new Date('2022-10-10T15:30:00+02:00')
3195
- *
3196
- * or using the dateUtils isoStringToDate function *with utc=false*
3197
- *
3198
- * date = isoStringToDate('2022-10-10T15:30:00Z', false)
3199
- *
3200
- * An ISO String *without a timezone* can be parsed with isoStringToDate
3201
- *
3202
- * date = isoStringToDate('2022-10-10T15:30:00')
3203
- *
3204
- * *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
3205
- *
3206
- * To parse an arbitrary date string with timezone use:
3207
- *
3208
- * date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
3209
- *
3210
- * To parse an arbitrary date string without timezone use:
3211
- *
3212
- * date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
3213
- *
3214
- *
3215
- * To safely convert dates to utc strings use:
3216
- *
3217
- * date.toISOString()
3218
- *
3219
- * To get parts of UTC time use
3220
- *
3221
- * date.getUTCHours()
3222
- * date.getUTCMins()
3223
- *
3224
- * To parse an arbitrary date string to a UTC string use:
3225
- *
3226
- * dateToString(new Date('2022-10-10T15:30:00Z', 'HH:ss dd MMM yyyy')
3227
- *
3228
- */
3229
-
3230
- /**
3231
- * Parse an ISO string to a date
3232
- *
3233
- * Expects the following props:
3234
- * @param {string} input - string containing date
3235
- *
3236
- * @returns {Date} Date
3237
- * @example
3238
- * ``` isoStringToDate("2022-5-10T20:32:00+00:00")) ```
3239
- */
3240
-
3241
- var isoStringToDate = function isoStringToDate(input, utc) {
3242
- if (utc === void 0) {
3243
- utc = true;
3244
- }
3245
-
3246
- var parsed = dateFns.parseISO(input);
3247
-
3248
- if (utc) {
3249
- return setUTCDate(parsed);
3250
- }
3251
-
3252
- return parsed;
3253
- };
3254
- /**
3255
- * Parse a string to a date
3256
- *
3257
- * ***NOTE: String will be parsed in local time if utc is set to false***
3258
- *
3259
- * Expects the following props:
3260
- * @param {string} input - string containing date
3261
- * @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
3262
- * @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
3263
- * @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
3264
- *
3265
- * @returns {Date} Date
3266
- * @example
3267
- * ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
3268
- */
3269
-
3270
- var stringToDate = function stringToDate(input, strFormat, utc, referenceDate) {
3271
- if (utc === void 0) {
3272
- utc = true;
3273
- }
3274
-
3275
- if (referenceDate === void 0) {
3276
- referenceDate = new Date();
3277
- }
3278
-
3279
- var parsed = dateFns.parse(input, strFormat, referenceDate);
3280
-
3281
- if (utc) {
3282
- return setUTCDate(parsed);
3283
- }
3284
-
3285
- return parsed;
3286
- };
3287
- /**
3288
- * Use this if you initialise a date without a timezone to set it to utc correctly
3289
- * eg.
3290
- * new Date(2022, 10, 12, 15, 30)
3291
- * should be:
3292
- * setUTCDate(new Date(2022, 10, 12, 15, 30))
3293
- *
3294
- * Expects the following props:
3295
- * @param {Date} inDate - date to be set to UTC
3296
- *
3297
- * @returns {Date} - Date in UTC
3298
- * @example
3299
- * ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
3300
- */
3301
-
3302
- var setUTCDate = function setUTCDate(inDate) {
3303
- var utcDate = new Date(inDate);
3304
- utcDate.setUTCFullYear(inDate.getFullYear(), inDate.getMonth(), inDate.getDate());
3305
- utcDate.setUTCHours(inDate.getHours(), inDate.getMinutes(), inDate.getSeconds(), inDate.getMilliseconds());
3306
- return utcDate;
3307
- };
3308
- /**
3309
- * Format a date to a string
3310
- *
3311
- * Expects the following props:
3312
- * @param {Date} inDate - date to be formatted
3313
- * @param {string} strFormat - format of string
3314
- * @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
3315
- *
3316
- * @returns {string} - formatted date string
3317
- * @example
3318
- * ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
3319
- */
3320
-
3321
- var dateToString = function dateToString(inDate, strFormat, utc) {
3322
- if (utc === void 0) {
3323
- utc = true;
3324
- }
3325
-
3326
- if (utc) {
3327
- return dateFns.format(new Date(inDate.getUTCFullYear(), inDate.getUTCMonth(), inDate.getUTCDate(), inDate.getUTCHours(), inDate.getUTCMinutes(), inDate.getUTCSeconds()), strFormat);
3328
- }
3329
-
3330
- return dateFns.format(inDate, strFormat);
3331
- };
3332
- /**
3333
- * Find out if a date is between two other dates.
3334
- *
3335
- * Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
3336
- *
3337
- * Expects the following props:
3338
- * @param {Date} date - date to be tested
3339
- * @param {Date} from - first date
3340
- * @param {Date} to - last date
3341
- * @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
3342
- *
3343
- * @returns {boolen} - true if date is between, otherwise false
3344
- *
3345
- */
3346
-
3347
- var isBetween = function isBetween(date, from, to, inclusivity) {
3348
- if (inclusivity === void 0) {
3349
- inclusivity = '()';
3350
- }
3351
-
3352
- if (!['()', '[]', '(]', '[)'].includes(inclusivity)) {
3353
- throw new Error('Inclusivity parameter must be one of (), [], (], [)');
3354
- }
3355
-
3356
- var isBeforeEqual = inclusivity[0] === '[';
3357
- var isAfterEqual = inclusivity[1] === ']';
3358
- return (isBeforeEqual ? dateFns.isEqual(from, date) || dateFns.isBefore(from, date) : dateFns.isBefore(from, date)) && (isAfterEqual ? dateFns.isEqual(to, date) || dateFns.isAfter(to, date) : dateFns.isAfter(to, date));
3359
- };
3360
- /**
3361
- * Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
3362
- *
3363
- * @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
3364
- * @param month The month for the new Date object (0-11).
3365
- * @param day The day for the new Date object (1-31).
3366
- * @param hours The hour for the new Date object (0-23).
3367
- * @param minutes The minute for the new Date object (0-59).
3368
- * @param seconds The second for the new Date object (0-59).
3369
- * @param milliseconds The millisecond for the new Date object (0-999).
3370
- * @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
3371
- *
3372
- * @example
3373
- * createDate(2022, 11, 13);
3374
- * // => 2022-12-13T00:00:00.000Z
3375
- *
3376
- * @example
3377
- * createDate('2022-12-13T00:00:00.000Z');
3378
- * // => 2022-12-13T00:00:00.000Z
3379
- */
3380
-
3381
- var createDate = function createDate(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds) {
3382
- if (hours === void 0) {
3383
- hours = 0;
3384
- }
3385
-
3386
- if (minutes === void 0) {
3387
- minutes = 0;
3388
- }
3389
-
3390
- if (seconds === void 0) {
3391
- seconds = 0;
3392
- }
3393
-
3394
- if (milliseconds === void 0) {
3395
- milliseconds = 0;
3396
- }
3397
-
3398
- if (yearOrIsoString === undefined) {
3399
- return new Date();
3400
- }
3401
-
3402
- if (typeof yearOrIsoString === 'string') {
3403
- return new Date(yearOrIsoString);
3404
- }
3405
-
3406
- return new Date(yearOrIsoString, month, day, hours, minutes, seconds, milliseconds);
3407
- };
3408
- /**
3409
- *
3410
- * @param date
3411
- * @param duration
3412
- * @returns {Date} the new Date
3413
- */
3414
-
3415
- var add = function add(date, duration) {
3416
- return dateFns.add(date, duration);
3417
- };
3418
- /**
3419
- *
3420
- * @param date
3421
- * @param duration
3422
- * @returns {Date} the new Date
3423
- */
3424
-
3425
- var sub = function sub(date, duration) {
3426
- return dateFns.sub(date, duration);
3427
- };
3428
- /**
3429
- * Finds the number of minuts between to dates
3430
- *
3431
- * @param dateLeft - the later date
3432
- * @param dateRight - the earlier date
3433
- * @returns {number} the number of minutes
3434
- */
3435
-
3436
- var differenceInMinutes = function differenceInMinutes(dateLeft, dateRight) {
3437
- return dateFns.differenceInMinutes(dateLeft, dateRight);
3438
- };
3439
- /**
3440
- * Finds the number of hours between to dates
3441
- *
3442
- * @param dateLeft - the later date
3443
- * @param dateRight - the earlier date
3444
- * @returns {number} the number of hours
3445
- */
3446
-
3447
- var differenceInHours = function differenceInHours(dateLeft, dateRight) {
3448
- return dateFns.differenceInHours(dateLeft, dateRight);
3449
- };
3450
-
3451
- /* *
3452
- * Licensed under the Apache License, Version 2.0 (the "License");
3453
- * you may not use this file except in compliance with the License.
3454
- * You may obtain a copy of the License at
3455
- *
3456
- * http://www.apache.org/licenses/LICENSE-2.0
3457
- *
3458
- * Unless required by applicable law or agreed to in writing, software
3459
- * distributed under the License is distributed on an "AS IS" BASIS,
3460
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3461
- * See the License for the specific language governing permissions and
3462
- * limitations under the License.
3463
- *
3464
- * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
3465
- * Copyright 2022 - Finnish Meteorological Institute (FMI)
3466
- * */
3467
-
3468
- var index = /*#__PURE__*/Object.freeze({
3469
- __proto__: null,
3470
- isoStringToDate: isoStringToDate,
3471
- stringToDate: stringToDate,
3472
- setUTCDate: setUTCDate,
3473
- dateToString: dateToString,
3474
- isBetween: isBetween,
3475
- createDate: createDate,
3476
- add: add,
3477
- sub: sub,
3478
- differenceInMinutes: differenceInMinutes,
3479
- differenceInHours: differenceInHours
3480
- });
3481
-
3482
- exports.AlertBanner = AlertBanner;
3483
- exports.AlertIcon = AlertIcon;
3484
- exports.AppHeader = AppHeader;
3485
- exports.AppLayout = AppLayout;
3486
- exports.Avatar = Avatar;
3487
- exports.ConfirmationDialog = ConfirmationDialog;
3488
- exports.ConfirmationServiceProvider = ConfirmationServiceProvider;
3489
- exports.CustomAccordion = CustomAccordion;
3490
- exports.CustomDialog = CustomDialog;
3491
- exports.CustomIconButton = CustomIconButton;
3492
- exports.CustomSlider = CustomSlider;
3493
- exports.CustomToggleButton = CustomToggleButton;
3494
- exports.CustomTooltip = CustomTooltip;
3495
- exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
3496
- exports.Draggable = DraggableComponent$1;
3497
- exports.ErrorBoundary = ErrorBoundary;
3498
- exports.Resizable = ResizeComponent;
3499
- exports.SearchHighlight = SearchHighlight;
3500
- exports.StatusTag = StatusTag;
3501
- exports.ToggleMenu = ToggleMenu;
3502
- exports.ToolContainer = ToolContainer;
3503
- exports.ToolContainerDraggable = DraggableComponent;
3504
- exports.ToolFooter = ToolFooter;
3505
- exports.ToolHeader = ToolHeader;
3506
- exports.TooltipSelect = TooltipSelect;
3507
- exports.UserMenu = UserMenu;
3508
- exports.UserMenuItemCheatSheet = UserMenuItemCheatSheet;
3509
- exports.UserMenuItemTheme = MenuItemTheme;
3510
- exports.adjustPosition = adjustPosition;
3511
- exports.calculateDialogSizeAndPosition = calculateDialogSizeAndPosition;
3512
- exports.dateUtils = index;
3513
- exports.defaultDelay = defaultDelay;
3514
- exports.getAxiosErrorMessage = getAxiosErrorMessage;
3515
- exports.getAxiosWarningMessage = getAxiosWarningMessage;
3516
- exports.getErrorMessage = getErrorMessage;
3517
- exports.getInitials = getInitials;
3518
- exports.getPosition = getPosition;
3519
- exports.getWarningMessage = getWarningMessage;
3520
- exports.isAxiosError = isAxiosError;
3521
- exports.showPrompt = showPrompt;
3522
- exports.sliderHeaderStyle = sliderHeaderStyle;
3523
- exports.tooltipContainerStyles = tooltipContainerStyles;
3524
- exports.useConfirmationDialog = useConfirmationDialog;
3525
- exports.useControlledTooltip = useControlledTooltip;
3526
- exports.useDialogActions = useDialogActions;
3527
- exports.useIsMounted = useIsMounted;
3528
- exports.useMakeSureContainerStaysInsideWindow = useMakeSureContainerStaysInsideWindow;
3529
- exports.usePoller = usePoller;
3530
- exports.usePreventBrowserClose = usePreventBrowserClose;
3531
- exports.usePrevious = usePrevious;
3532
- exports.useUserMenu = useUserMenu;
3533
- exports.withEggs = withEggs;
3534
-
3535
- Object.defineProperty(exports, '__esModule', { value: true });
3536
-
3537
- }));