@entur-partner/common 11.0.0-alpha.1 → 11.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/ErrorBoundary.d.ts +1 -1
- package/dist/RouteLeavingGuard.d.ts +1 -1
- package/dist/common.cjs.development.js +88 -117
- 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 +89 -118
- package/dist/common.esm.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/styles.css +70 -141
- package/dist/{UserMenu/index.d.ts → user-menu/UserMenu.d.ts} +4 -11
- package/dist/user-menu/components/CookieSettingsMenuItem.d.ts +7 -0
- package/dist/{UserMenu → user-menu}/components/CustomOverflowMenu.d.ts +0 -1
- package/dist/{UserMenu → user-menu}/components/CustomOverflowMenuItem.d.ts +0 -1
- package/dist/user-menu/components/LocaleSwitchMenuItem.d.ts +7 -0
- package/dist/user-menu/components/LogOutMenuItem.d.ts +7 -0
- package/dist/user-menu/components/UserMenuItem.d.ts +7 -0
- package/dist/{UserMenu → user-menu}/components/VersionMenuItem.d.ts +2 -2
- package/dist/user-menu/components/useOutsideClick.d.ts +2 -0
- package/package.json +11 -8
- package/dist/BetaTopNavigation.d.ts +0 -9
- package/dist/UserMenu/components/CookieSettingsMenuItem.d.ts +0 -9
- package/dist/UserMenu/components/LanguageSwitchMenuItem.d.ts +0 -10
- package/dist/UserMenu/components/LogOutMenuItem.d.ts +0 -9
- package/dist/UserMenu/components/UserMenuItem.d.ts +0 -9
- package/dist/UserMenu/useOutsideClick.d.ts +0 -2
package/dist/ErrorBoundary.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class ErrorBoundary extends Component<Props, State> {
|
|
|
16
16
|
constructor(props: Props);
|
|
17
17
|
static getDerivedStateFromError(error: Error): State;
|
|
18
18
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
19
|
-
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
19
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
20
20
|
}
|
|
21
21
|
export declare const LANGUAGE_STORAGE_KEY = "EP::locale";
|
|
22
22
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModalProps } from "@entur/modal";
|
|
2
|
-
import type { Location } from "history";
|
|
3
2
|
import { type FC, type ReactNode } from "react";
|
|
3
|
+
import { type Location } from "react-router-dom";
|
|
4
4
|
export interface RouteLeavingGuardProps extends Partial<ModalProps> {
|
|
5
5
|
title: string;
|
|
6
6
|
closeLabel: string;
|
|
@@ -16,6 +16,7 @@ var form = require('@entur/form');
|
|
|
16
16
|
var dropdown = require('@entur/dropdown');
|
|
17
17
|
var icons = require('@entur/icons');
|
|
18
18
|
|
|
19
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
19
20
|
var ActionBarLeft = function ActionBarLeft(_ref) {
|
|
20
21
|
var children = _ref.children;
|
|
21
22
|
return React.createElement("div", {
|
|
@@ -196,17 +197,6 @@ var AuditInfo = function AuditInfo(_ref) {
|
|
|
196
197
|
}));
|
|
197
198
|
};
|
|
198
199
|
|
|
199
|
-
var BetaTopNavigation = function BetaTopNavigation(_ref) {
|
|
200
|
-
var _ref$as = _ref.as,
|
|
201
|
-
Component = _ref$as === void 0 ? "nav" : _ref$as,
|
|
202
|
-
className = _ref.className,
|
|
203
|
-
children = _ref.children;
|
|
204
|
-
var classList = cx([className]);
|
|
205
|
-
return React.createElement(Component, {
|
|
206
|
-
className: classList
|
|
207
|
-
}, " ", children);
|
|
208
|
-
};
|
|
209
|
-
|
|
210
200
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
211
201
|
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
212
202
|
pathname = _ref.pathname,
|
|
@@ -468,7 +458,6 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
|
|
|
468
458
|
})));
|
|
469
459
|
};
|
|
470
460
|
|
|
471
|
-
/// <reference types="vite/client" />
|
|
472
461
|
/**
|
|
473
462
|
* Returns true if the provided flag exist in localStorage
|
|
474
463
|
* or is set as an environment variable.
|
|
@@ -477,8 +466,11 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
|
|
|
477
466
|
* you can drop the VITE_APP_ prefix.
|
|
478
467
|
*/
|
|
479
468
|
function featureFlag(flag) {
|
|
480
|
-
var _window$localStorage, _window$localStorage2;
|
|
481
|
-
return
|
|
469
|
+
var _import$meta, _window$localStorage, _window$localStorage2;
|
|
470
|
+
return (
|
|
471
|
+
// biome-ignore lint/suspicious/noExplicitAny: We dont have vite types here
|
|
472
|
+
((_import$meta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('common.cjs.development.js', document.baseURI).href)) })) == 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"
|
|
473
|
+
);
|
|
482
474
|
}
|
|
483
475
|
/**
|
|
484
476
|
* Returns true if the provided flag exist in localStorage
|
|
@@ -836,6 +828,29 @@ var Unbutton = function Unbutton(_ref) {
|
|
|
836
828
|
}), children);
|
|
837
829
|
};
|
|
838
830
|
|
|
831
|
+
/*global EventListener WindowEventHandlers*/
|
|
832
|
+
function useEventListener(eventName, handler, element) {
|
|
833
|
+
if (element === void 0) {
|
|
834
|
+
element = window;
|
|
835
|
+
}
|
|
836
|
+
var savedHandler = React.useRef(null);
|
|
837
|
+
React.useEffect(function () {
|
|
838
|
+
savedHandler.current = handler;
|
|
839
|
+
}, [handler]);
|
|
840
|
+
React.useEffect(function () {
|
|
841
|
+
var _element;
|
|
842
|
+
var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
|
|
843
|
+
if (!isSupported) return;
|
|
844
|
+
var eventListener = function eventListener(event) {
|
|
845
|
+
return savedHandler.current == null ? void 0 : savedHandler.current(event);
|
|
846
|
+
};
|
|
847
|
+
element.addEventListener(eventName, eventListener);
|
|
848
|
+
return function () {
|
|
849
|
+
element.removeEventListener(eventName, eventListener);
|
|
850
|
+
};
|
|
851
|
+
}, [eventName, element]);
|
|
852
|
+
}
|
|
853
|
+
|
|
839
854
|
var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
840
855
|
return React.createElement("button", _extends({
|
|
841
856
|
className: cx(props.className, "eps-overflow-menu__item"),
|
|
@@ -844,21 +859,17 @@ var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
|
844
859
|
};
|
|
845
860
|
|
|
846
861
|
var CookieSettingsMenuItem = function CookieSettingsMenuItem(_ref) {
|
|
847
|
-
var
|
|
848
|
-
|
|
849
|
-
onCookieSettingsOpen = _ref.onCookieSettingsOpen;
|
|
862
|
+
var locale = _ref.locale,
|
|
863
|
+
onClick = _ref.onClick;
|
|
850
864
|
return React.createElement(CustomOverflowMenuItem, {
|
|
851
|
-
onClick:
|
|
852
|
-
onCookieSettingsOpen();
|
|
853
|
-
setOpen(false);
|
|
854
|
-
},
|
|
865
|
+
onClick: onClick,
|
|
855
866
|
className: "eps-overflow-menu__item"
|
|
856
867
|
}, React.createElement("span", {
|
|
857
868
|
"aria-hidden": true
|
|
858
869
|
}, React.createElement(icons.CookieIcon, {
|
|
859
870
|
size: "1rem",
|
|
860
871
|
inline: true
|
|
861
|
-
})),
|
|
872
|
+
})), locale === "en-GB" ? "Cookie settings" : "Cookieinstillinger");
|
|
862
873
|
};
|
|
863
874
|
|
|
864
875
|
function useOutsideClick(ref, buttonRef, handler) {
|
|
@@ -946,18 +957,12 @@ var CustomOverflowMenu = function CustomOverflowMenu(_ref) {
|
|
|
946
957
|
}, children));
|
|
947
958
|
};
|
|
948
959
|
|
|
949
|
-
var
|
|
950
|
-
var
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
name = _ref.name;
|
|
954
|
-
var useB47LanguageKey = useFeatureToggle("USE_BCP-47_LANGUAGE_KEY");
|
|
955
|
-
var norwegianLanguageKey = useB47LanguageKey ? "nb-NO" : "nb";
|
|
956
|
-
var englishLanguageKey = useB47LanguageKey ? "en-GB" : "en";
|
|
957
|
-
return React.createElement(React.Fragment, null, language === englishLanguageKey ? React.createElement(CustomOverflowMenuItem, {
|
|
960
|
+
var LocaleSwitchMenuItem = function LocaleSwitchMenuItem(_ref) {
|
|
961
|
+
var locale = _ref.locale,
|
|
962
|
+
onLocaleChange = _ref.onLocaleChange;
|
|
963
|
+
return React.createElement(React.Fragment, null, locale === "en-GB" ? React.createElement(CustomOverflowMenuItem, {
|
|
958
964
|
onClick: function onClick() {
|
|
959
|
-
|
|
960
|
-
setOpen(false);
|
|
965
|
+
onLocaleChange("nb-NO");
|
|
961
966
|
},
|
|
962
967
|
className: "eps-overflow-menu__item"
|
|
963
968
|
}, React.createElement("span", {
|
|
@@ -966,10 +971,9 @@ var LanguageSwitchMenuItem = function LanguageSwitchMenuItem(_ref) {
|
|
|
966
971
|
}, React.createElement(icons.NorwayIcon, {
|
|
967
972
|
size: "1rem",
|
|
968
973
|
inline: true
|
|
969
|
-
})),
|
|
974
|
+
})), "Bytt til norsk") : React.createElement(CustomOverflowMenuItem, {
|
|
970
975
|
onClick: function onClick() {
|
|
971
|
-
|
|
972
|
-
setOpen(false);
|
|
976
|
+
onLocaleChange("en-GB");
|
|
973
977
|
},
|
|
974
978
|
className: "eps-overflow-menu__item"
|
|
975
979
|
}, React.createElement("span", {
|
|
@@ -978,18 +982,14 @@ var LanguageSwitchMenuItem = function LanguageSwitchMenuItem(_ref) {
|
|
|
978
982
|
}, React.createElement(icons.UKIcon, {
|
|
979
983
|
size: "1rem",
|
|
980
984
|
inline: true
|
|
981
|
-
})),
|
|
985
|
+
})), "Switch to English"));
|
|
982
986
|
};
|
|
983
987
|
|
|
984
988
|
var LogOutMenuItem = function LogOutMenuItem(_ref) {
|
|
985
|
-
var
|
|
986
|
-
|
|
987
|
-
onLogout = _ref.onLogout;
|
|
989
|
+
var onClick = _ref.onClick,
|
|
990
|
+
locale = _ref.locale;
|
|
988
991
|
return React.createElement(CustomOverflowMenuItem, {
|
|
989
|
-
onClick:
|
|
990
|
-
onLogout();
|
|
991
|
-
setOpen(false);
|
|
992
|
-
},
|
|
992
|
+
onClick: onClick,
|
|
993
993
|
"data-testid": "user-menu-logout",
|
|
994
994
|
className: "eps-overflow-menu__item"
|
|
995
995
|
}, React.createElement("span", {
|
|
@@ -997,41 +997,28 @@ var LogOutMenuItem = function LogOutMenuItem(_ref) {
|
|
|
997
997
|
}, React.createElement(icons.LogOutIcon, {
|
|
998
998
|
size: "1rem",
|
|
999
999
|
inline: true
|
|
1000
|
-
})),
|
|
1000
|
+
})), locale === "en-GB" ? "Log out " : "Logg ut");
|
|
1001
1001
|
};
|
|
1002
1002
|
|
|
1003
1003
|
var UserMenuItem = function UserMenuItem(_ref) {
|
|
1004
|
-
var
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
to: "/permission-admin/my-profile",
|
|
1009
|
-
style: {
|
|
1010
|
-
textDecoration: "none"
|
|
1011
|
-
}
|
|
1012
|
-
}, React.createElement(CustomOverflowMenuItem, {
|
|
1013
|
-
onClick: function onClick() {
|
|
1014
|
-
setOpen(false);
|
|
1015
|
-
onNavigateToMyProfile();
|
|
1016
|
-
},
|
|
1004
|
+
var locale = _ref.locale,
|
|
1005
|
+
onClick = _ref.onClick;
|
|
1006
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
1007
|
+
onClick: onClick,
|
|
1017
1008
|
className: "eps-overflow-menu__item"
|
|
1018
1009
|
}, React.createElement("span", {
|
|
1019
1010
|
"aria-hidden": true
|
|
1020
1011
|
}, React.createElement(icons.UserIcon, {
|
|
1021
1012
|
size: "1rem",
|
|
1022
1013
|
inline: true
|
|
1023
|
-
})),
|
|
1014
|
+
})), locale === "en-GB" ? "My profile" : "Min profil");
|
|
1024
1015
|
};
|
|
1025
1016
|
|
|
1026
1017
|
var VersionMenuItem = function VersionMenuItem(_ref) {
|
|
1027
|
-
var
|
|
1028
|
-
|
|
1029
|
-
var navigate = reactRouterDom.useNavigate(); // Hide useNavigate from standalone micro-frontends because it is not under RouterProvider
|
|
1018
|
+
var locale = _ref.locale,
|
|
1019
|
+
onClick = _ref.onClick;
|
|
1030
1020
|
return React.createElement(CustomOverflowMenuItem, {
|
|
1031
|
-
onClick:
|
|
1032
|
-
navigate("/app-version");
|
|
1033
|
-
setOpen(false);
|
|
1034
|
-
},
|
|
1021
|
+
onClick: onClick,
|
|
1035
1022
|
className: "eps-overflow-menu__item"
|
|
1036
1023
|
}, React.createElement("span", {
|
|
1037
1024
|
"aria-hidden": true
|
|
@@ -1039,25 +1026,23 @@ var VersionMenuItem = function VersionMenuItem(_ref) {
|
|
|
1039
1026
|
className: "eps-version-icon",
|
|
1040
1027
|
size: "1rem",
|
|
1041
1028
|
inline: true
|
|
1042
|
-
})),
|
|
1029
|
+
})), locale === "en-GB" ? "Version" : "Versjon");
|
|
1043
1030
|
};
|
|
1044
1031
|
|
|
1045
|
-
/** biome-ignore-all lint/correctness/useUniqueElementIds: Ignore unique id for now */
|
|
1046
1032
|
var UserMenu = function UserMenu(_ref) {
|
|
1047
1033
|
var className = _ref.className,
|
|
1048
|
-
messages = _ref.messages,
|
|
1049
1034
|
onLogout = _ref.onLogout,
|
|
1050
|
-
|
|
1035
|
+
_onLocaleChange = _ref.onLocaleChange,
|
|
1051
1036
|
userName = _ref.userName,
|
|
1052
|
-
|
|
1037
|
+
locale = _ref.locale,
|
|
1053
1038
|
environment = _ref.environment,
|
|
1054
1039
|
showVersionItem = _ref.showVersionItem,
|
|
1055
1040
|
showMyProfileItem = _ref.showMyProfileItem,
|
|
1056
1041
|
showCookieSettingsItem = _ref.showCookieSettingsItem,
|
|
1057
1042
|
onNavigateToMyProfile = _ref.onNavigateToMyProfile,
|
|
1058
1043
|
_ref$onCookieSettings = _ref.onCookieSettingsOpen,
|
|
1059
|
-
onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings
|
|
1060
|
-
|
|
1044
|
+
onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings,
|
|
1045
|
+
onVersionItemClick = _ref.onVersionItemClick;
|
|
1061
1046
|
var _useState = React.useState(false),
|
|
1062
1047
|
open = _useState[0],
|
|
1063
1048
|
setOpen = _useState[1];
|
|
@@ -1066,62 +1051,48 @@ var UserMenu = function UserMenu(_ref) {
|
|
|
1066
1051
|
}, React.createElement(CustomOverflowMenu, {
|
|
1067
1052
|
open: open,
|
|
1068
1053
|
onOpenChange: setOpen,
|
|
1069
|
-
className:
|
|
1054
|
+
className: cx(["eps-user-menu__trigger-button", className]),
|
|
1070
1055
|
userName: userName,
|
|
1071
1056
|
environment: environment
|
|
1072
1057
|
}, React.createElement("div", {
|
|
1073
1058
|
id: "eps-overflow-menu"
|
|
1074
|
-
}, React.createElement(
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}),
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1059
|
+
}, React.createElement(LocaleSwitchMenuItem, {
|
|
1060
|
+
locale: locale,
|
|
1061
|
+
onLocaleChange: function onLocaleChange(newLocale) {
|
|
1062
|
+
_onLocaleChange(newLocale);
|
|
1063
|
+
setOpen(false);
|
|
1064
|
+
}
|
|
1065
|
+
}), showVersionItem && React.createElement(VersionMenuItem, {
|
|
1066
|
+
locale: locale,
|
|
1067
|
+
onClick: function onClick() {
|
|
1068
|
+
onVersionItemClick == null || onVersionItemClick();
|
|
1069
|
+
setOpen(false);
|
|
1070
|
+
}
|
|
1071
|
+
}), showMyProfileItem && React.createElement(UserMenuItem, {
|
|
1072
|
+
locale: locale,
|
|
1073
|
+
onClick: function onClick() {
|
|
1074
|
+
onNavigateToMyProfile();
|
|
1075
|
+
setOpen(false);
|
|
1076
|
+
}
|
|
1077
|
+
}), showCookieSettingsItem && React.createElement(CookieSettingsMenuItem, {
|
|
1078
|
+
locale: locale,
|
|
1079
|
+
onClick: function onClick() {
|
|
1080
|
+
onCookieSettingsOpen();
|
|
1081
|
+
setOpen(false);
|
|
1082
|
+
}
|
|
1090
1083
|
}), React.createElement(LogOutMenuItem, {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1084
|
+
locale: locale,
|
|
1085
|
+
onClick: function onClick() {
|
|
1086
|
+
onLogout();
|
|
1087
|
+
setOpen(false);
|
|
1088
|
+
}
|
|
1094
1089
|
}))));
|
|
1095
1090
|
};
|
|
1096
1091
|
|
|
1097
|
-
/*global EventListener WindowEventHandlers*/
|
|
1098
|
-
function useEventListener(eventName, handler, element) {
|
|
1099
|
-
if (element === void 0) {
|
|
1100
|
-
element = window;
|
|
1101
|
-
}
|
|
1102
|
-
var savedHandler = React.useRef();
|
|
1103
|
-
React.useEffect(function () {
|
|
1104
|
-
savedHandler.current = handler;
|
|
1105
|
-
}, [handler]);
|
|
1106
|
-
React.useEffect(function () {
|
|
1107
|
-
var _element;
|
|
1108
|
-
var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
|
|
1109
|
-
if (!isSupported) return;
|
|
1110
|
-
var eventListener = function eventListener(event) {
|
|
1111
|
-
return savedHandler.current == null ? void 0 : savedHandler.current(event);
|
|
1112
|
-
};
|
|
1113
|
-
element.addEventListener(eventName, eventListener);
|
|
1114
|
-
return function () {
|
|
1115
|
-
element.removeEventListener(eventName, eventListener);
|
|
1116
|
-
};
|
|
1117
|
-
}, [eventName, element]);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
1092
|
exports.ActionBar = ActionBar;
|
|
1121
1093
|
exports.ActionBarLeft = ActionBarLeft;
|
|
1122
1094
|
exports.ActionBarRight = ActionBarRight;
|
|
1123
1095
|
exports.AuditInfo = AuditInfo;
|
|
1124
|
-
exports.BetaTopNavigation = BetaTopNavigation;
|
|
1125
1096
|
exports.Box = Box;
|
|
1126
1097
|
exports.Breadcrumbs = Breadcrumbs;
|
|
1127
1098
|
exports.ConfirmModal = ConfirmModal;
|