@fluxo-dev/shell 0.0.26 → 0.0.27

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/index.esm.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useState, Suspense, forwardRef, createElement as createElement$2, useEffect, createContext, useContext, useLayoutEffect, useRef, useCallback, useMemo, memo, isValidElement, cloneElement, useImperativeHandle, lazy } from 'react';
3
+ import React__default, { useState, Suspense, forwardRef, createElement as createElement$2, useEffect, useCallback, createContext, useContext, useLayoutEffect, useRef, useMemo, memo, isValidElement, cloneElement, useImperativeHandle, lazy } from 'react';
4
4
  import { useSelector, Provider } from 'react-redux';
5
- import { useLocation, Navigate, Outlet, useNavigate, Link, Route, useSearchParams, createBrowserRouter, RouterProvider } from 'react-router-dom';
6
- import { DataCard, NoData, ConfirmModal, ShellPage, ErrorPage as ErrorPage$1, WaitData, FlxRoutes } from '@fluxo-dev/ui-components';
5
+ import { useLocation, Navigate, Outlet, useNavigate, Link, useOutlet, Route, useSearchParams, createBrowserRouter, RouterProvider } from 'react-router-dom';
6
+ import { DataCard, useFlxNavigate, NoData, ConfirmModal, ShellPage, ErrorPage as ErrorPage$1, WaitData, FlxRoutes } from '@fluxo-dev/ui-components';
7
7
  import { ModuleLoader } from '@fluxo-dev/shell-mfe';
8
- import { Text, TextInput, ActionIcon, useMantineTheme, AppShell, Stack, Group, Burger, Badge, Drawer, NavLink, Popover, Avatar, Center, Divider, Button, Anchor, Tooltip, Space, useMantineColorScheme, UnstyledButton, Box, ThemeIcon, Collapse, ScrollArea, rem, Loader, Grid, PasswordInput, ColorSwatch, FileButton, NumberInput, Alert, ColorInput, Checkbox, Modal, Switch, Select, Chip, LoadingOverlay, Image as Image$1, Menu, Textarea, Table, MultiSelect, Card, MantineProvider } from '@mantine/core';
8
+ import { Text, TextInput, ActionIcon, useMantineTheme, AppShell, Stack, Group, Burger, Badge, Drawer, NavLink, Popover, Avatar, Center, Divider, Button, Tabs, Anchor, Tooltip, Space, useMantineColorScheme, UnstyledButton, Box, ThemeIcon, Collapse, ScrollArea, rem, Loader, Grid, PasswordInput, ColorSwatch, FileButton, NumberInput, Alert, ColorInput, Checkbox, Modal, Switch, Select, Chip, LoadingOverlay, Image as Image$1, Menu, Textarea, Table, MultiSelect, Card, MantineProvider } from '@mantine/core';
9
9
  import { openSpotlight, Spotlight } from '@mantine/spotlight';
10
10
  import { useOs, useHotkeys, useIdle } from '@mantine/hooks';
11
11
  import { AppType, AppState, FluxoStateDispatcher, FluxoClientSys, UserService, AppMenuContextType, ApiKeyService, DomainRoleService, EmailServerProviderType } from '@fluxo-dev/api-client-base';
@@ -1133,17 +1133,78 @@ for (var COLLECTION_NAME in DOMIterables) {
1133
1133
  }
1134
1134
  }
1135
1135
 
1136
- var $$8 = _export;
1137
1136
  var DESCRIPTORS$3 = descriptors;
1137
+ var fails$5 = fails$c;
1138
+ var objectKeys = objectKeys$2;
1139
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1140
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
1141
+ var toObject$2 = toObject$4;
1142
+ var IndexedObject = indexedObject;
1143
+
1144
+ var nativeAssign = Object.assign;
1145
+ var defineProperty$2 = Object.defineProperty;
1146
+
1147
+ // `Object.assign` method
1148
+ // https://tc39.github.io/ecma262/#sec-object.assign
1149
+ var objectAssign$1 = !nativeAssign || fails$5(function () {
1150
+ // should have correct order of operations (Edge bug)
1151
+ if (DESCRIPTORS$3 && nativeAssign({ b: 1 }, nativeAssign(defineProperty$2({}, 'a', {
1152
+ enumerable: true,
1153
+ get: function () {
1154
+ defineProperty$2(this, 'b', {
1155
+ value: 3,
1156
+ enumerable: false
1157
+ });
1158
+ }
1159
+ }), { b: 2 })).b !== 1) return true;
1160
+ // should work with symbols and should have deterministic property order (V8 bug)
1161
+ var A = {};
1162
+ var B = {};
1163
+ // eslint-disable-next-line no-undef
1164
+ var symbol = Symbol();
1165
+ var alphabet = 'abcdefghijklmnopqrst';
1166
+ A[symbol] = 7;
1167
+ alphabet.split('').forEach(function (chr) { B[chr] = chr; });
1168
+ return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
1169
+ }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
1170
+ var T = toObject$2(target);
1171
+ var argumentsLength = arguments.length;
1172
+ var index = 1;
1173
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1174
+ var propertyIsEnumerable = propertyIsEnumerableModule.f;
1175
+ while (argumentsLength > index) {
1176
+ var S = IndexedObject(arguments[index++]);
1177
+ var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
1178
+ var length = keys.length;
1179
+ var j = 0;
1180
+ var key;
1181
+ while (length > j) {
1182
+ key = keys[j++];
1183
+ if (!DESCRIPTORS$3 || propertyIsEnumerable.call(S, key)) T[key] = S[key];
1184
+ }
1185
+ } return T;
1186
+ } : nativeAssign;
1187
+
1188
+ var $$8 = _export;
1189
+ var assign$1 = objectAssign$1;
1190
+
1191
+ // `Object.assign` method
1192
+ // https://tc39.github.io/ecma262/#sec-object.assign
1193
+ $$8({ target: 'Object', stat: true, forced: Object.assign !== assign$1 }, {
1194
+ assign: assign$1
1195
+ });
1196
+
1197
+ var $$7 = _export;
1198
+ var DESCRIPTORS$2 = descriptors;
1138
1199
  var global$9 = global$l;
