@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.
@@ -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 { useSearchParams, Link as Link$1, useInRouterContext, useBlocker, useNavigate } from 'react-router-dom';
5
+ import { Link as Link$1, useInRouterContext, useBlocker, useNavigate } 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,42 +192,21 @@ 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,
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,
212
199
  children = _ref.children;
213
- return React.createElement(ProjectContext.Provider, {
214
- value: {
215
- defaultProjectId: defaultProjectId,
216
- projectName: projectName
217
- }
218
- }, children);
200
+ var classList = cx([className]);
201
+ return React.createElement(Component, {
202
+ className: classList
203
+ }, " ", children);
219
204
  };
220
205
 
221
206
  var Breadcrumbs = function Breadcrumbs(_ref) {
222
207
  var prependBreadcrumbItem = _ref.prependBreadcrumbItem,
223
208
  pathname = _ref.pathname,
224
209
  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
210
  var paths = splitUrlPath(pathname);
232
211
  var breadcrumbs = paths.map(function (path) {
233
212
  return {
@@ -248,13 +227,10 @@ var Breadcrumbs = function Breadcrumbs(_ref) {
248
227
  as: "span"
249
228
  }, title);
250
229
  }
251
- if (!projectValue) {
252
- searchParams.set(projectName, defaultProjectId);
253
- }
254
230
  return React.createElement(BreadcrumbItem, {
255
231
  key: path,
256
232
  as: Link$1,
257
- to: path + "?" + searchParams.toString()
233
+ to: path
258
234
  }, title);
259
235
  });
260
236
  if (prependBreadcrumbItem) {
@@ -1137,36 +1113,5 @@ function useEventListener(eventName, handler, element) {
1137
1113
  }, [eventName, element]);
1138
1114
  }
1139
1115
 
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 };
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 };
1172
1117
  //# sourceMappingURL=common.esm.js.map