@entur-partner/common 10.0.2-alpha.0 → 10.0.3
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/common.cjs.development.js +1 -70
- 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 +65 -65
- package/package.json +10 -7
- package/dist/ProjectProvider.d.ts +0 -15
- package/dist/useNavigateParams.d.ts +0 -9
|
@@ -196,42 +196,10 @@ var AuditInfo = function AuditInfo(_ref) {
|
|
|
196
196
|
}));
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
var ProjectContext = /*#__PURE__*/React.createContext(undefined);
|
|
200
|
-
var useProject = function useProject() {
|
|
201
|
-
var context = React.useContext(ProjectContext);
|
|
202
|
-
if (!context) {
|
|
203
|
-
throw new Error("Must be used within a ProjectProvider");
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
defaultProjectId: context.defaultProjectId,
|
|
207
|
-
projectName: context.projectName
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
/**
|
|
211
|
-
* A Provider to sync project id across micro-frontends. Used by useNavigateParams to ensure project id is always present in the url.
|
|
212
|
-
*/
|
|
213
|
-
var ProjectProvider = function ProjectProvider(_ref) {
|
|
214
|
-
var defaultProjectId = _ref.defaultProjectId,
|
|
215
|
-
projectName = _ref.projectName,
|
|
216
|
-
children = _ref.children;
|
|
217
|
-
return React.createElement(ProjectContext.Provider, {
|
|
218
|
-
value: {
|
|
219
|
-
defaultProjectId: defaultProjectId,
|
|
220
|
-
projectName: projectName
|
|
221
|
-
}
|
|
222
|
-
}, children);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
199
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
226
200
|
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
227
201
|
pathname = _ref.pathname,
|
|
228
202
|
onBreadcrumbLookup = _ref.onBreadcrumbLookup;
|
|
229
|
-
var _useProject = useProject(),
|
|
230
|
-
projectName = _useProject.projectName,
|
|
231
|
-
defaultProjectId = _useProject.defaultProjectId;
|
|
232
|
-
var _useSearchParams = reactRouterDom.useSearchParams(),
|
|
233
|
-
searchParams = _useSearchParams[0];
|
|
234
|
-
var projectValue = searchParams.get(projectName);
|
|
235
203
|
var paths = util.splitUrlPath(pathname);
|
|
236
204
|
var breadcrumbs = paths.map(function (path) {
|
|
237
205
|
return {
|
|
@@ -252,13 +220,10 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
|
252
220
|
as: "span"
|
|
253
221
|
}, title);
|
|
254
222
|
}
|
|
255
|
-
if (!projectValue) {
|
|
256
|
-
searchParams.set(projectName, defaultProjectId);
|
|
257
|
-
}
|
|
258
223
|
return React.createElement(menu.BreadcrumbItem, {
|
|
259
224
|
key: path,
|
|
260
225
|
as: reactRouterDom.Link,
|
|
261
|
-
to: path
|
|
226
|
+
to: path
|
|
262
227
|
}, title);
|
|
263
228
|
});
|
|
264
229
|
if (prependBreadcrumbItem) {
|
|
@@ -1141,37 +1106,6 @@ function useEventListener(eventName, handler, element) {
|
|
|
1141
1106
|
}, [eventName, element]);
|
|
1142
1107
|
}
|
|
1143
1108
|
|
|
1144
|
-
/**
|
|
1145
|
-
* A custom hook that wraps the useNavigate hook from react-router-dom for MicroFrontend State
|
|
1146
|
-
*
|
|
1147
|
-
* @param to can be a string path, a To object, or a number (delta)
|
|
1148
|
-
* @param options contains options for modifying the navigation
|
|
1149
|
-
* @returns a function that navigates to the specified path with organisationId in the search params
|
|
1150
|
-
*/
|
|
1151
|
-
function useNavigateParams() {
|
|
1152
|
-
var _useProject = useProject(),
|
|
1153
|
-
projectName = _useProject.projectName,
|
|
1154
|
-
defaultProjectId = _useProject.defaultProjectId;
|
|
1155
|
-
var navigate = reactRouterDom.useNavigate();
|
|
1156
|
-
var _useSearchParams = reactRouterDom.useSearchParams(),
|
|
1157
|
-
searchParams = _useSearchParams[0];
|
|
1158
|
-
var projectValue = searchParams.get(projectName);
|
|
1159
|
-
var navigateParam = function navigateParam(to, options) {
|
|
1160
|
-
if (options === void 0) {
|
|
1161
|
-
options = {};
|
|
1162
|
-
}
|
|
1163
|
-
if (projectValue == null) {
|
|
1164
|
-
searchParams.set(projectName, defaultProjectId);
|
|
1165
|
-
}
|
|
1166
|
-
if (typeof to === "number") {
|
|
1167
|
-
navigate(to + "?" + searchParams.toString(), options);
|
|
1168
|
-
} else {
|
|
1169
|
-
navigate(to + "?" + searchParams.toString(), options);
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
return navigateParam;
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
1109
|
exports.ActionBar = ActionBar;
|
|
1176
1110
|
exports.ActionBarLeft = ActionBarLeft;
|
|
1177
1111
|
exports.ActionBarRight = ActionBarRight;
|
|
@@ -1196,7 +1130,6 @@ exports.OrganisationDropDown = OrganisationDropDown;
|
|
|
1196
1130
|
exports.PageTitle = PageTitle;
|
|
1197
1131
|
exports.Pager = Pager;
|
|
1198
1132
|
exports.PermissionCheck = PermissionCheck;
|
|
1199
|
-
exports.ProjectProvider = ProjectProvider;
|
|
1200
1133
|
exports.RouteLeavingGuard = RouteLeavingGuard;
|
|
1201
1134
|
exports.Stack = Stack;
|
|
1202
1135
|
exports.StatusLabel = StatusLabel;
|
|
@@ -1210,6 +1143,4 @@ exports.responsiveProp = responsiveProp;
|
|
|
1210
1143
|
exports.useDocumentTitle = useDocumentTitle;
|
|
1211
1144
|
exports.useEventListener = useEventListener;
|
|
1212
1145
|
exports.useFeatureToggle = useFeatureToggle;
|
|
1213
|
-
exports.useNavigateParams = useNavigateParams;
|
|
1214
|
-
exports.useProject = useProject;
|
|
1215
1146
|
//# sourceMappingURL=common.cjs.development.js.map
|