@entur-partner/common 11.0.0-alpha.0 → 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 +66 -137
- 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/common.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { Children, Component, useState, useEffect, useRef } from 'react';
|
|
|
2
2
|
import { localeDate, localeDateTime, isDate, isDateString, splitUrlPath, isString, isFunction, assertIsDefined, hasAllPermissions, hasOneOfPermissions } from '@entur-partner/util';
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import { BreadcrumbItem, BreadcrumbNavigation, Pagination } from '@entur/menu';
|
|
5
|
-
import { Link as Link$1, useInRouterContext, useBlocker
|
|
5
|
+
import { Link as Link$1, useInRouterContext, useBlocker } from 'react-router-dom';
|
|
6
6
|
import { ButtonGroup, SecondaryButton, PrimaryButton, Button } from '@entur/button';
|
|
7
7
|
import { Modal } from '@entur/modal';
|
|
8
8
|
import { Paragraph, Link as Link$2, Heading6 } from '@entur/typography';
|
|
@@ -192,17 +192,6 @@ var AuditInfo = function AuditInfo(_ref) {
|
|
|
192
192
|
}));
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
var BetaTopNavigation = function BetaTopNavigation(_ref) {
|
|
196
|
-
var _ref$as = _ref.as,
|
|
197
|
-
Component = _ref$as === void 0 ? "nav" : _ref$as,
|
|
198
|
-
className = _ref.className,
|
|
199
|
-
children = _ref.children;
|
|
200
|
-
var classList = cx([className]);
|
|
201
|
-
return React.createElement(Component, {
|
|
202
|
-
className: classList
|
|
203
|
-
}, " ", children);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
195
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
207
196
|
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
208
197
|
pathname = _ref.pathname,
|
|
@@ -464,7 +453,6 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
|
|
|
464
453
|
})));
|
|
465
454
|
};
|
|
466
455
|
|
|
467
|
-
/// <reference types="vite/client" />
|
|
468
456
|
/**
|
|
469
457
|
* Returns true if the provided flag exist in localStorage
|
|
470
458
|
* or is set as an environment variable.
|
|
@@ -473,8 +461,11 @@ var ExpandableMultiLanguageInput = function ExpandableMultiLanguageInput(_ref) {
|
|
|
473
461
|
* you can drop the VITE_APP_ prefix.
|
|
474
462
|
*/
|
|
475
463
|
function featureFlag(flag) {
|
|
476
|
-
var _window$localStorage, _window$localStorage2;
|
|
477
|
-
return
|
|
464
|
+
var _import$meta, _window$localStorage, _window$localStorage2;
|
|
465
|
+
return (
|
|
466
|
+
// biome-ignore lint/suspicious/noExplicitAny: We dont have vite types here
|
|
467
|
+
((_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"
|
|
468
|
+
);
|
|
478
469
|
}
|
|
479
470
|
/**
|
|
480
471
|
* Returns true if the provided flag exist in localStorage
|
|
@@ -832,6 +823,29 @@ var Unbutton = function Unbutton(_ref) {
|
|
|
832
823
|
}), children);
|
|
833
824
|
};
|
|
834
825
|
|
|
826
|
+
/*global EventListener WindowEventHandlers*/
|
|
827
|
+
function useEventListener(eventName, handler, element) {
|
|
828
|
+
if (element === void 0) {
|
|
829
|
+
element = window;
|
|
830
|
+
}
|
|
831
|
+
var savedHandler = useRef(null);
|
|
832
|
+
useEffect(function () {
|
|
833
|
+
savedHandler.current = handler;
|
|
834
|
+
}, [handler]);
|
|
835
|
+
useEffect(function () {
|
|
836
|
+
var _element;
|
|
837
|
+
var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
|
|
838
|
+
if (!isSupported) return;
|
|
839
|
+
var eventListener = function eventListener(event) {
|
|
840
|
+
return savedHandler.current == null ? void 0 : savedHandler.current(event);
|
|
841
|
+
};
|
|
842
|
+
element.addEventListener(eventName, eventListener);
|
|
843
|
+
return function () {
|
|
844
|
+
element.removeEventListener(eventName, eventListener);
|
|
845
|
+
};
|
|
846
|
+
}, [eventName, element]);
|
|
847
|
+
}
|
|
848
|
+
|
|
835
849
|
var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
836
850
|
return React.createElement("button", _extends({
|
|
837
851
|
className: cx(props.className, "eps-overflow-menu__item"),
|
|
@@ -840,21 +854,17 @@ var CustomOverflowMenuItem = function CustomOverflowMenuItem(props) {
|
|
|
840
854
|
};
|
|
841
855
|
|
|
842
856
|
var CookieSettingsMenuItem = function CookieSettingsMenuItem(_ref) {
|
|
843
|
-
var
|
|
844
|
-
|
|
845
|
-
onCookieSettingsOpen = _ref.onCookieSettingsOpen;
|
|
857
|
+
var locale = _ref.locale,
|
|
858
|
+
onClick = _ref.onClick;
|
|
846
859
|
return React.createElement(CustomOverflowMenuItem, {
|
|
847
|
-
onClick:
|
|
848
|
-
onCookieSettingsOpen();
|
|
849
|
-
setOpen(false);
|
|
850
|
-
},
|
|
860
|
+
onClick: onClick,
|
|
851
861
|
className: "eps-overflow-menu__item"
|
|
852
862
|
}, React.createElement("span", {
|
|
853
863
|
"aria-hidden": true
|
|
854
864
|
}, React.createElement(CookieIcon, {
|
|
855
865
|
size: "1rem",
|
|
856
866
|
inline: true
|
|
857
|
-
})),
|
|
867
|
+
})), locale === "en-GB" ? "Cookie settings" : "Cookieinstillinger");
|
|
858
868
|
};
|
|
859
869
|
|
|
860
870
|
function useOutsideClick(ref, buttonRef, handler) {
|
|
@@ -942,18 +952,12 @@ var CustomOverflowMenu = function CustomOverflowMenu(_ref) {
|
|
|
942
952
|
}, children));
|
|
943
953
|
};
|
|
944
954
|
|
|
945
|
-
var
|
|
946
|
-
var
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
name = _ref.name;
|
|
950
|
-
var useB47LanguageKey = useFeatureToggle("USE_BCP-47_LANGUAGE_KEY");
|
|
951
|
-
var norwegianLanguageKey = useB47LanguageKey ? "nb-NO" : "nb";
|
|
952
|
-
var englishLanguageKey = useB47LanguageKey ? "en-GB" : "en";
|
|
953
|
-
return React.createElement(React.Fragment, null, language === englishLanguageKey ? React.createElement(CustomOverflowMenuItem, {
|
|
955
|
+
var LocaleSwitchMenuItem = function LocaleSwitchMenuItem(_ref) {
|
|
956
|
+
var locale = _ref.locale,
|
|
957
|
+
onLocaleChange = _ref.onLocaleChange;
|
|
958
|
+
return React.createElement(React.Fragment, null, locale === "en-GB" ? React.createElement(CustomOverflowMenuItem, {
|
|
954
959
|
onClick: function onClick() {
|
|
955
|
-
|
|
956
|
-
setOpen(false);
|
|
960
|
+
onLocaleChange("nb-NO");
|
|
957
961
|
},
|
|
958
962
|
className: "eps-overflow-menu__item"
|
|
959
963
|
}, React.createElement("span", {
|
|
@@ -962,10 +966,9 @@ var LanguageSwitchMenuItem = function LanguageSwitchMenuItem(_ref) {
|
|
|
962
966
|
}, React.createElement(NorwayIcon, {
|
|
963
967
|
size: "1rem",
|
|
964
968
|
inline: true
|
|
965
|
-
})),
|
|
969
|
+
})), "Bytt til norsk") : React.createElement(CustomOverflowMenuItem, {
|
|
966
970
|
onClick: function onClick() {
|
|
967
|
-
|
|
968
|
-
setOpen(false);
|
|
971
|
+
onLocaleChange("en-GB");
|
|
969
972
|
},
|
|
970
973
|
className: "eps-overflow-menu__item"
|
|
971
974
|
}, React.createElement("span", {
|
|
@@ -974,18 +977,14 @@ var LanguageSwitchMenuItem = function LanguageSwitchMenuItem(_ref) {
|
|
|
974
977
|
}, React.createElement(UKIcon, {
|
|
975
978
|
size: "1rem",
|
|
976
979
|
inline: true
|
|
977
|
-
})),
|
|
980
|
+
})), "Switch to English"));
|
|
978
981
|
};
|
|
979
982
|
|
|
980
983
|
var LogOutMenuItem = function LogOutMenuItem(_ref) {
|
|
981
|
-
var
|
|
982
|
-
|
|
983
|
-
onLogout = _ref.onLogout;
|
|
984
|
+
var onClick = _ref.onClick,
|
|
985
|
+
locale = _ref.locale;
|
|
984
986
|
return React.createElement(CustomOverflowMenuItem, {
|
|
985
|
-
onClick:
|
|
986
|
-
onLogout();
|
|
987
|
-
setOpen(false);
|
|
988
|
-
},
|
|
987
|
+
onClick: onClick,
|
|
989
988
|
"data-testid": "user-menu-logout",
|
|
990
989
|
className: "eps-overflow-menu__item"
|
|
991
990
|
}, React.createElement("span", {
|
|
@@ -993,41 +992,28 @@ var LogOutMenuItem = function LogOutMenuItem(_ref) {
|
|
|
993
992
|
}, React.createElement(LogOutIcon, {
|
|
994
993
|
size: "1rem",
|
|
995
994
|
inline: true
|
|
996
|
-
})),
|
|
995
|
+
})), locale === "en-GB" ? "Log out " : "Logg ut");
|
|
997
996
|
};
|
|
998
997
|
|
|
999
998
|
var UserMenuItem = function UserMenuItem(_ref) {
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
to: "/permission-admin/my-profile",
|
|
1005
|
-
style: {
|
|
1006
|
-
textDecoration: "none"
|
|
1007
|
-
}
|
|
1008
|
-
}, React.createElement(CustomOverflowMenuItem, {
|
|
1009
|
-
onClick: function onClick() {
|
|
1010
|
-
setOpen(false);
|
|
1011
|
-
onNavigateToMyProfile();
|
|
1012
|
-
},
|
|
999
|
+
var locale = _ref.locale,
|
|
1000
|
+
onClick = _ref.onClick;
|
|
1001
|
+
return React.createElement(CustomOverflowMenuItem, {
|
|
1002
|
+
onClick: onClick,
|
|
1013
1003
|
className: "eps-overflow-menu__item"
|
|
1014
1004
|
}, React.createElement("span", {
|
|
1015
1005
|
"aria-hidden": true
|
|
1016
1006
|
}, React.createElement(UserIcon, {
|
|
1017
1007
|
size: "1rem",
|
|
1018
1008
|
inline: true
|
|
1019
|
-
})),
|
|
1009
|
+
})), locale === "en-GB" ? "My profile" : "Min profil");
|
|
1020
1010
|
};
|
|
1021
1011
|
|
|
1022
1012
|
var VersionMenuItem = function VersionMenuItem(_ref) {
|
|
1023
|
-
var
|
|
1024
|
-
|
|
1025
|
-
var navigate = useNavigate(); // Hide useNavigate from standalone micro-frontends because it is not under RouterProvider
|
|
1013
|
+
var locale = _ref.locale,
|
|
1014
|
+
onClick = _ref.onClick;
|
|
1026
1015
|
return React.createElement(CustomOverflowMenuItem, {
|
|
1027
|
-
onClick:
|
|
1028
|
-
navigate("/app-version");
|
|
1029
|
-
setOpen(false);
|
|
1030
|
-
},
|
|
1016
|
+
onClick: onClick,
|
|
1031
1017
|
className: "eps-overflow-menu__item"
|
|
1032
1018
|
}, React.createElement("span", {
|
|
1033
1019
|
"aria-hidden": true
|
|
@@ -1035,25 +1021,23 @@ var VersionMenuItem = function VersionMenuItem(_ref) {
|
|
|
1035
1021
|
className: "eps-version-icon",
|
|
1036
1022
|
size: "1rem",
|
|
1037
1023
|
inline: true
|
|
1038
|
-
})),
|
|
1024
|
+
})), locale === "en-GB" ? "Version" : "Versjon");
|
|
1039
1025
|
};
|
|
1040
1026
|
|
|
1041
|
-
/** biome-ignore-all lint/correctness/useUniqueElementIds: Ignore unique id for now */
|
|
1042
1027
|
var UserMenu = function UserMenu(_ref) {
|
|
1043
1028
|
var className = _ref.className,
|
|
1044
|
-
messages = _ref.messages,
|
|
1045
1029
|
onLogout = _ref.onLogout,
|
|
1046
|
-
|
|
1030
|
+
_onLocaleChange = _ref.onLocaleChange,
|
|
1047
1031
|
userName = _ref.userName,
|
|
1048
|
-
|
|
1032
|
+
locale = _ref.locale,
|
|
1049
1033
|
environment = _ref.environment,
|
|
1050
1034
|
showVersionItem = _ref.showVersionItem,
|
|
1051
1035
|
showMyProfileItem = _ref.showMyProfileItem,
|
|
1052
1036
|
showCookieSettingsItem = _ref.showCookieSettingsItem,
|
|
1053
1037
|
onNavigateToMyProfile = _ref.onNavigateToMyProfile,
|
|
1054
1038
|
_ref$onCookieSettings = _ref.onCookieSettingsOpen,
|
|
1055
|
-
onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings
|
|
1056
|
-
|
|
1039
|
+
onCookieSettingsOpen = _ref$onCookieSettings === void 0 ? function () {} : _ref$onCookieSettings,
|
|
1040
|
+
onVersionItemClick = _ref.onVersionItemClick;
|
|
1057
1041
|
var _useState = useState(false),
|
|
1058
1042
|
open = _useState[0],
|
|
1059
1043
|
setOpen = _useState[1];
|
|
@@ -1062,56 +1046,43 @@ var UserMenu = function UserMenu(_ref) {
|
|
|
1062
1046
|
}, React.createElement(CustomOverflowMenu, {
|
|
1063
1047
|
open: open,
|
|
1064
1048
|
onOpenChange: setOpen,
|
|
1065
|
-
className:
|
|
1049
|
+
className: cx(["eps-user-menu__trigger-button", className]),
|
|
1066
1050
|
userName: userName,
|
|
1067
1051
|
environment: environment
|
|
1068
1052
|
}, React.createElement("div", {
|
|
1069
1053
|
id: "eps-overflow-menu"
|
|
1070
|
-
}, React.createElement(
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}),
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1054
|
+
}, React.createElement(LocaleSwitchMenuItem, {
|
|
1055
|
+
locale: locale,
|
|
1056
|
+
onLocaleChange: function onLocaleChange(newLocale) {
|
|
1057
|
+
_onLocaleChange(newLocale);
|
|
1058
|
+
setOpen(false);
|
|
1059
|
+
}
|
|
1060
|
+
}), showVersionItem && React.createElement(VersionMenuItem, {
|
|
1061
|
+
locale: locale,
|
|
1062
|
+
onClick: function onClick() {
|
|
1063
|
+
onVersionItemClick == null || onVersionItemClick();
|
|
1064
|
+
setOpen(false);
|
|
1065
|
+
}
|
|
1066
|
+
}), showMyProfileItem && React.createElement(UserMenuItem, {
|
|
1067
|
+
locale: locale,
|
|
1068
|
+
onClick: function onClick() {
|
|
1069
|
+
onNavigateToMyProfile();
|
|
1070
|
+
setOpen(false);
|
|
1071
|
+
}
|
|
1072
|
+
}), showCookieSettingsItem && React.createElement(CookieSettingsMenuItem, {
|
|
1073
|
+
locale: locale,
|
|
1074
|
+
onClick: function onClick() {
|
|
1075
|
+
onCookieSettingsOpen();
|
|
1076
|
+
setOpen(false);
|
|
1077
|
+
}
|
|
1086
1078
|
}), React.createElement(LogOutMenuItem, {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1079
|
+
locale: locale,
|
|
1080
|
+
onClick: function onClick() {
|
|
1081
|
+
onLogout();
|
|
1082
|
+
setOpen(false);
|
|
1083
|
+
}
|
|
1090
1084
|
}))));
|
|
1091
1085
|
};
|
|
1092
1086
|
|
|
1093
|
-
|
|
1094
|
-
function useEventListener(eventName, handler, element) {
|
|
1095
|
-
if (element === void 0) {
|
|
1096
|
-
element = window;
|
|
1097
|
-
}
|
|
1098
|
-
var savedHandler = useRef();
|
|
1099
|
-
useEffect(function () {
|
|
1100
|
-
savedHandler.current = handler;
|
|
1101
|
-
}, [handler]);
|
|
1102
|
-
useEffect(function () {
|
|
1103
|
-
var _element;
|
|
1104
|
-
var isSupported = (_element = element) == null ? void 0 : _element.addEventListener;
|
|
1105
|
-
if (!isSupported) return;
|
|
1106
|
-
var eventListener = function eventListener(event) {
|
|
1107
|
-
return savedHandler.current == null ? void 0 : savedHandler.current(event);
|
|
1108
|
-
};
|
|
1109
|
-
element.addEventListener(eventName, eventListener);
|
|
1110
|
-
return function () {
|
|
1111
|
-
element.removeEventListener(eventName, eventListener);
|
|
1112
|
-
};
|
|
1113
|
-
}, [eventName, element]);
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
export { ActionBar, ActionBarLeft, ActionBarRight, AuditInfo, BetaTopNavigation, 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 };
|
|
1087
|
+
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 };
|
|
1117
1088
|
//# sourceMappingURL=common.esm.js.map
|