@entur-partner/common 5.3.0 → 6.0.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/PermissionCheckedRoute.d.ts +2 -2
- package/dist/UserMenu.d.ts +5 -1
- package/dist/common.cjs.development.js +45 -59
- package/dist/common.cjs.development.js.map +1 -1
- package/dist/common.cjs.production.min.js +1 -1
- package/dist/common.cjs.production.min.js.map +1 -1
- package/dist/common.esm.js +47 -61
- package/dist/common.esm.js.map +1 -1
- package/dist/styles.css +68 -68
- package/package.json +5 -5
package/dist/common.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { Children, useState, useRef, useEffect, Component } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
import { Link as Link$1, Heading6, Paragraph } from '@entur/typography';
|
|
4
|
-
import { NorwayIcon, UKIcon,
|
|
4
|
+
import { NorwayIcon, UKIcon, UserIcon, LogOutIcon, DownArrowIcon, ChannelsIcon } from '@entur/icons';
|
|
5
5
|
import { SecondaryButton, Button, PrimaryButton, ButtonGroup } from '@entur/button';
|
|
6
|
-
import {
|
|
6
|
+
import { Link as Link$2, useNavigate, useInRouterContext, useBlocker, redirect, Route } 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';
|
|
@@ -338,7 +338,6 @@ var UserMenu = function UserMenu(_ref) {
|
|
|
338
338
|
showVersionItem = _ref.showVersionItem,
|
|
339
339
|
showMyProfileItem = _ref.showMyProfileItem,
|
|
340
340
|
onNavigateToMyProfile = _ref.onNavigateToMyProfile;
|
|
341
|
-
var history = useHistory();
|
|
342
341
|
var triggerClassList = cx(['eps-user-menu__trigger-button', className]);
|
|
343
342
|
|
|
344
343
|
var _useState = useState(false),
|
|
@@ -379,19 +378,10 @@ var UserMenu = function UserMenu(_ref) {
|
|
|
379
378
|
}, React.createElement(UKIcon, {
|
|
380
379
|
size: "1rem",
|
|
381
380
|
inline: true
|
|
382
|
-
})), messages.switchLanguage), showVersionItem && messages.appVersion && React.createElement(
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
className: "eps-overflow-menu__item"
|
|
388
|
-
}, React.createElement("span", {
|
|
389
|
-
"aria-hidden": true
|
|
390
|
-
}, React.createElement(ChannelsIcon, {
|
|
391
|
-
className: "eps-version-icon",
|
|
392
|
-
size: "1rem",
|
|
393
|
-
inline: true
|
|
394
|
-
})), messages.appVersion), showMyProfileItem && messages.myProfile && React.createElement(Link$2, {
|
|
381
|
+
})), messages.switchLanguage), showVersionItem && messages.appVersion && React.createElement(VersionCustomOverflowMenuItems, {
|
|
382
|
+
title: messages.appVersion,
|
|
383
|
+
setOpen: setOpen
|
|
384
|
+
}), showMyProfileItem && messages.myProfile && React.createElement(Link$2, {
|
|
395
385
|
to: "/permission-admin/my-profile",
|
|
396
386
|
style: {
|
|
397
387
|
textDecoration: 'none'
|
|
@@ -479,6 +469,26 @@ var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
|
479
469
|
}, props));
|
|
480
470
|
};
|
|
481
471
|
|
|
472
|
+
var VersionCustomOverflowMenuItems = function VersionCustomOverflowMenuItems(_ref3) {
|
|
473
|
+
var title = _ref3.title,
|
|
474
|
+
setOpen = _ref3.setOpen;
|
|
475
|
+
var navigate = useNavigate(); // Hide useNavigate from standalone micro-frontends because it is not under RouterProvider
|
|
476
|
+
|
|
477
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
478
|
+
onClick: function onClick() {
|
|
479
|
+
navigate('/app-version');
|
|
480
|
+
setOpen(false);
|
|
481
|
+
},
|
|
482
|
+
className: "eps-overflow-menu__item"
|
|
483
|
+
}, React.createElement("span", {
|
|
484
|
+
"aria-hidden": true
|
|
485
|
+
}, React.createElement(ChannelsIcon, {
|
|
486
|
+
className: "eps-version-icon",
|
|
487
|
+
size: "1rem",
|
|
488
|
+
inline: true
|
|
489
|
+
})), title);
|
|
490
|
+
};
|
|
491
|
+
|
|
482
492
|
function elementContainsEventTarget(element, event) {
|
|
483
493
|
if (!element) {
|
|
484
494
|
return false;
|
|
@@ -931,41 +941,25 @@ var RouteLeavingGuard = function RouteLeavingGuard(_ref) {
|
|
|
931
941
|
shouldBlockNavigation = _ref.shouldBlockNavigation,
|
|
932
942
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
933
943
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
setLastLocation(nextLocation);
|
|
952
|
-
return false;
|
|
944
|
+
assertIsDefined(useInRouterContext() ? true : undefined, "RouteLeavingGuard must be used within a data router.");
|
|
945
|
+
var blocker = useBlocker(function (_ref2) {
|
|
946
|
+
var currentLocation = _ref2.currentLocation,
|
|
947
|
+
nextLocation = _ref2.nextLocation;
|
|
948
|
+
return currentLocation.pathname !== nextLocation.pathname && shouldBlockNavigation(nextLocation);
|
|
949
|
+
});
|
|
950
|
+
return React.createElement(ConfirmModal, _extends({
|
|
951
|
+
onDismiss: function onDismiss() {
|
|
952
|
+
if (blocker.state === 'blocked') {
|
|
953
|
+
blocker.reset();
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
open: blocker.state === 'blocked',
|
|
957
|
+
onConfirm: function onConfirm() {
|
|
958
|
+
if (blocker.state === 'blocked') {
|
|
959
|
+
blocker.proceed();
|
|
960
|
+
}
|
|
953
961
|
}
|
|
954
|
-
|
|
955
|
-
return true;
|
|
956
|
-
};
|
|
957
|
-
|
|
958
|
-
var handleConfirm = function handleConfirm() {
|
|
959
|
-
history.push(lastLocation.pathname);
|
|
960
|
-
};
|
|
961
|
-
|
|
962
|
-
return React.createElement(React.Fragment, null, React.createElement(Prompt, {
|
|
963
|
-
message: allowNavigation
|
|
964
|
-
}), React.createElement(ConfirmModal, _extends({
|
|
965
|
-
onDismiss: closeModal,
|
|
966
|
-
open: status === 'BLOCKED',
|
|
967
|
-
onConfirm: handleConfirm
|
|
968
|
-
}, rest), children));
|
|
962
|
+
}, rest), children);
|
|
969
963
|
};
|
|
970
964
|
|
|
971
965
|
var Pager = function Pager(_ref) {
|
|
@@ -1035,19 +1029,11 @@ var PermissionCheckedRoute = function PermissionCheckedRoute(_ref) {
|
|
|
1035
1029
|
onReject = _ref.onReject,
|
|
1036
1030
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1037
1031
|
|
|
1038
|
-
var redirect = React.createElement(Redirect, {
|
|
1039
|
-
to: {
|
|
1040
|
-
pathname: '/unauthorized',
|
|
1041
|
-
state: {
|
|
1042
|
-
from: props.location
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
1032
|
return React.createElement(PermissionCheck, {
|
|
1047
1033
|
permissions: actualPermissions,
|
|
1048
1034
|
all: all,
|
|
1049
1035
|
oneOf: oneOf,
|
|
1050
|
-
fallback: onReject ? onReject : redirect
|
|
1036
|
+
fallback: onReject != null ? onReject : redirect('/unauthorized')
|
|
1051
1037
|
}, React.createElement(Route, _extends({}, props), children));
|
|
1052
1038
|
};
|
|
1053
1039
|
|
|
@@ -1145,8 +1131,8 @@ function PageTitle(_ref) {
|
|
|
1145
1131
|
}).map(function (_ref3) {
|
|
1146
1132
|
var title = _ref3.title;
|
|
1147
1133
|
return title;
|
|
1148
|
-
}).reverse().join('
|
|
1149
|
-
return React.createElement(Helmet, null, React.createElement("title", null, pageTitles, "
|
|
1134
|
+
}).reverse().join(' | ');
|
|
1135
|
+
return React.createElement(Helmet, null, React.createElement("title", null, pageTitles, " | Entur Partner"));
|
|
1150
1136
|
}
|
|
1151
1137
|
|
|
1152
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 };
|