@entur-partner/common 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import cx from 'classnames';
3
3
  import { Link as Link$1, Heading6, Paragraph } from '@entur/typography';
4
4
  import { NorwayIcon, UKIcon, UserIcon, LogOutIcon, DownArrowIcon, ChannelsIcon } from '@entur/icons';
5
5
  import { SecondaryButton, Button, PrimaryButton, ButtonGroup } from '@entur/button';
6
- import { Link as Link$2, useNavigate, useInRouterContext, useBlocker, redirect, Route } from 'react-router-dom';
6
+ import { Link as Link$2, useNavigate, useInRouterContext, useBlocker } from 'react-router-dom';
7
7
  import { SearchableDropdown } from '@entur/dropdown';
8
8
  import { SegmentedControl, SegmentedChoice } from '@entur/form';
9
9
  import { assertIsDefined, localeDate, localeDateTime, isDate, isDateString, isString, hasAllPermissions, hasOneOfPermissions, splitUrlPath } from '@entur-partner/util';
@@ -17,26 +17,21 @@ function _extends() {
17
17
  _extends = Object.assign ? Object.assign.bind() : function (target) {
18
18
  for (var i = 1; i < arguments.length; i++) {
19
19
  var source = arguments[i];
20
-
21
20
  for (var key in source) {
22
21
  if (Object.prototype.hasOwnProperty.call(source, key)) {
23
22
  target[key] = source[key];
24
23
  }
25
24
  }
26
25
  }
27
-
28
26
  return target;
29
27
  };
30
28
  return _extends.apply(this, arguments);
31
29
  }
32
-
33
30
  function _inheritsLoose(subClass, superClass) {
34
31
  subClass.prototype = Object.create(superClass.prototype);
35
32
  subClass.prototype.constructor = subClass;
36
-
37
33
  _setPrototypeOf(subClass, superClass);
38
34
  }
39
-
40
35
  function _setPrototypeOf(o, p) {
41
36
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
42
37
  o.__proto__ = p;
@@ -44,23 +39,20 @@ function _setPrototypeOf(o, p) {
44
39
  };
45
40
  return _setPrototypeOf(o, p);
46
41
  }
47
-
48
42
  function _objectWithoutPropertiesLoose(source, excluded) {
49
43
  if (source == null) return {};
50
44
  var target = {};
51
45
  var sourceKeys = Object.keys(source);
52
46
  var key, i;
53
-
54
47
  for (i = 0; i < sourceKeys.length; i++) {
55
48
  key = sourceKeys[i];
56
49
  if (excluded.indexOf(key) >= 0) continue;
57
50
  target[key] = source[key];
58
51
  }
59
-
60
52
  return target;
61
53
  }
62
54
 
