@entur-partner/common 10.0.2-alpha.0 → 10.0.2
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/Link.d.ts +1 -1
- package/dist/common.cjs.development.js +8 -77
- 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 +3 -69
- package/dist/common.esm.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/styles.css +89 -89
- package/package.json +8 -5
- package/dist/ProjectProvider.d.ts +0 -15
- package/dist/useNavigateParams.d.ts +0 -9
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 {
|
|
5
|
+
import { Link as Link$1, useInRouterContext, useBlocker, useNavigate } from 'react-router';
|
|
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,42 +192,10 @@ var AuditInfo = function AuditInfo(_ref) {
|
|
|
192
192
|
}));
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
var ProjectContext = /*#__PURE__*/React.createContext(undefined);
|
|
196
|
-
var useProject = function useProject() {
|
|
197
|
-
var context = React.useContext(ProjectContext);
|
|
198
|
-
if (!context) {
|
|
199
|
-
throw new Error("Must be used within a ProjectProvider");
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
defaultProjectId: context.defaultProjectId,
|
|
203
|
-
projectName: context.projectName
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* A Provider to sync project id across micro-frontends. Used by useNavigateParams to ensure project id is always present in the url.
|
|
208
|
-
*/
|
|
209
|
-
var ProjectProvider = function ProjectProvider(_ref) {
|
|
210
|
-
var defaultProjectId = _ref.defaultProjectId,
|
|
211
|
-
projectName = _ref.projectName,
|
|
212
|
-
children = _ref.children;
|
|
213
|
-
return React.createElement(ProjectContext.Provider, {
|
|
214
|
-
value: {
|
|
215
|
-
defaultProjectId: defaultProjectId,
|
|
216
|
-
projectName: projectName
|
|
217
|
-
}
|
|
218
|
-
}, children);
|
|
219
|
-
};
|
|
220
|
-
|
|
221
195
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
222
196
|
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
223
197
|
pathname = _ref.pathname,
|
|
224
198
|
onBreadcrumbLookup = _ref.onBreadcrumbLookup;
|
|
225
|
-
var _useProject = useProject(),
|
|
226
|
-
projectName = _useProject.projectName,
|
|
227
|
-
defaultProjectId = _useProject.defaultProjectId;
|
|
228
|
-
var _useSearchParams = useSearchParams(),
|
|
229
|
-
searchParams = _useSearchParams[0];
|
|
230
|
-
var projectValue = searchParams.get(projectName);
|
|
231
199
|
var paths = splitUrlPath(pathname);
|
|
232
200
|
var breadcrumbs = paths.map(function (path) {
|
|
233
201
|
return {
|
|
@@ -248,13 +216,10 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
|
248
216
|
as: "span"
|
|
249
217
|
}, title);
|
|
250
218
|
}
|
|
251
|
-
if (!projectValue) {
|
|
252
|
-
searchParams.set(projectName, defaultProjectId);
|
|
253
|
-
}
|
|
254
219
|
return React.createElement(BreadcrumbItem, {
|
|
255
220
|
key: path,
|
|
256
221
|
as: Link$1,
|
|
257
|
-
to: path
|
|
222
|
+
to: path
|
|
258
223
|
}, title);
|
|
259
224
|
});
|
|
260
225
|
if (prependBreadcrumbItem) {
|
|
@@ -1137,36 +1102,5 @@ function useEventListener(eventName, handler, element) {
|
|
|
1137
1102
|
}, [eventName, element]);
|
|
1138
1103
|
}
|
|
1139
1104
|
|
|
1140
|
-
|
|
1141
|
-
* A custom hook that wraps the useNavigate hook from react-router-dom for MicroFrontend State
|
|
1142
|
-
*
|
|
1143
|
-
* @param to can be a string path, a To object, or a number (delta)
|
|
1144
|
-
* @param options contains options for modifying the navigation
|
|
1145
|
-
* @returns a function that navigates to the specified path with organisationId in the search params
|
|
1146
|
-
*/
|
|
1147
|
-
function useNavigateParams() {
|
|
1148
|
-
var _useProject = useProject(),
|
|
1149
|
-
projectName = _useProject.projectName,
|
|
1150
|
-
defaultProjectId = _useProject.defaultProjectId;
|
|
1151
|
-
var navigate = useNavigate();
|
|
1152
|
-
var _useSearchParams = useSearchParams(),
|
|
1153
|
-
searchParams = _useSearchParams[0];
|
|
1154
|
-
var projectValue = searchParams.get(projectName);
|
|
1155
|
-
var navigateParam = function navigateParam(to, options) {
|
|
1156
|
-
if (options === void 0) {
|
|
1157
|
-
options = {};
|
|
1158
|
-
}
|
|
1159
|
-
if (projectValue == null) {
|
|
1160
|
-
searchParams.set(projectName, defaultProjectId);
|
|
1161
|
-
}
|
|
1162
|
-
if (typeof to === "number") {
|
|
1163
|
-
navigate(to + "?" + searchParams.toString(), options);
|
|
1164
|
-
} else {
|
|
1165
|
-
navigate(to + "?" + searchParams.toString(), options);
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
return navigateParam;
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
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, ProjectProvider, RouteLeavingGuard, Stack, StatusLabel, Text, Unbutton, UserMenu, featureFlag, getColorForEnvironment, getHumanReadableEnvironment, responsiveProp, useDocumentTitle, useEventListener, useFeatureToggle, useNavigateParams, useProject };
|
|
1105
|
+
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 };
|
|
1172
1106
|
//# sourceMappingURL=common.esm.js.map
|