1139
1200
  var has$4 = has$e;
1140
1201
  var isObject$5 = isObject$b;
1141
- var defineProperty$2 = objectDefineProperty.f;
1202
+ var defineProperty$1 = objectDefineProperty.f;
1142
1203
  var copyConstructorProperties = copyConstructorProperties$2;
1143
1204
 
1144
1205
  var NativeSymbol = global$9.Symbol;
1145
1206
 
1146
- if (DESCRIPTORS$3 && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
1207
+ if (DESCRIPTORS$2 && typeof NativeSymbol == 'function' && (!('description' in NativeSymbol.prototype) ||
1147
1208
  // Safari 12 bug
1148
1209
  NativeSymbol().description !== undefined
1149
1210
  )) {
@@ -1163,20 +1224,20 @@ if (DESCRIPTORS$3 && typeof NativeSymbol == 'function' && (!('description' in Na
1163
1224
  symbolPrototype.constructor = SymbolWrapper;
1164
1225
 
1165
1226
  var symbolToString = symbolPrototype.toString;
1166
- var native = String(NativeSymbol('test')) == 'Symbol(test)';
1227
+ var native$1 = String(NativeSymbol('test')) == 'Symbol(test)';
1167
1228
  var regexp = /^Symbol\((.*)\)[^)]+$/;
1168
- defineProperty$2(symbolPrototype, 'description', {
1229
+ defineProperty$1(symbolPrototype, 'description', {
1169
1230
  configurable: true,
1170
1231
  get: function description() {
1171
1232
  var symbol = isObject$5(this) ? this.valueOf() : this;
1172
1233
  var string = symbolToString.call(symbol);
1173
1234
  if (has$4(EmptyStringDescriptionStore, symbol)) return '';
1174
- var desc = native ? string.slice(7, -1) : string.replace(regexp, '$1');
1235
+ var desc = native$1 ? string.slice(7, -1) : string.replace(regexp, '$1');
1175
1236
  return desc === '' ? undefined : desc;
1176
1237
  }
1177
1238
  });
1178
1239
 
1179
- $$8({ global: true, forced: true }, {
1240
+ $$7({ global: true, forced: true }, {
1180
1241
  Symbol: SymbolWrapper
1181
1242
  });
1182
1243
  }
@@ -1195,7 +1256,7 @@ var redefineAll$1 = function (target, src, options) {
1195
1256
  var getBuiltIn$3 = getBuiltIn$6;
1196
1257
  var definePropertyModule = objectDefineProperty;
1197
1258
  var wellKnownSymbol$a = wellKnownSymbol$g;
1198
- var DESCRIPTORS$2 = descriptors;
1259
+ var DESCRIPTORS$1 = descriptors;
1199
1260
 
1200
1261
  var SPECIES$3 = wellKnownSymbol$a('species');
1201
1262
 
@@ -1203,7 +1264,7 @@ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
1203
1264
  var Constructor = getBuiltIn$3(CONSTRUCTOR_NAME);
1204
1265
  var defineProperty = definePropertyModule.f;
1205
1266
 
1206
- if (DESCRIPTORS$2 && Constructor && !Constructor[SPECIES$3]) {
1267
+ if (DESCRIPTORS$1 && Constructor && !Constructor[SPECIES$3]) {
1207
1268
  defineProperty(Constructor, SPECIES$3, {
1208
1269
  configurable: true,
1209
1270
  get: function () { return this; }
@@ -1429,7 +1490,7 @@ var userAgent$1 = engineUserAgent;
1429
1490
  var engineIsIos = /(iphone|ipod|ipad).*applewebkit/i.test(userAgent$1);
1430
1491
 
1431
1492
  var global$7 = global$l;
1432
- var fails$5 = fails$c;
1493
+ var fails$4 = fails$c;
1433
1494
  var classof$4 = classofRaw$1;
1434
1495
  var bind$2 = functionBindContext;
1435
1496
  var html = html$2;
@@ -1510,7 +1571,7 @@ if (!set || !clear) {
1510
1571
  global$7.addEventListener &&
1511
1572
  typeof postMessage == 'function' &&
1512
1573
  !global$7.importScripts &&
1513
- !fails$5(post) &&
1574
+ !fails$4(post) &&
1514
1575
  location.protocol !== 'file:'
1515
1576
  ) {
1516
1577
  defer = post;
@@ -1686,7 +1747,7 @@ if (v8) {
1686
1747
 
1687
1748
  var engineV8Version = version && +version;
1688
1749
 
1689
- var $$7 = _export;
1750
+ var $$6 = _export;
1690
1751
  var global$3 = global$l;
1691
1752
  var getBuiltIn$1 = getBuiltIn$6;
1692
1753
  var NativePromise$1 = nativePromiseConstructor;
@@ -1978,7 +2039,7 @@ if (FORCED$1) {
1978
2039
  }, { unsafe: true });
1979
2040
 
1980
2041
  // wrap fetch result
1981
- if (typeof $fetch == 'function') $$7({ global: true, enumerable: true, forced: true }, {
2042
+ if (typeof $fetch == 'function') $$6({ global: true, enumerable: true, forced: true }, {
1982
2043
  // eslint-disable-next-line no-unused-vars
1983
2044
  fetch: function fetch(input /* , init */) {
1984
2045
  return promiseResolve$1(PromiseConstructor, $fetch.apply(global$3, arguments));
@@ -1987,7 +2048,7 @@ if (FORCED$1) {
1987
2048
  }
1988
2049
  }
1989
2050
 
1990
- $$7({ global: true, wrap: true, forced: FORCED$1 }, {
2051
+ $$6({ global: true, wrap: true, forced: FORCED$1 }, {
1991
2052
  Promise: PromiseConstructor
1992
2053
  });
1993
2054
 
@@ -1997,7 +2058,7 @@ setSpecies(PROMISE);
1997
2058
  PromiseWrapper = getBuiltIn$1(PROMISE);
1998
2059
 
1999
2060
  // statics
2000
- $$7({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2061
+ $$6({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2001
2062
  // `Promise.reject` method
2002
2063
  // https://tc39.github.io/ecma262/#sec-promise.reject
2003
2064
  reject: function reject(r) {
@@ -2007,7 +2068,7 @@ $$7({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2007
2068
  }
2008
2069
  });
2009
2070
 
2010
- $$7({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2071
+ $$6({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2011
2072
  // `Promise.resolve` method
2012
2073
  // https://tc39.github.io/ecma262/#sec-promise.resolve
2013
2074
  resolve: function resolve(x) {
@@ -2015,7 +2076,7 @@ $$7({ target: PROMISE, stat: true, forced: FORCED$1 }, {
2015
2076
  }
2016
2077
  });
2017
2078
 
2018
- $$7({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
2079
+ $$6({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
2019
2080
  // `Promise.all` method
2020
2081
  // https://tc39.github.io/ecma262/#sec-promise.all
2021
2082
  all: function all(iterable) {
@@ -2062,22 +2123,22 @@ $$7({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
2062
2123
  }
2063
2124
  });
2064
2125
 
2065
- var $$6 = _export;
2126
+ var $$5 = _export;
2066
2127
  var NativePromise = nativePromiseConstructor;
2067
- var fails$4 = fails$c;
2128
+ var fails$3 = fails$c;
2068
2129
  var getBuiltIn = getBuiltIn$6;
2069
2130
  var speciesConstructor = speciesConstructor$2;
2070
2131
  var promiseResolve = promiseResolve$2;
2071
2132
  var redefine$1 = redefine$6.exports;
2072
2133
 
2073
2134
  // Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
2074
- var NON_GENERIC = !!NativePromise && fails$4(function () {
2135
+ var NON_GENERIC = !!NativePromise && fails$3(function () {
2075
2136
  NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
2076
2137
  });
2077
2138
 
2078
2139
  // `Promise.prototype.finally` method
2079
2140
  // https://tc39.github.io/ecma262/#sec-promise.prototype.finally
2080
- $$6({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
2141
+ $$5({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
2081
2142
  'finally': function (onFinally) {
2082
2143
  var C = speciesConstructor(this, getBuiltIn('Promise'));
2083
2144
  var isFunction = typeof onFinally == 'function';
@@ -2478,7 +2539,7 @@ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
2478
2539
  var hasOwnProperty = Object.prototype.hasOwnProperty;
2479
2540
  var propIsEnumerable = Object.prototype.propertyIsEnumerable;
2480
2541
 
2481
- function toObject$2(val) {
2542
+ function toObject$1(val) {
2482
2543
  if (val === null || val === undefined) {
2483
2544
  throw new TypeError('Object.assign cannot be called with null or undefined');
2484
2545
  }
@@ -2530,9 +2591,9 @@ function shouldUseNative() {
2530
2591
  }
2531
2592
  }
2532
2593
 
2533
- var objectAssign$1 = shouldUseNative() ? Object.assign : function (target, source) {
2594
+ var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
2534
2595
  var from;
2535
- var to = toObject$2(target);
2596
+ var to = toObject$1(target);
2536
2597
  var symbols;
2537
2598
 
2538
2599
  for (var s = 1; s < arguments.length; s++) {
@@ -2680,7 +2741,7 @@ var checkPropTypes_1 = checkPropTypes$1;
2680
2741
  */
2681
2742
 
2682
2743
  var ReactIs$1 = reactIs.exports;
2683
- var assign$1 = objectAssign$1;
2744
+ var assign = objectAssign;
2684
2745
 
2685
2746
  var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
2686
2747
  var has$1 = has$3;
@@ -3119,7 +3180,7 @@ var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
3119
3180
  return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
3120
3181
  }
3121
3182
  // We need to check all keys in case some are required but missing from props.
3122
- var allKeys = assign$1({}, props[propName], shapeTypes);
3183
+ var allKeys = assign({}, props[propName], shapeTypes);
3123
3184
  for (var key in allKeys) {
3124
3185
  var checker = shapeTypes[key];
3125
3186
  if (has$1(shapeTypes, key) && typeof checker !== 'function') {
@@ -4525,8 +4586,310 @@ function AppBar(props) {
4525
4586
  });
4526
4587
  }
4527
4588
 
4528
- function AppContent() {
4529
- return jsx(Outlet, {});
4589
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
4590
+ // require the crypto API and do not support built-in fallback to lower quality random number
4591
+ // generators (like Math.random()).
4592
+ let getRandomValues;
4593
+ const rnds8 = new Uint8Array(16);
4594
+ function rng() {
4595
+ // lazy load so that environments that need to polyfill have a chance to do so
4596
+ if (!getRandomValues) {
4597
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
4598
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
4599
+
4600
+ if (!getRandomValues) {
4601
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
4602
+ }
4603
+ }
4604
+
4605
+ return getRandomValues(rnds8);
4606
+ }
4607
+
4608
+ /**
4609
+ * Convert array of 16 byte values to UUID string format of the form:
4610
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4611
+ */
4612
+
4613
+ const byteToHex = [];
4614
+
4615
+ for (let i = 0; i < 256; ++i) {
4616
+ byteToHex.push((i + 0x100).toString(16).slice(1));
4617
+ }
4618
+
4619
+ function unsafeStringify(arr, offset = 0) {
4620
+ // Note: Be careful editing this code! It's been tuned for performance
4621
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
4622
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
4623
+ }
4624
+
4625
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
4626
+ var native = {
4627
+ randomUUID
4628
+ };
4629
+
4630
+ function v4(options, buf, offset) {
4631
+ if (native.randomUUID && !buf && !options) {
4632
+ return native.randomUUID();
4633
+ }
4634
+
4635
+ options = options || {};
4636
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
4637
+
4638
+ rnds[6] = rnds[6] & 0x0f | 0x40;
4639
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
4640
+
4641
+ if (buf) {
4642
+ offset = offset || 0;
4643
+
4644
+ for (let i = 0; i < 16; ++i) {
4645
+ buf[offset + i] = rnds[i];
4646
+ }
4647
+
4648
+ return buf;
4649
+ }
4650
+
4651
+ return unsafeStringify(rnds);
4652
+ }
4653
+
4654
+ class ShellSessionCollection {
4655
+ constructor(sessions = [], currentSessionId) {
4656
+ this._sessions = sessions;
4657
+ this._currentSessionId = currentSessionId;
4658
+ }
4659
+ get currentSession() {
4660
+ return this._currentSessionId ? this.getSession(this._currentSessionId) : null;
4661
+ }
4662
+ addSession(title, element, url) {
4663
+ const session = new ShellSession(title, element, url);
4664
+ this._sessions.push(session);
4665
+ return session;
4666
+ }
4667
+ removeSession(id) {
4668
+ this._sessions = this._sessions.filter(s => s.id !== id);
4669
+ }
4670
+ getSession(id) {
4671
+ return this._sessions.find(s => s.id === id);
4672
+ }
4673
+ get sessions() {
4674
+ return this._sessions;
4675
+ }
4676
+ getCurrentSessionId() {
4677
+ return this._currentSessionId;
4678
+ }
4679
+ getCurrentSession() {
4680
+ return this.getSession(this._currentSessionId);
4681
+ }
4682
+ setCurrentSession(id) {
4683
+ this._currentSessionId = id;
4684
+ }
4685
+ updateSession(id, title, element, url) {
4686
+ const session = this.getSession(id);
4687
+ if (session) {
4688
+ session.updateSession(title, element, url);
4689
+ }
4690
+ }
4691
+ getPreviuosSessionId() {
4692
+ const index = this._sessions.findIndex(s => s.id === this._currentSessionId);
4693
+ if (index > 0) {
4694
+ return this._sessions[index - 1].id;
4695
+ }
4696
+ return this._sessions[this._sessions.length - 1].id;
4697
+ }
4698
+ getNextSessionId() {
4699
+ const index = this._sessions.findIndex(s => s.id === this._currentSessionId);
4700
+ if (index < this._sessions.length - 1) {
4701
+ return this._sessions[index + 1].id;
4702
+ }
4703
+ return this._sessions[0].id;
4704
+ }
4705
+ }
4706
+ class ShellSession {
4707
+ constructor(title, element, url) {
4708
+ this._id = v4();
4709
+ this._title = title;
4710
+ this._element = element;
4711
+ this._url = url;
4712
+ }
4713
+ get id() {
4714
+ return this._id;
4715
+ }
4716
+ get title() {
4717
+ return this._title;
4718
+ }
4719
+ get element() {
4720
+ return this._element;
4721
+ }
4722
+ get url() {
4723
+ return this._url;
4724
+ }
4725
+ updateSession(title, element, url) {
4726
+ this._title = title;
4727
+ this._element = element;
4728
+ this._url = url;
4729
+ }
4730
+ }
4731
+
4732
+ const defaultState = {
4733
+ addSession: () => '',
4734
+ removeSession: () => {},
4735
+ getSession: () => {},
4736
+ sessions: () => [],
4737
+ updateSession: () => {},
4738
+ getCurrentSessionId: () => null,
4739
+ getCurrentSession: () => null,
4740
+ setCurrentSession: () => {},
4741
+ isCurrentSessionDisableable: () => false
4742
+ };
4743
+ const ShellSessionContext = /*#__PURE__*/React__default.createContext(defaultState);
4744
+ function ShellSessionProvider(props) {
4745
+ useHotkeys([['shift+s', () => {
4746
+ addSession(`Dashboard`, null, '/');
4747
+ }]]);
4748
+ useHotkeys([['shift+x', () => {
4749
+ removeSession(getCurrentSessionId());
4750
+ }]], [], true);
4751
+ useHotkeys([['shift+ArrowLeft', () => {
4752
+ setCurrentSession(sessionCollection.getPreviuosSessionId());
4753
+ }]], [], true);
4754
+ useHotkeys([['shift+ArrowRight', () => {
4755
+ setCurrentSession(sessionCollection.getNextSessionId());
4756
+ }]], [], true);
4757
+ const [sessionCollection, setSessionCollection] = React__default.useState(new ShellSessionCollection([], null));
4758
+ const navigate = useFlxNavigate();
4759
+ const addSession = useCallback((title, element, url) => {
4760
+ const cloned = new ShellSessionCollection(sessionCollection.sessions, sessionCollection.getCurrentSessionId());
4761
+ const s = cloned.addSession(title, element, url);
4762
+ cloned.setCurrentSession(s.id);
4763
+ setSessionCollection(cloned);
4764
+ navigate(s.url, {
4765
+ state: {
4766
+ title: title
4767
+ }
4768
+ });
4769
+ return s.id;
4770
+ }, [sessionCollection]);
4771
+ const removeSession = useCallback(id => {
4772
+ if (!isCurrentSessionDisableable()) return;
4773
+ const cloned = new ShellSessionCollection(sessionCollection.sessions, sessionCollection.getCurrentSessionId());
4774
+ cloned.removeSession(id);
4775
+ cloned.setCurrentSession(cloned.sessions[cloned.sessions.length - 1].id);
4776
+ setSessionCollection(cloned);
4777
+ }, [sessionCollection]);
4778
+ const getSession = useCallback(id => {
4779
+ return sessionCollection.getSession(id);
4780
+ }, [sessionCollection]);
4781
+ const sessions = useCallback(() => {
4782
+ return sessionCollection.sessions;
4783
+ }, [sessionCollection]);
4784
+ const updateSession = useCallback((id, title, element, url) => {
4785
+ const cloned = new ShellSessionCollection(sessionCollection.sessions, sessionCollection.getCurrentSessionId());
4786
+ cloned.updateSession(id, title, element, url);
4787
+ setSessionCollection(cloned);
4788
+ }, [sessionCollection]);
4789
+ const setCurrentSession = useCallback(id => {
4790
+ const cloned = new ShellSessionCollection(sessionCollection.sessions, id);
4791
+ cloned.setCurrentSession(id);
4792
+ setSessionCollection(cloned);
4793
+ navigate(cloned.getCurrentSession().url, {
4794
+ state: {
4795
+ title: cloned.getCurrentSession().title
4796
+ }
4797
+ });
4798
+ }, [sessionCollection]);
4799
+ const getCurrentSessionId = useCallback(() => {
4800
+ return sessionCollection.getCurrentSessionId();
4801
+ }, [sessionCollection]);
4802
+ const getCurrentSession = useCallback(() => {
4803
+ return sessionCollection.getCurrentSession();
4804
+ }, [sessionCollection]);
4805
+ const isCurrentSessionDisableable = useCallback(() => {
4806
+ return sessionCollection.sessions.length > 1;
4807
+ }, [sessionCollection]);
4808
+ return jsx(ShellSessionContext.Provider, {
4809
+ value: {
4810
+ sessions: sessions,
4811
+ addSession: addSession,
4812
+ removeSession: removeSession,
4813
+ getSession: getSession,
4814
+ updateSession: updateSession,
4815
+ getCurrentSessionId: getCurrentSessionId,
4816
+ getCurrentSession: getCurrentSession,
4817
+ setCurrentSession: setCurrentSession,
4818
+ isCurrentSessionDisableable: isCurrentSessionDisableable
4819
+ },
4820
+ children: props.children
4821
+ });
4822
+ }
4823
+
4824
+ function AppContent(props) {
4825
+ const sessionContext = React__default.useContext(ShellSessionContext);
4826
+ useEffect(() => {
4827
+ if (props.withMultipleSessions) {
4828
+ const newSessionId = sessionContext.addSession('Dashboard', null, '/');
4829
+ sessionContext.setCurrentSession(newSessionId);
4830
+ }
4831
+ }, []);
4832
+ const outletContext = useOutlet();
4833
+ const location = useLocation();
4834
+ useEffect(() => {
4835
+ var _a, _b;
4836
+ if (props.withMultipleSessions) {
4837
+ const currentSession = sessionContext.getCurrentSession();
4838
+ if (currentSession) {
4839
+ sessionContext.updateSession(currentSession.id, (_b = (_a = location.state) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : 'Sessione', outletContext, location.pathname);
4840
+ }
4841
+ }
4842
+ }, [location]);
4843
+ return jsx(Fragment, {
4844
+ children: props.withMultipleSessions ? jsxs(Tabs, {
4845
+ value: sessionContext.getCurrentSessionId(),
4846
+ keepMounted: true,
4847
+ children: [jsxs(Tabs.List, {
4848
+ style: {
4849
+ alignItems: 'center',
4850
+ position: 'sticky',
4851
+ width: '100%',
4852
+ overflowAnchor: 'none',
4853
+ top: 48,
4854
+ zIndex: 50,
4855
+ marginBottom: 0,
4856
+ background: '#fff'
4857
+ },
4858
+ children: [sessionContext.sessions().map((session, i) => {
4859
+ return jsx(Tabs.Tab, {
4860
+ style: {
4861
+ borderTop: '2px solid #ececec'
4862
+ },
4863
+ value: session.id,
4864
+ onClick: v => {
4865
+ sessionContext.setCurrentSession(session.id);
4866
+ },
4867
+ children: session.title
4868
+ }, session.id);
4869
+ }), jsxs(Group, {
4870
+ ml: 'auto',
4871
+ children: [jsx(ActionIcon, {
4872
+ disabled: !sessionContext.isCurrentSessionDisableable(),
4873
+ onClick: () => sessionContext.removeSession(sessionContext.getCurrentSessionId()),
4874
+ children: jsx(IconX, {
4875
+ size: 18
4876
+ })
4877
+ }), jsx(ActionIcon, {
4878
+ onClick: () => sessionContext.addSession("Test", null, "/"),
4879
+ ml: 'auto',
4880
+ children: jsx(IconPlus, {
4881
+ size: 18
4882
+ })
4883
+ })]
4884
+ })]
4885
+ }), sessionContext.sessions().map(session => {
4886
+ return jsx(Tabs.Panel, {
4887
+ value: session.id,
4888
+ children: session.element
4889
+ }, session.id);
4890
+ })]
4891
+ }) : jsx(Outlet, {})
4892
+ });
4530
4893
  }
4531
4894
 
4532
4895
  function FooterBar(props) {
@@ -4607,6 +4970,9 @@ function FooterBar(props) {
4607
4970
  children: [hasAdminAccess && jsxs(Fragment, {
4608
4971
  children: [jsx(Link, {
4609
4972
  to: '/settings',
4973
+ state: {
4974
+ title: 'Amministrazione'
4975
+ },
4610
4976
  style: {
4611
4977
  textDecoration: 'none'
4612
4978
  },
@@ -4687,6 +5053,9 @@ function NavBarItem({
4687
5053
  color: colorScheme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],
4688
5054
  borderLeft: `1px solid ${colorScheme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`
4689
5055
  },
5056
+ state: {
5057
+ title: link.label
5058
+ },
4690
5059
  to: '/' + link.routerLink,
4691
5060
  children: link.label
4692
5061
  }, link.label + '_' + i);
@@ -4696,7 +5065,11 @@ function NavBarItem({
4696
5065
  children: navbarOpened ? jsxs(Fragment, {
4697
5066
  children: [jsx(UnstyledButton, {
4698
5067
  onClick: () => {
4699
- if (hasLinks) setOpened(o => !o);else navigate('/' + routerLink);
5068
+ if (hasLinks) setOpened(o => !o);else navigate('/' + routerLink, {
5069
+ state: {
5070
+ title: label
5071
+ }
5072
+ });
4700
5073
  },
4701
5074
  className: level === 0 ? style['control'] : style['controlSub'],
4702
5075
  children: jsxs(Group, {
@@ -4835,67 +5208,6 @@ function Navbar() {
4835
5208
  });
4836
5209
  }
4837
5210
 
4838
- var DESCRIPTORS$1 = descriptors;
4839
- var fails$3 = fails$c;
4840
- var objectKeys = objectKeys$2;
4841
- var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
4842
- var propertyIsEnumerableModule = objectPropertyIsEnumerable;
4843
- var toObject$1 = toObject$4;
4844
- var IndexedObject = indexedObject;
4845
-
4846
- var nativeAssign = Object.assign;
4847
- var defineProperty$1 = Object.defineProperty;
4848
-
4849
- // `Object.assign` method
4850
- // https://tc39.github.io/ecma262/#sec-object.assign
4851
- var objectAssign = !nativeAssign || fails$3(function () {
4852
- // should have correct order of operations (Edge bug)
4853
- if (DESCRIPTORS$1 && nativeAssign({ b: 1 }, nativeAssign(defineProperty$1({}, 'a', {
4854
- enumerable: true,
4855
- get: function () {
4856
- defineProperty$1(this, 'b', {
4857
- value: 3,
4858
- enumerable: false
4859
- });
4860
- }
4861
- }), { b: 2 })).b !== 1) return true;
4862
- // should work with symbols and should have deterministic property order (V8 bug)
4863
- var A = {};
4864
- var B = {};
4865
- // eslint-disable-next-line no-undef
4866
- var symbol = Symbol();
4867
- var alphabet = 'abcdefghijklmnopqrst';
4868
- A[symbol] = 7;
4869
- alphabet.split('').forEach(function (chr) { B[chr] = chr; });
4870
- return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
4871
- }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
4872
- var T = toObject$1(target);
4873
- var argumentsLength = arguments.length;
4874
- var index = 1;
4875
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
4876
- var propertyIsEnumerable = propertyIsEnumerableModule.f;
4877
- while (argumentsLength > index) {
4878
- var S = IndexedObject(arguments[index++]);
4879
- var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
4880
- var length = keys.length;
4881
- var j = 0;
4882
- var key;
4883
- while (length > j) {
4884
- key = keys[j++];
4885
- if (!DESCRIPTORS$1 || propertyIsEnumerable.call(S, key)) T[key] = S[key];
4886
- }
4887
- } return T;
4888
- } : nativeAssign;
4889
-
4890
- var $$5 = _export;
4891
- var assign = objectAssign;
4892
-
4893
- // `Object.assign` method
4894
- // https://tc39.github.io/ecma262/#sec-object.assign
4895
- $$5({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
4896
- assign: assign
4897
- });
4898
-
4899
5211
  class AppMenuService {
4900
5212
  getSpotlightMenu(menu, parentTitle) {
4901
5213
  return __awaiter(this, void 0, void 0, function* () {
@@ -4940,7 +5252,11 @@ function ShellSpotlight() {
4940
5252
  return Object.assign(Object.assign({}, group), {
4941
5253
  actions: group.actions.map(action => {
4942
5254
  return Object.assign(Object.assign({}, action), {
4943
- onClick: () => navigateTo(action.id)
5255
+ onClick: () => navigateTo(action.id, {
5256
+ state: {
5257
+ title: action.label
5258
+ }
5259
+ })
4944
5260
  });
4945
5261
  })
4946
5262
  });
@@ -4972,7 +5288,7 @@ function AppLayout(props) {
4972
5288
  const {
4973
5289
  navbarOpened
4974
5290
  } = useSelector(state => state.layout);
4975
- return jsxs(Fragment, {
5291
+ return jsxs(ShellSessionProvider, {
4976
5292
  children: [jsxs(AppShell, {
4977
5293
  padding: 0,
4978
5294
  styles: {
@@ -5001,7 +5317,9 @@ function AppLayout(props) {
5001
5317
  }), jsx(Navbar, {}), jsx(AppShell.Main, {
5002
5318
  children: jsx(Suspense, {
5003
5319
  fallback: jsx(Loader, {}),
5004
- children: jsx(AppContent, {})
5320
+ children: jsx(AppContent, {
5321
+ withMultipleSessions: props.withMultipleSessions
5322
+ })
5005
5323
  })
5006
5324
  }), jsx(AppShell.Footer, {
5007
5325
  children: jsx(FooterBar, {
@@ -30190,12 +30508,16 @@ function FluxoShell(props) {
30190
30508
  const generateRoutesFromEmbeddedModules = frontend => {
30191
30509
  const embeddedModules = [...frontend.modules, reportsModule, workflowModule];
30192
30510
  const rObjs = [];
30511
+ let routes = {};
30193
30512
  embeddedModules.forEach(eModule => {
30194
30513
  rObjs.push({
30195
30514
  path: `/${eModule.scope}/${eModule.name}/*`,
30196
30515
  children: eModule.getRouteObject()
30197
30516
  });
30517
+ const aa = eModule.getRouteMap();
30518
+ routes = Object.assign(Object.assign({}, routes), aa);
30198
30519
  });
30520
+ FluxoStateDispatcher.dispatchSetRoutes(routes);
30199
30521
  return rObjs;
30200
30522
  };
30201
30523
  const generateRoutesFromJitApps = frontend => {
@@ -30357,6 +30679,7 @@ function FluxoShell(props) {
30357
30679
  const FrontendLayout = () => {
30358
30680
  var _a, _b;
30359
30681
  return (_a = frontendByRender === null || frontendByRender === void 0 ? void 0 : frontendByRender.layout) !== null && _a !== void 0 ? _a : jsx(AppLayout, {
30682
+ withMultipleSessions: props.withMultipleSessions,
30360
30683
  brandName: (_b = props.brandName) !== null && _b !== void 0 ? _b : 'Fluxo',
30361
30684
  appVersion: props.appVersion
30362
30685
  });
@@ -30376,6 +30699,7 @@ function FluxoShell(props) {
30376
30699
  FluxoStateDispatcher.dispatchSetCurrentFrontend(res.currentFrontend);
30377
30700
  FluxoStateDispatcher.dispatchAllowedFrontends(res.frontends);
30378
30701
  FluxoStateDispatcher.dispatchHasAdminAccess(res.hasAdminAccess);
30702
+ if (props.withMultipleSessions) FluxoStateDispatcher.dispatchSetSessionMode('multi-session');else FluxoStateDispatcher.dispatchSetSessionMode('single-session');
30379
30703
  const rObjs = [generateAuthRoutes(), {
30380
30704
  path: 'frontend-switcher',
30381
30705
  element: jsx(ProtectedRoute, {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fluxo-dev/shell",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "peerDependencies": {
5
- "@fluxo-dev/shell-hub": "0.0.26",
6
- "@fluxo-dev/shell-korebi": "0.0.26",
7
- "@fluxo-dev/shell-mfe": "0.0.26",
8
- "@fluxo-dev/shell-printing": "0.0.26",
9
- "@fluxo-dev/shell-reporting": "0.0.26",
10
- "@fluxo-dev/shell-workflow": "0.0.26"
5
+ "@fluxo-dev/shell-hub": "0.0.27",
6
+ "@fluxo-dev/shell-korebi": "0.0.27",
7
+ "@fluxo-dev/shell-mfe": "0.0.27",
8
+ "@fluxo-dev/shell-printing": "0.0.27",
9
+ "@fluxo-dev/shell-reporting": "0.0.27",
10
+ "@fluxo-dev/shell-workflow": "0.0.27"
11
11
  },
12
12
  "module": "./index.esm.js",
13
13
  "type": "module",
package/src/lib/app.d.ts CHANGED
@@ -16,6 +16,7 @@ export interface FluxoShellProps {
16
16
  frontends: ShellFrontend[];
17
17
  clientInitialization: () => Promise<void>;
18
18
  brandName?: string;
19
+ withMultipleSessions: boolean;
19
20
  }
20
21
  export declare function FluxoShell(props: FluxoShellProps): import("react/jsx-runtime").JSX.Element;
21
22
  export default FluxoShell;
@@ -1,6 +1,7 @@
1
1
  export interface AppLayoutProps {
2
2
  appVersion: string;
3
3
  brandName: string;
4
+ withMultipleSessions: boolean;
4
5
  }
5
6
  declare function AppLayout(props: AppLayoutProps): import("react/jsx-runtime").JSX.Element;
6
7
  export default AppLayout;
@@ -1,2 +1,5 @@
1
- declare function AppContent(): import("react/jsx-runtime").JSX.Element;
1
+ export interface AppContentProps {
2
+ withMultipleSessions: boolean;
3
+ }
4
+ declare function AppContent(props: AppContentProps): import("react/jsx-runtime").JSX.Element;
2
5
  export default AppContent;
@@ -0,0 +1,18 @@
1
+ import { ShellSession } from "./shell-session";
2
+ import React from "react";
3
+ interface ShellSessionContextData {
4
+ addSession: (title: string, element: React.ReactElement | null, url: string) => string;
5
+ removeSession: (id: string) => void;
6
+ getSession: (id: string) => void;
7
+ sessions: () => ShellSession[];
8
+ updateSession: (id: string, title: string, element: React.ReactElement | null, url: string) => void;
9
+ getCurrentSessionId: () => string | null;
10
+ getCurrentSession: () => ShellSession | null | undefined;
11
+ setCurrentSession: (id: string) => void;
12
+ isCurrentSessionDisableable: () => boolean;
13
+ }
14
+ export declare const ShellSessionContext: React.Context<ShellSessionContextData>;
15
+ export declare function ShellSessionProvider(props: {
16
+ children: React.ReactNode;
17
+ }): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ export declare class ShellSessionCollection {
3
+ private _sessions;
4
+ private _currentSessionId;
5
+ constructor(sessions: ShellSession[] | undefined, currentSessionId: string | null);
6
+ get currentSession(): ShellSession | null | undefined;
7
+ addSession(title: string, element: React.ReactElement | null, url: string): ShellSession;
8
+ removeSession(id: string): void;
9
+ getSession(id: string): ShellSession | undefined;
10
+ get sessions(): ShellSession[];
11
+ getCurrentSessionId(): string | null;
12
+ getCurrentSession(): ShellSession | null | undefined;
13
+ setCurrentSession(id: string): void;
14
+ updateSession(id: string, title: string, element: React.ReactElement | null, url: string): void;
15
+ getPreviuosSessionId(): string;
16
+ getNextSessionId(): string;
17
+ }
18
+ export declare class ShellSession {
19
+ private readonly _id;
20
+ private _title;
21
+ private _element;
22
+ private _url;
23
+ constructor(title: string, element: React.ReactElement | null, url: string);
24
+ get id(): string;
25
+ get title(): string;
26
+ get element(): React.ReactElement | null;
27
+ get url(): string;
28
+ updateSession(title: string, element: React.ReactElement | null, url: string): void;
29
+ }