@entur-partner/common 11.2.4 → 11.2.5

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.
@@ -1,1233 +0,0 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { localeDate, localeDateTime, isDate, isDateString, splitUrlPath, isString, isFunction, assertIsDefined, hasAllPermissions, hasOneOfPermissions } from '@entur-partner/util';
3
- import cx from 'classnames';
4
- import { Children, Component, useState, useEffect, useRef } from 'react';
5
- import { BreadcrumbItem, BreadcrumbNavigation, Pagination } from '@entur/menu';
6
- import { Link as Link$1, useInRouterContext, useBlocker } from 'react-router-dom';
7
- import { ButtonGroup, SecondaryButton, PrimaryButton, Button } from '@entur/button';
8
- import { Modal } from '@entur/modal';
9
- import { Paragraph, Link as Link$2, Heading6 } from '@entur/typography';
10
- import { BannerAlertBox } from '@entur/alert';
11
- import { ExpandablePanel } from '@entur/expand';
12
- import { SegmentedControl, SegmentedChoice } from '@entur/form';
13
- import { SearchableDropdown } from '@entur/dropdown';
14
- import { CookieIcon, UserIcon, DownArrowIcon, NorwayIcon, UKIcon, LogOutIcon, ChannelsIcon } from '@entur/icons';
15
-
16
- var ActionBarLeft = function ActionBarLeft(_ref) {
17
- var children = _ref.children;
18
- return jsx("div", {
19
- className: "eps-action-bar-left",
20
- children: children
21
- });
22
- };
23
- var ActionBarRight = function ActionBarRight(_ref2) {
24
- var children = _ref2.children;
25
- return jsx("div", {
26
- className: "eps-action-bar-right",
27
- children: children
28
- });
29
- };
30
- var ActionBar = function ActionBar(_ref3) {
31
- var children = _ref3.children;
32
- return jsxs(Fragment, {
33
- children: [jsx("div", {
34
- className: "eps-action-bar-padding"
35
- }), jsx("div", {
36
- className: "eps-action-bar",
37
- children: children
38
- })]
39
- });
40
- };
41
-
42
- function _extends() {
43
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
44
- for (var e = 1; e < arguments.length; e++) {
45
- var t = arguments[e];
46
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
47
- }
48
- return n;
49
- }, _extends.apply(null, arguments);
50
- }
51
- function _inheritsLoose(t, o) {
52
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
53
- }
54
- function _objectWithoutPropertiesLoose(r, e) {
55
- if (null == r) return {};
56
- var t = {};
57
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
58
- if (-1 !== e.indexOf(n)) continue;
59
- t[n] = r[n];
60
- }
61
- return t;
62
- }
63
- function _setPrototypeOf(t, e) {
64
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
65
- return t.__proto__ = e, t;
66
- }, _setPrototypeOf(t, e);
67
- }
68
-
69
- var _excluded$e = ["date", "locale", "as", "hideTime"];
70
- /**
71
- *
72
- * @deprecated Consider to use localeDate and localeDateTime functions from @entur-partner/util instead.
73
- */
74
- var FormatDateTime = function FormatDateTime(_ref) {
75
- var date = _ref.date,
76
- locale = _ref.locale,
77
- _ref$as = _ref.as,
78
- Component = _ref$as === void 0 ? "main" : _ref$as,
79
- hideTime = _ref.hideTime,
80
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
81
- return jsx(Component, _extends({}, rest, {
82
- children: hideTime ? localeDate(date, locale) : localeDateTime(date, locale)
83
- }));
84
- };
85
-
86
- 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"];
87
- function responsiveProp(prefix, prop) {
88
- if (Array.isArray(prop)) {
89
- var classes = [];
90
- prop[0] && classes.push(prefix + prop[0]);
91
- prop[1] && classes.push("" + prefix + prop[1] + "-lg");
92
- prop[2] && classes.push("" + prefix + prop[2] + "-xl");
93
- return classes;
94
- }
95
- return [prefix + prop];
96
- }
97
- /**
98
- *
99
- * @deprecated Consider to use Tailwind or similar utility-first CSS framework instead.
100
- */
101
- var Box = function Box(_ref) {
102
- var _ref$as = _ref.as,
103
- Component = _ref$as === void 0 ? "div" : _ref$as,
104
- children = _ref.children,
105
- contrast = _ref.contrast,
106
- paddingTop = _ref.paddingTop,
107
- paddingRight = _ref.paddingRight,
108
- paddingBottom = _ref.paddingBottom,
109
- paddingLeft = _ref.paddingLeft,
110
- paddingX = _ref.paddingX,
111
- paddingY = _ref.paddingY,
112
- padding = _ref.padding,
113
- marginTop = _ref.marginTop,
114
- marginRight = _ref.marginRight,
115
- marginBottom = _ref.marginBottom,
116
- marginLeft = _ref.marginLeft,
117
- marginX = _ref.marginX,
118
- marginY = _ref.marginY,
119
- margin = _ref.margin,
120
- display = _ref.display,
121
- justifyContent = _ref.justifyContent,
122
- alignItems = _ref.alignItems,
123
- maxWidth = _ref.maxWidth,
124
- width = _ref.width,
125
- background = _ref.background,
126
- color = _ref.color,
127
- flexDirection = _ref.flexDirection,
128
- flexWrap = _ref.flexWrap,
129
- className = _ref.className,
130
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
131
- var classes = [];
132
- var resolvedPaddingTop = paddingTop || paddingY || padding;
133
- var resolvedPaddingBottom = paddingBottom || paddingY || padding;
134
- var resolvedPaddingLeft = paddingLeft || paddingX || padding;
135
- var resolvedPaddingRight = paddingRight || paddingX || padding;
136
- var resolvedMarginTop = marginTop || marginY || margin;
137
- var resolvedMarginBottom = marginBottom || marginY || margin;
138
- var resolvedMarginLeft = marginLeft || marginX || margin;
139
- var resolvedMarginRight = marginRight || marginX || margin;
140
- contrast && classes.push("eds-contrast");
141
- resolvedPaddingTop && classes.push.apply(classes, responsiveProp("eps-pt-", resolvedPaddingTop));
142
- resolvedPaddingBottom && classes.push.apply(classes, responsiveProp("eps-pb-", resolvedPaddingBottom));
143
- resolvedPaddingLeft && classes.push.apply(classes, responsiveProp("eps-pl-", resolvedPaddingLeft));
144
- resolvedPaddingRight && classes.push.apply(classes, responsiveProp("eps-pr-", resolvedPaddingRight));
145
- resolvedMarginTop && classes.push.apply(classes, responsiveProp("eps-mt-", resolvedMarginTop));
146
- resolvedMarginBottom && classes.push.apply(classes, responsiveProp("eps-mb-", resolvedMarginBottom));
147
- resolvedMarginLeft && classes.push.apply(classes, responsiveProp("eps-ml-", resolvedMarginLeft));
148
- resolvedMarginRight && classes.push.apply(classes, responsiveProp("eps-mr-", resolvedMarginRight));
149
- display && classes.push.apply(classes, responsiveProp("eps-", display));
150
- justifyContent && classes.push.apply(classes, responsiveProp("eps-justify-", justifyContent));
151
- if (alignItems) {
152
- classes.push.apply(classes, responsiveProp("eps-items-", alignItems));
153
- }
154
- maxWidth && classes.push.apply(classes, responsiveProp("eps-max-w-", maxWidth));
155
- width && classes.push.apply(classes, responsiveProp("eps-w-", width));
156
- color && classes.push("eps-color-" + color);
157
- background && classes.push("eps-bg-" + background);
158
- flexDirection && classes.push.apply(classes, responsiveProp("eps-flex-", flexDirection));
159
- flexWrap && classes.push.apply(classes, responsiveProp("eps-flex-wrap-", flexWrap));
160
- var classList = cx(classes, className);
161
- return jsx(Component, _extends({
162
- className: classList
163
- }, rest, {
164
- children: children
165
- }));
166
- };
167
-
168
- /**
169
- * @deprecated Consider to use Tailwind or CSS/SCSS directly.
170
- */
171
- var Stack = function Stack(_ref) {
172
- var children = _ref.children,
173
- space = _ref.space,
174
- className = _ref.className;
175
- var stackItems = Children.toArray(children);
176
- if (stackItems.length <= 1) {
177
- return jsx(Fragment, {
178
- children: stackItems
179
- });
180
- }
181
- return jsx("div", {
182
- className: className,
183
- children: stackItems.map(function (child, index) {
184
- return index === stackItems.length - 1 ? jsx("div", {
185
- children: child
186
- }, index) : jsx(Box, {
187
- paddingBottom: space,
188
- children: child
189
- }, index);
190
- })
191
- });
192
- };
193
-
194
- var _excluded$c = ["items", "locale", "className"];
195
- /**
196
- * @deprecated Only Product Frontend uses this component. Consider to move it there.
197
- */
198
- var AuditInfo = function AuditInfo(_ref) {
199
- var items = _ref.items,
200
- locale = _ref.locale,
201
- className = _ref.className,
202
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$c);
203
- var classNames = cx("ep-audit-info", className);
204
- return jsx("div", _extends({
205
- className: classNames
206
- }, rest, {
207
- children: items.map(function (_ref2) {
208
- var label = _ref2.label,
209
- value = _ref2.value;
210
- return jsxs(Stack, {
211
- space: "small",
212
- children: [jsx("div", {
213
- className: "ep-audit-info-label",
214
- children: label
215
- }), jsx("div", {
216
- children: isDate(value) || isDateString(value) ? jsx(FormatDateTime, {
217
- date: value,
218
- locale: locale
219
- }) : jsx("span", {
220
- children: value
221
- })
222
- })]
223
- }, value.toString());
224
- })
225
- }));
226
- };
227
-
228
- var Breadcrumbs = function Breadcrumbs(_ref) {
229
- var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
230
- pathname = _ref.pathname,
231
- onBreadcrumbLookup = _ref.onBreadcrumbLookup;
232
- var paths = splitUrlPath(pathname);
233
- var breadcrumbs = paths.map(function (path) {
234
- return {
235
- title: onBreadcrumbLookup(path),
236
- path: path
237
- };
238
- }).filter(function (_ref2) {
239
- var title = _ref2.title;
240
- return title !== undefined;
241
- });
242
- var breadcrumbElements = breadcrumbs.map(function (_ref3, i) {
243
- var title = _ref3.title,
244
- path = _ref3.path;
245
- var isLast = i === breadcrumbs.length - 1;
246
- if (isLast) {
247
- return jsx(BreadcrumbItem, {
248
- as: "span",
249
- children: title
250
- }, path);
251
- }
252
- return jsx(BreadcrumbItem, {
253
- as: Link$1,
254
- to: path,
255
- children: title
256
- }, path);
257
- });
258
- if (prependBreadcrumbItem) {
259
- return jsx(BreadcrumbNavigation, {
260
- children: [prependBreadcrumbItem].concat(breadcrumbElements)
261
- });
262
- }
263
- return jsx(BreadcrumbNavigation, {
264
- children: breadcrumbElements
265
- });
266
- };
267
-
268
- var _excluded$b = ["isOpen", "children", "message", "size", "buttons", "onConfirm", "messages", "onClose", "onDismiss"];
269
- var ConfirmModal = function ConfirmModal(_ref) {
270
- var _ref$isOpen = _ref.isOpen,
271
- isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
272
- children = _ref.children,
273
- message = _ref.message,
274
- _ref$size = _ref.size,
275
- size = _ref$size === void 0 ? "medium" : _ref$size,
276
- buttons = _ref.buttons,
277
- onConfirm = _ref.onConfirm,
278
- messages = _ref.messages,
279
- onClose = _ref.onClose,
280
- onDismiss = _ref.onDismiss,
281
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
282
- var childrenToRender = children ? children : message;
283
- var handleDismiss = onClose ? onClose : onDismiss;
284
- return jsxs(Modal, _extends({
285
- size: size,
286
- open: isOpen,
287
- onDismiss: handleDismiss
288
- }, rest, {
289
- children: [isString(childrenToRender) ? jsx(Paragraph, {
290
- children: childrenToRender
291
- }) : jsx(Box, {
292
- paddingBottom: "medium",
293
- children: childrenToRender
294
- }), jsx(ButtonGroup, {
295
- children: onConfirm ? jsxs(Fragment, {
296
- children: [jsx(SecondaryButton, {
297
- onClick: handleDismiss,
298
- "data-testid": "cancel-modal-button",
299
- children: messages.cancel
300
- }), jsx(PrimaryButton, {
301
- onClick: onConfirm,
302
- "data-testid": "confirm-modal-button",
303
- children: messages.confirm
304
- })]
305
- }) : buttons
306
- })]
307
- }));
308
- };
309
-
310
- var Content = function Content(_ref) {
311
- var _ref$as = _ref.as,
312
- Component = _ref$as === void 0 ? "main" : _ref$as,
313
- className = _ref.className,
314
- children = _ref.children;
315
- var classList = cx(["eps-content", className]);
316
- return jsx(Component, {
317
- className: classList,
318
- children: children
319
- });
320
- };
321
-
322
- var _environmentColors, _humanReadableEnviron;
323
- var Environment;
324
- (function (Environment) {
325
- Environment["Local"] = "local";
326
- Environment["Development"] = "dev";
327
- Environment["Staging"] = "staging";
328
- Environment["Production"] = "prod";
329
- })(Environment || (Environment = {}));
330
- var environmentColors = (_environmentColors = {}, _environmentColors[Environment.Local] = "#B482FB", _environmentColors[Environment.Development] = "#5AC39A", _environmentColors[Environment.Staging] = "#FFCA28", _environmentColors);
331
- /**
332
- * Gets the color for the given environment. This is the color used for the environment
333
- * indicator. There is no color for production as it should not have any special environment
334
- * indication.
335
- */
336
- var getColorForEnvironment = function getColorForEnvironment(environment) {
337
- return environmentColors[environment];
338
- };
339
- var humanReadableEnvironment = (_humanReadableEnviron = {}, _humanReadableEnviron[Environment.Local] = "Local", _humanReadableEnviron[Environment.Development] = "Dev", _humanReadableEnviron[Environment.Staging] = "Staging", _humanReadableEnviron[Environment.Production] = "Prod", _humanReadableEnviron);
340
- var getHumanReadableEnvironment = function getHumanReadableEnvironment(environment) {
341
- return humanReadableEnvironment[environment];
342
- };
343
-
344
- var _excluded$a = ["title", "accentColor"];
345
- var EnturPartnerLogoSvg = function EnturPartnerLogoSvg(_ref) {
346
- var title = _ref.title,
347
- _ref$accentColor = _ref.accentColor,
348
- accentColor = _ref$accentColor === void 0 ? "#FF5959" : _ref$accentColor,
349
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
350
- return jsxs("svg", _extends({
351
- width: 257,
352
- height: 37,
353
- viewBox: "0 0 257 37"
354
- }, rest, {
355
- children: [jsx("title", {
356
- children: title
357
- }), jsxs("g", {
358
- fill: "none",
359
- fillRule: "evenodd",
360
- children: [jsx("path", {
361
- fill: "#FFF",
362
- d: "M0 .231V25.72h18.745v-4.318H4.869v-6.163h12.31v-4.318H4.87V4.55h13.876V.231z"
363
- }), jsx("path", {
364
- fill: accentColor,
365
- d: "M0 36.408h45.253v-4.32H0z"
366
- }), jsx("path", {
367
- fill: "#FFF",
368
- 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"
369
- }), jsx("g", {
370
- fill: accentColor,
371
- children: jsx("path", {
372
- 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"
373
- })
374
- })]
375
- })]
376
- }));
377
- };
378
- var EnturPartnerLogo = function EnturPartnerLogo(_ref2) {
379
- var _ref2$as = _ref2.as,
380
- Component = _ref2$as === void 0 ? "nav" : _ref2$as,
381
- className = _ref2.className,
382
- altText = _ref2.altText,
383
- environment = _ref2.environment;
384
- var classList = cx(["eps-logo-wrapper", className]);
385
- return jsx(Component, {
386
- className: classList,
387
- children: jsx(EnturPartnerLogoSvg, {
388
- title: altText,
389
- className: "logo",
390
- accentColor: environment !== undefined && environment !== Environment.Production ? getColorForEnvironment(environment) : undefined
391
- })
392
- });
393
- };
394
-
395
- var newAppVersionErrorMessage = "Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.";
396
- var ErrorBoundary = /*#__PURE__*/function (_Component) {
397
- function ErrorBoundary(props) {
398
- var _this;
399
- _this = _Component.call(this, props) || this;
400
- _this.state = {
401
- error: null
402
- };
403
- return _this;
404
- }
405
- _inheritsLoose(ErrorBoundary, _Component);
406
- ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
407
- return {
408
- error: error
409
- };
410
- };
411
- var _proto = ErrorBoundary.prototype;
412
- _proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
413
- var _this$props$handleErr, _this$props;
414
- // React always logs in development
415
- (_this$props$handleErr = (_this$props = this.props).handleError) == null || _this$props$handleErr.call(_this$props, error, errorInfo);
416
- };
417
- _proto.render = function render() {
418
- var _this2 = this;
419
- var error = this.state.error;
420
- var _this$props2 = this.props,
421
- fallback = _this$props2.fallback,
422
- children = _this$props2.children;
423
- if (error) {
424
- if (isFunction(fallback)) {
425
- return fallback({
426
- retry: function retry() {
427
- return _this2.setState({
428
- error: null
429
- });
430
- },
431
- error: error
432
- });
433
- } else if (error.name === "NotFoundError" && error.message === newAppVersionErrorMessage) {
434
- return jsx(RefreshBannerInfo, {});
435
- }
436
- return fallback;
437
- }
438
- return children;
439
- };
440
- return ErrorBoundary;
441
- }(Component);
442
- var LANGUAGE_STORAGE_KEY = "EP::locale";
443
- function RefreshBannerInfo() {
444
- // Taken from ./app-shell/src/storage.ts
445
- var language = localStorage.getItem(LANGUAGE_STORAGE_KEY);
446
- var isNorwegian = language === "nb" || language === "nb-NO";
447
- return jsx(Box, {
448
- maxWidth: "large",
449
- children: jsxs(BannerAlertBox, {
450
- variant: "info",
451
- title: isNorwegian ? "En ny versjon av nettsiden er tilgjengelig." : "A new version of the website is available.",
452
- children: [jsx(Box, {
453
- paddingBottom: "medium",
454
- children: jsx(Paragraph, {
455
- margin: "none",
456
- children: isNorwegian ? "Vennligst oppdater." : "Please refresh."
457
- })
458
- }), jsx(PrimaryButton, {
459
- onClick: function onClick() {
460
- return window.location.reload();
461
- },
462
- children: isNorwegian ? "Oppdater" : "Refresh"
463
- })]
464
- })
465
- });
466
- }
467
-
468
- var _excluded$9 = ["title", "inputComponent", "languages", "values", "onChange", "name", "variant", "feedback"];
469
- /**
470
- * @deprecated No longer in use by anyone.
471
- */
472
- var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
473
- var title = _ref.title,
474
- InputComponent = _ref.inputComponent,
475
- languages = _ref.languages,
476
- values = _ref.values,
477
- onChange = _ref.onChange,
478
- name = _ref.name,
479
- variant = _ref.variant,
480
- feedback = _ref.feedback,
481
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
482
- var handleOnChange = function handleOnChange(language, value) {
483
- var changes = _extends({}, values);
484
- if (value === "" || !value) {
485
- delete changes[language];
486
- } else {
487
- changes[language] = value;
488
- }
489
- onChange(changes);
490
- };
491
- return jsx(ExpandablePanel, {
492
- title: title,
493
- defaultOpen: true,
494
- contentStyle: {
495
- padding: "4px 4px 4px 4px",
496
- marginTop: "16px",
497
- marginBottom: "16px"
498
- },
499
- children: jsx(Stack, {
500
- space: "medium",
501
- children: languages.map(function (_ref2) {
502
- var langKey = _ref2.value,
503
- label = _ref2.label,
504
- required = _ref2.required;
505
- return jsx(InputComponent, _extends({
506
- "data-testid": "multi-lang-input-" + name + "-" + langKey,
507
- label: required ? label + "*" : label,
508
- variant: variant == null ? void 0 : variant(langKey),
509
- feedback: feedback == null ? void 0 : feedback(langKey),
510
- name: name,
511
- onChange: function onChange(e) {
512
- handleOnChange(langKey, e.target.value);
513
- },
514
- value: values[langKey] || ""
515
- }, rest), title + langKey);
516
- })
517
- })
518
- });
519
- };
520
-
521
- /**
522
- * Returns true if the provided flag exist in localStorage
523
- * or is set as an environment variable.
524
- *
525
- * @param flag case sensitive flag. If it is an environment variable
526
- * you can drop the VITE_APP_ prefix.
527
- */
528
- function featureFlag(flag) {
529
- var _import$meta, _window$localStorage, _window$localStorage2;
530
- return (
531
- // biome-ignore lint/suspicious/noExplicitAny: We dont have vite types here
532
- ((_import$meta = import.meta) == null || (_import$meta = _import$meta.env) == null ? void 0 : _import$meta["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"
533
- );
534
- }
535
- /**
536
- * Returns true if the provided flag exist in localStorage
537
- * or is set as an environment variable.
538
- *
539
- * @deprecated use featureFlag instead.
540
- * @param flag case sensitive flag. If it is an environment variable
541
- * you can drop the VITE_APP_ prefix.
542
- */
543
- function useFeatureToggle(flag) {
544
- return featureFlag(flag);
545
- }
546
- var FeatureToggle = function FeatureToggle(_ref) {
547
- var children = _ref.children,
548
- flag = _ref.flag;
549
- var feature = featureFlag(flag);
550
- if (feature) {
551
- return jsx(Fragment, {
552
- children: children
553
- });
554
- }
555
- return null;
556
- };
557
-
558
- var _excluded$8 = ["amount", "as"];
559
- /**
560
- *
561
- * @deprecated Moved to @entur-partner/util as a function instead.
562
- */
563
- var FormatCurrencyAmount = function FormatCurrencyAmount(_ref) {
564
- var amount = _ref.amount,
565
- _ref$as = _ref.as,
566
- Component = _ref$as === void 0 ? "span" : _ref$as,
567
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
568
- var parsedAmount = Number(amount) || 0;
569
- var formattedAmount = new Intl.NumberFormat("nb-NO", {
570
- maximumFractionDigits: 2,
571
- minimumFractionDigits: 2
572
- }).format(parsedAmount);
573
- return jsx(Component, _extends({}, rest, {
574
- children: formattedAmount
575
- }));
576
- };
577
-
578
- var _excluded$7 = ["language", "options", "className", "onChange"];
579
- /**
580
- *
581
- * @deprecated This component is no longer in use by anyone.
582
- */
583
- var LanguageSelect = function LanguageSelect(_ref) {
584
- var language = _ref.language,
585
- options = _ref.options,
586
- className = _ref.className,
587
- _onChange = _ref.onChange,
588
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
589
- var classNames = cx("eps-language-select", className);
590
- return jsx("div", _extends({}, rest, {
591
- className: classNames,
592
- children: jsx(SegmentedControl, {
593
- onChange: function onChange(language) {
594
- assertIsDefined(language);
595
- if (typeof language === "string") {
596
- _onChange(language);
597
- }
598
- },
599
- selectedValue: language,
600
- children: options.map(function (option) {
601
- return jsxs(SegmentedChoice, {
602
- value: option.value,
603
- children: [option.label, option.required && jsx("span", {
604
- className: "asterisk-margin",
605
- children: "*"
606
- })]
607
- }, option.value);
608
- })
609
- })
610
- }));
611
- };
612
-
613
- /**
614
- *
615
- * @deprecated Use Link from react-router instead.
616
- */
617
- var Link = function Link(props) {
618
- return jsx(Link$2, _extends({}, props, {
619
- as: Link$1,
620
- children: props.children
621
- }));
622
- };
623
-
624
- var _excluded$6 = ["children", "className"];
625
- /**
626
- * @deprecated LinkButton is not UU compliant and should be replaced with a regular Link or Button component depending on the use case.
627
- */
628
- var LinkButton = function LinkButton(_ref) {
629
- var children = _ref.children,
630
- className = _ref.className,
631
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
632
- return jsx(Link$2, _extends({}, rest, {
633
- as: "button",
634
- className: cx("eps-link-button", className),
635
- children: children
636
- }));
637
- };
638
-
639
- var Menu = function Menu(_ref) {
640
- var _ref$as = _ref.as,
641
- Component = _ref$as === void 0 ? "nav" : _ref$as,
642
- className = _ref.className,
643
- children = _ref.children;
644
- var classList = cx(["eds-contrast", "eps-menu", className]);
645
- return jsx(Component, {
646
- className: classList,
647
- children: children
648
- });
649
- };
650
-
651
- var _excluded$5 = ["className", "inputComponent", "alertLabel", "alertLevel", "name", "languages", "values", "onChange", "defaultLanguage", "label", "onBlur"];
652
- /**
653
- * @deprecated No longer in use by anyone.
654
- */
655
- var MultiLanguageInput = function MultiLanguageInput(_ref) {
656
- var className = _ref.className,
657
- InputComponent = _ref.inputComponent,
658
- alertLabel = _ref.alertLabel,
659
- alertLevel = _ref.alertLevel,
660
- name = _ref.name,
661
- languages = _ref.languages,
662
- values = _ref.values,
663
- onChange = _ref.onChange,
664
- _ref$defaultLanguage = _ref.defaultLanguage,
665
- defaultLanguage = _ref$defaultLanguage === void 0 ? "nob" : _ref$defaultLanguage,
666
- _ref$label = _ref.label,
667
- label = _ref$label === void 0 ? "" : _ref$label,
668
- _ref$onBlur = _ref.onBlur,
669
- onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
670
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
671
- var _useState = useState(defaultLanguage),
672
- language = _useState[0],
673
- setLanguage = _useState[1];
674
- var classNames = cx("multi-language-input", className);
675
- var currentValue = values[language];
676
- var handleOnBlur = function handleOnBlur(e) {
677
- e.persist();
678
- var currentTarget = e.currentTarget;
679
- setTimeout(function () {
680
- if (currentTarget && !currentTarget.contains(document.activeElement)) {
681
- onBlur(e);
682
- }
683
- }, 0);
684
- };
685
- var handleLanguageChange = function handleLanguageChange(language) {
686
- setLanguage(language);
687
- };
688
- var handleOnChange = function handleOnChange(value) {
689
- var changes = Object.assign({}, values);
690
- if (value === "" || !value) {
691
- delete changes[language];
692
- } else {
693
- changes[language] = value;
694
- }
695
- onChange(changes);
696
- };
697
- return (
698
- // biome-ignore lint/a11y/noStaticElementInteractions: Legacy component
699
- jsx("div", {
700
- className: classNames,
701
- // biome-ignore lint/a11y/noNoninteractiveTabindex: Legacy component
702
- tabIndex: 0,
703
- onBlur: handleOnBlur,
704
- "data-testid": "multi-lang-input-" + name,
705
- children: jsxs(Stack, {
706
- space: "extraSmall",
707
- children: [jsx(LanguageSelect, {
708
- language: language,
709
- options: languages,
710
- onChange: function onChange(lang) {
711
- return handleLanguageChange(lang);
712
- }
713
- }), jsx(InputComponent, _extends({
714
- label: label,
715
- variant: alertLevel,
716
- feedback: alertLabel,
717
- name: name,
718
- className: "language-item",
719
- onChange: function onChange(e) {
720
- return handleOnChange(e.target.value);
721
- },
722
- value: currentValue || ""
723
- }, rest))]
724
- })
725
- })
726
- );
727
- };
728
-
729
- var _excluded$4 = ["label", "organisations", "onChange", "selectedOrganisationId"];
730
- var OrganisationDropDown = function OrganisationDropDown(_ref) {
731
- var label = _ref.label,
732
- organisations = _ref.organisations,
733
- handleChange = _ref.onChange,
734
- selectedOrganisationId = _ref.selectedOrganisationId,
735
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
736
- var _useState = useState(),
737
- selectedOrganisation = _useState[0],
738
- setSelectedOrganisation = _useState[1];
739
- useEffect(function () {
740
- setSelectedOrganisation(organisations.find(function (org) {
741
- return org.organisationId === selectedOrganisationId;
742
- }));
743
- }, [selectedOrganisationId, organisations]);
744
- return jsx(SearchableDropdown, _extends({
745
- label: label,
746
- items: [].concat(organisations.sort(function (a, b) {
747
- return a.tradingName.localeCompare(b.tradingName, "nb");
748
- }).map(function (organisation) {
749
- return {
750
- value: organisation.organisationId,
751
- label: organisation.tradingName
752
- };
753
- })),
754
- selectedItem: selectedOrganisation ? {
755
- value: selectedOrganisation.organisationId,
756
- label: selectedOrganisation.tradingName
757
- } : null,
758
- onChange: function onChange(selectedValue) {
759
- if (selectedValue) {
760
- handleChange(selectedValue.value);
761
- }
762
- },
763
- clearable: false
764
- }, rest));
765
- };
766
-
767
- /**
768
- * @deprecated use Pagination directly instead
769
- */
770
- var Pager = function Pager(_ref) {
771
- var collectionSize = _ref.collectionSize,
772
- pageSize = _ref.pageSize,
773
- _onPageChange = _ref.onPageChange,
774
- currentPage = _ref.currentPage;
775
- var pageCount = Math.ceil(collectionSize / pageSize);
776
- return jsx(Pagination, {
777
- pageCount: pageCount,
778
- currentPage: currentPage,
779
- onPageChange: function onPageChange(page) {
780
- _onPageChange(page);
781
- }
782
- });
783
- };
784
-
785
- var useDocumentTitle = function useDocumentTitle(_ref) {
786
- var title = _ref.title,
787
- suffix = _ref.suffix;
788
- useEffect(function () {
789
- if (suffix) {
790
- document.title = "" + title + suffix;
791
- } else {
792
- document.title = title;
793
- }
794
- }, [title, suffix]);
795
- };
796
- var PageTitle = function PageTitle(_ref2) {
797
- var pathname = _ref2.pathname,
798
- onBreadcrumbLookup = _ref2.onBreadcrumbLookup,
799
- _ref2$appTitle = _ref2.appTitle,
800
- appTitle = _ref2$appTitle === void 0 ? "Entur Partner" : _ref2$appTitle;
801
- var paths = splitUrlPath(pathname);
802
- var pageTitles = paths.map(function (path) {
803
- return {
804
- title: onBreadcrumbLookup(path),
805
- path: path
806
- };
807
- }).filter(function (_ref3) {
808
- var title = _ref3.title;
809
- return title !== undefined;
810
- }).map(function (_ref4) {
811
- var title = _ref4.title;
812
- return title;
813
- }).reverse().join(" | ");
814
- var title = pageTitles ? pageTitles + " | " + appTitle : appTitle;
815
- useDocumentTitle({
816
- title: title
817
- });
818
- return null;
819
- };
820
-
821
- /**
822
- * Note: This component uses BusinessCapability, not because we only want to
823
- * check BusinessCapabilities but because it represents a minimal subset of
824
- * what we need to check.
825
- */
826
- var PermissionCheck = function PermissionCheck(_ref) {
827
- var children = _ref.children,
828
- _ref$fallback = _ref.fallback,
829
- fallback = _ref$fallback === void 0 ? null : _ref$fallback,
830
- permissions = _ref.permissions,
831
- _ref$oneOf = _ref.oneOf,
832
- oneOf = _ref$oneOf === void 0 ? [] : _ref$oneOf,
833
- _ref$all = _ref.all,
834
- all = _ref$all === void 0 ? [] : _ref$all;
835
- var allIsAllowed = hasAllPermissions(all, permissions);
836
- var oneOfIsAllowed = hasOneOfPermissions(oneOf, permissions);
837
- var allowed = allIsAllowed && oneOfIsAllowed;
838
- return jsx(Fragment, {
839
- children: allowed ? children : fallback
840
- });
841
- };
842
-
843
- var _excluded$3 = ["children", "shouldBlockNavigation"];
844
- var RouteLeavingGuard = function RouteLeavingGuard(_ref) {
845
- var children = _ref.children,
846
- shouldBlockNavigation = _ref.shouldBlockNavigation,
847
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
848
- assertIsDefined(useInRouterContext() ? true : undefined, "RouteLeavingGuard must be used within a data router.");
849
- var blocker = useBlocker(function (_ref2) {
850
- var currentLocation = _ref2.currentLocation,
851
- nextLocation = _ref2.nextLocation;
852
- return currentLocation.pathname !== nextLocation.pathname && shouldBlockNavigation(nextLocation);
853
- });
854
- return jsx(ConfirmModal, _extends({
855
- onDismiss: function onDismiss() {
856
- if (blocker.state === "blocked") {
857
- blocker.reset();
858
- }
859
- },
860
- open: blocker.state === "blocked",
861
- onConfirm: function onConfirm() {
862
- if (blocker.state === "blocked") {
863
- blocker.proceed();
864
- }
865
- }
866
- }, rest, {
867
- children: children
868
- }));
869
- };
870
-
871
- /**
872
- * @deprecated Consider to copy component for own usage or use entur design system.
873
- */
874
- var StatusLabel = function StatusLabel(_ref) {
875
- var _ref$active = _ref.active,
876
- active = _ref$active === void 0 ? false : _ref$active,
877
- _ref$label = _ref.label,
878
- label = _ref$label === void 0 ? "" : _ref$label,
879
- aggressiveInactive = _ref.aggressiveInactive,
880
- showBullet = _ref.showBullet,
881
- center = _ref.center;
882
- var bulletClassNames = cx("eps-status-label__bullet", {
883
- active: active,
884
- aggressive: aggressiveInactive
885
- });
886
- var statusLabelClassNames = cx("eps-status-label", {
887
- center: center
888
- });
889
- return jsxs("div", {
890
- className: statusLabelClassNames,
891
- children: [showBullet && jsx("div", {
892
- className: bulletClassNames
893
- }), jsx("div", {
894
- children: label
895
- })]
896
- });
897
- };
898
-
899
- var _excluded$2 = ["as", "children", "fontSize", "color", "lineHeight", "fontWeight", "className"];
900
- /**
901
- *
902
- * @deprecated Use Entur design system Text component.
903
- */
904
- var Text = function Text(_ref) {
905
- var _ref$as = _ref.as,
906
- component = _ref$as === void 0 ? "span" : _ref$as,
907
- children = _ref.children,
908
- fontSize = _ref.fontSize,
909
- color = _ref.color,
910
- lineHeight = _ref.lineHeight,
911
- fontWeight = _ref.fontWeight,
912
- className = _ref.className,
913
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
914
- var classes = [];
915
- fontSize && classes.push.apply(classes, responsiveProp("eps-font-size-", fontSize));
916
- lineHeight && classes.push.apply(classes, responsiveProp("eps-line-height-", lineHeight));
917
- fontWeight && classes.push("eps-font-weight-" + fontWeight);
918
- var classList = cx(classes, className);
919
- return jsx(Box, _extends({
920
- as: component,
921
- color: color,
922
- className: classList
923
- }, rest, {
924
- children: children
925
- }));
926
- };
927
-
928
- var _excluded$1 = ["children", "className"];
929
- /**
930
- * @deprecated Consider to copy component for own usage.
931
- */
932
- var Unbutton = function Unbutton(_ref) {
933
- var children = _ref.children,
934
- className = _ref.className,
935
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
936
- return jsx(Button, _extends({
937
- variant: "primary"
938
- }, rest, {
939
- className: cx("eps-unbutton", className),
940
- children: children
941
- }));
942
- };
943
-
944
- /*global EventListener WindowEventHandlers*/
945
- function useEventListener(eventName, handler, element) {
946
- if (element === void 0) {
947
- element = window;
948
- }
949
- var savedHandler = useRef(null);
950
- useEffect(function () {
951
- savedHandler.current = handler;
952
- }, [handler]);
953
- useEffect(function () {
954
- var _element;
955
- var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
956
- if (!isSupported) return;
957
- var eventListener = function eventListener(event) {
958
- return savedHandler.current == null ? void 0 : savedHandler.current(event);
959
- };
960
- element.addEventListener(eventName, eventListener);
961
- return function () {
962
- element.removeEventListener(eventName, eventListener);
963
- };
964
- }, [eventName, element]);
965
- }
966
-
967
- var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
968
- return jsx("button", _extends({
969
- className: cx(props.className, "eps-overflow-menu__item"),
970
- role: "menuitem"
971
- }, props));
972
- };
973
-
974
- var CookieSettingsMenuItem = function CookieSettingsMenuItem(_ref) {
975
- var locale = _ref.locale,
976
- onClick = _ref.onClick;
977
- return jsxs(CustomOverflowMenuItem, {
978
- onClick: onClick,
979
- className: "eps-overflow-menu__item",
980
- children: [jsx("span", {
981
- "aria-hidden": true,
982
- children: jsx(CookieIcon, {
983
- size: "1rem",
984
- inline: true
985
- })
986
- }), locale === "en-GB" ? "Cookie settings" : "Cookieinstillinger"]
987
- });
988
- };
989
-
990
- function useOutsideClick(ref, buttonRef, handler) {
991
- useEffect(function () {
992
- var listener = function listener(event) {
993
- if (elementContainsEventTarget(ref.current, event) || elementContainsEventTarget(buttonRef.current, event)) {
994
- return;
995
- }
996
- handler();
997
- };
998
- document.addEventListener("mousedown", listener);
999
- document.addEventListener("touchstart", listener);
1000
- return function () {
1001
- document.removeEventListener("mousedown", listener);
1002
- document.removeEventListener("touchstart", listener);
1003
- };
1004
- }, [ref, buttonRef, handler]);
1005
- }
1006
- function elementContainsEventTarget(element, event) {
1007
- if (!element) {
1008
- return false;
1009
- }
1010
- if (element.contains(event.target)) {
1011
- return true;
1012
- }
1013
- // For elements inside a Shadow DOM we need to check the composedPath
1014
- if (event.composed && event.composedPath) {
1015
- var contains = event.composedPath().find(function (target) {
1016
- if (target === window) {
1017
- return false;
1018
- }
1019
- return element.contains(target);
1020
- });
1021
- return !!contains;
1022
- }
1023
- return false;
1024
- }
1025
-
1026
- var _excluded = ["className", "children", "userName", "open", "onOpenChange", "environment"];
1027
- var CustomOverflowMenu = function CustomOverflowMenu(_ref) {
1028
- var className = _ref.className,
1029
- children = _ref.children,
1030
- userName = _ref.userName,
1031
- open = _ref.open,
1032
- onOpenChange = _ref.onOpenChange,
1033
- environment = _ref.environment,
1034
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1035
- var overflowItemsClasses = cx("eps-overflow-menu__group", {
1036
- "eps-overflow-menu__group--open": open
1037
- });
1038
- var overflowContentRef = useRef(null);
1039
- var overflowMenuTriggerRef = useRef(null);
1040
- useOutsideClick(overflowContentRef, overflowMenuTriggerRef, function () {
1041
- return onOpenChange(false);
1042
- });
1043
- return jsxs("div", {
1044
- children: [jsx(SecondaryButton, _extends({
1045
- className: cx("eps-overflow-menu__button", className),
1046
- onClick: function onClick() {
1047
- return onOpenChange(!open);
1048
- },
1049
- "aria-haspopup": true,
1050
- "aria-expanded": open,
1051
- ref: overflowMenuTriggerRef
1052
- }, rest, {
1053
- children: jsxs("div", {
1054
- className: "eps-overflow-menu__button-contents",
1055
- children: [jsx("span", {
1056
- className: "eds-overflow-menu__user-icon",
1057
- children: jsx(UserIcon, {
1058
- inline: true
1059
- })
1060
- }), jsxs(Heading6, {
1061
- margin: "none",
1062
- as: "span",
1063
- children: [userName, environment !== undefined && environment !== Environment.Production && jsxs("span", {
1064
- style: {
1065
- color: getColorForEnvironment(environment)
1066
- },
1067
- children: [" ", "(", getHumanReadableEnvironment(environment), ")"]
1068
- })]
1069
- }), jsx("span", {
1070
- className: "eps-arrow-icon",
1071
- children: jsx(DownArrowIcon, {
1072
- inline: true
1073
- })
1074
- })]
1075
- })
1076
- })), open && jsx("div", {
1077
- className: overflowItemsClasses,
1078
- role: "menu",
1079
- ref: overflowContentRef,
1080
- children: children
1081
- })]
1082
- });
1083
- };
1084
-
1085
- var LocaleSwitchMenuItem = function LocaleSwitchMenuItem(_ref) {
1086
- var locale = _ref.locale,
1087
- onLocaleChange = _ref.onLocaleChange;
1088
- return jsx(Fragment, {
1089
- children: locale === "en-GB" ? jsxs(CustomOverflowMenuItem, {
1090
- onClick: function onClick() {
1091
- onLocaleChange("nb-NO");
1092
- },
1093
- className: "eps-overflow-menu__item",
1094
- children: [jsx("span", {
1095
- "aria-hidden": true,
1096
- className: "eps-overflow-menu__icon-margin",
1097
- children: jsx(NorwayIcon, {
1098
- size: "1rem",
1099
- inline: true
1100
- })
1101
- }), "Bytt til norsk"]
1102
- }) : jsxs(CustomOverflowMenuItem, {
1103
- onClick: function onClick() {
1104
- onLocaleChange("en-GB");
1105
- },
1106
- className: "eps-overflow-menu__item",
1107
- children: [jsx("span", {
1108
- "aria-hidden": true,
1109
- className: "eps-overflow-menu__icon-margin",
1110
- children: jsx(UKIcon, {
1111
- size: "1rem",
1112
- inline: true
1113
- })
1114
- }), "Switch to English"]
1115
- })
1116
- });
1117
- };
1118
-
1119
- var LogOutMenuItem = function LogOutMenuItem(_ref) {
1120
- var onClick = _ref.onClick,
1121
- locale = _ref.locale;
1122
- return jsxs(CustomOverflowMenuItem, {
1123
- onClick: onClick,
1124
- "data-testid": "user-menu-logout",
1125
- className: "eps-overflow-menu__item",
1126
- children: [jsx("span", {
1127
- "aria-hidden": true,
1128
- children: jsx(LogOutIcon, {
1129
- size: "1rem",
1130
- inline: true
1131
- })
1132
- }), locale === "en-GB" ? "Log out " : "Logg ut"]
1133
- });
1134
- };
1135
-
1136
- var UserMenuItem = function UserMenuItem(_ref) {
1137
- var locale = _ref.locale,
1138
- onClick = _ref.onClick;
1139
- return jsxs(CustomOverflowMenuItem, {
1140
- onClick: onClick,
1141
- className: "eps-overflow-menu__item",
1142
- children: [jsx("span", {
1143
- "aria-hidden": true,
1144
- children: jsx(UserIcon, {
1145
- size: "1rem",
1146
- inline: true
1147
- })
1148
- }), locale === "en-GB" ? "My profile" : "Min profil"]
1149
- });
1150
- };
1151
-
1152
- var VersionMenuItem = function VersionMenuItem(_ref) {
1153
- var locale = _ref.locale,
1154
- onClick = _ref.onClick;
1155
- return jsxs(CustomOverflowMenuItem, {
1156
- onClick: onClick,
1157
- className: "eps-overflow-menu__item",
1158
- children: [jsx("span", {
1159
- "aria-hidden": true,
1160
- children: jsx(ChannelsIcon, {
1161
- className: "eps-version-icon",
1162
- size: "1rem",
1163
- inline: true
1164
- })
1165
- }), locale === "en-GB" ? "Version" : "Versjon"]
1166
- });
1167
- };
1168
-
1169
- var UserMenu = function UserMenu(_ref) {
1170
- var className = _ref.className,
1171
- onLogout = _ref.onLogout,
1172
- _onLocaleChange = _ref.onLocaleChange,
1173
- userName = _ref.userName,
1174
- locale = _ref.locale,
1175
- environment = _ref.environment,
1176
- showVersionItem = _ref.showVersionItem,
1177
- showMyProfileItem = _ref.showMyProfileItem,
1178
- showCookieSettingsItem = _ref.showCookieSettingsItem,
1179
- onNavigateToMyProfile = _ref.onNavigateToMyProfile,
1180
- _ref$onCookieSettings = _ref.onCookieSettingsOpen,
1181
- onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings,
1182
- onVersionItemClick = _ref.onVersionItemClick;
1183
- var _useState = useState(false),
1184
- open = _useState[0],
1185
- setOpen = _useState[1];
1186
- return jsx("div", {
1187
- id: "eps-user-menu",
1188
- children: jsx(CustomOverflowMenu, {
1189
- open: open,
1190
- onOpenChange: setOpen,
1191
- className: cx(["eps-user-menu__trigger-button", className]),
1192
- userName: userName,
1193
- environment: environment,
1194
- children: jsxs("div", {
1195
- id: "eps-overflow-menu",
1196
- children: [jsx(LocaleSwitchMenuItem, {
1197
- locale: locale,
1198
- onLocaleChange: function onLocaleChange(newLocale) {
1199
- _onLocaleChange(newLocale);
1200
- setOpen(false);
1201
- }
1202
- }), showVersionItem && jsx(VersionMenuItem, {
1203
- locale: locale,
1204
- onClick: function onClick() {
1205
- onVersionItemClick == null || onVersionItemClick();
1206
- setOpen(false);
1207
- }
1208
- }), showMyProfileItem && jsx(UserMenuItem, {
1209
- locale: locale,
1210
- onClick: function onClick() {
1211
- onNavigateToMyProfile();
1212
- setOpen(false);
1213
- }
1214
- }), showCookieSettingsItem && jsx(CookieSettingsMenuItem, {
1215
- locale: locale,
1216
- onClick: function onClick() {
1217
- onCookieSettingsOpen();
1218
- setOpen(false);
1219
- }
1220
- }), jsx(LogOutMenuItem, {
1221
- locale: locale,
1222
- onClick: function onClick() {
1223
- onLogout();
1224
- setOpen(false);
1225
- }
1226
- })]
1227
- })
1228
- })
1229
- });
1230
- };
1231
-
1232
- 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, RouteLeavingGuard, Stack, StatusLabel, Text, Unbutton, UserMenu, featureFlag, getColorForEnvironment, getHumanReadableEnvironment, responsiveProp, useDocumentTitle, useEventListener, useFeatureToggle };
1233
- //# sourceMappingURL=common.esm.js.map