@mcurros2/microm 1.1.319-0 → 1.1.321-0
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/index.d.ts +21 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +104 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -826,6 +826,7 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
|
|
|
826
826
|
if (data?.requires_two_factor && data?.two_factor_challenge_id) return data;
|
|
827
827
|
if (data && data.access_token) {
|
|
828
828
|
const token = new (0, $78KzE.MicroMToken)(data.access_token, data.expires_in, data['refresh-token'], data.token_type, data);
|
|
829
|
+
await this.#deleteEnabledMenus();
|
|
829
830
|
await this.#setToken(token);
|
|
830
831
|
try {
|
|
831
832
|
await this.#DATA_STORAGE.saveData(this.#APP_ID, $16abd72d1aa9b62d$var$REMEMBER_USER_DATA_KEY, rememberme ? username : null);
|
|
@@ -884,6 +885,7 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
|
|
|
884
885
|
const data = await response.json();
|
|
885
886
|
if (data && data.access_token) {
|
|
886
887
|
const token = new (0, $78KzE.MicroMToken)(data.access_token, data.expires_in, data['refresh-token'], data.token_type, data);
|
|
888
|
+
await this.#deleteEnabledMenus();
|
|
887
889
|
await this.#setToken(token);
|
|
888
890
|
try {
|
|
889
891
|
await this.#DATA_STORAGE.saveData(this.#APP_ID, $16abd72d1aa9b62d$var$REMEMBER_USER_DATA_KEY, rememberme ? username ?? null : null);
|
|
@@ -1267,6 +1269,10 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
|
|
|
1267
1269
|
}
|
|
1268
1270
|
async #loadToken() {
|
|
1269
1271
|
if (!this.#TOKEN) this.#TOKEN = await this.#TOKEN_STORAGE.readToken(this.#APP_ID);
|
|
1272
|
+
if (!this.#TOKEN) {
|
|
1273
|
+
console.warn('No token found, clearing enabled menus');
|
|
1274
|
+
this.#ENABLED_MENUS.clear();
|
|
1275
|
+
}
|
|
1270
1276
|
}
|
|
1271
1277
|
async #setToken(token) {
|
|
1272
1278
|
await this.#TOKEN_STORAGE.saveToken(this.#APP_ID, token);
|
|
@@ -1371,12 +1377,8 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
|
|
|
1371
1377
|
return result;
|
|
1372
1378
|
}
|
|
1373
1379
|
//*** Enabled menus
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
const data = await this.#readEnabledMenus();
|
|
1377
|
-
this.#ENABLED_MENUS = data ? new Set(data) : new Set();
|
|
1378
|
-
}
|
|
1379
|
-
return this.#ENABLED_MENUS;
|
|
1380
|
+
getMenus() {
|
|
1381
|
+
return new Set(this.#ENABLED_MENUS);
|
|
1380
1382
|
}
|
|
1381
1383
|
async #getAPIEnabledMenus(username, abort_signal = null) {
|
|
1382
1384
|
if (!this.#TOKEN) return;
|
|
@@ -1400,6 +1402,7 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
|
|
|
1400
1402
|
return await this.#DATA_STORAGE.readData(this.#APP_ID, $16abd72d1aa9b62d$var$ENABLED_MENUS_DATA_KEY);
|
|
1401
1403
|
}
|
|
1402
1404
|
async #deleteEnabledMenus() {
|
|
1405
|
+
this.#ENABLED_MENUS.clear();
|
|
1403
1406
|
await this.#DATA_STORAGE.deleteData(this.#APP_ID, $16abd72d1aa9b62d$var$ENABLED_MENUS_DATA_KEY);
|
|
1404
1407
|
}
|
|
1405
1408
|
//*** File upload/download
|
|
@@ -37060,24 +37063,15 @@ function $85ebd7a43eb2f762$export$3c1a5eed89d78dce(props) {
|
|
|
37060
37063
|
|
|
37061
37064
|
parcelRegister("dZWTZ", function(module, exports) {
|
|
37062
37065
|
|
|
37063
|
-
$parcel$export(module.exports, "UseMenuContentDefaultProps", function () { return $468dbc1019a115f1$export$5920af2d37d82a1b; });
|
|
37064
37066
|
$parcel$export(module.exports, "useMenuContent", function () { return $468dbc1019a115f1$export$48c6e824f65803ea; });
|
|
37065
37067
|
|
|
37066
37068
|
|
|
37067
|
-
|
|
37068
|
-
|
|
37069
37069
|
var $e8sJv = parcelRequire("e8sJv");
|
|
37070
37070
|
|
|
37071
37071
|
var $4jQJd = parcelRequire("4jQJd");
|
|
37072
|
-
const $468dbc1019a115f1$export$5920af2d37d82a1b = {
|
|
37073
|
-
enableMenuSecurity: true,
|
|
37074
|
-
defaultLoadingComponent: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Skeleton), {}),
|
|
37075
|
-
searchMenuItemsWithContentOnly: true
|
|
37076
|
-
};
|
|
37077
37072
|
const $468dbc1019a115f1$var$triggerItemAction = async (props)=>{
|
|
37078
37073
|
const { item: item, setOpened: setOpened, onActiveChange: onActiveChange, onSubitemActiveChange: onSubitemActiveChange, autoHideNavBarOnClick: autoHideNavBarOnClick } = props;
|
|
37079
37074
|
if (!item.noActive) {
|
|
37080
|
-
// MMC: TODO, change the activeIDState to a single state
|
|
37081
37075
|
onActiveChange(item.ID);
|
|
37082
37076
|
onSubitemActiveChange(item.ID);
|
|
37083
37077
|
} else {
|
|
@@ -37088,7 +37082,7 @@ const $468dbc1019a115f1$var$triggerItemAction = async (props)=>{
|
|
|
37088
37082
|
if ((item.content || item.subitems) && item.menuPath) (0, $e8sJv.navigateToRoute)(item.menuPath);
|
|
37089
37083
|
if (autoHideNavBarOnClick && !item.subitems) setOpened(false);
|
|
37090
37084
|
};
|
|
37091
|
-
const $468dbc1019a115f1$var$populateMenuPaths = (items, parentPath
|
|
37085
|
+
const $468dbc1019a115f1$var$populateMenuPaths = (items, parentPath, parentDescription, menuId)=>{
|
|
37092
37086
|
items.forEach((item)=>{
|
|
37093
37087
|
item.menuId = menuId;
|
|
37094
37088
|
const currentPath = `${parentPath}/${item.ID}`;
|
|
@@ -37117,10 +37111,10 @@ const $468dbc1019a115f1$var$filterEnabledItems = (items, menuId, enabled)=>{
|
|
|
37117
37111
|
return item;
|
|
37118
37112
|
});
|
|
37119
37113
|
};
|
|
37120
|
-
const $468dbc1019a115f1$var$
|
|
37114
|
+
const $468dbc1019a115f1$var$createSpotlightActions = (items, baseActionProps, searchMenuItemsWithContentOnly, actions = [])=>{
|
|
37121
37115
|
for (const item of items)if (item.section === 'items') {
|
|
37122
37116
|
const group = item.menuPathDescription?.split("/").map((part)=>part.trim()).filter(Boolean)[0];
|
|
37123
|
-
if (!searchMenuItemsWithContentOnly ||
|
|
37117
|
+
if (!searchMenuItemsWithContentOnly || item.content || item.onClick) actions.push({
|
|
37124
37118
|
id: item.ID,
|
|
37125
37119
|
title: item.label,
|
|
37126
37120
|
description: `${item.menuPathDescription}${item.description ? ` - ${item.description}` : ""}`,
|
|
@@ -37131,125 +37125,121 @@ const $468dbc1019a115f1$var$CreateSpotlightActions = (items, baseActionProps, se
|
|
|
37131
37125
|
item: item
|
|
37132
37126
|
})
|
|
37133
37127
|
});
|
|
37134
|
-
if (item.subitems) $468dbc1019a115f1$var$
|
|
37128
|
+
if (item.subitems) $468dbc1019a115f1$var$createSpotlightActions(item.subitems, baseActionProps, searchMenuItemsWithContentOnly, actions);
|
|
37135
37129
|
}
|
|
37136
37130
|
return actions;
|
|
37137
37131
|
};
|
|
37138
|
-
|
|
37139
|
-
|
|
37140
|
-
|
|
37141
|
-
|
|
37142
|
-
|
|
37143
|
-
|
|
37144
|
-
|
|
37145
|
-
|
|
37146
|
-
|
|
37147
|
-
|
|
37148
|
-
|
|
37149
|
-
|
|
37132
|
+
const $468dbc1019a115f1$var$createMenuStateSetters = (menuIds, setState)=>Object.fromEntries(menuIds.map((menuId)=>[
|
|
37133
|
+
menuId,
|
|
37134
|
+
(value)=>{
|
|
37135
|
+
setState((current)=>{
|
|
37136
|
+
const currentValue = current[menuId] ?? '';
|
|
37137
|
+
const nextValue = typeof value === 'function' ? value(currentValue) : value;
|
|
37138
|
+
return nextValue === currentValue ? current : {
|
|
37139
|
+
...current,
|
|
37140
|
+
[menuId]: nextValue
|
|
37141
|
+
};
|
|
37142
|
+
});
|
|
37143
|
+
}
|
|
37144
|
+
]));
|
|
37145
|
+
function $468dbc1019a115f1$export$48c6e824f65803ea({ menus: menuConfig, client: client, setContent: setContent, setOpened: setOpened, isLoggedIn: isLoggedIn, setIsLoggedIn: setIsLoggedIn, loggedInInfo: loggedInInfo, theme: theme, enableMenuSecurity: enableMenuSecurity = true, searchMenuItemsWithContentOnly: searchMenuItemsWithContentOnly = true }) {
|
|
37146
|
+
const menuIds = (0, $b4te3$react.useMemo)(()=>Object.keys(menuConfig), [
|
|
37147
|
+
menuConfig
|
|
37148
|
+
]);
|
|
37149
|
+
const mainMenuId = (0, $b4te3$react.useMemo)(()=>{
|
|
37150
|
+
const mainMenuIds = Object.entries(menuConfig).filter(([, config])=>config.isMain).map(([menuId])=>menuId);
|
|
37151
|
+
if (mainMenuIds.length !== 1) throw new Error(`useMenuContent requires exactly one main menu; received ${mainMenuIds.length}.`);
|
|
37152
|
+
return mainMenuIds[0];
|
|
37153
|
+
}, [
|
|
37154
|
+
menuConfig
|
|
37155
|
+
]);
|
|
37156
|
+
const [activeIds, setActiveIds] = (0, $b4te3$react.useState)({});
|
|
37157
|
+
const [subitemActiveIds, setSubitemActiveIds] = (0, $b4te3$react.useState)({});
|
|
37158
|
+
const activeSetters = (0, $b4te3$react.useMemo)(()=>$468dbc1019a115f1$var$createMenuStateSetters(menuIds, setActiveIds), [
|
|
37159
|
+
menuIds
|
|
37160
|
+
]);
|
|
37161
|
+
const subitemActiveSetters = (0, $b4te3$react.useMemo)(()=>$468dbc1019a115f1$var$createMenuStateSetters(menuIds, setSubitemActiveIds), [
|
|
37162
|
+
menuIds
|
|
37163
|
+
]);
|
|
37164
|
+
const materializedMenus = (0, $b4te3$react.useMemo)(()=>{
|
|
37165
|
+
const enabledMenus = client.getMenus();
|
|
37166
|
+
const menuProps = {
|
|
37150
37167
|
client: client,
|
|
37151
37168
|
setContent: setContent,
|
|
37152
37169
|
setOpened: setOpened,
|
|
37153
37170
|
isLoggedIn: isLoggedIn,
|
|
37154
37171
|
setIsLoggedIn: setIsLoggedIn,
|
|
37155
37172
|
loggedInInfo: loggedInInfo,
|
|
37156
|
-
|
|
37157
|
-
}
|
|
37158
|
-
|
|
37159
|
-
|
|
37173
|
+
theme: theme
|
|
37174
|
+
};
|
|
37175
|
+
return Object.fromEntries(Object.entries(menuConfig).map(([menuId, config])=>{
|
|
37176
|
+
const allItems = config.menu(menuProps);
|
|
37177
|
+
$468dbc1019a115f1$var$populateMenuPaths(allItems, `/${menuId}`, '', menuId);
|
|
37178
|
+
const items = isLoggedIn ? enableMenuSecurity ? $468dbc1019a115f1$var$filterEnabledItems(allItems, menuId, enabledMenus) : allItems : [];
|
|
37179
|
+
return [
|
|
37180
|
+
menuId,
|
|
37181
|
+
{
|
|
37182
|
+
items: items,
|
|
37183
|
+
menuPathsDictionary: $468dbc1019a115f1$var$createMenuDictionary(items)
|
|
37184
|
+
}
|
|
37185
|
+
];
|
|
37186
|
+
}));
|
|
37160
37187
|
}, [
|
|
37161
|
-
|
|
37188
|
+
menuConfig,
|
|
37162
37189
|
client,
|
|
37163
37190
|
setContent,
|
|
37164
37191
|
setOpened,
|
|
37165
37192
|
isLoggedIn,
|
|
37166
37193
|
setIsLoggedIn,
|
|
37167
37194
|
loggedInInfo,
|
|
37168
|
-
|
|
37195
|
+
theme,
|
|
37196
|
+
enableMenuSecurity
|
|
37169
37197
|
]);
|
|
37170
|
-
|
|
37171
|
-
|
|
37172
|
-
|
|
37173
|
-
|
|
37174
|
-
|
|
37175
|
-
|
|
37176
|
-
|
|
37177
|
-
|
|
37178
|
-
|
|
37179
|
-
|
|
37180
|
-
|
|
37181
|
-
|
|
37198
|
+
const menus = (0, $b4te3$react.useMemo)(()=>Object.fromEntries(menuIds.map((menuId)=>{
|
|
37199
|
+
const materializedMenu = materializedMenus[menuId];
|
|
37200
|
+
const baseActionProps = {
|
|
37201
|
+
setContent: setContent,
|
|
37202
|
+
setOpened: setOpened,
|
|
37203
|
+
clearContent: true,
|
|
37204
|
+
onActiveChange: activeSetters[menuId],
|
|
37205
|
+
onSubitemActiveChange: subitemActiveSetters[menuId]
|
|
37206
|
+
};
|
|
37207
|
+
const result = {
|
|
37208
|
+
activeIDState: [
|
|
37209
|
+
activeIds[menuId] ?? '',
|
|
37210
|
+
activeSetters[menuId]
|
|
37211
|
+
],
|
|
37212
|
+
subitemActiveIDState: [
|
|
37213
|
+
subitemActiveIds[menuId] ?? '',
|
|
37214
|
+
subitemActiveSetters[menuId]
|
|
37215
|
+
],
|
|
37216
|
+
items: materializedMenu.items,
|
|
37217
|
+
actions: $468dbc1019a115f1$var$createSpotlightActions(materializedMenu.items, baseActionProps, searchMenuItemsWithContentOnly),
|
|
37218
|
+
menuPathsDictionary: materializedMenu.menuPathsDictionary
|
|
37219
|
+
};
|
|
37220
|
+
return [
|
|
37221
|
+
menuId,
|
|
37222
|
+
result
|
|
37223
|
+
];
|
|
37224
|
+
})), [
|
|
37225
|
+
menuIds,
|
|
37226
|
+
materializedMenus,
|
|
37182
37227
|
setContent,
|
|
37183
37228
|
setOpened,
|
|
37184
|
-
|
|
37185
|
-
|
|
37186
|
-
|
|
37229
|
+
activeIds,
|
|
37230
|
+
activeSetters,
|
|
37231
|
+
subitemActiveIds,
|
|
37232
|
+
subitemActiveSetters,
|
|
37187
37233
|
searchMenuItemsWithContentOnly
|
|
37188
37234
|
]);
|
|
37189
|
-
|
|
37190
|
-
|
|
37191
|
-
|
|
37192
|
-
|
|
37193
|
-
internalItemsRef.current = internal_items;
|
|
37194
|
-
internalActionsRef.current = internal_actions;
|
|
37195
|
-
(0, $b4te3$react.useEffect)(()=>{
|
|
37196
|
-
let mounted = true;
|
|
37197
|
-
const get = async ()=>{
|
|
37198
|
-
setIsLoading(true);
|
|
37199
|
-
try {
|
|
37200
|
-
const menuItems = internalItemsRef.current;
|
|
37201
|
-
const menuActions = internalActionsRef.current;
|
|
37202
|
-
if (isLoggedIn) {
|
|
37203
|
-
if (enableMenuSecurity) {
|
|
37204
|
-
const enabled = await client.getMenus();
|
|
37205
|
-
const enabled_items = $468dbc1019a115f1$var$filterEnabledItems(menuItems, menuId, enabled);
|
|
37206
|
-
const enabled_actions = menuActions.filter((item)=>enabled.has(`${menuId}_${item.id}`));
|
|
37207
|
-
if (!mounted) return;
|
|
37208
|
-
setMenuDictionary($468dbc1019a115f1$var$createMenuDictionary(enabled_items));
|
|
37209
|
-
setItems(enabled_items);
|
|
37210
|
-
setActions(enabled_actions);
|
|
37211
|
-
} else {
|
|
37212
|
-
if (!mounted) return;
|
|
37213
|
-
setMenuDictionary($468dbc1019a115f1$var$createMenuDictionary(menuItems));
|
|
37214
|
-
setItems(menuItems);
|
|
37215
|
-
setActions(menuActions);
|
|
37216
|
-
}
|
|
37217
|
-
} else {
|
|
37218
|
-
if (!mounted) return;
|
|
37219
|
-
setItems([]);
|
|
37220
|
-
setActions([]);
|
|
37221
|
-
setMenuDictionary({});
|
|
37222
|
-
}
|
|
37223
|
-
} finally{
|
|
37224
|
-
if (mounted) setIsLoading(false);
|
|
37225
|
-
}
|
|
37226
|
-
};
|
|
37227
|
-
get();
|
|
37228
|
-
return ()=>{
|
|
37229
|
-
mounted = false;
|
|
37230
|
-
};
|
|
37231
|
-
}, [
|
|
37232
|
-
client,
|
|
37233
|
-
isLoggedIn,
|
|
37234
|
-
menuId,
|
|
37235
|
-
enableMenuSecurity
|
|
37236
|
-
]);
|
|
37237
|
-
const result = (0, $b4te3$react.useMemo)(()=>({
|
|
37238
|
-
activeIDState: activeIDState,
|
|
37239
|
-
subitemActiveIDState: subitemActiveIDState,
|
|
37240
|
-
items: items,
|
|
37241
|
-
actions: actions,
|
|
37242
|
-
menuPathsDictionary: menuDictionary,
|
|
37243
|
-
isLoading: isLoading
|
|
37235
|
+
return (0, $b4te3$react.useMemo)(()=>({
|
|
37236
|
+
menus: menus,
|
|
37237
|
+
mainMenuId: mainMenuId,
|
|
37238
|
+
mainMenu: menus[mainMenuId]
|
|
37244
37239
|
}), [
|
|
37245
|
-
|
|
37246
|
-
|
|
37247
|
-
items,
|
|
37248
|
-
actions,
|
|
37249
|
-
menuDictionary,
|
|
37250
|
-
isLoading
|
|
37240
|
+
menus,
|
|
37241
|
+
mainMenuId
|
|
37251
37242
|
]);
|
|
37252
|
-
return result;
|
|
37253
37243
|
}
|
|
37254
37244
|
|
|
37255
37245
|
});
|