63
- var _excluded$f = ["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"];
55
+ var _excluded$e = ["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"];
64
56
  function responsiveProp(prefix, prop) {
65
57
  if (Array.isArray(prop)) {
66
58
  var classes = [];
@@ -69,40 +61,38 @@ function responsiveProp(prefix, prop) {
69
61
  prop[2] && classes.push("" + prefix + prop[2] + "-xl");
70
62
  return classes;
71
63
  }
72
-
73
64
  return [prefix + prop];
74
65
  }
75
66
  var Box = function Box(_ref) {
76
67
  var _ref$as = _ref.as,
77
- Component = _ref$as === void 0 ? 'div' : _ref$as,
78
- children = _ref.children,
79
- contrast = _ref.contrast,
80
- paddingTop = _ref.paddingTop,
81
- paddingRight = _ref.paddingRight,
82
- paddingBottom = _ref.paddingBottom,
83
- paddingLeft = _ref.paddingLeft,
84
- paddingX = _ref.paddingX,
85
- paddingY = _ref.paddingY,
86
- padding = _ref.padding,
87
- marginTop = _ref.marginTop,
88
- marginRight = _ref.marginRight,
89
- marginBottom = _ref.marginBottom,
90
- marginLeft = _ref.marginLeft,
91
- marginX = _ref.marginX,
92
- marginY = _ref.marginY,
93
- margin = _ref.margin,
94
- display = _ref.display,
95
- justifyContent = _ref.justifyContent,
96
- alignItems = _ref.alignItems,
97
- maxWidth = _ref.maxWidth,
98
- width = _ref.width,
99
- background = _ref.background,
100
- color = _ref.color,
101
- flexDirection = _ref.flexDirection,
102
- flexWrap = _ref.flexWrap,
103
- className = _ref.className,
104
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$f);
105
-
68
+ Component = _ref$as === void 0 ? 'div' : _ref$as,
69
+ children = _ref.children,
70
+ contrast = _ref.contrast,
71
+ paddingTop = _ref.paddingTop,
72
+ paddingRight = _ref.paddingRight,
73
+ paddingBottom = _ref.paddingBottom,
74
+ paddingLeft = _ref.paddingLeft,
75
+ paddingX = _ref.paddingX,
76
+ paddingY = _ref.paddingY,
77
+ padding = _ref.padding,
78
+ marginTop = _ref.marginTop,
79
+ marginRight = _ref.marginRight,
80
+ marginBottom = _ref.marginBottom,
81
+ marginLeft = _ref.marginLeft,
82
+ marginX = _ref.marginX,
83
+ marginY = _ref.marginY,
84
+ margin = _ref.margin,
85
+ display = _ref.display,
86
+ justifyContent = _ref.justifyContent,
87
+ alignItems = _ref.alignItems,
88
+ maxWidth = _ref.maxWidth,
89
+ width = _ref.width,
90
+ background = _ref.background,
91
+ color = _ref.color,
92
+ flexDirection = _ref.flexDirection,
93
+ flexWrap = _ref.flexWrap,
94
+ className = _ref.className,
95
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
106
96
  var classes = [];
107
97
  var resolvedPaddingTop = paddingTop || paddingY || padding;
108
98
  var resolvedPaddingBottom = paddingBottom || paddingY || padding;
@@ -123,11 +113,9 @@ var Box = function Box(_ref) {
123
113
  resolvedMarginRight && classes.push.apply(classes, responsiveProp('eps-mr-', resolvedMarginRight));
124
114
  display && classes.push.apply(classes, responsiveProp('eps-', display));
125
115
  justifyContent && classes.push.apply(classes, responsiveProp('eps-justify-', justifyContent));
126
-
127
116
  if (alignItems) {
128
117
  classes.push.apply(classes, responsiveProp('eps-items-', alignItems));
129
118
  }
130
-
131
119
  maxWidth && classes.push.apply(classes, responsiveProp('eps-max-w-', maxWidth));
132
120
  width && classes.push.apply(classes, responsiveProp('eps-w-', width));
133
121
  color && classes.push("eps-color-" + color);
@@ -142,14 +130,12 @@ var Box = function Box(_ref) {
142
130
 
143
131
  var Stack = function Stack(_ref) {
144
132
  var children = _ref.children,
145
- space = _ref.space,
146
- className = _ref.className;
133
+ space = _ref.space,
134
+ className = _ref.className;
147
135
  var stackItems = Children.toArray(children);
148
-
149
136
  if (stackItems.length <= 1) {
150
137
  return React.createElement(React.Fragment, null, stackItems);
151
138
  }
152
-
153
139
  return React.createElement("div", {
154
140
  className: className
155
141
  }, stackItems.map(function (child, index) {
@@ -168,14 +154,12 @@ var ActionBarLeft = function ActionBarLeft(_ref) {
168
154
  className: "eps-action-bar-left"
169
155
  }, children);
170
156
  };
171
-
172
157
  var ActionBarRight = function ActionBarRight(_ref2) {
173
158
  var children = _ref2.children;
174
159
  return React.createElement("div", {
175
160
  className: "eps-action-bar-right"
176
161
  }, children);
177
162
  };
178
-
179
163
  var ActionBar = function ActionBar(_ref3) {
180
164
  var children = _ref3.children;
181
165
  return React.createElement(React.Fragment, null, React.createElement("div", {
@@ -185,12 +169,11 @@ var ActionBar = function ActionBar(_ref3) {
185
169
  }, children));
186
170
  };
187
171
 
188
- var _excluded$e = ["children", "className"];
172
+ var _excluded$d = ["children", "className"];
189
173
  var LinkButton = function LinkButton(_ref) {
190
174
  var children = _ref.children,
191
- className = _ref.className,
192
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$e);
193
-
175
+ className = _ref.className,
176
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
194
177
  return React.createElement(Link$1, _extends({}, rest, {
195
178
  as: "button",
196
179
  className: cx('eps-link-button', className)
@@ -204,10 +187,8 @@ var LinkButton = function LinkButton(_ref) {
204
187
  * @param flag case sensitive flag. If it is an environment variable
205
188
  * you can drop the REACT_APP_ prefix.
206
189
  */
207
-
208
190
  function featureFlag(flag) {
209
191
  var _window$localStorage, _window$localStorage2;
210
-
211
192
  return process.env["REACT_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("REACT_APP_" + flag)) === 'true';
212
193
  }
213
194
  /**
@@ -217,40 +198,33 @@ function featureFlag(flag) {
217
198
  * @param flag case sensitive flag. If it is an environment variable
218
199
  * you can drop the REACT_APP_ prefix.
219
200
  */
220
-
221
201
  function useFeatureToggle(flag) {
222
202
  return featureFlag(flag);
223
203
  }
224
204
  var FeatureToggle = function FeatureToggle(_ref) {
225
205
  var children = _ref.children,
226
- flag = _ref.flag;
206
+ flag = _ref.flag;
227
207
  var feature = useFeatureToggle(flag);
228
-
229
208
  if (feature) {
230
209
  return React.createElement(React.Fragment, null, children);
231
210
  }
232
-
233
211
  return null;
234
212
  };
235
213
 
236
214
  var _environmentColors, _humanReadableEnviron;
237
-
238
215
  var Environment;
239
-
240
216
  (function (Environment) {
241
217
  Environment["Local"] = "local";
242
218
  Environment["Development"] = "dev";
243
219
  Environment["Staging"] = "staging";
244
220
  Environment["Production"] = "prod";
245
221
  })(Environment || (Environment = {}));
246
-
247
222
  var environmentColors = (_environmentColors = {}, _environmentColors[Environment.Local] = '#B482FB', _environmentColors[Environment.Development] = '#5AC39A', _environmentColors[Environment.Staging] = '#FFCA28', _environmentColors);
248
223
  /**
249
224
  * Gets the color for the given environment. This is the color used for the environment
250
225
  * indicator. There is no color for production as it should not have any special environment
251
226
  * indication.
252
227
  */
253
-
254
228
  var getColorForEnvironment = function getColorForEnvironment(environment) {
255
229
  return environmentColors[environment];
256
230
  };
@@ -259,13 +233,12 @@ var getHumanReadableEnvironment = function getHumanReadableEnvironment(environme
259
233
  return humanReadableEnvironment[environment];
260
234
  };
261
235
 
262
- var _excluded$d = ["title", "accentColor"];
236
+ var _excluded$c = ["title", "accentColor"];
263
237
  var EnturPartnerLogoSvg = function EnturPartnerLogoSvg(_ref) {
264
238
  var title = _ref.title,
265
- _ref$accentColor = _ref.accentColor,
266
- accentColor = _ref$accentColor === void 0 ? '#FF5959' : _ref$accentColor,
267
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$d);
268
-
239
+ _ref$accentColor = _ref.accentColor,
240
+ accentColor = _ref$accentColor === void 0 ? '#FF5959' : _ref$accentColor,
241
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$c);
269
242
  return React.createElement("svg", _extends({
270
243
  width: 257,
271
244
  height: 37,
@@ -290,10 +263,10 @@ var EnturPartnerLogoSvg = function EnturPartnerLogoSvg(_ref) {
290
263
  };
291
264
  var EnturPartnerLogo = function EnturPartnerLogo(_ref2) {
292
265
  var _ref2$as = _ref2.as,
293
- Component = _ref2$as === void 0 ? 'nav' : _ref2$as,
294
- className = _ref2.className,
295
- altText = _ref2.altText,
296
- environment = _ref2.environment;
266
+ Component = _ref2$as === void 0 ? 'nav' : _ref2$as,
267
+ className = _ref2.className,
268
+ altText = _ref2.altText,
269
+ environment = _ref2.environment;
297
270
  var classList = cx(['eps-logo-wrapper', className]);
298
271
  return React.createElement(Component, {
299
272
  className: classList
@@ -306,9 +279,9 @@ var EnturPartnerLogo = function EnturPartnerLogo(_ref2) {
306
279
 
307
280
  var Menu = function Menu(_ref) {
308
281
  var _ref$as = _ref.as,
309
- Component = _ref$as === void 0 ? 'nav' : _ref$as,
310
- className = _ref.className,
311
- children = _ref.children;
282
+ Component = _ref$as === void 0 ? 'nav' : _ref$as,
283
+ className = _ref.className,
284
+ children = _ref.children;
312
285
  var classList = cx(['eds-contrast', 'eps-menu', className]);
313
286
  return React.createElement(Component, {
314
287
  className: classList
@@ -317,33 +290,31 @@ var Menu = function Menu(_ref) {
317
290
 
318
291
  var Content = function Content(_ref) {
319
292
  var _ref$as = _ref.as,
320
- Component = _ref$as === void 0 ? 'main' : _ref$as,
321
- className = _ref.className,
322
- children = _ref.children;
293
+ Component = _ref$as === void 0 ? 'main' : _ref$as,
294
+ className = _ref.className,
295
+ children = _ref.children;
323
296
  var classList = cx(['eps-content', className]);
324
297
  return React.createElement(Component, {
325
298
  className: classList
326
299
  }, children);
327
300
  };
328
301
 
329
- var _excluded$c = ["className", "children", "userName", "open", "onOpenChange", "environment"];
302
+ var _excluded$b = ["className", "children", "userName", "open", "onOpenChange", "environment"];
330
303
  var UserMenu = function UserMenu(_ref) {
331
304
  var className = _ref.className,
332
- messages = _ref.messages,
333
- onLogout = _ref.onLogout,
334
- onLanguageChange = _ref.onLanguageChange,
335
- userName = _ref.userName,
336
- language = _ref.language,
337
- environment = _ref.environment,
338
- showVersionItem = _ref.showVersionItem,
339
- showMyProfileItem = _ref.showMyProfileItem,
340
- onNavigateToMyProfile = _ref.onNavigateToMyProfile;
305
+ messages = _ref.messages,
306
+ onLogout = _ref.onLogout,
307
+ onLanguageChange = _ref.onLanguageChange,
308
+ userName = _ref.userName,
309
+ language = _ref.language,
310
+ environment = _ref.environment,
311
+ showVersionItem = _ref.showVersionItem,
312
+ showMyProfileItem = _ref.showMyProfileItem,
313
+ onNavigateToMyProfile = _ref.onNavigateToMyProfile;
341
314
  var triggerClassList = cx(['eps-user-menu__trigger-button', className]);
342
-
343
315
  var _useState = useState(false),
344
- open = _useState[0],
345
- setOpen = _useState[1];
346
-
316
+ open = _useState[0],
317
+ setOpen = _useState[1];
347
318
  return React.createElement("div", {
348
319
  id: "eps-user-menu"
349
320
  }, React.createElement(CustomOverflowMenu, {
@@ -411,16 +382,14 @@ var UserMenu = function UserMenu(_ref) {
411
382
  inline: true
412
383
  })), messages.logout))));
413
384
  };
414
-
415
385
  var CustomOverflowMenu = function CustomOverflowMenu(_ref2) {
416
386
  var className = _ref2.className,
417
- children = _ref2.children,
418
- userName = _ref2.userName,
419
- open = _ref2.open,
420
- onOpenChange = _ref2.onOpenChange,
421
- environment = _ref2.environment,
422
- rest = _objectWithoutPropertiesLoose(_ref2, _excluded$c);
423
-
387
+ children = _ref2.children,
388
+ userName = _ref2.userName,
389
+ open = _ref2.open,
390
+ onOpenChange = _ref2.onOpenChange,
391
+ environment = _ref2.environment,
392
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded$b);
424
393
  var overflowItemsClasses = cx('eps-overflow-menu__group', {
425
394
  'eps-overflow-menu__group--open': open
426
395
  });
@@ -461,19 +430,16 @@ var CustomOverflowMenu = function CustomOverflowMenu(_ref2) {
461
430
  ref: overflowContentRef
462
431
  }, children));
463
432
  };
464
-
465
433
  var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
466
434
  return React.createElement("button", _extends({
467
435
  className: cx(props.className, 'eps-overflow-menu__item'),
468
436
  role: "menuitem"
469
437
  }, props));
470
438
  };
471
-
472
439
  var VersionCustomOverflowMenuItems = function VersionCustomOverflowMenuItems(_ref3) {
473
440
  var title = _ref3.title,
474
- setOpen = _ref3.setOpen;
441
+ setOpen = _ref3.setOpen;
475
442
  var navigate = useNavigate(); // Hide useNavigate from standalone micro-frontends because it is not under RouterProvider
476
-
477
443
  return React.createElement(CustomOverflowMenuItem, {
478
444
  onClick: function onClick() {
479
445
  navigate('/app-version');
@@ -488,41 +454,33 @@ var VersionCustomOverflowMenuItems = function VersionCustomOverflowMenuItems(_re
488
454
  inline: true
489
455
  })), title);
490
456
  };
491
-
492
457
  function elementContainsEventTarget(element, event) {
493
458
  if (!element) {
494
459
  return false;
495
460
  }
496
-
497
461
  if (element.contains(event.target)) {
498
462
  return true;
499
- } // For elements inside a Shadow DOM we need to check the composedPath
500
-
501
-
463
+ }
464
+ // For elements inside a Shadow DOM we need to check the composedPath
502
465
  if (event.composed && event.composedPath) {
503
466
  var contains = event.composedPath().find(function (target) {
504
467
  if (target === window) {
505
468
  return false;
506
469
  }
507
-
508
470
  return element.contains(target);
509
471
  });
510
472
  return contains ? true : false;
511
473
  }
512
-
513
474
  return false;
514
475
  }
515
-
516
476
  function useOutsideClick(ref, buttonRef, handler) {
517
477
  React.useEffect(function () {
518
478
  var listener = function listener(event) {
519
479
  if (elementContainsEventTarget(ref.current, event) || elementContainsEventTarget(buttonRef.current, event)) {
520
480
  return;
521
481
  }
522
-
523
482
  handler();
524
483
  };
525
-
526
484
  document.addEventListener('mousedown', listener);
527
485
  document.addEventListener('touchstart', listener);
528
486
  return function () {
@@ -532,14 +490,13 @@ function useOutsideClick(ref, buttonRef, handler) {
532
490
  }, [ref, buttonRef, handler]);
533
491
  }
534
492
 
535
- var _excluded$b = ["label", "organisations", "onChange", "selectedOrganisationId"];
493
+ var _excluded$a = ["label", "organisations", "onChange", "selectedOrganisationId"];
536
494
  var OrganisationDropDown = function OrganisationDropDown(_ref) {
537
495
  var label = _ref.label,
538
- organisations = _ref.organisations,
539
- handleChange = _ref.onChange,
540
- selectedOrganisationId = _ref.selectedOrganisationId,
541
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
542
-
496
+ organisations = _ref.organisations,
497
+ handleChange = _ref.onChange,
498
+ selectedOrganisationId = _ref.selectedOrganisationId,
499
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
543
500
  var selectedOrganisation = organisations.find(function (org) {
544
501
  return org.id === selectedOrganisationId;
545
502
  });
@@ -571,7 +528,6 @@ function useEventListener(eventName, handler, element) {
571
528
  if (element === void 0) {
572
529
  element = window;
573
530
  }
574
-
575
531
  var savedHandler = useRef();
576
532
  useEffect(function () {
577
533
  savedHandler.current = handler;
@@ -579,11 +535,9 @@ function useEventListener(eventName, handler, element) {
579
535
  useEffect(function () {
580
536
  var isSupported = element && element.addEventListener;
581
537
  if (!isSupported) return;
582
-
583
538
  var eventListener = function eventListener(event) {
584
539
  return savedHandler.current == null ? void 0 : savedHandler.current(event);
585
540
  };
586
-
587
541
  element.addEventListener(eventName, eventListener);
588
542
  return function () {
589
543
  element.removeEventListener(eventName, eventListener);
@@ -591,21 +545,19 @@ function useEventListener(eventName, handler, element) {
591
545
  }, [eventName, element]);
592
546
  }
593
547
 
594
- var _excluded$a = ["language", "options", "className", "onChange"];
548
+ var _excluded$9 = ["language", "options", "className", "onChange"];
595
549
  var LanguageSelect = function LanguageSelect(_ref) {
596
550
  var language = _ref.language,
597
- options = _ref.options,
598
- className = _ref.className,
599
- _onChange = _ref.onChange,
600
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
601
-
551
+ options = _ref.options,
552
+ className = _ref.className,
553
+ _onChange = _ref.onChange,
554
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
602
555
  var classNames = cx('eps-language-select', className);
603
556
  return React.createElement("div", _extends({}, rest, {
604
557
  className: classNames
605
558
  }), React.createElement(SegmentedControl, {
606
559
  onChange: function onChange(language) {
607
560
  assertIsDefined(language);
608
-
609
561
  _onChange(language);
610
562
  },
611
563
  selectedValue: language
@@ -619,30 +571,26 @@ var LanguageSelect = function LanguageSelect(_ref) {
619
571
  })));
620
572
  };
621
573
 
622
- var _excluded$9 = ["title", "inputComponent", "languages", "values", "onChange", "name", "variant", "feedback"];
574
+ var _excluded$8 = ["title", "inputComponent", "languages", "values", "onChange", "name", "variant", "feedback"];
623
575
  var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
624
576
  var title = _ref.title,
625
- InputComponent = _ref.inputComponent,
626
- languages = _ref.languages,
627
- values = _ref.values,
628
- onChange = _ref.onChange,
629
- name = _ref.name,
630
- variant = _ref.variant,
631
- feedback = _ref.feedback,
632
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
633
-
577
+ InputComponent = _ref.inputComponent,
578
+ languages = _ref.languages,
579
+ values = _ref.values,
580
+ onChange = _ref.onChange,
581
+ name = _ref.name,
582
+ variant = _ref.variant,
583
+ feedback = _ref.feedback,
584
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
634
585
  var handleOnChange = function handleOnChange(language, value) {
635
586
  var changes = _extends({}, values);
636
-
637
587
  if (value === '' || !value) {
638
588
  delete changes[language];
639
589
  } else {
640
590
  changes[language] = value;
641
591
  }
642
-
643
592
  onChange(changes);
644
593
  };
645
-
646
594
  return React.createElement(ExpandablePanel, {
647
595
  title: title,
648
596
  defaultOpen: true,
@@ -655,8 +603,8 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
655
603
  space: "medium"
656
604
  }, languages.map(function (_ref2) {
657
605
  var langKey = _ref2.value,
658
- label = _ref2.label,
659
- required = _ref2.required;
606
+ label = _ref2.label,
607
+ required = _ref2.required;
660
608
  return React.createElement(InputComponent, _extends({
661
609
  "data-testid": "multi-lang-input-" + name + "-" + langKey,
662
610
  key: title + langKey,
@@ -672,35 +620,31 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
672
620
  })));
673
621
  };
674
622
 
675
- var _excluded$8 = ["className", "inputComponent", "alertLabel", "alertLevel", "name", "languages", "values", "onChange", "defaultLanguage", "label", "onBlur"];
623
+ var _excluded$7 = ["className", "inputComponent", "alertLabel", "alertLevel", "name", "languages", "values", "onChange", "defaultLanguage", "label", "onBlur"];
676
624
  /**
677
625
  * @deprecated use ExpandableMultiLanguageInput
678
626
  */
679
-
680
627
  var MultiLanguageInput = function MultiLanguageInput(_ref) {
681
628
  var className = _ref.className,
682
- InputComponent = _ref.inputComponent,
683
- alertLabel = _ref.alertLabel,
684
- alertLevel = _ref.alertLevel,
685
- name = _ref.name,
686
- languages = _ref.languages,
687
- values = _ref.values,
688
- onChange = _ref.onChange,
689
- _ref$defaultLanguage = _ref.defaultLanguage,
690
- defaultLanguage = _ref$defaultLanguage === void 0 ? 'nob' : _ref$defaultLanguage,
691
- _ref$label = _ref.label,
692
- label = _ref$label === void 0 ? '' : _ref$label,
693
- _ref$onBlur = _ref.onBlur,
694
- onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
695
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
696
-
629
+ InputComponent = _ref.inputComponent,
630
+ alertLabel = _ref.alertLabel,
631
+ alertLevel = _ref.alertLevel,
632
+ name = _ref.name,
633
+ languages = _ref.languages,
634
+ values = _ref.values,
635
+ onChange = _ref.onChange,
636
+ _ref$defaultLanguage = _ref.defaultLanguage,
637
+ defaultLanguage = _ref$defaultLanguage === void 0 ? 'nob' : _ref$defaultLanguage,
638
+ _ref$label = _ref.label,
639
+ label = _ref$label === void 0 ? '' : _ref$label,
640
+ _ref$onBlur = _ref.onBlur,
641
+ onBlur = _ref$onBlur === void 0 ? function () {} : _ref$onBlur,
642
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
697
643
  var _useState = useState(defaultLanguage),
698
- language = _useState[0],
699
- setLanguage = _useState[1];
700
-
644
+ language = _useState[0],
645
+ setLanguage = _useState[1];
701
646
  var classNames = cx('multi-language-input', className);
702
647
  var currentValue = values[language];
703
-
704
648
  var handleOnBlur = function handleOnBlur(e) {
705
649
  e.persist();
706
650
  var currentTarget = e.currentTarget;
@@ -710,23 +654,18 @@ var MultiLanguageInput = function MultiLanguageInput(_ref) {
710
654
  }
711
655
  }, 0);
712
656
  };
713
-
714
657
  var handleLanguageChange = function handleLanguageChange(language) {
715
658
  setLanguage(language);
716
659
  };
717
-
718
660
  var handleOnChange = function handleOnChange(value) {
719
661
  var changes = Object.assign({}, values);
720
-
721
662
  if (value === '' || !value) {
722
663
  delete changes[language];
723
664
  } else {
724
665
  changes[language] = value;
725
666
  }
726
-
727
667
  onChange(changes);
728
668
  };
729
-
730
669
  return React.createElement("div", {
731
670
  className: classNames,
732
671
  tabIndex: 0,
@@ -753,12 +692,11 @@ var MultiLanguageInput = function MultiLanguageInput(_ref) {
753
692
  }, rest))));
754
693
  };
755
694
 
756
- var _excluded$7 = ["children", "className"];
695
+ var _excluded$6 = ["children", "className"];
757
696
  var Unbutton = function Unbutton(_ref) {
758
697
  var children = _ref.children,
759
- className = _ref.className,
760
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
761
-
698
+ className = _ref.className,
699
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
762
700
  return React.createElement(Button, _extends({
763
701
  variant: "primary"
764
702
  }, rest, {
@@ -773,40 +711,31 @@ function isFunction(functionToCheck) {
773
711
  var newAppVersionErrorMessage = "Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.";
774
712
  var ErrorBoundary = /*#__PURE__*/function (_Component) {
775
713
  _inheritsLoose(ErrorBoundary, _Component);
776
-
777
714
  function ErrorBoundary(props) {
778
715
  var _this;
779
-
780
716
  _this = _Component.call(this, props) || this;
781
717
  _this.state = {
782
718
  error: null
783
719
  };
784
720
  return _this;
785
721
  }
786
-
787
722
  ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
788
723
  return {
789
724
  error: error
790
725
  };
791
726
  };
792
-
793
727
  var _proto = ErrorBoundary.prototype;
794
-
795
728
  _proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
796
729
  var _this$props$handleErr, _this$props;
797
-
798
730
  // React always logs in development
799
731
  (_this$props$handleErr = (_this$props = this.props).handleError) == null ? void 0 : _this$props$handleErr.call(_this$props, error, errorInfo);
800
732
  };
801
-
802
733
  _proto.render = function render() {
803
734
  var _this2 = this;
804
-
805
735
  var error = this.state.error;
806
736
  var _this$props2 = this.props,
807
- fallback = _this$props2.fallback,
808
- children = _this$props2.children;
809
-
737
+ fallback = _this$props2.fallback,
738
+ children = _this$props2.children;
810
739
  if (error) {
811
740
  if (isFunction(fallback)) {
812
741
  return fallback({
@@ -820,17 +749,13 @@ var ErrorBoundary = /*#__PURE__*/function (_Component) {
820
749
  } else if (error.name === 'NotFoundError' && error.message === newAppVersionErrorMessage) {
821
750
  return React.createElement(RefreshBannerInfo, null);
822
751
  }
823
-
824
752
  return fallback;
825
753
  }
826
-
827
754
  return children;
828
755
  };
829
-
830
756
  return ErrorBoundary;
831
757
  }(Component);
832
758
  var LANGUAGE_STORAGE_KEY = 'EP::locale';
833
-
834
759
  function RefreshBannerInfo() {
835
760
  // Taken from ./app-shell/src/storage.ts
836
761
  var language = localStorage.getItem(LANGUAGE_STORAGE_KEY);
@@ -851,25 +776,23 @@ function RefreshBannerInfo() {
851
776
  }, isNorwegian ? 'Oppdater' : 'Refresh')));
852
777
  }
853
778
 
854
- var _excluded$6 = ["date", "locale", "as", "hideTime"];
779
+ var _excluded$5 = ["date", "locale", "as", "hideTime"];
855
780
  var FormatDateTime = function FormatDateTime(_ref) {
856
781
  var date = _ref.date,
857
- locale = _ref.locale,
858
- _ref$as = _ref.as,
859
- Component = _ref$as === void 0 ? 'main' : _ref$as,
860
- hideTime = _ref.hideTime,
861
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
862
-
782
+ locale = _ref.locale,
783
+ _ref$as = _ref.as,
784
+ Component = _ref$as === void 0 ? 'main' : _ref$as,
785
+ hideTime = _ref.hideTime,
786
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
863
787
  return React.createElement(Component, _extends({}, rest), hideTime ? localeDate(date, locale) : localeDateTime(date, locale));
864
788
  };
865
789
 
866
- var _excluded$5 = ["amount", "as"];
790
+ var _excluded$4 = ["amount", "as"];
867
791
  var FormatCurrencyAmount = function FormatCurrencyAmount(_ref) {
868
792
  var amount = _ref.amount,
869
- _ref$as = _ref.as,
870
- Component = _ref$as === void 0 ? 'span' : _ref$as,
871
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
872
-
793
+ _ref$as = _ref.as,
794
+ Component = _ref$as === void 0 ? 'span' : _ref$as,
795
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
873
796
  var parsedAmount = Number(amount) || 0;
874
797
  var formattedAmount = new Intl.NumberFormat('nb-NO', {
875
798
  maximumFractionDigits: 2,
@@ -878,19 +801,18 @@ var FormatCurrencyAmount = function FormatCurrencyAmount(_ref) {
878
801
  return React.createElement(Component, _extends({}, rest), formattedAmount);
879
802
  };
880
803
 
881
- var _excluded$4 = ["items", "locale", "className"];
804
+ var _excluded$3 = ["items", "locale", "className"];
882
805
  var AuditInfo = function AuditInfo(_ref) {
883
806
  var items = _ref.items,
884
- locale = _ref.locale,
885
- className = _ref.className,
886
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
887
-
807
+ locale = _ref.locale,
808
+ className = _ref.className,
809
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
888
810
  var classNames = cx('ep-audit-info', className);
889
811
  return React.createElement("div", _extends({
890
812
  className: classNames
891
813
  }, rest), items.map(function (_ref2, i) {
892
814
  var label = _ref2.label,
893
- value = _ref2.value;
815
+ value = _ref2.value;
894
816
  return React.createElement(Stack, {
895
817
  space: "small",
896
818
  key: i
@@ -903,21 +825,20 @@ var AuditInfo = function AuditInfo(_ref) {
903
825
  }));
904
826
  };
905
827
 
906
- var _excluded$3 = ["isOpen", "children", "message", "size", "buttons", "onConfirm", "messages", "onClose", "onDismiss"];
828
+ var _excluded$2 = ["isOpen", "children", "message", "size", "buttons", "onConfirm", "messages", "onClose", "onDismiss"];
907
829
  var ConfirmModal = function ConfirmModal(_ref) {
908
830
  var _ref$isOpen = _ref.isOpen,
909
- isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
910
- children = _ref.children,
911
- message = _ref.message,
912
- _ref$size = _ref.size,
913
- size = _ref$size === void 0 ? 'medium' : _ref$size,
914
- buttons = _ref.buttons,
915
- onConfirm = _ref.onConfirm,
916
- messages = _ref.messages,
917
- onClose = _ref.onClose,
918
- onDismiss = _ref.onDismiss,
919
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
920
-
831
+ isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
832
+ children = _ref.children,
833
+ message = _ref.message,
834
+ _ref$size = _ref.size,
835
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
836
+ buttons = _ref.buttons,
837
+ onConfirm = _ref.onConfirm,
838
+ messages = _ref.messages,
839
+ onClose = _ref.onClose,
840
+ onDismiss = _ref.onDismiss,
841
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
921
842
  var childrenToRender = children ? children : message;
922
843
  var handleDismiss = onClose ? onClose : onDismiss;
923
844
  return React.createElement(Modal, _extends({
@@ -935,16 +856,15 @@ var ConfirmModal = function ConfirmModal(_ref) {
935
856
  }, messages.confirm)) : buttons));
936
857
  };
937
858
 
938
- var _excluded$2 = ["children", "shouldBlockNavigation"];
859
+ var _excluded$1 = ["children", "shouldBlockNavigation"];
939
860
  var RouteLeavingGuard = function RouteLeavingGuard(_ref) {
940
861
  var children = _ref.children,
941
- shouldBlockNavigation = _ref.shouldBlockNavigation,
942
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
943
-
862
+ shouldBlockNavigation = _ref.shouldBlockNavigation,
863
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
944
864
  assertIsDefined(useInRouterContext() ? true : undefined, "RouteLeavingGuard must be used within a data router.");
945
865
  var blocker = useBlocker(function (_ref2) {
946
866
  var currentLocation = _ref2.currentLocation,
947
- nextLocation = _ref2.nextLocation;
867
+ nextLocation = _ref2.nextLocation;
948
868
  return currentLocation.pathname !== nextLocation.pathname && shouldBlockNavigation(nextLocation);
949
869
  });
950
870
  return React.createElement(ConfirmModal, _extends({
@@ -964,9 +884,9 @@ var RouteLeavingGuard = function RouteLeavingGuard(_ref) {
964
884
 
965
885
  var Pager = function Pager(_ref) {
966
886
  var collectionSize = _ref.collectionSize,
967
- pageSize = _ref.pageSize,
968
- _onPageChange = _ref.onPageChange,
969
- currentPage = _ref.currentPage;
887
+ pageSize = _ref.pageSize,
888
+ _onPageChange = _ref.onPageChange,
889
+ currentPage = _ref.currentPage;
970
890
  var pageCount = Math.ceil(collectionSize / pageSize);
971
891
  return React.createElement(Pagination, {
972
892
  pageCount: pageCount,
@@ -979,12 +899,12 @@ var Pager = function Pager(_ref) {
979
899
 
980
900
  var StatusLabel = function StatusLabel(_ref) {
981
901
  var _ref$active = _ref.active,
982
- active = _ref$active === void 0 ? false : _ref$active,
983
- _ref$label = _ref.label,
984
- label = _ref$label === void 0 ? '' : _ref$label,
985
- aggressiveInactive = _ref.aggressiveInactive,
986
- showBullet = _ref.showBullet,
987
- center = _ref.center;
902
+ active = _ref$active === void 0 ? false : _ref$active,
903
+ _ref$label = _ref.label,
904
+ label = _ref$label === void 0 ? '' : _ref$label,
905
+ aggressiveInactive = _ref.aggressiveInactive,
906
+ showBullet = _ref.showBullet,
907
+ center = _ref.center;
988
908
  var bulletClassNames = cx('eps-status-label__bullet', {
989
909
  active: active,
990
910
  aggressive: aggressiveInactive
@@ -1004,43 +924,25 @@ var StatusLabel = function StatusLabel(_ref) {
1004
924
  * check BusinessCapabilities but because it represents a minimal subset of
1005
925
  * what we need to check.
1006
926
  */
1007
-
1008
927
  var PermissionCheck = function PermissionCheck(_ref) {
1009
928
  var children = _ref.children,
1010
- _ref$fallback = _ref.fallback,
1011
- fallback = _ref$fallback === void 0 ? null : _ref$fallback,
1012
- permissions = _ref.permissions,
1013
- _ref$oneOf = _ref.oneOf,
1014
- oneOf = _ref$oneOf === void 0 ? [] : _ref$oneOf,
1015
- _ref$all = _ref.all,
1016
- all = _ref$all === void 0 ? [] : _ref$all;
929
+ _ref$fallback = _ref.fallback,
930
+ fallback = _ref$fallback === void 0 ? null : _ref$fallback,
931
+ permissions = _ref.permissions,
932
+ _ref$oneOf = _ref.oneOf,
933
+ oneOf = _ref$oneOf === void 0 ? [] : _ref$oneOf,
934
+ _ref$all = _ref.all,
935
+ all = _ref$all === void 0 ? [] : _ref$all;
1017
936
  var allIsAllowed = hasAllPermissions(all, permissions);
1018
937
  var oneOfIsAllowed = hasOneOfPermissions(oneOf, permissions);
1019
938
  var allowed = allIsAllowed && oneOfIsAllowed;
1020
939
  return React.createElement(React.Fragment, null, allowed ? children : fallback);
1021
940
  };
1022
941
 
1023
- var _excluded$1 = ["children", "actualPermissions", "all", "oneOf", "onReject"];
1024
- var PermissionCheckedRoute = function PermissionCheckedRoute(_ref) {
1025
- var children = _ref.children,
1026
- actualPermissions = _ref.actualPermissions,
1027
- all = _ref.all,
1028
- oneOf = _ref.oneOf,
1029
- onReject = _ref.onReject,
1030
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
1031
-
1032
- return React.createElement(PermissionCheck, {
1033
- permissions: actualPermissions,
1034
- all: all,
1035
- oneOf: oneOf,
1036
- fallback: onReject != null ? onReject : redirect('/unauthorized')
1037
- }, React.createElement(Route, _extends({}, props), children));
1038
- };
1039
-
1040
942
  var Breadcrumbs = function Breadcrumbs(_ref) {
1041
943
  var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
1042
- pathname = _ref.pathname,
1043
- onBreadcrumbLookup = _ref.onBreadcrumbLookup;
944
+ pathname = _ref.pathname,
945
+ onBreadcrumbLookup = _ref.onBreadcrumbLookup;
1044
946
  var paths = splitUrlPath(pathname);
1045
947
  var breadcrumbs = paths.map(function (path) {
1046
948
  return {
@@ -1053,27 +955,23 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
1053
955
  });
1054
956
  var breadcrumbElements = breadcrumbs.map(function (_ref3, i) {
1055
957
  var title = _ref3.title,
1056
- path = _ref3.path;
958
+ path = _ref3.path;
1057
959
  var isLast = i === breadcrumbs.length - 1;
1058
-
1059
960
  if (isLast) {
1060
961
  return React.createElement(BreadcrumbItem, {
1061
962
  key: path,
1062
963
  as: 'span'
1063
964
  }, title);
1064
965
  }
1065
-
1066
966
  return React.createElement(BreadcrumbItem, {
1067
967
  key: path,
1068
968
  as: Link$2,
1069
969
  to: path
1070
970
  }, title);
1071
971
  });
1072
-
1073
972
  if (prependBreadcrumbItem) {
1074
973
  return React.createElement(BreadcrumbNavigation, null, [prependBreadcrumbItem].concat(breadcrumbElements));
1075
974
  }
1076
-
1077
975
  return React.createElement(BreadcrumbNavigation, null, breadcrumbElements);
1078
976
  };
1079
977
 
@@ -1086,15 +984,14 @@ var Link = function Link(props) {
1086
984
  var _excluded = ["as", "children", "fontSize", "color", "lineHeight", "fontWeight", "className"];
1087
985
  var Text = function Text(_ref) {
1088
986
  var _ref$as = _ref.as,
1089
- component = _ref$as === void 0 ? 'span' : _ref$as,
1090
- children = _ref.children,
1091
- fontSize = _ref.fontSize,
1092
- color = _ref.color,
1093
- lineHeight = _ref.lineHeight,
1094
- fontWeight = _ref.fontWeight,
1095
- className = _ref.className,
1096
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1097
-
987
+ component = _ref$as === void 0 ? 'span' : _ref$as,
988
+ children = _ref.children,
989
+ fontSize = _ref.fontSize,
990
+ color = _ref.color,
991
+ lineHeight = _ref.lineHeight,
992
+ fontWeight = _ref.fontWeight,
993
+ className = _ref.className,
994
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1098
995
  var classes = [];
1099
996
  fontSize && classes.push.apply(classes, responsiveProp('eps-font-size-', fontSize));
1100
997
  lineHeight && classes.push.apply(classes, responsiveProp('eps-line-height-', lineHeight));
@@ -1115,10 +1012,9 @@ var Text = function Text(_ref) {
1115
1012
  * @param Props.onBreadcrumbLookup - A function that takes a path and returns a i18n translated string or undefined
1116
1013
  * @returns A Helmet component with updated title
1117
1014
  */
1118
-
1119
1015
  function PageTitle(_ref) {
1120
1016
  var pathname = _ref.pathname,
1121
- onBreadcrumbLookup = _ref.onBreadcrumbLookup;
1017
+ onBreadcrumbLookup = _ref.onBreadcrumbLookup;
1122
1018
  var paths = splitUrlPath(pathname);
1123
1019
  var pageTitles = paths.map(function (path) {
1124
1020
  return {
@@ -1135,5 +1031,5 @@ function PageTitle(_ref) {
1135
1031
  return React.createElement(Helmet, null, React.createElement("title", null, pageTitles, " | Entur Partner"));
1136
1032
  }
1137
1033
 
1138
- 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, PermissionCheckedRoute, RouteLeavingGuard, Stack, StatusLabel, Text, Unbutton, UserMenu, featureFlag, getColorForEnvironment, getHumanReadableEnvironment, responsiveProp, useEventListener, useFeatureToggle };
1034
+ 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, useEventListener, useFeatureToggle };
1139
1035
  //# sourceMappingURL=common.esm.js.map