@entur-partner/common 10.0.0 → 10.0.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionBar.d.ts +9 -0
- package/dist/AuditInfo.d.ts +14 -0
- package/dist/Box.d.ts +57 -0
- package/dist/Breadcrumbs.d.ts +8 -0
- package/dist/ConfirmModal.d.ts +28 -0
- package/dist/Content.d.ts +10 -0
- package/dist/EnturPartnerLogo.d.ts +19 -0
- package/dist/ErrorBoundary.d.ts +22 -0
- package/dist/ExpandableMultiLanguageInput.d.ts +17 -0
- package/dist/FeatureToggle.d.ts +25 -0
- package/dist/FormatCurrencyAmount.d.ts +8 -0
- package/dist/FormatDateTime.d.ts +7 -0
- package/dist/LanguageSelect.d.ts +16 -0
- package/dist/Link.d.ts +6 -0
- package/dist/LinkButton.d.ts +8 -0
- package/dist/Menu.d.ts +10 -0
- package/dist/MultiLanguageInput.d.ts +28 -0
- package/dist/OrganisationDropdown.d.ts +14 -0
- package/dist/PageTitle.d.ts +12 -0
- package/dist/Pager.d.ts +8 -0
- package/dist/PermissionCheck.d.ts +24 -0
- package/dist/ProjectProvider.d.ts +15 -0
- package/dist/RouteLeavingGuard.d.ts +14 -0
- package/dist/Stack.d.ts +9 -0
- package/dist/StatusLabel.d.ts +11 -0
- package/dist/Text.d.ts +21 -0
- package/dist/Unbutton.d.ts +7 -0
- package/dist/UserMenu/components/CookieSettingsMenuItem.d.ts +9 -0
- package/dist/UserMenu/components/CustomOverflowMenu.d.ts +11 -0
- package/dist/UserMenu/components/CustomOverflowMenuItem.d.ts +3 -0
- package/dist/UserMenu/components/LanguageSwitchMenuItem.d.ts +10 -0
- package/dist/UserMenu/components/LogOutMenuItem.d.ts +9 -0
- package/dist/UserMenu/components/UserMenuItem.d.ts +9 -0
- package/dist/UserMenu/components/VersionMenuItem.d.ts +5 -0
- package/dist/UserMenu/index.d.ts +26 -0
- package/dist/UserMenu/useOutsideClick.d.ts +2 -0
- package/dist/common.cjs.development.js +1215 -0
- package/dist/common.cjs.development.js.map +1 -0
- package/dist/common.cjs.production.min.js +2 -0
- package/dist/common.cjs.production.min.js.map +1 -0
- package/dist/common.esm.js +1172 -0
- package/dist/common.esm.js.map +1 -0
- package/dist/environment.d.ts +13 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +2774 -0
- package/dist/useEventListener.d.ts +3 -0
- package/dist/useNavigateParams.d.ts +9 -0
- package/package.json +5 -5
|
@@ -0,0 +1,1172 @@
|
|
|
1
|
+
import React, { Children, Component, useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { localeDate, localeDateTime, isDate, isDateString, splitUrlPath, isString, isFunction, assertIsDefined, hasAllPermissions, hasOneOfPermissions } from '@entur-partner/util';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { BreadcrumbItem, BreadcrumbNavigation, Pagination } from '@entur/menu';
|
|
5
|
+
import { useSearchParams, Link as Link$1, useInRouterContext, useBlocker, useNavigate } from 'react-router-dom';
|
|
6
|
+
import { ButtonGroup, SecondaryButton, PrimaryButton, Button } from '@entur/button';
|
|
7
|
+
import { Modal } from '@entur/modal';
|
|
8
|
+
import { Paragraph, Link as Link$2, Heading6 } from '@entur/typography';
|
|
9
|
+
import { BannerAlertBox } from '@entur/alert';
|
|
10
|
+
import { ExpandablePanel } from '@entur/expand';
|
|
11
|
+
import { SegmentedControl, SegmentedChoice } from '@entur/form';
|
|
12
|
+
import { SearchableDropdown } from '@entur/dropdown';
|
|
13
|
+
import { CookieIcon, UserIcon, DownArrowIcon, NorwayIcon, UKIcon, LogOutIcon, ChannelsIcon } from '@entur/icons';
|
|
14
|
+
|
|
15
|
+
var ActionBarLeft = function ActionBarLeft(_ref) {
|
|
16
|
+
var children = _ref.children;
|
|
17
|
+
return React.createElement("div", {
|
|
18
|
+
className: "eps-action-bar-left"
|
|
19
|
+
}, children);
|
|
20
|
+
};
|
|
21
|
+
var ActionBarRight = function ActionBarRight(_ref2) {
|
|
22
|
+
var children = _ref2.children;
|
|
23
|
+
return React.createElement("div", {
|
|
24
|
+
className: "eps-action-bar-right"
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
27
|
+
var ActionBar = function ActionBar(_ref3) {
|
|
28
|
+
var children = _ref3.children;
|
|
29
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
30
|
+
className: "eps-action-bar-padding"
|
|
31
|
+
}), React.createElement("div", {
|
|
32
|
+
className: "eps-action-bar"
|
|
33
|
+
}, children));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function _extends() {
|
|
37
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
38
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
39
|
+
var t = arguments[e];
|
|
40
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
41
|
+
}
|
|
42
|
+
return n;
|
|
43
|
+
}, _extends.apply(null, arguments);
|
|
44
|
+
}
|
|
45
|
+
function _inheritsLoose(t, o) {
|
|
46
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
47
|
+
}
|
|
48
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
49
|
+
if (null == r) return {};
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
52
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
53
|
+
t[n] = r[n];
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
}
|
|
57
|
+
function _setPrototypeOf(t, e) {
|
|
58
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
59
|
+
return t.__proto__ = e, t;
|
|
60
|
+
}, _setPrototypeOf(t, e);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var _excluded$e = ["date", "locale", "as", "hideTime"];
|
|
64
|
+
var FormatDateTime = function FormatDateTime(_ref) {
|
|
65
|
+
var date = _ref.date,
|
|
66
|
+
locale = _ref.locale,
|
|
67
|
+
_ref$as = _ref.as,
|
|
68
|
+
Component = _ref$as === void 0 ? "main" : _ref$as,
|
|
69
|
+
hideTime = _ref.hideTime,
|
|
70
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
|
|
71
|
+
return React.createElement(Component, _extends({}, rest), hideTime ? localeDate(date, locale) : localeDateTime(date, locale));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var _excluded$d = ["as", "children", "contrast", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "paddingX", "paddingY", "padding", "marginTop", "marginRight", "marginBottom", "marginLeft", "marginX", "marginY", "margin", "display", "justifyContent", "alignItems", "maxWidth", "width", "background", "color", "flexDirection", "flexWrap", "className"];
|
|
75
|
+
function responsiveProp(prefix, prop) {
|
|
76
|
+
if (Array.isArray(prop)) {
|
|
77
|
+
var classes = [];
|
|
78
|
+
prop[0] && classes.push(prefix + prop[0]);
|
|
79
|
+
prop[1] && classes.push("" + prefix + prop[1] + "-lg");
|
|
80
|
+
prop[2] && classes.push("" + prefix + prop[2] + "-xl");
|
|
81
|
+
return classes;
|
|
82
|
+
}
|
|
83
|
+
return [prefix + prop];
|
|
84
|
+
}
|
|
85
|
+
var Box = function Box(_ref) {
|
|
86
|
+
var _ref$as = _ref.as,
|
|
87
|
+
Component = _ref$as === void 0 ? "div" : _ref$as,
|
|
88
|
+
children = _ref.children,
|
|
89
|
+
contrast = _ref.contrast,
|
|
90
|
+
paddingTop = _ref.paddingTop,
|
|
91
|
+
paddingRight = _ref.paddingRight,
|
|
92
|
+
paddingBottom = _ref.paddingBottom,
|
|
93
|
+
paddingLeft = _ref.paddingLeft,
|
|
94
|
+
paddingX = _ref.paddingX,
|
|
95
|
+
paddingY = _ref.paddingY,
|
|
96
|
+
padding = _ref.padding,
|
|
97
|
+
marginTop = _ref.marginTop,
|
|
98
|
+
marginRight = _ref.marginRight,
|
|
99
|
+
marginBottom = _ref.marginBottom,
|
|
100
|
+
marginLeft = _ref.marginLeft,
|
|
101
|
+
marginX = _ref.marginX,
|
|
102
|
+
marginY = _ref.marginY,
|
|
103
|
+
margin = _ref.margin,
|
|
104
|
+
display = _ref.display,
|
|
105
|
+
justifyContent = _ref.justifyContent,
|
|
106
|
+
alignItems = _ref.alignItems,
|
|
107
|
+
maxWidth = _ref.maxWidth,
|
|
108
|
+
width = _ref.width,
|
|
109
|
+
background = _ref.background,
|
|
110
|
+
color = _ref.color,
|
|
111
|
+
flexDirection = _ref.flexDirection,
|
|
112
|
+
flexWrap = _ref.flexWrap,
|
|
113
|
+
className = _ref.className,
|
|
114
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
115
|
+
var classes = [];
|
|
116
|
+
var resolvedPaddingTop = paddingTop || paddingY || padding;
|
|
117
|
+
var resolvedPaddingBottom = paddingBottom || paddingY || padding;
|
|
118
|
+
var resolvedPaddingLeft = paddingLeft || paddingX || padding;
|
|
119
|
+
var resolvedPaddingRight = paddingRight || paddingX || padding;
|
|
120
|
+
var resolvedMarginTop = marginTop || marginY || margin;
|
|
121
|
+
var resolvedMarginBottom = marginBottom || marginY || margin;
|
|
122
|
+
var resolvedMarginLeft = marginLeft || marginX || margin;
|
|
123
|
+
var resolvedMarginRight = marginRight || marginX || margin;
|
|
124
|
+
contrast && classes.push("eds-contrast");
|
|
125
|
+
resolvedPaddingTop && classes.push.apply(classes, responsiveProp("eps-pt-", resolvedPaddingTop));
|
|
126
|
+
resolvedPaddingBottom && classes.push.apply(classes, responsiveProp("eps-pb-", resolvedPaddingBottom));
|
|
127
|
+
resolvedPaddingLeft && classes.push.apply(classes, responsiveProp("eps-pl-", resolvedPaddingLeft));
|
|
128
|
+
resolvedPaddingRight && classes.push.apply(classes, responsiveProp("eps-pr-", resolvedPaddingRight));
|
|
129
|
+
resolvedMarginTop && classes.push.apply(classes, responsiveProp("eps-mt-", resolvedMarginTop));
|
|
130
|
+
resolvedMarginBottom && classes.push.apply(classes, responsiveProp("eps-mb-", resolvedMarginBottom));
|
|
131
|
+
resolvedMarginLeft && classes.push.apply(classes, responsiveProp("eps-ml-", resolvedMarginLeft));
|
|
132
|
+
resolvedMarginRight && classes.push.apply(classes, responsiveProp("eps-mr-", resolvedMarginRight));
|
|
133
|
+
display && classes.push.apply(classes, responsiveProp("eps-", display));
|
|
134
|
+
justifyContent && classes.push.apply(classes, responsiveProp("eps-justify-", justifyContent));
|
|
135
|
+
if (alignItems) {
|
|
136
|
+
classes.push.apply(classes, responsiveProp("eps-items-", alignItems));
|
|
137
|
+
}
|
|
138
|
+
maxWidth && classes.push.apply(classes, responsiveProp("eps-max-w-", maxWidth));
|
|
139
|
+
width && classes.push.apply(classes, responsiveProp("eps-w-", width));
|
|
140
|
+
color && classes.push("eps-color-" + color);
|
|
141
|
+
background && classes.push("eps-bg-" + background);
|
|
142
|
+
flexDirection && classes.push.apply(classes, responsiveProp("eps-flex-", flexDirection));
|
|
143
|
+
flexWrap && classes.push.apply(classes, responsiveProp("eps-flex-wrap-", flexWrap));
|
|
144
|
+
var classList = cx(classes, className);
|
|
145
|
+
return React.createElement(Component, _extends({
|
|
146
|
+
className: classList
|
|
147
|
+
}, rest), children);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** biome-ignore-all lint/suspicious/noArrayIndexKey: Ignore for now. Should be tested properly before doing changes */
|
|
151
|
+
var Stack = function Stack(_ref) {
|
|
152
|
+
var children = _ref.children,
|
|
153
|
+
space = _ref.space,
|
|
154
|
+
className = _ref.className;
|
|
155
|
+
var stackItems = Children.toArray(children);
|
|
156
|
+
if (stackItems.length <= 1) {
|
|
157
|
+
return React.createElement(React.Fragment, null, stackItems);
|
|
158
|
+
}
|
|
159
|
+
return React.createElement("div", {
|
|
160
|
+
className: className
|
|
161
|
+
}, stackItems.map(function (child, index) {
|
|
162
|
+
return index === stackItems.length - 1 ? React.createElement("div", {
|
|
163
|
+
key: index
|
|
164
|
+
}, child) : React.createElement(Box, {
|
|
165
|
+
paddingBottom: space,
|
|
166
|
+
key: index
|
|
167
|
+
}, child);
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var _excluded$c = ["items", "locale", "className"];
|
|
172
|
+
var AuditInfo = function AuditInfo(_ref) {
|
|
173
|
+
var items = _ref.items,
|
|
174
|
+
locale = _ref.locale,
|
|
175
|
+
className = _ref.className,
|
|
176
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
177
|
+
var classNames = cx("ep-audit-info", className);
|
|
178
|
+
return React.createElement("div", _extends({
|
|
179
|
+
className: classNames
|
|
180
|
+
}, rest), items.map(function (_ref2) {
|
|
181
|
+
var label = _ref2.label,
|
|
182
|
+
value = _ref2.value;
|
|
183
|
+
return React.createElement(Stack, {
|
|
184
|
+
space: "small",
|
|
185
|
+
key: value.toString()
|
|
186
|
+
}, React.createElement("div", {
|
|
187
|
+
className: "ep-audit-info-label"
|
|
188
|
+
}, label), React.createElement("div", null, isDate(value) || isDateString(value) ? React.createElement(FormatDateTime, {
|
|
189
|
+
date: value,
|
|
190
|
+
locale: locale
|
|
191
|
+
}) : React.createElement("span", null, value)));
|
|
192
|
+
}));
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
var ProjectContext = /*#__PURE__*/React.createContext(undefined);
|
|
196
|
+
var useProject = function useProject() {
|
|
197
|
+
var context = React.useContext(ProjectContext);
|
|
198
|
+
if (!context) {
|
|
199
|
+
throw new Error("Must be used within a ProjectProvider");
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
defaultProjectId: context.defaultProjectId,
|
|
203
|
+
projectName: context.projectName
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* A Provider to sync project id across micro-frontends. Used by useNavigateParams to ensure project id is always present in the url.
|
|
208
|
+
*/
|
|
209
|
+
var ProjectProvider = function ProjectProvider(_ref) {
|
|
210
|
+
var defaultProjectId = _ref.defaultProjectId,
|
|
211
|
+
projectName = _ref.projectName,
|
|
212
|
+
children = _ref.children;
|
|
213
|
+
return React.createElement(ProjectContext.Provider, {
|
|
214
|
+
value: {
|
|
215
|
+
defaultProjectId: defaultProjectId,
|
|
216
|
+
projectName: projectName
|
|
217
|
+
}
|
|
218
|
+
}, children);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
222
|
+
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
223
|
+
pathname = _ref.pathname,
|
|
224
|
+
onBreadcrumbLookup = _ref.onBreadcrumbLookup;
|
|
225
|
+
var _useProject = useProject(),
|
|
226
|
+
projectName = _useProject.projectName,
|
|
227
|
+
defaultProjectId = _useProject.defaultProjectId;
|
|
228
|
+
var _useSearchParams = useSearchParams(),
|
|
229
|
+
searchParams = _useSearchParams[0];
|
|
230
|
+
var projectValue = searchParams.get(projectName);
|
|
231
|
+
var paths = splitUrlPath(pathname);
|
|
232
|
+
var breadcrumbs = paths.map(function (path) {
|
|
233
|
+
return {
|
|
234
|
+
title: onBreadcrumbLookup(path),
|
|
235
|
+
path: path
|
|
236
|
+
};
|
|
237
|
+
}).filter(function (_ref2) {
|
|
238
|
+
var title = _ref2.title;
|
|
239
|
+
return title !== undefined;
|
|
240
|
+
});
|
|
241
|
+
var breadcrumbElements = breadcrumbs.map(function (_ref3, i) {
|
|
242
|
+
var title = _ref3.title,
|
|
243
|
+
path = _ref3.path;
|
|
244
|
+
var isLast = i === breadcrumbs.length - 1;
|
|
245
|
+
if (isLast) {
|
|
246
|
+
return React.createElement(BreadcrumbItem, {
|
|
247
|
+
key: path,
|
|
248
|
+
as: "span"
|
|
249
|
+
}, title);
|
|
250
|
+
}
|
|
251
|
+
if (!projectValue) {
|
|
252
|
+
searchParams.set(projectName, defaultProjectId);
|
|
253
|
+
}
|
|
254
|
+
return React.createElement(BreadcrumbItem, {
|
|
255
|
+
key: path,
|
|
256
|
+
as: Link$1,
|
|
257
|
+
to: path + "?" + searchParams.toString()
|
|
258
|
+
}, title);
|
|
259
|
+
});
|
|
260
|
+
if (prependBreadcrumbItem) {
|
|
261
|
+
return React.createElement(BreadcrumbNavigation, null, [prependBreadcrumbItem].concat(breadcrumbElements));
|
|
262
|
+
}
|
|
263
|
+
return React.createElement(BreadcrumbNavigation, null, breadcrumbElements);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
var _excluded$b = ["isOpen", "children", "message", "size", "buttons", "onConfirm", "messages", "onClose", "onDismiss"];
|
|
267
|
+
var ConfirmModal = function ConfirmModal(_ref) {
|
|
268
|
+
var _ref$isOpen = _ref.isOpen,
|
|
269
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
270
|
+
children = _ref.children,
|
|
271
|
+
message = _ref.message,
|
|
272
|
+
_ref$size = _ref.size,
|
|
273
|
+
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
274
|
+
buttons = _ref.buttons,
|
|
275
|
+
onConfirm = _ref.onConfirm,
|
|
276
|
+
messages = _ref.messages,
|
|
277
|
+
onClose = _ref.onClose,
|
|
278
|
+
onDismiss = _ref.onDismiss,
|
|
279
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
280
|
+
var childrenToRender = children ? children : message;
|
|
281
|
+
var handleDismiss = onClose ? onClose : onDismiss;
|
|
282
|
+
return React.createElement(Modal, _extends({
|
|
283
|
+
size: size,
|
|
284
|
+
open: isOpen,
|
|
285
|
+
onDismiss: handleDismiss
|
|
286
|
+
}, rest), isString(childrenToRender) ? React.createElement(Paragraph, null, childrenToRender) : React.createElement(Box, {
|
|
287
|
+
paddingBottom: "medium"
|
|
288
|
+
}, childrenToRender), React.createElement(ButtonGroup, null, onConfirm ? React.createElement(React.Fragment, null, React.createElement(SecondaryButton, {
|
|
289
|
+
onClick: handleDismiss,
|
|
290
|
+
"data-testid": "cancel-modal-button"
|
|
291
|
+
}, messages.cancel), React.createElement(PrimaryButton, {
|
|
292
|
+
onClick: onConfirm,
|
|
293
|
+
"data-testid": "confirm-modal-button"
|
|
294
|
+
}, messages.confirm)) : buttons));
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
var Content = function Content(_ref) {
|
|
298
|
+
var _ref$as = _ref.as,
|
|
299
|
+
Component = _ref$as === void 0 ? "main" : _ref$as,
|
|
300
|
+
className = _ref.className,
|
|
301
|
+
children = _ref.children;
|
|
302
|
+
var classList = cx(["eps-content", className]);
|
|
303
|
+
return React.createElement(Component, {
|
|
304
|
+
className: classList
|
|
305
|
+
}, children);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
var _environmentColors, _humanReadableEnviron;
|
|
309
|
+
var Environment;
|
|
310
|
+
(function (Environment) {
|
|
311
|
+
Environment["Local"] = "local";
|
|
312
|
+
Environment["Development"] = "dev";
|
|
313
|
+
Environment["Staging"] = "staging";
|
|
314
|
+
Environment["Production"] = "prod";
|
|
315
|
+
})(Environment || (Environment = {}));
|
|
316
|
+
var environmentColors = (_environmentColors = {}, _environmentColors[Environment.Local] = "#B482FB", _environmentColors[Environment.Development] = "#5AC39A", _environmentColors[Environment.Staging] = "#FFCA28", _environmentColors);
|
|
317
|
+
/**
|
|
318
|
+
* Gets the color for the given environment. This is the color used for the environment
|
|
319
|
+
* indicator. There is no color for production as it should not have any special environment
|
|
320
|
+
* indication.
|
|
321
|
+
*/
|
|
322
|
+
var getColorForEnvironment = function getColorForEnvironment(environment) {
|
|
323
|
+
return environmentColors[environment];
|
|
324
|
+
};
|
|
325
|
+
var humanReadableEnvironment = (_humanReadableEnviron = {}, _humanReadableEnviron[Environment.Local] = "Local", _humanReadableEnviron[Environment.Development] = "Dev", _humanReadableEnviron[Environment.Staging] = "Staging", _humanReadableEnviron[Environment.Production] = "Prod", _humanReadableEnviron);
|
|
326
|
+
var getHumanReadableEnvironment = function getHumanReadableEnvironment(environment) {
|
|
327
|
+
return humanReadableEnvironment[environment];
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
var _excluded$a = ["title", "accentColor"];
|
|
331
|
+
var EnturPartnerLogoSvg = function EnturPartnerLogoSvg(_ref) {
|
|
332
|
+
var title = _ref.title,
|
|
333
|
+
_ref$accentColor = _ref.accentColor,
|
|
334
|
+
accentColor = _ref$accentColor === void 0 ? "#FF5959" : _ref$accentColor,
|
|
335
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
336
|
+
return React.createElement("svg", _extends({
|
|
337
|
+
width: 257,
|
|
338
|
+
height: 37,
|
|
339
|
+
viewBox: "0 0 257 37"
|
|
340
|
+
}, rest), React.createElement("title", null, title), React.createElement("g", {
|
|
341
|
+
fill: "none",
|
|
342
|
+
fillRule: "evenodd"
|
|
343
|
+
}, React.createElement("path", {
|
|
344
|
+
fill: "#FFF",
|
|
345
|
+
d: "M0 .231V25.72h18.745v-4.318H4.869v-6.163h12.31v-4.318H4.87V4.55h13.876V.231z"
|
|
346
|
+
}), React.createElement("path", {
|
|
347
|
+
fill: accentColor,
|
|
348
|
+
d: "M0 36.408h45.253v-4.32H0z"
|
|
349
|
+
}), React.createElement("path", {
|
|
350
|
+
fill: "#FFF",
|
|
351
|
+
d: "M40.384.231v15.425L23.656.231h-.521V25.72h4.869V10.573L44.732 25.72h.521V.23zM69.25 15.238h-7.267v21.17h-4.87v-21.17H49.81V10.92h19.44zM83.863 36.86c-1.646 0-3.142-.255-4.486-.765-1.345-.51-2.493-1.23-3.443-2.159-.95-.928-1.687-2.054-2.208-3.378-.522-1.323-.783-2.797-.783-4.422V10.92h4.869v15.216c0 1.277.209 2.333.626 3.169.417.836.933 1.497 1.548 1.985a5.346 5.346 0 001.982 1.01c.707.186 1.339.278 1.895.278.557 0 1.188-.092 1.896-.279a5.35 5.35 0 001.982-1.01c.614-.487 1.13-1.148 1.548-1.984.417-.836.625-1.892.625-3.169V10.92h4.87v15.216c0 1.625-.256 3.1-.766 4.422-.51 1.324-1.24 2.45-2.19 3.378-.952.929-2.1 1.648-3.444 2.159-1.344.51-2.851.766-4.52.766M104.21 24.047h5.546c1.016 0 1.854-.127 2.513-.383.658-.255 1.179-.592 1.56-1.01.381-.418.641-.888.78-1.41.138-.522.208-1.05.208-1.584 0-.627-.099-1.207-.295-1.741a3.718 3.718 0 00-.901-1.393c-.405-.394-.924-.708-1.56-.94-.636-.232-1.404-.348-2.305-.348h-5.546v8.81zm0 4.248v8.113h-4.87V10.92h11.567c1.3 0 2.49.215 3.57.644 1.08.43 2.004 1.033 2.77 1.81a8.287 8.287 0 011.794 2.787c.43 1.079.645 2.257.645 3.534 0 .952-.128 1.874-.383 2.768-.256.894-.61 1.7-1.063 2.42a7.32 7.32 0 01-1.672 1.863 5.929 5.929 0 01-2.178 1.096l6.339 8.566h-5.808l-5.893-8.113h-4.818z"
|
|
352
|
+
}), React.createElement("g", {
|
|
353
|
+
fill: accentColor
|
|
354
|
+
}, React.createElement("path", {
|
|
355
|
+
d: "M141.051 23.448h5.628c4.185 0 5.989-1.984 5.989-4.942 0-2.742-1.515-4.618-5.989-4.618h-5.628v9.56zm0 3.067v9.776h-3.571V10.75h9.632c6.674 0 9.127 3.211 9.127 7.54 0 4.979-3.102 8.226-9.2 8.226h-5.988zM169.695 28.715c-1.371-.288-2.958-.505-4.401-.505-2.85 0-4.041 1.263-4.041 3.139s1.407 2.706 3.463 2.706c2.49 0 4.979-1.443 4.979-4.221v-1.119zm-4.293-2.958c1.551 0 3.174.253 4.293.469v-.83c0-2.525-1.154-3.896-4.33-3.896-2.164 0-3.824.866-4.942 2.092l-2.02-2.272c1.732-1.66 3.644-2.598 7.07-2.598 5.052 0 7.469 1.876 7.469 7.215v10.354h-3.211V34.02h-.108c-1.082 1.767-3.211 2.705-5.592 2.705-3.32 0-6.241-1.66-6.241-5.303 0-3.103 1.912-5.664 7.612-5.664zM178.965 19.191h3.211v2.886h.108c.938-1.984 2.922-3.355 5.231-3.355.47 0 .938.036 1.335.144l-.144 3.14a6.77 6.77 0 00-1.552-.181c-3.246 0-4.798 2.633-4.798 5.483v8.983h-3.39v-17.1zM199.961 36.291h-1.912c-4.004 0-5.988-.938-5.988-5.772v-8.55h-2.778V19.19h2.778v-4.654h3.355v4.654h4.473v2.778h-4.473v7.973c0 3.427 1.587 3.535 3.319 3.535h1.226v2.814zM219.767 36.291h-3.391V26.84c0-2.778-1.083-5.375-4.257-5.375-3.14 0-5.268 2.597-5.268 6.169v8.658h-3.391v-17.1h3.32v2.814h.143c.794-1.623 3.067-3.283 5.99-3.283 4.941 0 6.854 3.644 6.854 8.081v9.488zM227.847 26.262h10.57c0-2.597-2.272-4.726-5.087-4.726-2.922 0-5.014 1.948-5.483 4.726zm-.036 2.453c.397 3.355 2.633 5.195 5.844 5.195 2.778 0 4.618-1.623 5.484-2.67l2.164 1.804c-1.37 1.913-4.365 3.716-8.045 3.716-4.942 0-8.73-3.535-8.73-8.55 0-5.195 3.752-9.488 8.983-9.488 5.303 0 8.009 4.365 8.009 8.19 0 .649-.036 1.226-.072 1.803H227.81zM246.245 19.191h3.21v2.886h.109c.938-1.984 2.922-3.355 5.231-3.355.469 0 .938.036 1.335.144l-.145 3.14a6.77 6.77 0 00-1.551-.181c-3.247 0-4.798 2.633-4.798 5.483v8.983h-3.391v-17.1z"
|
|
356
|
+
}))));
|
|
357
|
+
};
|
|
358
|
+
var EnturPartnerLogo = function EnturPartnerLogo(_ref2) {
|
|
359
|
+
var _ref2$as = _ref2.as,
|
|
360
|
+
Component = _ref2$as === void 0 ? "nav" : _ref2$as,
|
|
361
|
+
className = _ref2.className,
|
|
362
|
+
altText = _ref2.altText,
|
|
363
|
+
environment = _ref2.environment;
|
|
364
|
+
var classList = cx(["eps-logo-wrapper", className]);
|
|
365
|
+
return React.createElement(Component, {
|
|
366
|
+
className: classList
|
|
367
|
+
}, React.createElement(EnturPartnerLogoSvg, {
|
|
368
|
+
title: altText,
|
|
369
|
+
className: "logo",
|
|
370
|
+
accentColor: environment !== undefined && environment !== Environment.Production ? getColorForEnvironment(environment) : undefined
|
|
371
|
+
}));
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
var newAppVersionErrorMessage = "Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.";
|
|
375
|
+
var ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
376
|
+
function ErrorBoundary(props) {
|
|
377
|
+
var _this;
|
|
378
|
+
_this = _Component.call(this, props) || this;
|
|
379
|
+
_this.state = {
|
|
380
|
+
error: null
|
|
381
|
+
};
|
|
382
|
+
return _this;
|
|
383
|
+
}
|
|
384
|
+
_inheritsLoose(ErrorBoundary, _Component);
|
|
385
|
+
ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
|
|
386
|
+
return {
|
|
387
|
+
error: error
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
var _proto = ErrorBoundary.prototype;
|
|
391
|
+
_proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
|
|
392
|
+
var _this$props$handleErr, _this$props;
|
|
393
|
+
// React always logs in development
|
|
394
|
+
(_this$props$handleErr = (_this$props = this.props).handleError) == null || _this$props$handleErr.call(_this$props, error, errorInfo);
|
|
395
|
+
};
|
|
396
|
+
_proto.render = function render() {
|
|
397
|
+
var _this2 = this;
|
|
398
|
+
var error = this.state.error;
|
|
399
|
+
var _this$props2 = this.props,
|
|
400
|
+
fallback = _this$props2.fallback,
|
|
401
|
+
children = _this$props2.children;
|
|
402
|
+
if (error) {
|
|
403
|
+
if (isFunction(fallback)) {
|
|
404
|
+
return fallback({
|
|
405
|
+
retry: function retry() {
|
|
406
|
+
return _this2.setState({
|
|
407
|
+
error: null
|
|
408
|
+
});
|
|
409
|
+
},
|
|
410
|
+
error: error
|
|
411
|
+
});
|
|
412
|
+
} else if (error.name === "NotFoundError" && error.message === newAppVersionErrorMessage) {
|
|
413
|
+
return React.createElement(RefreshBannerInfo, null);
|
|
414
|
+
}
|
|
415
|
+
return fallback;
|
|
416
|
+
}
|
|
417
|
+
return children;
|
|
418
|
+
};
|
|
419
|
+
return ErrorBoundary;
|
|
420
|
+
}(Component);
|
|
421
|
+
var LANGUAGE_STORAGE_KEY = "EP::locale";
|
|
422
|
+
function RefreshBannerInfo() {
|
|
423
|
+
// Taken from ./app-shell/src/storage.ts
|
|
424
|
+
var language = localStorage.getItem(LANGUAGE_STORAGE_KEY);
|
|
425
|
+
var isNorwegian = language === "nb" || language === "nb-NO";
|
|
426
|
+
return React.createElement(Box, {
|
|
427
|
+
maxWidth: "large"
|
|
428
|
+
}, React.createElement(BannerAlertBox, {
|
|
429
|
+
variant: "info",
|
|
430
|
+
title: isNorwegian ? "En ny versjon av nettsiden er tilgjengelig." : "A new version of the website is available."
|
|
431
|
+
}, React.createElement(Box, {
|
|
432
|
+
paddingBottom: "medium"
|
|
433
|
+
}, React.createElement(Paragraph, {
|
|
434
|
+
margin: "none"
|
|
435
|
+
}, isNorwegian ? "Vennligst oppdater." : "Please refresh.")), React.createElement(PrimaryButton, {
|
|
436
|
+
onClick: function onClick() {
|
|
437
|
+
return window.location.reload();
|
|
438
|
+
}
|
|
439
|
+
}, isNorwegian ? "Oppdater" : "Refresh")));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
var _excluded$9 = ["title", "inputComponent", "languages", "values", "onChange", "name", "variant", "feedback"];
|
|
443
|
+
var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
|
|
444
|
+
var title = _ref.title,
|
|
445
|
+
InputComponent = _ref.inputComponent,
|
|
446
|
+
languages = _ref.languages,
|
|
447
|
+
values = _ref.values,
|
|
448
|
+
onChange = _ref.onChange,
|
|
449
|
+
name = _ref.name,
|
|
450
|
+
variant = _ref.variant,
|
|
451
|
+
feedback = _ref.feedback,
|
|
452
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
453
|
+
var handleOnChange = function handleOnChange(language, value) {
|
|
454
|
+
var changes = _extends({}, values);
|
|
455
|
+
if (value === "" || !value) {
|
|
456
|
+
delete changes[language];
|
|
457
|
+
} else {
|
|
458
|
+
changes[language] = value;
|
|
459
|
+
}
|
|
460
|
+
onChange(changes);
|
|
461
|
+
};
|
|
462
|
+
return React.createElement(ExpandablePanel, {
|
|
463
|
+
title: title,
|
|
464
|
+
defaultOpen: true,
|
|
465
|
+
contentStyle: {
|
|
466
|
+
padding: "4px 4px 4px 4px",
|
|
467
|
+
marginTop: "16px",
|
|
468
|
+
marginBottom: "16px"
|
|
469
|
+
}
|
|
470
|
+
}, React.createElement(Stack, {
|
|
471
|
+
space: "medium"
|
|
472
|
+
}, languages.map(function (_ref2) {
|
|
473
|
+
var langKey = _ref2.value,
|
|
474
|
+
label = _ref2.label,
|
|
475
|
+
required = _ref2.required;
|
|
476
|
+
return React.createElement(InputComponent, _extends({
|
|
477
|
+
"data-testid": "multi-lang-input-" + name + "-" + langKey,
|
|
478
|
+
key: title + langKey,
|
|
479
|
+
label: required ? label + "*" : label,
|
|
480
|
+
variant: variant == null ? void 0 : variant(langKey),
|
|
481
|
+
feedback: feedback == null ? void 0 : feedback(langKey),
|
|
482
|
+
name: name,
|
|
483
|
+
onChange: function onChange(e) {
|
|
484
|
+
handleOnChange(langKey, e.target.value);
|
|
485
|
+
},
|
|
486
|
+
value: values[langKey] || ""
|
|
487
|
+
}, rest));
|
|
488
|
+
})));
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
/// <reference types="vite/client" />
|
|
492
|
+
/**
|
|
493
|
+
* Returns true if the provided flag exist in localStorage
|
|
494
|
+
* or is set as an environment variable.
|
|
495
|
+
*
|
|
496
|
+
* @param flag case sensitive flag. If it is an environment variable
|
|
497
|
+
* you can drop the VITE_APP_ prefix.
|
|
498
|
+
*/
|
|
499
|
+
function featureFlag(flag) {
|
|
500
|
+
var _window$localStorage, _window$localStorage2;
|
|
501
|
+
return import.meta.env["VITE_APP_" + flag] === "true" || ((_window$localStorage = window.localStorage) == null ? void 0 : _window$localStorage.getItem(flag)) === "true" || ((_window$localStorage2 = window.localStorage) == null ? void 0 : _window$localStorage2.getItem("VITE_APP_" + flag)) === "true";
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Returns true if the provided flag exist in localStorage
|
|
505
|
+
* or is set as an environment variable.
|
|
506
|
+
*
|
|
507
|
+
* @param flag case sensitive flag. If it is an environment variable
|
|
508
|
+
* you can drop the VITE_APP_ prefix.
|
|
509
|
+
*/
|
|
510
|
+
function useFeatureToggle(flag) {
|
|
511
|
+
return featureFlag(flag);
|
|
512
|
+
}
|
|
513
|
+
var FeatureToggle = function FeatureToggle(_ref) {
|
|
514
|
+
var children = _ref.children,
|
|
515
|
+
flag = _ref.flag;
|
|
516
|
+
var feature = useFeatureToggle(flag);
|
|
517
|
+
if (feature) {
|
|
518
|
+
return React.createElement(React.Fragment, null, children);
|
|
519
|
+
}
|
|
520
|
+
return null;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
var _excluded$8 = ["amount", "as"];
|
|
524
|
+
var FormatCurrencyAmount = function FormatCurrencyAmount(_ref) {
|
|
525
|
+
var amount = _ref.amount,
|
|
526
|
+
_ref$as = _ref.as,
|
|
527
|
+
Component = _ref$as === void 0 ? "span" : _ref$as,
|
|
528
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
529
|
+
var parsedAmount = Number(amount) || 0;
|
|
530
|
+
var formattedAmount = new Intl.NumberFormat("nb-NO", {
|
|
531
|
+
maximumFractionDigits: 2,
|
|
532
|
+
minimumFractionDigits: 2
|
|
533
|
+
}).format(parsedAmount);
|
|
534
|
+
return React.createElement(Component, _extends({}, rest), formattedAmount);
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
var _excluded$7 = ["language", "options", "className", "onChange"];
|
|
538
|
+
var LanguageSelect = function LanguageSelect(_ref) {
|
|
539
|
+
var language = _ref.language,
|
|
540
|
+
options = _ref.options,
|
|
541
|
+
className = _ref.className,
|
|
542
|
+
_onChange = _ref.onChange,
|
|
543
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
544
|
+
var classNames = cx("eps-language-select", className);
|
|
545
|
+
return React.createElement("div", _extends({}, rest, {
|
|
546
|
+
className: classNames
|
|
547
|
+
}), React.createElement(SegmentedControl, {
|
|
548
|
+
onChange: function onChange(language) {
|
|
549
|
+
assertIsDefined(language);
|
|
550
|
+
_onChange(language);
|
|
551
|
+
},
|
|
552
|
+
selectedValue: language
|
|
553
|
+
}, options.map(function (option) {
|
|
554
|
+
return React.createElement(SegmentedChoice, {
|
|
555
|
+
key: option.value,
|
|
556
|
+
value: option.value
|
|
557
|
+
}, option.label, option.required && React.createElement("span", {
|
|
558
|
+
className: "asterisk-margin"
|
|
559
|
+
}, "*"));
|
|
560
|
+
})));
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
var Link = function Link(props) {
|
|
564
|
+
return React.createElement(Link$2, _extends({}, props, {
|
|
565
|
+
as: Link$1
|
|
566
|
+
}), props.children);
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
var _excluded$6 = ["children", "className"];
|
|
570
|
+
var LinkButton = function LinkButton(_ref) {
|
|
571
|
+
var children = _ref.children,
|
|
572
|
+
className = _ref.className,
|
|
573
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
574
|
+
return React.createElement(Link$2, _extends({}, rest, {
|
|
575
|
+
as: "button",
|
|
576
|
+
className: cx("eps-link-button", className)
|
|
577
|
+
}), children);
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
var Menu = function Menu(_ref) {
|
|
581
|
+
var _ref$as = _ref.as,
|
|
582
|
+
Component = _ref$as === void 0 ? "nav" : _ref$as,
|
|
583
|
+
className = _ref.className,
|
|
584
|
+
children = _ref.children;
|
|
585
|
+
var classList = cx(["eds-contrast", "eps-menu", className]);
|
|
586
|
+
return React.createElement(Component, {
|
|
587
|
+
className: classList
|
|
588
|
+
}, children);
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
var _excluded$5 = ["className", "inputComponent", "alertLabel", "alertLevel", "name", "languages", "values", "onChange", "defaultLanguage", "label", "onBlur"];
|
|
592
|
+
/**
|
|
593
|
+
* @deprecated use ExpandableMultiLanguageInput
|
|
594
|
+
*/
|
|
595
|
+
var MultiLanguageInput = function MultiLanguageInput(_ref) {
|
|
596
|
+
var className = _ref.className,
|
|
597
|
+
InputComponent = _ref.inputComponent,
|
|
598
|
+
alertLabel = _ref.alertLabel,
|
|
599
|
+
alertLevel = _ref.alertLevel,
|
|
600
|
+
name = _ref.name,
|
|
601
|
+
languages = _ref.languages,
|
|
602
|
+
values = _ref.values,
|
|
603
|
+
onChange = _ref.onChange,
|
|
604
|
+
_ref$defaultLanguage = _ref.defaultLanguage,
|
|
605
|
+
defaultLanguage = _ref$defaultLanguage === void 0 ? "nob" : _ref$defaultLanguage,
|
|
606
|
+
_ref$label = _ref.label,
|
|
607
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
608
|
+
_ref$onBlur = _ref.onBlur,
|
|
609
|
+
onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
|
|
610
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
611
|
+
var _useState = useState(defaultLanguage),
|
|
612
|
+
language = _useState[0],
|
|
613
|
+
setLanguage = _useState[1];
|
|
614
|
+
var classNames = cx("multi-language-input", className);
|
|
615
|
+
var currentValue = values[language];
|
|
616
|
+
var handleOnBlur = function handleOnBlur(e) {
|
|
617
|
+
e.persist();
|
|
618
|
+
var currentTarget = e.currentTarget;
|
|
619
|
+
setTimeout(function () {
|
|
620
|
+
if (currentTarget && !currentTarget.contains(document.activeElement)) {
|
|
621
|
+
onBlur(e);
|
|
622
|
+
}
|
|
623
|
+
}, 0);
|
|
624
|
+
};
|
|
625
|
+
var handleLanguageChange = function handleLanguageChange(language) {
|
|
626
|
+
setLanguage(language);
|
|
627
|
+
};
|
|
628
|
+
var handleOnChange = function handleOnChange(value) {
|
|
629
|
+
var changes = Object.assign({}, values);
|
|
630
|
+
if (value === "" || !value) {
|
|
631
|
+
delete changes[language];
|
|
632
|
+
} else {
|
|
633
|
+
changes[language] = value;
|
|
634
|
+
}
|
|
635
|
+
onChange(changes);
|
|
636
|
+
};
|
|
637
|
+
return (
|
|
638
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Legacy component
|
|
639
|
+
React.createElement("div", {
|
|
640
|
+
className: classNames,
|
|
641
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: Legacy component
|
|
642
|
+
tabIndex: 0,
|
|
643
|
+
onBlur: handleOnBlur,
|
|
644
|
+
"data-testid": "multi-lang-input-" + name
|
|
645
|
+
}, React.createElement(Stack, {
|
|
646
|
+
space: "extraSmall"
|
|
647
|
+
}, React.createElement(LanguageSelect, {
|
|
648
|
+
language: language,
|
|
649
|
+
options: languages,
|
|
650
|
+
onChange: function onChange(lang) {
|
|
651
|
+
return handleLanguageChange(lang);
|
|
652
|
+
}
|
|
653
|
+
}), React.createElement(InputComponent, _extends({
|
|
654
|
+
label: label,
|
|
655
|
+
variant: alertLevel,
|
|
656
|
+
feedback: alertLabel,
|
|
657
|
+
name: name,
|
|
658
|
+
className: "language-item",
|
|
659
|
+
onChange: function onChange(e) {
|
|
660
|
+
return handleOnChange(e.target.value);
|
|
661
|
+
},
|
|
662
|
+
value: currentValue || ""
|
|
663
|
+
}, rest))))
|
|
664
|
+
);
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
var _excluded$4 = ["label", "organisations", "onChange", "selectedOrganisationId"];
|
|
668
|
+
var OrganisationDropDown = function OrganisationDropDown(_ref) {
|
|
669
|
+
var label = _ref.label,
|
|
670
|
+
organisations = _ref.organisations,
|
|
671
|
+
handleChange = _ref.onChange,
|
|
672
|
+
selectedOrganisationId = _ref.selectedOrganisationId,
|
|
673
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
674
|
+
var _useState = useState(),
|
|
675
|
+
selectedOrganisation = _useState[0],
|
|
676
|
+
setSelectedOrganisation = _useState[1];
|
|
677
|
+
useEffect(function () {
|
|
678
|
+
setSelectedOrganisation(organisations.find(function (org) {
|
|
679
|
+
return org.organisationId === selectedOrganisationId;
|
|
680
|
+
}));
|
|
681
|
+
}, [selectedOrganisationId, organisations]);
|
|
682
|
+
return React.createElement(SearchableDropdown, _extends({
|
|
683
|
+
label: label,
|
|
684
|
+
items: [].concat(organisations.sort(function (a, b) {
|
|
685
|
+
return a.tradingName.localeCompare(b.tradingName, "nb");
|
|
686
|
+
}).map(function (organisation) {
|
|
687
|
+
return {
|
|
688
|
+
value: organisation.organisationId,
|
|
689
|
+
label: organisation.tradingName
|
|
690
|
+
};
|
|
691
|
+
})),
|
|
692
|
+
selectedItem: selectedOrganisation ? {
|
|
693
|
+
value: selectedOrganisation.organisationId,
|
|
694
|
+
label: selectedOrganisation.tradingName
|
|
695
|
+
} : null,
|
|
696
|
+
onChange: function onChange(selectedValue) {
|
|
697
|
+
if (selectedValue) {
|
|
698
|
+
handleChange(selectedValue.value);
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
clearable: false
|
|
702
|
+
}, rest));
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
var Pager = function Pager(_ref) {
|
|
706
|
+
var collectionSize = _ref.collectionSize,
|
|
707
|
+
pageSize = _ref.pageSize,
|
|
708
|
+
_onPageChange = _ref.onPageChange,
|
|
709
|
+
currentPage = _ref.currentPage;
|
|
710
|
+
var pageCount = Math.ceil(collectionSize / pageSize);
|
|
711
|
+
return React.createElement(Pagination, {
|
|
712
|
+
pageCount: pageCount,
|
|
713
|
+
currentPage: currentPage,
|
|
714
|
+
onPageChange: function onPageChange(page) {
|
|
715
|
+
_onPageChange(page);
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
var useDocumentTitle = function useDocumentTitle(_ref) {
|
|
721
|
+
var title = _ref.title,
|
|
722
|
+
suffix = _ref.suffix;
|
|
723
|
+
useEffect(function () {
|
|
724
|
+
if (suffix) {
|
|
725
|
+
document.title = "" + title + suffix;
|
|
726
|
+
} else {
|
|
727
|
+
document.title = title;
|
|
728
|
+
}
|
|
729
|
+
}, [title, suffix]);
|
|
730
|
+
};
|
|
731
|
+
var PageTitle = function PageTitle(_ref2) {
|
|
732
|
+
var pathname = _ref2.pathname,
|
|
733
|
+
onBreadcrumbLookup = _ref2.onBreadcrumbLookup,
|
|
734
|
+
_ref2$appTitle = _ref2.appTitle,
|
|
735
|
+
appTitle = _ref2$appTitle === void 0 ? "Entur Partner" : _ref2$appTitle;
|
|
736
|
+
var paths = splitUrlPath(pathname);
|
|
737
|
+
var pageTitles = paths.map(function (path) {
|
|
738
|
+
return {
|
|
739
|
+
title: onBreadcrumbLookup(path),
|
|
740
|
+
path: path
|
|
741
|
+
};
|
|
742
|
+
}).filter(function (_ref3) {
|
|
743
|
+
var title = _ref3.title;
|
|
744
|
+
return title !== undefined;
|
|
745
|
+
}).map(function (_ref4) {
|
|
746
|
+
var title = _ref4.title;
|
|
747
|
+
return title;
|
|
748
|
+
}).reverse().join(" | ");
|
|
749
|
+
var title = pageTitles ? pageTitles + " | " + appTitle : appTitle;
|
|
750
|
+
useDocumentTitle({
|
|
751
|
+
title: title
|
|
752
|
+
});
|
|
753
|
+
return null;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Note: This component uses BusinessCapability, not because we only want to
|
|
758
|
+
* check BusinessCapabilities but because it represents a minimal subset of
|
|
759
|
+
* what we need to check.
|
|
760
|
+
*/
|
|
761
|
+
var PermissionCheck = function PermissionCheck(_ref) {
|
|
762
|
+
var children = _ref.children,
|
|
763
|
+
_ref$fallback = _ref.fallback,
|
|
764
|
+
fallback = _ref$fallback === void 0 ? null : _ref$fallback,
|
|
765
|
+
permissions = _ref.permissions,
|
|
766
|
+
_ref$oneOf = _ref.oneOf,
|
|
767
|
+
oneOf = _ref$oneOf === void 0 ? [] : _ref$oneOf,
|
|
768
|
+
_ref$all = _ref.all,
|
|
769
|
+
all = _ref$all === void 0 ? [] : _ref$all;
|
|
770
|
+
var allIsAllowed = hasAllPermissions(all, permissions);
|
|
771
|
+
var oneOfIsAllowed = hasOneOfPermissions(oneOf, permissions);
|
|
772
|
+
var allowed = allIsAllowed && oneOfIsAllowed;
|
|
773
|
+
return React.createElement(React.Fragment, null, allowed ? children : fallback);
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
var _excluded$3 = ["children", "shouldBlockNavigation"];
|
|
777
|
+
var RouteLeavingGuard = function RouteLeavingGuard(_ref) {
|
|
778
|
+
var children = _ref.children,
|
|
779
|
+
shouldBlockNavigation = _ref.shouldBlockNavigation,
|
|
780
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
781
|
+
assertIsDefined(useInRouterContext() ? true : undefined, "RouteLeavingGuard must be used within a data router.");
|
|
782
|
+
var blocker = useBlocker(function (_ref2) {
|
|
783
|
+
var currentLocation = _ref2.currentLocation,
|
|
784
|
+
nextLocation = _ref2.nextLocation;
|
|
785
|
+
return currentLocation.pathname !== nextLocation.pathname && shouldBlockNavigation(nextLocation);
|
|
786
|
+
});
|
|
787
|
+
return React.createElement(ConfirmModal, _extends({
|
|
788
|
+
onDismiss: function onDismiss() {
|
|
789
|
+
if (blocker.state === "blocked") {
|
|
790
|
+
blocker.reset();
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
open: blocker.state === "blocked",
|
|
794
|
+
onConfirm: function onConfirm() {
|
|
795
|
+
if (blocker.state === "blocked") {
|
|
796
|
+
blocker.proceed();
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}, rest), children);
|
|
800
|
+
};
|
|
801
|
+
|
|
802
|
+
var StatusLabel = function StatusLabel(_ref) {
|
|
803
|
+
var _ref$active = _ref.active,
|
|
804
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
805
|
+
_ref$label = _ref.label,
|
|
806
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
807
|
+
aggressiveInactive = _ref.aggressiveInactive,
|
|
808
|
+
showBullet = _ref.showBullet,
|
|
809
|
+
center = _ref.center;
|
|
810
|
+
var bulletClassNames = cx("eps-status-label__bullet", {
|
|
811
|
+
active: active,
|
|
812
|
+
aggressive: aggressiveInactive
|
|
813
|
+
});
|
|
814
|
+
var statusLabelClassNames = cx("eps-status-label", {
|
|
815
|
+
center: center
|
|
816
|
+
});
|
|
817
|
+
return React.createElement("div", {
|
|
818
|
+
className: statusLabelClassNames
|
|
819
|
+
}, showBullet && React.createElement("div", {
|
|
820
|
+
className: bulletClassNames
|
|
821
|
+
}), React.createElement("div", null, label));
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
var _excluded$2 = ["as", "children", "fontSize", "color", "lineHeight", "fontWeight", "className"];
|
|
825
|
+
var Text = function Text(_ref) {
|
|
826
|
+
var _ref$as = _ref.as,
|
|
827
|
+
component = _ref$as === void 0 ? "span" : _ref$as,
|
|
828
|
+
children = _ref.children,
|
|
829
|
+
fontSize = _ref.fontSize,
|
|
830
|
+
color = _ref.color,
|
|
831
|
+
lineHeight = _ref.lineHeight,
|
|
832
|
+
fontWeight = _ref.fontWeight,
|
|
833
|
+
className = _ref.className,
|
|
834
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
835
|
+
var classes = [];
|
|
836
|
+
fontSize && classes.push.apply(classes, responsiveProp("eps-font-size-", fontSize));
|
|
837
|
+
lineHeight && classes.push.apply(classes, responsiveProp("eps-line-height-", lineHeight));
|
|
838
|
+
fontWeight && classes.push("eps-font-weight-" + fontWeight);
|
|
839
|
+
var classList = cx(classes, className);
|
|
840
|
+
return React.createElement(Box, _extends({
|
|
841
|
+
as: component,
|
|
842
|
+
color: color,
|
|
843
|
+
className: classList
|
|
844
|
+
}, rest), children);
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
var _excluded$1 = ["children", "className"];
|
|
848
|
+
var Unbutton = function Unbutton(_ref) {
|
|
849
|
+
var children = _ref.children,
|
|
850
|
+
className = _ref.className,
|
|
851
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
852
|
+
return React.createElement(Button, _extends({
|
|
853
|
+
variant: "primary"
|
|
854
|
+
}, rest, {
|
|
855
|
+
className: cx("eps-unbutton", className)
|
|
856
|
+
}), children);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
860
|
+
return React.createElement("button", _extends({
|
|
861
|
+
className: cx(props.className, "eps-overflow-menu__item"),
|
|
862
|
+
role: "menuitem"
|
|
863
|
+
}, props));
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
var CookieSettingsMenuItem = function CookieSettingsMenuItem(_ref) {
|
|
867
|
+
var name = _ref.name,
|
|
868
|
+
setOpen = _ref.setOpen,
|
|
869
|
+
onCookieSettingsOpen = _ref.onCookieSettingsOpen;
|
|
870
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
871
|
+
onClick: function onClick() {
|
|
872
|
+
onCookieSettingsOpen();
|
|
873
|
+
setOpen(false);
|
|
874
|
+
},
|
|
875
|
+
className: "eps-overflow-menu__item"
|
|
876
|
+
}, React.createElement("span", {
|
|
877
|
+
"aria-hidden": true
|
|
878
|
+
}, React.createElement(CookieIcon, {
|
|
879
|
+
size: "1rem",
|
|
880
|
+
inline: true
|
|
881
|
+
})), name);
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
function useOutsideClick(ref, buttonRef, handler) {
|
|
885
|
+
React.useEffect(function () {
|
|
886
|
+
var listener = function listener(event) {
|
|
887
|
+
if (elementContainsEventTarget(ref.current, event) || elementContainsEventTarget(buttonRef.current, event)) {
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
handler();
|
|
891
|
+
};
|
|
892
|
+
document.addEventListener("mousedown", listener);
|
|
893
|
+
document.addEventListener("touchstart", listener);
|
|
894
|
+
return function () {
|
|
895
|
+
document.removeEventListener("mousedown", listener);
|
|
896
|
+
document.removeEventListener("touchstart", listener);
|
|
897
|
+
};
|
|
898
|
+
}, [ref, buttonRef, handler]);
|
|
899
|
+
}
|
|
900
|
+
function elementContainsEventTarget(element, event) {
|
|
901
|
+
if (!element) {
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
if (element.contains(event.target)) {
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
// For elements inside a Shadow DOM we need to check the composedPath
|
|
908
|
+
if (event.composed && event.composedPath) {
|
|
909
|
+
var contains = event.composedPath().find(function (target) {
|
|
910
|
+
if (target === window) {
|
|
911
|
+
return false;
|
|
912
|
+
}
|
|
913
|
+
return element.contains(target);
|
|
914
|
+
});
|
|
915
|
+
return !!contains;
|
|
916
|
+
}
|
|
917
|
+
return false;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
var _excluded = ["className", "children", "userName", "open", "onOpenChange", "environment"];
|
|
921
|
+
var CustomOverflowMenu = function CustomOverflowMenu(_ref) {
|
|
922
|
+
var className = _ref.className,
|
|
923
|
+
children = _ref.children,
|
|
924
|
+
userName = _ref.userName,
|
|
925
|
+
open = _ref.open,
|
|
926
|
+
onOpenChange = _ref.onOpenChange,
|
|
927
|
+
environment = _ref.environment,
|
|
928
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
929
|
+
var overflowItemsClasses = cx("eps-overflow-menu__group", {
|
|
930
|
+
"eps-overflow-menu__group--open": open
|
|
931
|
+
});
|
|
932
|
+
var overflowContentRef = React.useRef(null);
|
|
933
|
+
var overflowMenuTriggerRef = React.useRef(null);
|
|
934
|
+
useOutsideClick(overflowContentRef, overflowMenuTriggerRef, function () {
|
|
935
|
+
return onOpenChange(false);
|
|
936
|
+
});
|
|
937
|
+
return React.createElement("div", null, React.createElement(SecondaryButton, _extends({
|
|
938
|
+
className: cx("eps-overflow-menu__button", className),
|
|
939
|
+
onClick: function onClick() {
|
|
940
|
+
return onOpenChange(!open);
|
|
941
|
+
},
|
|
942
|
+
"aria-haspopup": true,
|
|
943
|
+
"aria-expanded": open,
|
|
944
|
+
ref: overflowMenuTriggerRef
|
|
945
|
+
}, rest), React.createElement("div", {
|
|
946
|
+
className: "eps-overflow-menu__button-contents"
|
|
947
|
+
}, React.createElement("span", {
|
|
948
|
+
className: "eds-overflow-menu__user-icon"
|
|
949
|
+
}, React.createElement(UserIcon, {
|
|
950
|
+
inline: true
|
|
951
|
+
})), React.createElement(Heading6, {
|
|
952
|
+
margin: "none",
|
|
953
|
+
as: "span"
|
|
954
|
+
}, userName, environment !== undefined && environment !== Environment.Production && React.createElement("span", {
|
|
955
|
+
style: {
|
|
956
|
+
color: getColorForEnvironment(environment)
|
|
957
|
+
}
|
|
958
|
+
}, " ", "(", getHumanReadableEnvironment(environment), ")")), React.createElement("span", {
|
|
959
|
+
className: "eps-arrow-icon"
|
|
960
|
+
}, React.createElement(DownArrowIcon, {
|
|
961
|
+
inline: true
|
|
962
|
+
})))), open && React.createElement("div", {
|
|
963
|
+
className: overflowItemsClasses,
|
|
964
|
+
role: "menu",
|
|
965
|
+
ref: overflowContentRef
|
|
966
|
+
}, children));
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
var LanguageSwitchMenuItem = function LanguageSwitchMenuItem(_ref) {
|
|
970
|
+
var language = _ref.language,
|
|
971
|
+
onLanguageChange = _ref.onLanguageChange,
|
|
972
|
+
setOpen = _ref.setOpen,
|
|
973
|
+
name = _ref.name;
|
|
974
|
+
var useB47LanguageKey = useFeatureToggle("USE_BCP-47_LANGUAGE_KEY");
|
|
975
|
+
var norwegianLanguageKey = useB47LanguageKey ? "nb-NO" : "nb";
|
|
976
|
+
var englishLanguageKey = useB47LanguageKey ? "en-GB" : "en";
|
|
977
|
+
return React.createElement(React.Fragment, null, language === englishLanguageKey ? React.createElement(CustomOverflowMenuItem, {
|
|
978
|
+
onClick: function onClick() {
|
|
979
|
+
onLanguageChange(norwegianLanguageKey);
|
|
980
|
+
setOpen(false);
|
|
981
|
+
},
|
|
982
|
+
className: "eps-overflow-menu__item"
|
|
983
|
+
}, React.createElement("span", {
|
|
984
|
+
"aria-hidden": true,
|
|
985
|
+
className: "eps-overflow-menu__icon-margin"
|
|
986
|
+
}, React.createElement(NorwayIcon, {
|
|
987
|
+
size: "1rem",
|
|
988
|
+
inline: true
|
|
989
|
+
})), name) : React.createElement(CustomOverflowMenuItem, {
|
|
990
|
+
onClick: function onClick() {
|
|
991
|
+
onLanguageChange(englishLanguageKey);
|
|
992
|
+
setOpen(false);
|
|
993
|
+
},
|
|
994
|
+
className: "eps-overflow-menu__item"
|
|
995
|
+
}, React.createElement("span", {
|
|
996
|
+
"aria-hidden": true,
|
|
997
|
+
className: "eps-overflow-menu__icon-margin"
|
|
998
|
+
}, React.createElement(UKIcon, {
|
|
999
|
+
size: "1rem",
|
|
1000
|
+
inline: true
|
|
1001
|
+
})), name));
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
var LogOutMenuItem = function LogOutMenuItem(_ref) {
|
|
1005
|
+
var name = _ref.name,
|
|
1006
|
+
setOpen = _ref.setOpen,
|
|
1007
|
+
onLogout = _ref.onLogout;
|
|
1008
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
1009
|
+
onClick: function onClick() {
|
|
1010
|
+
onLogout();
|
|
1011
|
+
setOpen(false);
|
|
1012
|
+
},
|
|
1013
|
+
"data-testid": "user-menu-logout",
|
|
1014
|
+
className: "eps-overflow-menu__item"
|
|
1015
|
+
}, React.createElement("span", {
|
|
1016
|
+
"aria-hidden": true
|
|
1017
|
+
}, React.createElement(LogOutIcon, {
|
|
1018
|
+
size: "1rem",
|
|
1019
|
+
inline: true
|
|
1020
|
+
})), name);
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
var UserMenuItem = function UserMenuItem(_ref) {
|
|
1024
|
+
var name = _ref.name,
|
|
1025
|
+
setOpen = _ref.setOpen,
|
|
1026
|
+
onNavigateToMyProfile = _ref.onNavigateToMyProfile;
|
|
1027
|
+
return React.createElement(Link$1, {
|
|
1028
|
+
to: "/permission-admin/my-profile",
|
|
1029
|
+
style: {
|
|
1030
|
+
textDecoration: "none"
|
|
1031
|
+
}
|
|
1032
|
+
}, React.createElement(CustomOverflowMenuItem, {
|
|
1033
|
+
onClick: function onClick() {
|
|
1034
|
+
setOpen(false);
|
|
1035
|
+
onNavigateToMyProfile();
|
|
1036
|
+
},
|
|
1037
|
+
className: "eps-overflow-menu__item"
|
|
1038
|
+
}, React.createElement("span", {
|
|
1039
|
+
"aria-hidden": true
|
|
1040
|
+
}, React.createElement(UserIcon, {
|
|
1041
|
+
size: "1rem",
|
|
1042
|
+
inline: true
|
|
1043
|
+
})), name));
|
|
1044
|
+
};
|
|
1045
|
+
|
|
1046
|
+
var VersionMenuItem = function VersionMenuItem(_ref) {
|
|
1047
|
+
var title = _ref.title,
|
|
1048
|
+
setOpen = _ref.setOpen;
|
|
1049
|
+
var navigate = useNavigate(); // Hide useNavigate from standalone micro-frontends because it is not under RouterProvider
|
|
1050
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
1051
|
+
onClick: function onClick() {
|
|
1052
|
+
navigate("/app-version");
|
|
1053
|
+
setOpen(false);
|
|
1054
|
+
},
|
|
1055
|
+
className: "eps-overflow-menu__item"
|
|
1056
|
+
}, React.createElement("span", {
|
|
1057
|
+
"aria-hidden": true
|
|
1058
|
+
}, React.createElement(ChannelsIcon, {
|
|
1059
|
+
className: "eps-version-icon",
|
|
1060
|
+
size: "1rem",
|
|
1061
|
+
inline: true
|
|
1062
|
+
})), title);
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
/** biome-ignore-all lint/correctness/useUniqueElementIds: Ignore unique id for now */
|
|
1066
|
+
var UserMenu = function UserMenu(_ref) {
|
|
1067
|
+
var className = _ref.className,
|
|
1068
|
+
messages = _ref.messages,
|
|
1069
|
+
onLogout = _ref.onLogout,
|
|
1070
|
+
onLanguageChange = _ref.onLanguageChange,
|
|
1071
|
+
userName = _ref.userName,
|
|
1072
|
+
language = _ref.language,
|
|
1073
|
+
environment = _ref.environment,
|
|
1074
|
+
showVersionItem = _ref.showVersionItem,
|
|
1075
|
+
showMyProfileItem = _ref.showMyProfileItem,
|
|
1076
|
+
showCookieSettingsItem = _ref.showCookieSettingsItem,
|
|
1077
|
+
onNavigateToMyProfile = _ref.onNavigateToMyProfile,
|
|
1078
|
+
_ref$onCookieSettings = _ref.onCookieSettingsOpen,
|
|
1079
|
+
onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings;
|
|
1080
|
+
var triggerClassList = cx(["eps-user-menu__trigger-button", className]);
|
|
1081
|
+
var _useState = useState(false),
|
|
1082
|
+
open = _useState[0],
|
|
1083
|
+
setOpen = _useState[1];
|
|
1084
|
+
return React.createElement("div", {
|
|
1085
|
+
id: "eps-user-menu"
|
|
1086
|
+
}, React.createElement(CustomOverflowMenu, {
|
|
1087
|
+
open: open,
|
|
1088
|
+
onOpenChange: setOpen,
|
|
1089
|
+
className: triggerClassList,
|
|
1090
|
+
userName: userName,
|
|
1091
|
+
environment: environment
|
|
1092
|
+
}, React.createElement("div", {
|
|
1093
|
+
id: "eps-overflow-menu"
|
|
1094
|
+
}, React.createElement(LanguageSwitchMenuItem, {
|
|
1095
|
+
name: messages.switchLanguage,
|
|
1096
|
+
language: language,
|
|
1097
|
+
onLanguageChange: onLanguageChange,
|
|
1098
|
+
setOpen: setOpen
|
|
1099
|
+
}), showVersionItem && messages.appVersion && React.createElement(VersionMenuItem, {
|
|
1100
|
+
title: messages.appVersion,
|
|
1101
|
+
setOpen: setOpen
|
|
1102
|
+
}), showMyProfileItem && messages.myProfile && React.createElement(UserMenuItem, {
|
|
1103
|
+
name: messages.myProfile,
|
|
1104
|
+
setOpen: setOpen,
|
|
1105
|
+
onNavigateToMyProfile: onNavigateToMyProfile
|
|
1106
|
+
}), showCookieSettingsItem && messages.cookieSettings && React.createElement(CookieSettingsMenuItem, {
|
|
1107
|
+
name: messages.cookieSettings,
|
|
1108
|
+
setOpen: setOpen,
|
|
1109
|
+
onCookieSettingsOpen: onCookieSettingsOpen
|
|
1110
|
+
}), React.createElement(LogOutMenuItem, {
|
|
1111
|
+
name: messages.logout,
|
|
1112
|
+
setOpen: setOpen,
|
|
1113
|
+
onLogout: onLogout
|
|
1114
|
+
}))));
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
/*global EventListener WindowEventHandlers*/
|
|
1118
|
+
function useEventListener(eventName, handler, element) {
|
|
1119
|
+
if (element === void 0) {
|
|
1120
|
+
element = window;
|
|
1121
|
+
}
|
|
1122
|
+
var savedHandler = useRef();
|
|
1123
|
+
useEffect(function () {
|
|
1124
|
+
savedHandler.current = handler;
|
|
1125
|
+
}, [handler]);
|
|
1126
|
+
useEffect(function () {
|
|
1127
|
+
var _element;
|
|
1128
|
+
var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
|
|
1129
|
+
if (!isSupported) return;
|
|
1130
|
+
var eventListener = function eventListener(event) {
|
|
1131
|
+
return savedHandler.current == null ? void 0 : savedHandler.current(event);
|
|
1132
|
+
};
|
|
1133
|
+
element.addEventListener(eventName, eventListener);
|
|
1134
|
+
return function () {
|
|
1135
|
+
element.removeEventListener(eventName, eventListener);
|
|
1136
|
+
};
|
|
1137
|
+
}, [eventName, element]);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* A custom hook that wraps the useNavigate hook from react-router-dom for MicroFrontend State
|
|
1142
|
+
*
|
|
1143
|
+
* @param to can be a string path, a To object, or a number (delta)
|
|
1144
|
+
* @param options contains options for modifying the navigation
|
|
1145
|
+
* @returns a function that navigates to the specified path with organisationId in the search params
|
|
1146
|
+
*/
|
|
1147
|
+
function useNavigateParams() {
|
|
1148
|
+
var _useProject = useProject(),
|
|
1149
|
+
projectName = _useProject.projectName,
|
|
1150
|
+
defaultProjectId = _useProject.defaultProjectId;
|
|
1151
|
+
var navigate = useNavigate();
|
|
1152
|
+
var _useSearchParams = useSearchParams(),
|
|
1153
|
+
searchParams = _useSearchParams[0];
|
|
1154
|
+
var projectValue = searchParams.get(projectName);
|
|
1155
|
+
var navigateParam = function navigateParam(to, options) {
|
|
1156
|
+
if (options === void 0) {
|
|
1157
|
+
options = {};
|
|
1158
|
+
}
|
|
1159
|
+
if (projectValue == null) {
|
|
1160
|
+
searchParams.set(projectName, defaultProjectId);
|
|
1161
|
+
}
|
|
1162
|
+
if (typeof to === "number") {
|
|
1163
|
+
navigate(to + "?" + searchParams.toString(), options);
|
|
1164
|
+
} else {
|
|
1165
|
+
navigate(to + "?" + searchParams.toString(), options);
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
return navigateParam;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
export { ActionBar, ActionBarLeft, ActionBarRight, AuditInfo, Box, Breadcrumbs, ConfirmModal, Content, EnturPartnerLogo, EnturPartnerLogoSvg, Environment, ErrorBoundary, ExpandableMultiLanguageInput, FeatureToggle, FormatCurrencyAmount, FormatDateTime, LanguageSelect, Link, LinkButton, Menu, MultiLanguageInput, OrganisationDropDown, PageTitle, Pager, PermissionCheck, ProjectProvider, RouteLeavingGuard, Stack, StatusLabel, Text, Unbutton, UserMenu, featureFlag, getColorForEnvironment, getHumanReadableEnvironment, responsiveProp, useDocumentTitle, useEventListener, useFeatureToggle, useNavigateParams, useProject };
|
|
1172
|
+
//# sourceMappingURL=common.esm.js.map
|