@entur-partner/app-shell 2.0.24 → 2.1.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.
@@ -75,18 +75,17 @@ function _objectWithoutPropertiesLoose(source, excluded) {
75
75
  return target;
76
76
  }
77
77
 
78
- function createCommonjsModule(fn, module) {
79
- return module = { exports: {} }, fn(module, module.exports), module.exports;
80
- }
78
+ var runtime = {exports: {}};
79
+
80
+ /**
81
+ * Copyright (c) 2014-present, Facebook, Inc.
82
+ *
83
+ * This source code is licensed under the MIT license found in the
84
+ * LICENSE file in the root directory of this source tree.
85
+ */
81
86
 
82
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
83
- /**
84
- * Copyright (c) 2014-present, Facebook, Inc.
85
- *
86
- * This source code is licensed under the MIT license found in the
87
- * LICENSE file in the root directory of this source tree.
88
- */
89
- var runtime = function (exports) {
87
+ (function (module) {
88
+ var runtime = /*#__PURE__*/function (exports) {
90
89
 
91
90
  var Op = Object.prototype;
92
91
  var hasOwn = Op.hasOwnProperty;
@@ -172,13 +171,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
172
171
 
173
172
 
174
173
  var IteratorPrototype = {};
175
-
176
- IteratorPrototype[iteratorSymbol] = function () {
174
+ define(IteratorPrototype, iteratorSymbol, function () {
177
175
  return this;
178
- };
179
-
176
+ });
180
177
  var getProto = Object.getPrototypeOf;
181
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
178
+ var NativeIteratorPrototype = getProto && /*#__PURE__*/getProto( /*#__PURE__*/getProto( /*#__PURE__*/values([])));
182
179
 
183
180
  if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
184
181
  // This environment has a native %IteratorPrototype%; use it instead
@@ -186,10 +183,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
186
183
  IteratorPrototype = NativeIteratorPrototype;
187
184
  }
188
185
 
189
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
190
- GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
191
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
192
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
186
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = /*#__PURE__*/Object.create(IteratorPrototype);
187
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
188
+ define(Gp, "constructor", GeneratorFunctionPrototype);
189
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
190
+ GeneratorFunction.displayName = /*#__PURE__*/define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
193
191
  // Iterator interface in terms of a single ._invoke method.
194
192
 
195
193
  function defineIteratorMethods(prototype) {
@@ -293,11 +291,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
293
291
  }
294
292
 
295
293
  defineIteratorMethods(AsyncIterator.prototype);
296
-
297
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
294
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
298
295
  return this;
299
- };
300
-
296
+ });
301
297
  exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
302
298
  // AsyncIterator objects; they just return a Promise for the value of
303
299
  // the final result produced by the iterator.
@@ -474,13 +470,12 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
474
470
  // object to not be returned from this call. This ensures that doesn't happen.
475
471
  // See https://github.com/facebook/regenerator/issues/274 for more details.
476
472
 
477
- Gp[iteratorSymbol] = function () {
473
+ define(Gp, iteratorSymbol, function () {
478
474
  return this;
479
- };
480
-
481
- Gp.toString = function () {
475
+ });
476
+ define(Gp, "toString", function () {
482
477
  return "[object Generator]";
483
- };
478
+ });
484
479
 
485
480
  function pushTryEntry(locs) {
486
481
  var entry = {
@@ -785,25 +780,32 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
785
780
  // as the regeneratorRuntime namespace. Otherwise create a new empty
786
781
  // object. Either way, the resulting object will be used to initialize
787
782
  // the regeneratorRuntime variable at the top of this file.
788
- module.exports );
783
+ module.exports );
789
784
 
790
785
  try {
791
786
  regeneratorRuntime = runtime;
792
787
  } catch (accidentalStrictMode) {
793
788
  // This module should not be running in strict mode, so the above
794
789
  // assignment should always work unless something is misconfigured. Just
795
- // in case runtime.js accidentally runs in strict mode, we can escape
790
+ // in case runtime.js accidentally runs in strict mode, in modern engines
791
+ // we can explicitly access globalThis. In older engines we can escape
796
792
  // strict mode using a global Function call. This could conceivably fail
797
793
  // if a Content Security Policy forbids using Function, but in that case
798
794
  // the proper solution is to fix the accidental strict mode problem. If
799
795
  // you've misconfigured your bundler to force strict mode and applied a
800
796
  // CSP to forbid Function, and you're not willing to fix either of those
801
797
  // problems, please detail your unique predicament in a GitHub issue.
802
- Function("r", "regeneratorRuntime = r")(runtime);
798
+ if (typeof globalThis === "object") {
799
+ globalThis.regeneratorRuntime = runtime;
800
+ } else {
801
+ Function("r", "regeneratorRuntime = r")(runtime);
802
+ }
803
803
  }
804
- });
804
+ })(runtime);
805
805
 
