@entur-partner/common 10.0.2-alpha.0 → 11.0.0-alpha.1
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/BetaTopNavigation.d.ts +9 -0
- package/dist/common.cjs.development.js +10 -67
- 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 +11 -66
- package/dist/common.esm.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/styles.css +119 -48
- package/package.json +5 -5
- package/dist/ProjectProvider.d.ts +0 -15
- package/dist/useNavigateParams.d.ts +0 -9
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./BetaTopNavigation.scss";
|
|
2
|
+
import React, { FC, ReactNode } from "react";
|
|
3
|
+
interface BetaTopNavigationProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
as?: "nav" | React.ElementType;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const BetaTopNavigation: FC<BetaTopNavigationProps>;
|
|
9
|
+
export {};
|
|
@@ -196,42 +196,21 @@ var AuditInfo = function AuditInfo(_ref) {
|
|
|
196
196
|
}));
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
|
|
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,
|
|
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,
|
|
216
203
|
children = _ref.children;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
}, children);
|
|
204
|
+
var classList = cx([className]);
|
|
205
|
+
return React.createElement(Component, {
|
|
206
|
+
className: classList
|
|
207
|
+
}, " ", children);
|
|
223
208
|
};
|
|
224
209
|
|
|
225
210
|
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
226
211
|
var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
|
|
227
212
|
pathname = _ref.pathname,
|
|
228
213
|
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
214
|
var paths = util.splitUrlPath(pathname);
|
|
236
215
|
var breadcrumbs = paths.map(function (path) {
|
|
237
216
|
return {
|
|
@@ -252,13 +231,10 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
|
252
231
|
as: "span"
|
|
253
232
|
}, title);
|
|
254
233
|
}
|
|
255
|
-
if (!projectValue) {
|
|
256
|
-
searchParams.set(projectName, defaultProjectId);
|
|
257
|
-
}
|
|
258
234
|
return React.createElement(menu.BreadcrumbItem, {
|
|
259
235
|
key: path,
|
|
260
236
|
as: reactRouterDom.Link,
|
|
261
|
-
to: path
|
|
237
|
+
to: path
|
|
262
238
|
}, title);
|
|
263
239
|
});
|
|
264
240
|
if (prependBreadcrumbItem) {
|
|
@@ -1141,41 +1117,11 @@ function useEventListener(eventName, handler, element) {
|
|
|
1141
1117
|
}, [eventName, element]);
|
|
1142
1118
|
}
|
|
1143
1119
|
|
|
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
1120
|
exports.ActionBar = ActionBar;
|
|
1176
1121
|
exports.ActionBarLeft = ActionBarLeft;
|
|
1177
1122
|
exports.ActionBarRight = ActionBarRight;
|
|
1178
1123
|
exports.AuditInfo = AuditInfo;
|
|
1124
|
+
exports.BetaTopNavigation = BetaTopNavigation;
|
|
1179
1125
|
exports.Box = Box;
|
|
1180
1126
|
exports.Breadcrumbs = Breadcrumbs;
|
|
1181
1127
|
exports.ConfirmModal = ConfirmModal;
|
|
@@ -1196,7 +1142,6 @@ exports.OrganisationDropDown = OrganisationDropDown;
|
|
|
1196
1142
|
exports.PageTitle = PageTitle;
|
|
1197
1143
|
exports.Pager = Pager;
|
|
1198
1144
|
exports.PermissionCheck = PermissionCheck;
|
|
1199
|
-
exports.ProjectProvider = ProjectProvider;
|
|
1200
1145
|
exports.RouteLeavingGuard = RouteLeavingGuard;
|
|
1201
1146
|
exports.Stack = Stack;
|
|
1202
1147
|
exports.StatusLabel = StatusLabel;
|
|
@@ -1210,6 +1155,4 @@ exports.responsiveProp = responsiveProp;
|
|
|
1210
1155
|
exports.useDocumentTitle = useDocumentTitle;
|
|
1211
1156
|
exports.useEventListener = useEventListener;
|
|
1212
1157
|
exports.useFeatureToggle = useFeatureToggle;
|
|
1213
|
-
exports.useNavigateParams = useNavigateParams;
|
|
1214
|
-
exports.useProject = useProject;
|
|
1215
1158
|
//# sourceMappingURL=common.cjs.development.js.map
|