806
- var initialState = {
806
+ var _regeneratorRuntime = runtime.exports;
807
+
808
+ var initialState$1 = {
807
809
  status: 'AUTHENTICATING'
808
810
  };
809
811
  function authReducer(state, event) {
@@ -815,7 +817,7 @@ function authReducer(state, event) {
815
817
  };
816
818
 
817
819
  case 'LOGOUT':
818
- return initialState;
820
+ return initialState$1;
819
821
 
820
822
  case 'ERROR':
821
823
  return {
@@ -833,6 +835,7 @@ function authReducer(state, event) {
833
835
  }
834
836
  }
835
837
 
838
+ var _excluded$2 = ["children", "decorateUser"];
836
839
  var POST_LOGIN_ROUTE_KEY = '@entur-partner:post-login-route';
837
840
 
838
841
  var redirect = function redirect(pathname) {
@@ -850,15 +853,15 @@ var useAuth = function useAuth() {
850
853
  assertIsDefined(auth, 'A `<Auth0Provider>` component needs to be higher up in the component hierarchy.');
851
854
  return auth;
852
855
  };
853
- var initialState$1 = {
856
+ var initialState = {
854
857
  status: 'AUTHENTICATING'
855
858
  };
856
859
  var AuthProvider = function AuthProvider(_ref) {
857
860
  var children = _ref.children,
858
861
  decorateUser = _ref.decorateUser,
859
- initOptions = _objectWithoutPropertiesLoose(_ref, ["children", "decorateUser"]);
862
+ initOptions = _objectWithoutPropertiesLoose(_ref, _excluded$2);
860
863
 
861
- var _useReducer = useReducer(authReducer, initialState$1),
864
+ var _useReducer = useReducer(authReducer, initialState),
862
865
  state = _useReducer[0],
863
866
  dispatch = _useReducer[1];
864
867
 
@@ -868,9 +871,9 @@ var AuthProvider = function AuthProvider(_ref) {
868
871
 
869
872
  useEffect(function () {
870
873
  var initAuth0 = /*#__PURE__*/function () {
871
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
874
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
872
875
  var client, route, postLoginRoute, isAuthenticated, auth0User, token, user;
873
- return runtime_1.wrap(function _callee$(_context) {
876
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
874
877
  while (1) {
875
878
  switch (_context.prev = _context.next) {
876
879
  case 0:
@@ -969,10 +972,10 @@ var AuthProvider = function AuthProvider(_ref) {
969
972
  };
970
973
 
971
974
  var login = /*#__PURE__*/function () {
972
- var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(redirectUri) {
975
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(redirectUri) {
973
976
  var _window, location;
974
977
 
975
- return runtime_1.wrap(function _callee2$(_context2) {
978
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
976
979
  while (1) {
977
980
  switch (_context2.prev = _context2.next) {
978
981
  case 0:
@@ -1001,8 +1004,8 @@ var AuthProvider = function AuthProvider(_ref) {
1001
1004
  }();
1002
1005
 
1003
1006
  var getToken = /*#__PURE__*/function () {
1004
- var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(options) {
1005
- return runtime_1.wrap(function _callee3$(_context3) {
1007
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
1008
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1006
1009
  while (1) {
1007
1010
  switch (_context3.prev = _context3.next) {
1008
1011
  case 0:
@@ -1111,6 +1114,8 @@ var AppShell = function AppShell(_ref3) {
1111
1114
  }));
1112
1115
  };
1113
1116
 
1117
+ var _excluded$1 = ["navigate", "children", "onClick", "target"];
1118
+
1114
1119
  function isModifiedEvent(event) {
1115
1120
  return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1116
1121
  }
@@ -1120,9 +1125,9 @@ var MicroFrontendLink = function MicroFrontendLink(_ref) {
1120
1125
  children = _ref.children,
1121
1126
  _onClick = _ref.onClick,
1122
1127
  target = _ref.target,
1123
- rest = _objectWithoutPropertiesLoose(_ref, ["navigate", "children", "onClick", "target"]);
1128
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
1124
1129
 
1125
- return React.createElement("a", Object.assign({
1130
+ return React.createElement("a", _extends({
1126
1131
  onClick: function onClick(event) {
1127
1132
  try {
1128
1133
  if (_onClick) _onClick(event);
@@ -1136,9 +1141,9 @@ var MicroFrontendLink = function MicroFrontendLink(_ref) {
1136
1141
  !target || target === '_self') && // let browser handle "target=_blank" etc.
1137
1142
  !isModifiedEvent(event) // ignore clicks with modifier keys
1138
1143
  ) {
1139
- event.preventDefault();
1140
- navigate();
1141
- }
1144
+ event.preventDefault();
1145
+ navigate();
1146
+ }
1142
1147
  },
1143
1148
  target: target
1144
1149
  }, rest), children);
@@ -1148,7 +1153,11 @@ var MenuContext = /*#__PURE__*/React.createContext({
1148
1153
  addItems: function addItems() {},
1149
1154
  getItemsForPath: function getItemsForPath() {
1150
1155
  return [];
1151
- }
1156
+ },
1157
+ getMFNavigate: function getMFNavigate() {
1158
+ return undefined;
1159
+ },
1160
+ setMFNavigate: function setMFNavigate() {}
1152
1161
  });
1153
1162
  var useMenuGroupItems = function useMenuGroupItems(path) {
1154
1163
  var context = useContext(MenuContext);
@@ -1157,6 +1166,12 @@ var useMenuGroupItems = function useMenuGroupItems(path) {
1157
1166
  var useMenu = function useMenu() {
1158
1167
  return useContext(MenuContext);
1159
1168
  };
1169
+ var useMFNavigation = function useMFNavigation(path) {
1170
+ var _useMenu = useMenu(),
1171
+ getMFNavigate = _useMenu.getMFNavigate;
1172
+
1173
+ return getMFNavigate(path);
1174
+ };
1160
1175
  var MenuProvider = function MenuProvider(_ref) {
1161
1176
  var children = _ref.children;
1162
1177
 
@@ -1164,6 +1179,10 @@ var MenuProvider = function MenuProvider(_ref) {
1164
1179
  groups = _useState[0],
1165
1180
  setGroups = _useState[1];
1166
1181
 
1182
+ var _useState2 = useState({}),
1183
+ navFuncs = _useState2[0],
1184
+ setNavFuncs = _useState2[1];
1185
+
1167
1186
  var addItems = useCallback(function (newItems, path) {
1168
1187
  setGroups(function (prevState) {
1169
1188
  var _extends2;
@@ -1171,6 +1190,19 @@ var MenuProvider = function MenuProvider(_ref) {
1171
1190
  return _extends({}, prevState, (_extends2 = {}, _extends2[path] = newItems, _extends2));
1172
1191
  });
1173
1192
  }, [setGroups]);
1193
+
1194
+ var getMFNavigate = function getMFNavigate(path) {
1195
+ return navFuncs[path];
1196
+ };
1197
+
1198
+ var setMFNavigate = function setMFNavigate(path, navigation) {
1199
+ return setNavFuncs(function (prev) {
1200
+ var _extends3;
1201
+
1202
+ return _extends({}, prev, (_extends3 = {}, _extends3[path] = navigation, _extends3));
1203
+ });
1204
+ };
1205
+
1174
1206
  return React.createElement(MenuContext.Provider, {
1175
1207
  value: {
1176
1208
  addItems: addItems,
@@ -1178,7 +1210,9 @@ var MenuProvider = function MenuProvider(_ref) {
1178
1210
  var _groups$path;
1179
1211
 
1180
1212
  return (_groups$path = groups[path]) != null ? _groups$path : [];
1181
- }
1213
+ },
1214
+ getMFNavigate: getMFNavigate,
1215
+ setMFNavigate: setMFNavigate
1182
1216
  }
1183
1217
  }, children);
1184
1218
  };
@@ -1275,12 +1309,13 @@ var LanguageProvider = function LanguageProvider(_ref) {
1275
1309
  }, children);
1276
1310
  };
1277
1311
 
1312
+ var _excluded = ["getToken", "getOrganisations", "value", "onChange"];
1278
1313
  var OrganisationSelector = function OrganisationSelector(_ref) {
1279
1314
  var getToken = _ref.getToken,
1280
1315
  getOrganisations = _ref.getOrganisations,
1281
1316
  value = _ref.value,
1282
1317
  onChange = _ref.onChange,
1283
- rest = _objectWithoutPropertiesLoose(_ref, ["getToken", "getOrganisations", "value", "onChange"]);
1318
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1284
1319
 
1285
1320
  var _useState = useState([]),
1286
1321
  organisations = _useState[0],
@@ -1295,9 +1330,9 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
1295
1330
 
1296
1331
  useEffect(function () {
1297
1332
  var fetchOrganisations = /*#__PURE__*/function () {
1298
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1333
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1299
1334
  var token, organisations;
1300
- return runtime_1.wrap(function _callee$(_context) {
1335
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1301
1336
  while (1) {
1302
1337
  switch (_context.prev = _context.next) {
1303
1338
  case 0:
@@ -1347,7 +1382,7 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
1347
1382
  }));
1348
1383
 
1349
1384
  case 'SUCCESS':
1350
- return React.createElement(OrganisationDropDown, Object.assign({
1385
+ return React.createElement(OrganisationDropDown, _extends({
1351
1386
  label: language === 'nb' ? 'Organisasjon' : 'Organisation',
1352
1387
  selectedOrganisationId: value,
1353
1388
  organisations: organisations,
@@ -1362,5 +1397,5 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
1362
1397
  }
1363
1398
  };
1364
1399
 
1365
- export { AppShell, LanguageProvider, MenuProvider, MicroFrontendLink, OrganisationProvider, OrganisationSelector, languageStorage, organisationStorage, useLanguage, useMenu, useMenuGroupItems, useOrganisation, useOrganisationId };
1400
+ export { AppShell, LanguageProvider, MenuProvider, MicroFrontendLink, OrganisationProvider, OrganisationSelector, languageStorage, organisationStorage, useLanguage, useMFNavigation, useMenu, useMenuGroupItems, useOrganisation, useOrganisationId };
1366
1401
  //# sourceMappingURL=app-shell.esm.js.map