@fluxo-dev/shell 0.0.28 → 0.0.30
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.css +136 -0
- package/index.esm.js +1744 -49
- package/package.json +7 -7
- package/src/index.d.ts +1 -1
- package/src/lib/app.d.ts +8 -0
- package/src/lib/components/frontend-switch/frontend-switch.d.ts +4 -1
- package/src/lib/layouts/main/app-bar.d.ts +2 -0
- package/src/lib/layouts/main/app-layout.d.ts +3 -0
- package/src/lib/layouts/main/content.d.ts +2 -0
- package/src/lib/layouts/main/navbar.d.ts +5 -1
package/index.esm.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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, useCallback, createContext,
|
|
3
|
+
import React__default, { useState, Suspense, forwardRef, createElement as createElement$2, useEffect, useCallback, useMemo, createContext, useRef, useLayoutEffect, useReducer, useContext, useImperativeHandle, Fragment as Fragment$1, cloneElement, memo, isValidElement, lazy } from 'react';
|
|
4
4
|
import { useSelector, Provider } from 'react-redux';
|
|
5
5
|
import { useLocation, Navigate, Outlet, useNavigate, Link, useOutlet, Route, useSearchParams, createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
6
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, 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, 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 as Menu$1, 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';
|
|
12
12
|
import { showNotification, Notifications } from '@mantine/notifications';
|
|
13
13
|
import { useAppSelector, store as store$4 } from '@fluxo-dev/state';
|
|
14
|
+
import { unstable_batchedUpdates, flushSync as flushSync$1, createPortal } from 'react-dom';
|
|
14
15
|
import { useForm } from '@mantine/form';
|
|
15
16
|
import { RestApiDocumentation } from '@fluxo-dev/shell-korebi';
|
|
16
17
|
import { DatePickerInput, DatesProvider } from '@mantine/dates';
|
|
@@ -4344,7 +4345,8 @@ class AppJitManager {
|
|
|
4344
4345
|
}
|
|
4345
4346
|
}
|
|
4346
4347
|
|
|
4347
|
-
function FrontendSwitch() {
|
|
4348
|
+
function FrontendSwitch(props) {
|
|
4349
|
+
var _a;
|
|
4348
4350
|
const {
|
|
4349
4351
|
allowedFrontends
|
|
4350
4352
|
} = useAppSelector(a => a.layout);
|
|
@@ -4353,7 +4355,7 @@ function FrontendSwitch() {
|
|
|
4353
4355
|
children: allowedFrontends.length > 1 && jsx(ActionIcon, {
|
|
4354
4356
|
children: jsx(IconGridDots, {
|
|
4355
4357
|
size: 24,
|
|
4356
|
-
color: '#fff',
|
|
4358
|
+
color: (_a = props.iconColor) !== null && _a !== void 0 ? _a : '#fff',
|
|
4357
4359
|
onClick: () => navigate('frontend-switcher')
|
|
4358
4360
|
})
|
|
4359
4361
|
})
|
|
@@ -4448,7 +4450,7 @@ function AppBar(props) {
|
|
|
4448
4450
|
backgroundColor: (_b = (_a = props.previewMode) === null || _a === void 0 ? void 0 : _a.headerColor) !== null && _b !== void 0 ? _b : fluxoTheme.colors['brand'][7]
|
|
4449
4451
|
},
|
|
4450
4452
|
children: [jsxs(Group, {
|
|
4451
|
-
children: [jsx(Burger, {
|
|
4453
|
+
children: [props.shellUi.navigation === ShellUINavigation.Sidebar && jsx(Burger, {
|
|
4452
4454
|
tabIndex: -1,
|
|
4453
4455
|
disabled: props.previewMode !== undefined,
|
|
4454
4456
|
color: '#fff',
|
|
@@ -4840,7 +4842,10 @@ function AppContent(props) {
|
|
|
4840
4842
|
}
|
|
4841
4843
|
}
|
|
4842
4844
|
}, [location]);
|
|
4843
|
-
return jsx(
|
|
4845
|
+
return jsx("div", {
|
|
4846
|
+
style: {
|
|
4847
|
+
top: props.shellUi.navigation === ShellUINavigation.Sidebar ? 48 : 96
|
|
4848
|
+
},
|
|
4844
4849
|
children: props.withMultipleSessions ? jsxs(Tabs, {
|
|
4845
4850
|
value: sessionContext.getCurrentSessionId(),
|
|
4846
4851
|
keepMounted: true,
|
|
@@ -5173,7 +5178,1592 @@ IconFactory.icons = [{
|
|
|
5173
5178
|
})
|
|
5174
5179
|
}];
|
|
5175
5180
|
|
|
5176
|
-
|
|
5181
|
+
const isMenuOpen = state => !!state && state[0] === 'o';
|
|
5182
|
+
const batchedUpdates = unstable_batchedUpdates || (callback => callback());
|
|
5183
|
+
const values = Object.values || (obj => Object.keys(obj).map(key => obj[key]));
|
|
5184
|
+
const floatEqual = (a, b, diff = 0.0001) => Math.abs(a - b) < diff;
|
|
5185
|
+
const getTransition = (transition, name) => transition === true || !!(transition && transition[name]);
|
|
5186
|
+
const safeCall = (fn, arg) => typeof fn === 'function' ? fn(arg) : fn;
|
|
5187
|
+
const internalKey = '_szhsinMenu';
|
|
5188
|
+
const getName = component => component[internalKey];
|
|
5189
|
+
const mergeProps = (target, source) => {
|
|
5190
|
+
source && Object.keys(source).forEach(key => {
|
|
5191
|
+
const targetProp = target[key];
|
|
5192
|
+
const sourceProp = source[key];
|
|
5193
|
+
if (typeof sourceProp === 'function' && targetProp) {
|
|
5194
|
+
target[key] = (...arg) => {
|
|
5195
|
+
sourceProp(...arg);
|
|
5196
|
+
targetProp(...arg);
|
|
5197
|
+
};
|
|
5198
|
+
} else {
|
|
5199
|
+
target[key] = sourceProp;
|
|
5200
|
+
}
|
|
5201
|
+
});
|
|
5202
|
+
return target;
|
|
5203
|
+
};
|
|
5204
|
+
const parsePadding = paddingStr => {
|
|
5205
|
+
if (typeof paddingStr !== 'string') return {
|
|
5206
|
+
top: 0,
|
|
5207
|
+
right: 0,
|
|
5208
|
+
bottom: 0,
|
|
5209
|
+
left: 0
|
|
5210
|
+
};
|
|
5211
|
+
const padding = paddingStr.trim().split(/\s+/, 4).map(parseFloat);
|
|
5212
|
+
const top = !isNaN(padding[0]) ? padding[0] : 0;
|
|
5213
|
+
const right = !isNaN(padding[1]) ? padding[1] : top;
|
|
5214
|
+
return {
|
|
5215
|
+
top,
|
|
5216
|
+
right,
|
|
5217
|
+
bottom: !isNaN(padding[2]) ? padding[2] : top,
|
|
5218
|
+
left: !isNaN(padding[3]) ? padding[3] : right
|
|
5219
|
+
};
|
|
5220
|
+
};
|
|
5221
|
+
const getScrollAncestor = node => {
|
|
5222
|
+
while (node) {
|
|
5223
|
+
node = node.parentNode;
|
|
5224
|
+
if (!node || node === document.body || !node.parentNode) return;
|
|
5225
|
+
const {
|
|
5226
|
+
overflow,
|
|
5227
|
+
overflowX,
|
|
5228
|
+
overflowY
|
|
5229
|
+
} = getComputedStyle(node);
|
|
5230
|
+
if (/auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)) return node;
|
|
5231
|
+
}
|
|
5232
|
+
};
|
|
5233
|
+
function commonProps(isDisabled, isHovering) {
|
|
5234
|
+
return {
|
|
5235
|
+
'aria-disabled': isDisabled || undefined,
|
|
5236
|
+
tabIndex: isHovering ? 0 : -1
|
|
5237
|
+
};
|
|
5238
|
+
}
|
|
5239
|
+
function indexOfNode(nodeList, node) {
|
|
5240
|
+
for (let i = 0; i < nodeList.length; i++) {
|
|
5241
|
+
if (nodeList[i] === node) return i;
|
|
5242
|
+
}
|
|
5243
|
+
return -1;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5246
|
+
const stylePropTypes = name => ({
|
|
5247
|
+
[name ? `${name}ClassName` : 'className']: propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.func])
|
|
5248
|
+
});
|
|
5249
|
+
const menuPropTypes = {
|
|
5250
|
+
className: propTypes.exports.string,
|
|
5251
|
+
...stylePropTypes('menu'),
|
|
5252
|
+
arrowProps: propTypes.exports.object,
|
|
5253
|
+
focusProps: propTypes.exports.object,
|
|
5254
|
+
menuStyle: propTypes.exports.object,
|
|
5255
|
+
arrow: propTypes.exports.bool,
|
|
5256
|
+
setDownOverflow: propTypes.exports.bool,
|
|
5257
|
+
gap: propTypes.exports.number,
|
|
5258
|
+
shift: propTypes.exports.number,
|
|
5259
|
+
align: /*#__PURE__*/propTypes.exports.oneOf(['start', 'center', 'end']),
|
|
5260
|
+
direction: /*#__PURE__*/propTypes.exports.oneOf(['left', 'right', 'top', 'bottom']),
|
|
5261
|
+
position: /*#__PURE__*/propTypes.exports.oneOf(['auto', 'anchor', 'initial']),
|
|
5262
|
+
overflow: /*#__PURE__*/propTypes.exports.oneOf(['auto', 'visible', 'hidden'])
|
|
5263
|
+
};
|
|
5264
|
+
const rootMenuPropTypes = {
|
|
5265
|
+
...menuPropTypes,
|
|
5266
|
+
containerProps: propTypes.exports.object,
|
|
5267
|
+
initialMounted: propTypes.exports.bool,
|
|
5268
|
+
unmountOnClose: propTypes.exports.bool,
|
|
5269
|
+
transition: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.bool, /*#__PURE__*/propTypes.exports.exact({
|
|
5270
|
+
open: propTypes.exports.bool,
|
|
5271
|
+
close: propTypes.exports.bool,
|
|
5272
|
+
item: propTypes.exports.bool
|
|
5273
|
+
})]),
|
|
5274
|
+
transitionTimeout: propTypes.exports.number,
|
|
5275
|
+
boundingBoxRef: propTypes.exports.object,
|
|
5276
|
+
boundingBoxPadding: propTypes.exports.string,
|
|
5277
|
+
reposition: /*#__PURE__*/propTypes.exports.oneOf(['auto', 'initial']),
|
|
5278
|
+
repositionFlag: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
|
|
5279
|
+
viewScroll: /*#__PURE__*/propTypes.exports.oneOf(['auto', 'close', 'initial']),
|
|
5280
|
+
submenuOpenDelay: propTypes.exports.number,
|
|
5281
|
+
submenuCloseDelay: propTypes.exports.number,
|
|
5282
|
+
portal: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.bool, /*#__PURE__*/propTypes.exports.exact({
|
|
5283
|
+
target: propTypes.exports.object,
|
|
5284
|
+
stablePosition: propTypes.exports.bool
|
|
5285
|
+
})]),
|
|
5286
|
+
theming: propTypes.exports.string,
|
|
5287
|
+
onItemClick: propTypes.exports.func
|
|
5288
|
+
};
|
|
5289
|
+
const uncontrolledMenuPropTypes = {
|
|
5290
|
+
instanceRef: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.object, propTypes.exports.func]),
|
|
5291
|
+
onMenuChange: propTypes.exports.func
|
|
5292
|
+
};
|
|
5293
|
+
|
|
5294
|
+
const useBEM = ({
|
|
5295
|
+
block,
|
|
5296
|
+
element,
|
|
5297
|
+
modifiers,
|
|
5298
|
+
className
|
|
5299
|
+
}) => useMemo(() => {
|
|
5300
|
+
const blockElement = element ? `${block}__${element}` : block;
|
|
5301
|
+
let classString = blockElement;
|
|
5302
|
+
modifiers && Object.keys(modifiers).forEach(name => {
|
|
5303
|
+
const value = modifiers[name];
|
|
5304
|
+
if (value) classString += ` ${blockElement}--${value === true ? name : `${name}-${value}`}`;
|
|
5305
|
+
});
|
|
5306
|
+
let expandedClassName = typeof className === 'function' ? className(modifiers) : className;
|
|
5307
|
+
if (typeof expandedClassName === 'string') {
|
|
5308
|
+
expandedClassName = expandedClassName.trim();
|
|
5309
|
+
if (expandedClassName) classString += ` ${expandedClassName}`;
|
|
5310
|
+
}
|
|
5311
|
+
return classString;
|
|
5312
|
+
}, [block, element, modifiers, className]);
|
|
5313
|
+
|
|
5314
|
+
const menuContainerClass = 'szh-menu-container';
|
|
5315
|
+
const menuClass = 'szh-menu';
|
|
5316
|
+
const menuArrowClass = 'arrow';
|
|
5317
|
+
const menuItemClass = 'item';
|
|
5318
|
+
const HoverItemContext = /*#__PURE__*/createContext();
|
|
5319
|
+
const MenuListItemContext = /*#__PURE__*/createContext({});
|
|
5320
|
+
const MenuListContext = /*#__PURE__*/createContext({});
|
|
5321
|
+
const EventHandlersContext = /*#__PURE__*/createContext({});
|
|
5322
|
+
const RadioGroupContext = /*#__PURE__*/createContext({});
|
|
5323
|
+
const SettingsContext = /*#__PURE__*/createContext({});
|
|
5324
|
+
const Keys = /*#__PURE__*/Object.freeze({
|
|
5325
|
+
ENTER: 'Enter',
|
|
5326
|
+
ESC: 'Escape',
|
|
5327
|
+
SPACE: ' ',
|
|
5328
|
+
HOME: 'Home',
|
|
5329
|
+
END: 'End',
|
|
5330
|
+
LEFT: 'ArrowLeft',
|
|
5331
|
+
RIGHT: 'ArrowRight',
|
|
5332
|
+
UP: 'ArrowUp',
|
|
5333
|
+
DOWN: 'ArrowDown'
|
|
5334
|
+
});
|
|
5335
|
+
const HoverActionTypes = /*#__PURE__*/Object.freeze({
|
|
5336
|
+
RESET: 0,
|
|
5337
|
+
SET: 1,
|
|
5338
|
+
UNSET: 2,
|
|
5339
|
+
INCREASE: 3,
|
|
5340
|
+
DECREASE: 4,
|
|
5341
|
+
FIRST: 5,
|
|
5342
|
+
LAST: 6,
|
|
5343
|
+
SET_INDEX: 7
|
|
5344
|
+
});
|
|
5345
|
+
const CloseReason = /*#__PURE__*/Object.freeze({
|
|
5346
|
+
CLICK: 'click',
|
|
5347
|
+
CANCEL: 'cancel',
|
|
5348
|
+
BLUR: 'blur',
|
|
5349
|
+
SCROLL: 'scroll'
|
|
5350
|
+
});
|
|
5351
|
+
const FocusPositions = /*#__PURE__*/Object.freeze({
|
|
5352
|
+
FIRST: 'first',
|
|
5353
|
+
LAST: 'last'
|
|
5354
|
+
});
|
|
5355
|
+
const MenuStateMap = /*#__PURE__*/Object.freeze({
|
|
5356
|
+
entering: 'opening',
|
|
5357
|
+
entered: 'open',
|
|
5358
|
+
exiting: 'closing',
|
|
5359
|
+
exited: 'closed'
|
|
5360
|
+
});
|
|
5361
|
+
const positionAbsolute = 'absolute';
|
|
5362
|
+
const roleNone = 'presentation';
|
|
5363
|
+
const roleMenuitem = 'menuitem';
|
|
5364
|
+
const dummyItemProps = {
|
|
5365
|
+
'aria-hidden': true,
|
|
5366
|
+
role: roleMenuitem
|
|
5367
|
+
};
|
|
5368
|
+
|
|
5369
|
+
const MenuContainer = ({
|
|
5370
|
+
className,
|
|
5371
|
+
containerRef,
|
|
5372
|
+
containerProps,
|
|
5373
|
+
children,
|
|
5374
|
+
isOpen,
|
|
5375
|
+
theming,
|
|
5376
|
+
transition,
|
|
5377
|
+
onClose
|
|
5378
|
+
}) => {
|
|
5379
|
+
const itemTransition = getTransition(transition, 'item');
|
|
5380
|
+
const onKeyDown = ({
|
|
5381
|
+
key
|
|
5382
|
+
}) => {
|
|
5383
|
+
switch (key) {
|
|
5384
|
+
case Keys.ESC:
|
|
5385
|
+
safeCall(onClose, {
|
|
5386
|
+
key,
|
|
5387
|
+
reason: CloseReason.CANCEL
|
|
5388
|
+
});
|
|
5389
|
+
break;
|
|
5390
|
+
}
|
|
5391
|
+
};
|
|
5392
|
+
const onBlur = e => {
|
|
5393
|
+
if (isOpen && !e.currentTarget.contains(e.relatedTarget)) {
|
|
5394
|
+
safeCall(onClose, {
|
|
5395
|
+
reason: CloseReason.BLUR
|
|
5396
|
+
});
|
|
5397
|
+
}
|
|
5398
|
+
};
|
|
5399
|
+
return /*#__PURE__*/jsx("div", {
|
|
5400
|
+
...mergeProps({
|
|
5401
|
+
onKeyDown,
|
|
5402
|
+
onBlur
|
|
5403
|
+
}, containerProps),
|
|
5404
|
+
className: useBEM({
|
|
5405
|
+
block: menuContainerClass,
|
|
5406
|
+
modifiers: useMemo(() => ({
|
|
5407
|
+
theme: theming,
|
|
5408
|
+
itemTransition
|
|
5409
|
+
}), [theming, itemTransition]),
|
|
5410
|
+
className
|
|
5411
|
+
}),
|
|
5412
|
+
style: {
|
|
5413
|
+
position: 'absolute',
|
|
5414
|
+
...(containerProps == null ? void 0 : containerProps.style)
|
|
5415
|
+
},
|
|
5416
|
+
ref: containerRef,
|
|
5417
|
+
children: children
|
|
5418
|
+
});
|
|
5419
|
+
};
|
|
5420
|
+
|
|
5421
|
+
const createSubmenuCtx = () => {
|
|
5422
|
+
let timer,
|
|
5423
|
+
count = 0;
|
|
5424
|
+
return {
|
|
5425
|
+
toggle: isOpen => {
|
|
5426
|
+
isOpen ? count++ : count--;
|
|
5427
|
+
count = Math.max(count, 0);
|
|
5428
|
+
},
|
|
5429
|
+
on: (closeDelay, pending, settled) => {
|
|
5430
|
+
if (count) {
|
|
5431
|
+
if (!timer) timer = setTimeout(() => {
|
|
5432
|
+
timer = 0;
|
|
5433
|
+
pending();
|
|
5434
|
+
}, closeDelay);
|
|
5435
|
+
} else {
|
|
5436
|
+
settled == null || settled();
|
|
5437
|
+
}
|
|
5438
|
+
},
|
|
5439
|
+
off: () => {
|
|
5440
|
+
if (timer) {
|
|
5441
|
+
clearTimeout(timer);
|
|
5442
|
+
timer = 0;
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
};
|
|
5446
|
+
};
|
|
5447
|
+
|
|
5448
|
+
const useItems = (menuRef, focusRef) => {
|
|
5449
|
+
const [hoverItem, setHoverItem] = useState();
|
|
5450
|
+
const stateRef = useRef({
|
|
5451
|
+
items: [],
|
|
5452
|
+
hoverIndex: -1,
|
|
5453
|
+
sorted: false
|
|
5454
|
+
});
|
|
5455
|
+
const mutableState = stateRef.current;
|
|
5456
|
+
const updateItems = useCallback((item, isMounted) => {
|
|
5457
|
+
const {
|
|
5458
|
+
items
|
|
5459
|
+
} = mutableState;
|
|
5460
|
+
if (!item) {
|
|
5461
|
+
mutableState.items = [];
|
|
5462
|
+
} else if (isMounted) {
|
|
5463
|
+
items.push(item);
|
|
5464
|
+
} else {
|
|
5465
|
+
const index = items.indexOf(item);
|
|
5466
|
+
if (index > -1) {
|
|
5467
|
+
items.splice(index, 1);
|
|
5468
|
+
if (item.contains(document.activeElement)) {
|
|
5469
|
+
focusRef.current.focus();
|
|
5470
|
+
setHoverItem();
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
mutableState.hoverIndex = -1;
|
|
5475
|
+
mutableState.sorted = false;
|
|
5476
|
+
}, [mutableState, focusRef]);
|
|
5477
|
+
const dispatch = useCallback((actionType, item, nextIndex) => {
|
|
5478
|
+
const {
|
|
5479
|
+
items,
|
|
5480
|
+
hoverIndex
|
|
5481
|
+
} = mutableState;
|
|
5482
|
+
const sortItems = () => {
|
|
5483
|
+
if (mutableState.sorted) return;
|
|
5484
|
+
const orderedNodes = menuRef.current.querySelectorAll('.szh-menu__item');
|
|
5485
|
+
items.sort((a, b) => indexOfNode(orderedNodes, a) - indexOfNode(orderedNodes, b));
|
|
5486
|
+
mutableState.sorted = true;
|
|
5487
|
+
};
|
|
5488
|
+
let index = -1,
|
|
5489
|
+
newItem = undefined;
|
|
5490
|
+
switch (actionType) {
|
|
5491
|
+
case HoverActionTypes.RESET:
|
|
5492
|
+
break;
|
|
5493
|
+
case HoverActionTypes.SET:
|
|
5494
|
+
newItem = item;
|
|
5495
|
+
break;
|
|
5496
|
+
case HoverActionTypes.UNSET:
|
|
5497
|
+
newItem = prevItem => prevItem === item ? undefined : prevItem;
|
|
5498
|
+
break;
|
|
5499
|
+
case HoverActionTypes.FIRST:
|
|
5500
|
+
sortItems();
|
|
5501
|
+
index = 0;
|
|
5502
|
+
newItem = items[index];
|
|
5503
|
+
break;
|
|
5504
|
+
case HoverActionTypes.LAST:
|
|
5505
|
+
sortItems();
|
|
5506
|
+
index = items.length - 1;
|
|
5507
|
+
newItem = items[index];
|
|
5508
|
+
break;
|
|
5509
|
+
case HoverActionTypes.SET_INDEX:
|
|
5510
|
+
sortItems();
|
|
5511
|
+
index = nextIndex;
|
|
5512
|
+
newItem = items[index];
|
|
5513
|
+
break;
|
|
5514
|
+
case HoverActionTypes.INCREASE:
|
|
5515
|
+
sortItems();
|
|
5516
|
+
index = hoverIndex;
|
|
5517
|
+
if (index < 0) index = items.indexOf(item);
|
|
5518
|
+
index++;
|
|
5519
|
+
if (index >= items.length) index = 0;
|
|
5520
|
+
newItem = items[index];
|
|
5521
|
+
break;
|
|
5522
|
+
case HoverActionTypes.DECREASE:
|
|
5523
|
+
sortItems();
|
|
5524
|
+
index = hoverIndex;
|
|
5525
|
+
if (index < 0) index = items.indexOf(item);
|
|
5526
|
+
index--;
|
|
5527
|
+
if (index < 0) index = items.length - 1;
|
|
5528
|
+
newItem = items[index];
|
|
5529
|
+
break;
|
|
5530
|
+
default:
|
|
5531
|
+
if (process.env.NODE_ENV !== 'production') throw new Error(`[React-Menu] Unknown hover action type: ${actionType}`);
|
|
5532
|
+
}
|
|
5533
|
+
if (!newItem) index = -1;
|
|
5534
|
+
setHoverItem(newItem);
|
|
5535
|
+
mutableState.hoverIndex = index;
|
|
5536
|
+
}, [menuRef, mutableState]);
|
|
5537
|
+
return {
|
|
5538
|
+
hoverItem,
|
|
5539
|
+
dispatch,
|
|
5540
|
+
updateItems
|
|
5541
|
+
};
|
|
5542
|
+
};
|
|
5543
|
+
|
|
5544
|
+
const getNativeDimension = (transformed, untransformed) => Math.round(transformed) === untransformed ? transformed : untransformed;
|
|
5545
|
+
const getNormalizedClientRect = element => {
|
|
5546
|
+
const rect = element.getBoundingClientRect();
|
|
5547
|
+
rect.width = getNativeDimension(rect.width, element.offsetWidth);
|
|
5548
|
+
rect.height = getNativeDimension(rect.height, element.offsetHeight);
|
|
5549
|
+
return rect;
|
|
5550
|
+
};
|
|
5551
|
+
|
|
5552
|
+
const getPositionHelpers = (containerRef, menuRef, menuScroll, boundingBoxPadding) => {
|
|
5553
|
+
const menuRect = getNormalizedClientRect(menuRef.current);
|
|
5554
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
5555
|
+
const boundingRect = menuScroll === window ? {
|
|
5556
|
+
left: 0,
|
|
5557
|
+
top: 0,
|
|
5558
|
+
right: document.documentElement.clientWidth,
|
|
5559
|
+
bottom: window.innerHeight
|
|
5560
|
+
} : menuScroll.getBoundingClientRect();
|
|
5561
|
+
const padding = parsePadding(boundingBoxPadding);
|
|
5562
|
+
const getLeftOverflow = x => x + containerRect.left - boundingRect.left - padding.left;
|
|
5563
|
+
const getRightOverflow = x => x + containerRect.left + menuRect.width - boundingRect.right + padding.right;
|
|
5564
|
+
const getTopOverflow = y => y + containerRect.top - boundingRect.top - padding.top;
|
|
5565
|
+
const getBottomOverflow = y => y + containerRect.top + menuRect.height - boundingRect.bottom + padding.bottom;
|
|
5566
|
+
const confineHorizontally = x => {
|
|
5567
|
+
let leftOverflow = getLeftOverflow(x);
|
|
5568
|
+
if (leftOverflow < 0) {
|
|
5569
|
+
x -= leftOverflow;
|
|
5570
|
+
} else {
|
|
5571
|
+
const rightOverflow = getRightOverflow(x);
|
|
5572
|
+
if (rightOverflow > 0) {
|
|
5573
|
+
x -= rightOverflow;
|
|
5574
|
+
leftOverflow = getLeftOverflow(x);
|
|
5575
|
+
if (leftOverflow < 0) x -= leftOverflow;
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
return x;
|
|
5579
|
+
};
|
|
5580
|
+
const confineVertically = y => {
|
|
5581
|
+
let topOverflow = getTopOverflow(y);
|
|
5582
|
+
if (topOverflow < 0) {
|
|
5583
|
+
y -= topOverflow;
|
|
5584
|
+
} else {
|
|
5585
|
+
const bottomOverflow = getBottomOverflow(y);
|
|
5586
|
+
if (bottomOverflow > 0) {
|
|
5587
|
+
y -= bottomOverflow;
|
|
5588
|
+
topOverflow = getTopOverflow(y);
|
|
5589
|
+
if (topOverflow < 0) y -= topOverflow;
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
5592
|
+
return y;
|
|
5593
|
+
};
|
|
5594
|
+
return {
|
|
5595
|
+
menuRect,
|
|
5596
|
+
containerRect,
|
|
5597
|
+
getLeftOverflow,
|
|
5598
|
+
getRightOverflow,
|
|
5599
|
+
getTopOverflow,
|
|
5600
|
+
getBottomOverflow,
|
|
5601
|
+
confineHorizontally,
|
|
5602
|
+
confineVertically
|
|
5603
|
+
};
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5606
|
+
const placeArrowVertical = ({
|
|
5607
|
+
arrowRef,
|
|
5608
|
+
menuY,
|
|
5609
|
+
anchorRect,
|
|
5610
|
+
containerRect,
|
|
5611
|
+
menuRect
|
|
5612
|
+
}) => {
|
|
5613
|
+
let y = anchorRect.top - containerRect.top - menuY + anchorRect.height / 2;
|
|
5614
|
+
const offset = arrowRef.current.offsetHeight * 1.25;
|
|
5615
|
+
y = Math.max(offset, y);
|
|
5616
|
+
y = Math.min(y, menuRect.height - offset);
|
|
5617
|
+
return y;
|
|
5618
|
+
};
|
|
5619
|
+
|
|
5620
|
+
const placeLeftorRight = ({
|
|
5621
|
+
anchorRect,
|
|
5622
|
+
containerRect,
|
|
5623
|
+
menuRect,
|
|
5624
|
+
placeLeftorRightY,
|
|
5625
|
+
placeLeftX,
|
|
5626
|
+
placeRightX,
|
|
5627
|
+
getLeftOverflow,
|
|
5628
|
+
getRightOverflow,
|
|
5629
|
+
confineHorizontally,
|
|
5630
|
+
confineVertically,
|
|
5631
|
+
arrowRef,
|
|
5632
|
+
arrow,
|
|
5633
|
+
direction,
|
|
5634
|
+
position
|
|
5635
|
+
}) => {
|
|
5636
|
+
let computedDirection = direction;
|
|
5637
|
+
let y = placeLeftorRightY;
|
|
5638
|
+
if (position !== 'initial') {
|
|
5639
|
+
y = confineVertically(y);
|
|
5640
|
+
if (position === 'anchor') {
|
|
5641
|
+
y = Math.min(y, anchorRect.bottom - containerRect.top);
|
|
5642
|
+
y = Math.max(y, anchorRect.top - containerRect.top - menuRect.height);
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
let x, leftOverflow, rightOverflow;
|
|
5646
|
+
if (computedDirection === 'left') {
|
|
5647
|
+
x = placeLeftX;
|
|
5648
|
+
if (position !== 'initial') {
|
|
5649
|
+
leftOverflow = getLeftOverflow(x);
|
|
5650
|
+
if (leftOverflow < 0) {
|
|
5651
|
+
rightOverflow = getRightOverflow(placeRightX);
|
|
5652
|
+
if (rightOverflow <= 0 || -leftOverflow > rightOverflow) {
|
|
5653
|
+
x = placeRightX;
|
|
5654
|
+
computedDirection = 'right';
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
} else {
|
|
5659
|
+
x = placeRightX;
|
|
5660
|
+
if (position !== 'initial') {
|
|
5661
|
+
rightOverflow = getRightOverflow(x);
|
|
5662
|
+
if (rightOverflow > 0) {
|
|
5663
|
+
leftOverflow = getLeftOverflow(placeLeftX);
|
|
5664
|
+
if (leftOverflow >= 0 || -leftOverflow < rightOverflow) {
|
|
5665
|
+
x = placeLeftX;
|
|
5666
|
+
computedDirection = 'left';
|
|
5667
|
+
}
|
|
5668
|
+
}
|
|
5669
|
+
}
|
|
5670
|
+
}
|
|
5671
|
+
if (position === 'auto') x = confineHorizontally(x);
|
|
5672
|
+
const arrowY = arrow ? placeArrowVertical({
|
|
5673
|
+
menuY: y,
|
|
5674
|
+
arrowRef,
|
|
5675
|
+
anchorRect,
|
|
5676
|
+
containerRect,
|
|
5677
|
+
menuRect
|
|
5678
|
+
}) : undefined;
|
|
5679
|
+
return {
|
|
5680
|
+
arrowY,
|
|
5681
|
+
x,
|
|
5682
|
+
y,
|
|
5683
|
+
computedDirection
|
|
5684
|
+
};
|
|
5685
|
+
};
|
|
5686
|
+
|
|
5687
|
+
const placeArrowHorizontal = ({
|
|
5688
|
+
arrowRef,
|
|
5689
|
+
menuX,
|
|
5690
|
+
anchorRect,
|
|
5691
|
+
containerRect,
|
|
5692
|
+
menuRect
|
|
5693
|
+
}) => {
|
|
5694
|
+
let x = anchorRect.left - containerRect.left - menuX + anchorRect.width / 2;
|
|
5695
|
+
const offset = arrowRef.current.offsetWidth * 1.25;
|
|
5696
|
+
x = Math.max(offset, x);
|
|
5697
|
+
x = Math.min(x, menuRect.width - offset);
|
|
5698
|
+
return x;
|
|
5699
|
+
};
|
|
5700
|
+
|
|
5701
|
+
const placeToporBottom = ({
|
|
5702
|
+
anchorRect,
|
|
5703
|
+
containerRect,
|
|
5704
|
+
menuRect,
|
|
5705
|
+
placeToporBottomX,
|
|
5706
|
+
placeTopY,
|
|
5707
|
+
placeBottomY,
|
|
5708
|
+
getTopOverflow,
|
|
5709
|
+
getBottomOverflow,
|
|
5710
|
+
confineHorizontally,
|
|
5711
|
+
confineVertically,
|
|
5712
|
+
arrowRef,
|
|
5713
|
+
arrow,
|
|
5714
|
+
direction,
|
|
5715
|
+
position
|
|
5716
|
+
}) => {
|
|
5717
|
+
let computedDirection = direction === 'top' ? 'top' : 'bottom';
|
|
5718
|
+
let x = placeToporBottomX;
|
|
5719
|
+
if (position !== 'initial') {
|
|
5720
|
+
x = confineHorizontally(x);
|
|
5721
|
+
if (position === 'anchor') {
|
|
5722
|
+
x = Math.min(x, anchorRect.right - containerRect.left);
|
|
5723
|
+
x = Math.max(x, anchorRect.left - containerRect.left - menuRect.width);
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5726
|
+
let y, topOverflow, bottomOverflow;
|
|
5727
|
+
if (computedDirection === 'top') {
|
|
5728
|
+
y = placeTopY;
|
|
5729
|
+
if (position !== 'initial') {
|
|
5730
|
+
topOverflow = getTopOverflow(y);
|
|
5731
|
+
if (topOverflow < 0) {
|
|
5732
|
+
bottomOverflow = getBottomOverflow(placeBottomY);
|
|
5733
|
+
if (bottomOverflow <= 0 || -topOverflow > bottomOverflow) {
|
|
5734
|
+
y = placeBottomY;
|
|
5735
|
+
computedDirection = 'bottom';
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
}
|
|
5739
|
+
} else {
|
|
5740
|
+
y = placeBottomY;
|
|
5741
|
+
if (position !== 'initial') {
|
|
5742
|
+
bottomOverflow = getBottomOverflow(y);
|
|
5743
|
+
if (bottomOverflow > 0) {
|
|
5744
|
+
topOverflow = getTopOverflow(placeTopY);
|
|
5745
|
+
if (topOverflow >= 0 || -topOverflow < bottomOverflow) {
|
|
5746
|
+
y = placeTopY;
|
|
5747
|
+
computedDirection = 'top';
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5752
|
+
if (position === 'auto') y = confineVertically(y);
|
|
5753
|
+
const arrowX = arrow ? placeArrowHorizontal({
|
|
5754
|
+
menuX: x,
|
|
5755
|
+
arrowRef,
|
|
5756
|
+
anchorRect,
|
|
5757
|
+
containerRect,
|
|
5758
|
+
menuRect
|
|
5759
|
+
}) : undefined;
|
|
5760
|
+
return {
|
|
5761
|
+
arrowX,
|
|
5762
|
+
x,
|
|
5763
|
+
y,
|
|
5764
|
+
computedDirection
|
|
5765
|
+
};
|
|
5766
|
+
};
|
|
5767
|
+
|
|
5768
|
+
const positionMenu = ({
|
|
5769
|
+
arrow,
|
|
5770
|
+
align,
|
|
5771
|
+
direction,
|
|
5772
|
+
gap,
|
|
5773
|
+
shift,
|
|
5774
|
+
position,
|
|
5775
|
+
anchorRect,
|
|
5776
|
+
arrowRef,
|
|
5777
|
+
positionHelpers
|
|
5778
|
+
}) => {
|
|
5779
|
+
const {
|
|
5780
|
+
menuRect,
|
|
5781
|
+
containerRect
|
|
5782
|
+
} = positionHelpers;
|
|
5783
|
+
const isHorizontal = direction === 'left' || direction === 'right';
|
|
5784
|
+
let horizontalOffset = isHorizontal ? gap : shift;
|
|
5785
|
+
let verticalOffset = isHorizontal ? shift : gap;
|
|
5786
|
+
if (arrow) {
|
|
5787
|
+
const arrowElt = arrowRef.current;
|
|
5788
|
+
if (isHorizontal) {
|
|
5789
|
+
horizontalOffset += arrowElt.offsetWidth;
|
|
5790
|
+
} else {
|
|
5791
|
+
verticalOffset += arrowElt.offsetHeight;
|
|
5792
|
+
}
|
|
5793
|
+
}
|
|
5794
|
+
const placeLeftX = anchorRect.left - containerRect.left - menuRect.width - horizontalOffset;
|
|
5795
|
+
const placeRightX = anchorRect.right - containerRect.left + horizontalOffset;
|
|
5796
|
+
const placeTopY = anchorRect.top - containerRect.top - menuRect.height - verticalOffset;
|
|
5797
|
+
const placeBottomY = anchorRect.bottom - containerRect.top + verticalOffset;
|
|
5798
|
+
let placeToporBottomX, placeLeftorRightY;
|
|
5799
|
+
if (align === 'end') {
|
|
5800
|
+
placeToporBottomX = anchorRect.right - containerRect.left - menuRect.width;
|
|
5801
|
+
placeLeftorRightY = anchorRect.bottom - containerRect.top - menuRect.height;
|
|
5802
|
+
} else if (align === 'center') {
|
|
5803
|
+
placeToporBottomX = anchorRect.left - containerRect.left - (menuRect.width - anchorRect.width) / 2;
|
|
5804
|
+
placeLeftorRightY = anchorRect.top - containerRect.top - (menuRect.height - anchorRect.height) / 2;
|
|
5805
|
+
} else {
|
|
5806
|
+
placeToporBottomX = anchorRect.left - containerRect.left;
|
|
5807
|
+
placeLeftorRightY = anchorRect.top - containerRect.top;
|
|
5808
|
+
}
|
|
5809
|
+
placeToporBottomX += horizontalOffset;
|
|
5810
|
+
placeLeftorRightY += verticalOffset;
|
|
5811
|
+
const options = {
|
|
5812
|
+
...positionHelpers,
|
|
5813
|
+
anchorRect,
|
|
5814
|
+
placeLeftX,
|
|
5815
|
+
placeRightX,
|
|
5816
|
+
placeLeftorRightY,
|
|
5817
|
+
placeTopY,
|
|
5818
|
+
placeBottomY,
|
|
5819
|
+
placeToporBottomX,
|
|
5820
|
+
arrowRef,
|
|
5821
|
+
arrow,
|
|
5822
|
+
direction,
|
|
5823
|
+
position
|
|
5824
|
+
};
|
|
5825
|
+
switch (direction) {
|
|
5826
|
+
case 'left':
|
|
5827
|
+
case 'right':
|
|
5828
|
+
return placeLeftorRight(options);
|
|
5829
|
+
case 'top':
|
|
5830
|
+
case 'bottom':
|
|
5831
|
+
default:
|
|
5832
|
+
return placeToporBottom(options);
|
|
5833
|
+
}
|
|
5834
|
+
};
|
|
5835
|
+
|
|
5836
|
+
const useIsomorphicLayoutEffect$2 = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect;
|
|
5837
|
+
|
|
5838
|
+
function setRef$1(ref, instance) {
|
|
5839
|
+
typeof ref === 'function' ? ref(instance) : ref.current = instance;
|
|
5840
|
+
}
|
|
5841
|
+
const useCombinedRef = (refA, refB) => useMemo(() => {
|
|
5842
|
+
if (!refA) return refB;
|
|
5843
|
+
if (!refB) return refA;
|
|
5844
|
+
return instance => {
|
|
5845
|
+
setRef$1(refA, instance);
|
|
5846
|
+
setRef$1(refB, instance);
|
|
5847
|
+
};
|
|
5848
|
+
}, [refA, refB]);
|
|
5849
|
+
|
|
5850
|
+
const offScreen = -9999;
|
|
5851
|
+
const MenuList = ({
|
|
5852
|
+
ariaLabel,
|
|
5853
|
+
menuClassName,
|
|
5854
|
+
menuStyle,
|
|
5855
|
+
arrow,
|
|
5856
|
+
arrowProps = {},
|
|
5857
|
+
anchorPoint,
|
|
5858
|
+
anchorRef,
|
|
5859
|
+
containerRef,
|
|
5860
|
+
containerProps,
|
|
5861
|
+
focusProps,
|
|
5862
|
+
externalRef,
|
|
5863
|
+
parentScrollingRef,
|
|
5864
|
+
align = 'start',
|
|
5865
|
+
direction = 'bottom',
|
|
5866
|
+
position = 'auto',
|
|
5867
|
+
overflow = 'visible',
|
|
5868
|
+
setDownOverflow,
|
|
5869
|
+
repositionFlag,
|
|
5870
|
+
captureFocus = true,
|
|
5871
|
+
state,
|
|
5872
|
+
endTransition,
|
|
5873
|
+
isDisabled,
|
|
5874
|
+
menuItemFocus,
|
|
5875
|
+
gap = 0,
|
|
5876
|
+
shift = 0,
|
|
5877
|
+
children,
|
|
5878
|
+
onClose,
|
|
5879
|
+
...restProps
|
|
5880
|
+
}) => {
|
|
5881
|
+
const [menuPosition, setMenuPosition] = useState({
|
|
5882
|
+
x: offScreen,
|
|
5883
|
+
y: offScreen
|
|
5884
|
+
});
|
|
5885
|
+
const [arrowPosition, setArrowPosition] = useState({});
|
|
5886
|
+
const [overflowData, setOverflowData] = useState();
|
|
5887
|
+
const [expandedDirection, setExpandedDirection] = useState(direction);
|
|
5888
|
+
const [submenuCtx] = useState(createSubmenuCtx);
|
|
5889
|
+
const [reposSubmenu, forceReposSubmenu] = useReducer(c => c + 1, 1);
|
|
5890
|
+
const {
|
|
5891
|
+
transition,
|
|
5892
|
+
boundingBoxRef,
|
|
5893
|
+
boundingBoxPadding,
|
|
5894
|
+
rootMenuRef,
|
|
5895
|
+
rootAnchorRef,
|
|
5896
|
+
scrollNodesRef,
|
|
5897
|
+
reposition,
|
|
5898
|
+
viewScroll,
|
|
5899
|
+
submenuCloseDelay
|
|
5900
|
+
} = useContext(SettingsContext);
|
|
5901
|
+
const {
|
|
5902
|
+
submenuCtx: parentSubmenuCtx,
|
|
5903
|
+
reposSubmenu: reposFlag = repositionFlag
|
|
5904
|
+
} = useContext(MenuListContext);
|
|
5905
|
+
const menuRef = useRef(null);
|
|
5906
|
+
const focusRef = useRef();
|
|
5907
|
+
const arrowRef = useRef();
|
|
5908
|
+
const prevOpen = useRef(false);
|
|
5909
|
+
const latestMenuSize = useRef({
|
|
5910
|
+
width: 0,
|
|
5911
|
+
height: 0
|
|
5912
|
+
});
|
|
5913
|
+
const latestHandlePosition = useRef(() => {});
|
|
5914
|
+
const {
|
|
5915
|
+
hoverItem,
|
|
5916
|
+
dispatch,
|
|
5917
|
+
updateItems
|
|
5918
|
+
} = useItems(menuRef, focusRef);
|
|
5919
|
+
const isOpen = isMenuOpen(state);
|
|
5920
|
+
const openTransition = getTransition(transition, 'open');
|
|
5921
|
+
const closeTransition = getTransition(transition, 'close');
|
|
5922
|
+
const scrollNodes = scrollNodesRef.current;
|
|
5923
|
+
const onKeyDown = e => {
|
|
5924
|
+
switch (e.key) {
|
|
5925
|
+
case Keys.HOME:
|
|
5926
|
+
dispatch(HoverActionTypes.FIRST);
|
|
5927
|
+
break;
|
|
5928
|
+
case Keys.END:
|
|
5929
|
+
dispatch(HoverActionTypes.LAST);
|
|
5930
|
+
break;
|
|
5931
|
+
case Keys.UP:
|
|
5932
|
+
dispatch(HoverActionTypes.DECREASE, hoverItem);
|
|
5933
|
+
break;
|
|
5934
|
+
case Keys.DOWN:
|
|
5935
|
+
dispatch(HoverActionTypes.INCREASE, hoverItem);
|
|
5936
|
+
break;
|
|
5937
|
+
case Keys.SPACE:
|
|
5938
|
+
if (e.target && e.target.className.indexOf(menuClass) !== -1) {
|
|
5939
|
+
e.preventDefault();
|
|
5940
|
+
}
|
|
5941
|
+
return;
|
|
5942
|
+
default:
|
|
5943
|
+
return;
|
|
5944
|
+
}
|
|
5945
|
+
e.preventDefault();
|
|
5946
|
+
e.stopPropagation();
|
|
5947
|
+
};
|
|
5948
|
+
const onAnimationEnd = () => {
|
|
5949
|
+
if (state === 'closing') {
|
|
5950
|
+
setOverflowData();
|
|
5951
|
+
}
|
|
5952
|
+
safeCall(endTransition);
|
|
5953
|
+
};
|
|
5954
|
+
const onPointerMove = e => {
|
|
5955
|
+
e.stopPropagation();
|
|
5956
|
+
submenuCtx.on(submenuCloseDelay, () => {
|
|
5957
|
+
dispatch(HoverActionTypes.RESET);
|
|
5958
|
+
focusRef.current.focus();
|
|
5959
|
+
});
|
|
5960
|
+
};
|
|
5961
|
+
const onPointerLeave = e => {
|
|
5962
|
+
if (e.target === e.currentTarget) submenuCtx.off();
|
|
5963
|
+
};
|
|
5964
|
+
const handlePosition = useCallback(noOverflowCheck => {
|
|
5965
|
+
var _anchorRef$current;
|
|
5966
|
+
const anchorRect = anchorRef ? (_anchorRef$current = anchorRef.current) == null ? void 0 : _anchorRef$current.getBoundingClientRect() : anchorPoint ? {
|
|
5967
|
+
left: anchorPoint.x,
|
|
5968
|
+
right: anchorPoint.x,
|
|
5969
|
+
top: anchorPoint.y,
|
|
5970
|
+
bottom: anchorPoint.y,
|
|
5971
|
+
width: 0,
|
|
5972
|
+
height: 0
|
|
5973
|
+
} : null;
|
|
5974
|
+
if (!anchorRect) {
|
|
5975
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5976
|
+
console.warn('[React-Menu] Menu might not be positioned properly as one of the anchorRef or anchorPoint prop should be provided. If `anchorRef` is provided, the anchor must be mounted before menu is open.');
|
|
5977
|
+
}
|
|
5978
|
+
return;
|
|
5979
|
+
}
|
|
5980
|
+
if (!scrollNodes.menu) {
|
|
5981
|
+
scrollNodes.menu = (boundingBoxRef ? boundingBoxRef.current : getScrollAncestor(rootMenuRef.current)) || window;
|
|
5982
|
+
}
|
|
5983
|
+
const positionHelpers = getPositionHelpers(containerRef, menuRef, scrollNodes.menu, boundingBoxPadding);
|
|
5984
|
+
let {
|
|
5985
|
+
arrowX,
|
|
5986
|
+
arrowY,
|
|
5987
|
+
x,
|
|
5988
|
+
y,
|
|
5989
|
+
computedDirection
|
|
5990
|
+
} = positionMenu({
|
|
5991
|
+
arrow,
|
|
5992
|
+
align,
|
|
5993
|
+
direction,
|
|
5994
|
+
gap,
|
|
5995
|
+
shift,
|
|
5996
|
+
position,
|
|
5997
|
+
anchorRect,
|
|
5998
|
+
arrowRef,
|
|
5999
|
+
positionHelpers
|
|
6000
|
+
});
|
|
6001
|
+
const {
|
|
6002
|
+
menuRect
|
|
6003
|
+
} = positionHelpers;
|
|
6004
|
+
let menuHeight = menuRect.height;
|
|
6005
|
+
if (!noOverflowCheck && overflow !== 'visible') {
|
|
6006
|
+
const {
|
|
6007
|
+
getTopOverflow,
|
|
6008
|
+
getBottomOverflow
|
|
6009
|
+
} = positionHelpers;
|
|
6010
|
+
let height, overflowAmt;
|
|
6011
|
+
const prevHeight = latestMenuSize.current.height;
|
|
6012
|
+
const bottomOverflow = getBottomOverflow(y);
|
|
6013
|
+
if (bottomOverflow > 0 || floatEqual(bottomOverflow, 0) && floatEqual(menuHeight, prevHeight)) {
|
|
6014
|
+
height = menuHeight - bottomOverflow;
|
|
6015
|
+
overflowAmt = bottomOverflow;
|
|
6016
|
+
} else {
|
|
6017
|
+
const topOverflow = getTopOverflow(y);
|
|
6018
|
+
if (topOverflow < 0 || floatEqual(topOverflow, 0) && floatEqual(menuHeight, prevHeight)) {
|
|
6019
|
+
height = menuHeight + topOverflow;
|
|
6020
|
+
overflowAmt = 0 - topOverflow;
|
|
6021
|
+
if (height >= 0) y -= topOverflow;
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
if (height >= 0) {
|
|
6025
|
+
menuHeight = height;
|
|
6026
|
+
setOverflowData({
|
|
6027
|
+
height,
|
|
6028
|
+
overflowAmt
|
|
6029
|
+
});
|
|
6030
|
+
} else {
|
|
6031
|
+
setOverflowData();
|
|
6032
|
+
}
|
|
6033
|
+
}
|
|
6034
|
+
if (arrow) setArrowPosition({
|
|
6035
|
+
x: arrowX,
|
|
6036
|
+
y: arrowY
|
|
6037
|
+
});
|
|
6038
|
+
setMenuPosition({
|
|
6039
|
+
x,
|
|
6040
|
+
y
|
|
6041
|
+
});
|
|
6042
|
+
setExpandedDirection(computedDirection);
|
|
6043
|
+
latestMenuSize.current = {
|
|
6044
|
+
width: menuRect.width,
|
|
6045
|
+
height: menuHeight
|
|
6046
|
+
};
|
|
6047
|
+
}, [arrow, align, boundingBoxPadding, direction, gap, shift, position, overflow, anchorPoint, anchorRef, containerRef, boundingBoxRef, rootMenuRef, scrollNodes]);
|
|
6048
|
+
useIsomorphicLayoutEffect$2(() => {
|
|
6049
|
+
if (isOpen) {
|
|
6050
|
+
handlePosition();
|
|
6051
|
+
if (prevOpen.current) forceReposSubmenu();
|
|
6052
|
+
}
|
|
6053
|
+
prevOpen.current = isOpen;
|
|
6054
|
+
latestHandlePosition.current = handlePosition;
|
|
6055
|
+
}, [isOpen, handlePosition, reposFlag]);
|
|
6056
|
+
useIsomorphicLayoutEffect$2(() => {
|
|
6057
|
+
if (overflowData && !setDownOverflow) menuRef.current.scrollTop = 0;
|
|
6058
|
+
}, [overflowData, setDownOverflow]);
|
|
6059
|
+
useIsomorphicLayoutEffect$2(() => updateItems, [updateItems]);
|
|
6060
|
+
useEffect(() => {
|
|
6061
|
+
let {
|
|
6062
|
+
menu: menuScroll
|
|
6063
|
+
} = scrollNodes;
|
|
6064
|
+
if (!isOpen || !menuScroll) return;
|
|
6065
|
+
menuScroll = menuScroll.addEventListener ? menuScroll : window;
|
|
6066
|
+
if (!scrollNodes.anchors) {
|
|
6067
|
+
scrollNodes.anchors = [];
|
|
6068
|
+
let anchorScroll = getScrollAncestor(rootAnchorRef && rootAnchorRef.current);
|
|
6069
|
+
while (anchorScroll && anchorScroll !== menuScroll) {
|
|
6070
|
+
scrollNodes.anchors.push(anchorScroll);
|
|
6071
|
+
anchorScroll = getScrollAncestor(anchorScroll);
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
let scroll = viewScroll;
|
|
6075
|
+
if (scrollNodes.anchors.length && scroll === 'initial') scroll = 'auto';
|
|
6076
|
+
if (scroll === 'initial') return;
|
|
6077
|
+
const handleScroll = () => {
|
|
6078
|
+
if (scroll === 'auto') {
|
|
6079
|
+
batchedUpdates(() => handlePosition(true));
|
|
6080
|
+
} else {
|
|
6081
|
+
safeCall(onClose, {
|
|
6082
|
+
reason: CloseReason.SCROLL
|
|
6083
|
+
});
|
|
6084
|
+
}
|
|
6085
|
+
};
|
|
6086
|
+
const scrollObservers = scrollNodes.anchors.concat(viewScroll !== 'initial' ? menuScroll : []);
|
|
6087
|
+
scrollObservers.forEach(o => o.addEventListener('scroll', handleScroll));
|
|
6088
|
+
return () => scrollObservers.forEach(o => o.removeEventListener('scroll', handleScroll));
|
|
6089
|
+
}, [rootAnchorRef, scrollNodes, isOpen, onClose, viewScroll, handlePosition]);
|
|
6090
|
+
const hasOverflow = !!overflowData && overflowData.overflowAmt > 0;
|
|
6091
|
+
useEffect(() => {
|
|
6092
|
+
if (hasOverflow || !isOpen || !parentScrollingRef) return;
|
|
6093
|
+
const handleScroll = () => batchedUpdates(handlePosition);
|
|
6094
|
+
const parentScroll = parentScrollingRef.current;
|
|
6095
|
+
parentScroll.addEventListener('scroll', handleScroll);
|
|
6096
|
+
return () => parentScroll.removeEventListener('scroll', handleScroll);
|
|
6097
|
+
}, [isOpen, hasOverflow, parentScrollingRef, handlePosition]);
|
|
6098
|
+
useEffect(() => {
|
|
6099
|
+
if (typeof ResizeObserver !== 'function' || reposition === 'initial') return;
|
|
6100
|
+
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
6101
|
+
const {
|
|
6102
|
+
borderBoxSize,
|
|
6103
|
+
target
|
|
6104
|
+
} = entry;
|
|
6105
|
+
let width, height;
|
|
6106
|
+
if (borderBoxSize) {
|
|
6107
|
+
const {
|
|
6108
|
+
inlineSize,
|
|
6109
|
+
blockSize
|
|
6110
|
+
} = borderBoxSize[0] || borderBoxSize;
|
|
6111
|
+
width = inlineSize;
|
|
6112
|
+
height = blockSize;
|
|
6113
|
+
} else {
|
|
6114
|
+
const borderRect = getNormalizedClientRect(target);
|
|
6115
|
+
width = borderRect.width;
|
|
6116
|
+
height = borderRect.height;
|
|
6117
|
+
}
|
|
6118
|
+
if (width === 0 || height === 0) return;
|
|
6119
|
+
if (floatEqual(width, latestMenuSize.current.width, 1) && floatEqual(height, latestMenuSize.current.height, 1)) return;
|
|
6120
|
+
flushSync$1(() => {
|
|
6121
|
+
latestHandlePosition.current();
|
|
6122
|
+
forceReposSubmenu();
|
|
6123
|
+
});
|
|
6124
|
+
});
|
|
6125
|
+
const observeTarget = menuRef.current;
|
|
6126
|
+
resizeObserver.observe(observeTarget, {
|
|
6127
|
+
box: 'border-box'
|
|
6128
|
+
});
|
|
6129
|
+
return () => resizeObserver.unobserve(observeTarget);
|
|
6130
|
+
}, [reposition]);
|
|
6131
|
+
useEffect(() => {
|
|
6132
|
+
if (!isOpen) {
|
|
6133
|
+
dispatch(HoverActionTypes.RESET);
|
|
6134
|
+
if (!closeTransition) setOverflowData();
|
|
6135
|
+
return;
|
|
6136
|
+
}
|
|
6137
|
+
const {
|
|
6138
|
+
position,
|
|
6139
|
+
alwaysUpdate
|
|
6140
|
+
} = menuItemFocus || {};
|
|
6141
|
+
const setItemFocus = () => {
|
|
6142
|
+
if (position === FocusPositions.FIRST) {
|
|
6143
|
+
dispatch(HoverActionTypes.FIRST);
|
|
6144
|
+
} else if (position === FocusPositions.LAST) {
|
|
6145
|
+
dispatch(HoverActionTypes.LAST);
|
|
6146
|
+
} else if (position >= -1) {
|
|
6147
|
+
dispatch(HoverActionTypes.SET_INDEX, undefined, position);
|
|
6148
|
+
}
|
|
6149
|
+
};
|
|
6150
|
+
if (alwaysUpdate) {
|
|
6151
|
+
setItemFocus();
|
|
6152
|
+
} else if (captureFocus) {
|
|
6153
|
+
const id = setTimeout(() => {
|
|
6154
|
+
const menuElt = menuRef.current;
|
|
6155
|
+
if (menuElt && !menuElt.contains(document.activeElement)) {
|
|
6156
|
+
focusRef.current.focus();
|
|
6157
|
+
setItemFocus();
|
|
6158
|
+
}
|
|
6159
|
+
}, openTransition ? 170 : 100);
|
|
6160
|
+
return () => clearTimeout(id);
|
|
6161
|
+
}
|
|
6162
|
+
}, [isOpen, openTransition, closeTransition, captureFocus, menuItemFocus, dispatch]);
|
|
6163
|
+
const itemContext = useMemo(() => ({
|
|
6164
|
+
isParentOpen: isOpen,
|
|
6165
|
+
submenuCtx,
|
|
6166
|
+
dispatch,
|
|
6167
|
+
updateItems
|
|
6168
|
+
}), [isOpen, submenuCtx, dispatch, updateItems]);
|
|
6169
|
+
let maxHeight, overflowAmt;
|
|
6170
|
+
if (overflowData) {
|
|
6171
|
+
setDownOverflow ? overflowAmt = overflowData.overflowAmt : maxHeight = overflowData.height;
|
|
6172
|
+
}
|
|
6173
|
+
const listContext = useMemo(() => ({
|
|
6174
|
+
reposSubmenu,
|
|
6175
|
+
submenuCtx,
|
|
6176
|
+
overflow,
|
|
6177
|
+
overflowAmt,
|
|
6178
|
+
parentMenuRef: menuRef,
|
|
6179
|
+
parentDir: expandedDirection
|
|
6180
|
+
}), [reposSubmenu, submenuCtx, overflow, overflowAmt, expandedDirection]);
|
|
6181
|
+
const overflowStyle = maxHeight >= 0 ? {
|
|
6182
|
+
maxHeight,
|
|
6183
|
+
overflow
|
|
6184
|
+
} : undefined;
|
|
6185
|
+
const modifiers = useMemo(() => ({
|
|
6186
|
+
state,
|
|
6187
|
+
align,
|
|
6188
|
+
dir: expandedDirection
|
|
6189
|
+
}), [state, align, expandedDirection]);
|
|
6190
|
+
const arrowModifiers = useMemo(() => ({
|
|
6191
|
+
dir: expandedDirection
|
|
6192
|
+
}), [expandedDirection]);
|
|
6193
|
+
const _arrowClassName = useBEM({
|
|
6194
|
+
block: menuClass,
|
|
6195
|
+
element: menuArrowClass,
|
|
6196
|
+
modifiers: arrowModifiers,
|
|
6197
|
+
className: arrowProps.className
|
|
6198
|
+
});
|
|
6199
|
+
const menu = /*#__PURE__*/jsxs("ul", {
|
|
6200
|
+
role: "menu",
|
|
6201
|
+
"aria-label": ariaLabel,
|
|
6202
|
+
...commonProps(isDisabled),
|
|
6203
|
+
...mergeProps({
|
|
6204
|
+
onPointerEnter: parentSubmenuCtx == null ? void 0 : parentSubmenuCtx.off,
|
|
6205
|
+
onPointerMove,
|
|
6206
|
+
onPointerLeave,
|
|
6207
|
+
onKeyDown,
|
|
6208
|
+
onAnimationEnd
|
|
6209
|
+
}, restProps),
|
|
6210
|
+
ref: useCombinedRef(externalRef, menuRef),
|
|
6211
|
+
className: useBEM({
|
|
6212
|
+
block: menuClass,
|
|
6213
|
+
modifiers,
|
|
6214
|
+
className: menuClassName
|
|
6215
|
+
}),
|
|
6216
|
+
style: {
|
|
6217
|
+
...menuStyle,
|
|
6218
|
+
...overflowStyle,
|
|
6219
|
+
margin: 0,
|
|
6220
|
+
display: state === 'closed' ? 'none' : undefined,
|
|
6221
|
+
position: positionAbsolute,
|
|
6222
|
+
left: menuPosition.x,
|
|
6223
|
+
top: menuPosition.y
|
|
6224
|
+
},
|
|
6225
|
+
children: [/*#__PURE__*/jsx("li", {
|
|
6226
|
+
tabIndex: -1,
|
|
6227
|
+
style: {
|
|
6228
|
+
position: positionAbsolute,
|
|
6229
|
+
left: 0,
|
|
6230
|
+
top: 0,
|
|
6231
|
+
display: 'block',
|
|
6232
|
+
outline: 'none'
|
|
6233
|
+
},
|
|
6234
|
+
ref: focusRef,
|
|
6235
|
+
...dummyItemProps,
|
|
6236
|
+
...focusProps
|
|
6237
|
+
}), arrow && /*#__PURE__*/jsx("li", {
|
|
6238
|
+
...dummyItemProps,
|
|
6239
|
+
...arrowProps,
|
|
6240
|
+
className: _arrowClassName,
|
|
6241
|
+
style: {
|
|
6242
|
+
display: 'block',
|
|
6243
|
+
position: positionAbsolute,
|
|
6244
|
+
left: arrowPosition.x,
|
|
6245
|
+
top: arrowPosition.y,
|
|
6246
|
+
...arrowProps.style
|
|
6247
|
+
},
|
|
6248
|
+
ref: arrowRef
|
|
6249
|
+
}), /*#__PURE__*/jsx(MenuListContext.Provider, {
|
|
6250
|
+
value: listContext,
|
|
6251
|
+
children: /*#__PURE__*/jsx(MenuListItemContext.Provider, {
|
|
6252
|
+
value: itemContext,
|
|
6253
|
+
children: /*#__PURE__*/jsx(HoverItemContext.Provider, {
|
|
6254
|
+
value: hoverItem,
|
|
6255
|
+
children: safeCall(children, modifiers)
|
|
6256
|
+
})
|
|
6257
|
+
})
|
|
6258
|
+
})]
|
|
6259
|
+
});
|
|
6260
|
+
return containerProps ? /*#__PURE__*/jsx(MenuContainer, {
|
|
6261
|
+
...containerProps,
|
|
6262
|
+
isOpen: isOpen,
|
|
6263
|
+
children: menu
|
|
6264
|
+
}) : menu;
|
|
6265
|
+
};
|
|
6266
|
+
|
|
6267
|
+
const ControlledMenu = /*#__PURE__*/forwardRef(function ControlledMenu({
|
|
6268
|
+
'aria-label': ariaLabel,
|
|
6269
|
+
className,
|
|
6270
|
+
containerProps,
|
|
6271
|
+
initialMounted,
|
|
6272
|
+
unmountOnClose,
|
|
6273
|
+
transition,
|
|
6274
|
+
transitionTimeout,
|
|
6275
|
+
boundingBoxRef,
|
|
6276
|
+
boundingBoxPadding,
|
|
6277
|
+
reposition = 'auto',
|
|
6278
|
+
submenuOpenDelay = 300,
|
|
6279
|
+
submenuCloseDelay = 150,
|
|
6280
|
+
viewScroll = 'initial',
|
|
6281
|
+
portal,
|
|
6282
|
+
theming,
|
|
6283
|
+
onItemClick,
|
|
6284
|
+
...restProps
|
|
6285
|
+
}, externalRef) {
|
|
6286
|
+
const containerRef = useRef(null);
|
|
6287
|
+
const scrollNodesRef = useRef({});
|
|
6288
|
+
const {
|
|
6289
|
+
anchorRef,
|
|
6290
|
+
state,
|
|
6291
|
+
onClose
|
|
6292
|
+
} = restProps;
|
|
6293
|
+
const settings = useMemo(() => ({
|
|
6294
|
+
initialMounted,
|
|
6295
|
+
unmountOnClose,
|
|
6296
|
+
transition,
|
|
6297
|
+
transitionTimeout,
|
|
6298
|
+
boundingBoxRef,
|
|
6299
|
+
boundingBoxPadding,
|
|
6300
|
+
rootMenuRef: containerRef,
|
|
6301
|
+
rootAnchorRef: anchorRef,
|
|
6302
|
+
scrollNodesRef,
|
|
6303
|
+
reposition,
|
|
6304
|
+
viewScroll,
|
|
6305
|
+
submenuOpenDelay,
|
|
6306
|
+
submenuCloseDelay
|
|
6307
|
+
}), [initialMounted, unmountOnClose, transition, transitionTimeout, anchorRef, boundingBoxRef, boundingBoxPadding, reposition, viewScroll, submenuOpenDelay, submenuCloseDelay]);
|
|
6308
|
+
const eventHandlers = useMemo(() => ({
|
|
6309
|
+
handleClick(event, isCheckorRadio) {
|
|
6310
|
+
if (!event.stopPropagation) safeCall(onItemClick, event);
|
|
6311
|
+
let keepOpen = event.keepOpen;
|
|
6312
|
+
if (keepOpen === undefined) {
|
|
6313
|
+
keepOpen = isCheckorRadio && event.key === Keys.SPACE;
|
|
6314
|
+
}
|
|
6315
|
+
if (!keepOpen) {
|
|
6316
|
+
safeCall(onClose, {
|
|
6317
|
+
value: event.value,
|
|
6318
|
+
key: event.key,
|
|
6319
|
+
reason: CloseReason.CLICK
|
|
6320
|
+
});
|
|
6321
|
+
}
|
|
6322
|
+
},
|
|
6323
|
+
handleClose(key) {
|
|
6324
|
+
safeCall(onClose, {
|
|
6325
|
+
key,
|
|
6326
|
+
reason: CloseReason.CLICK
|
|
6327
|
+
});
|
|
6328
|
+
}
|
|
6329
|
+
}), [onItemClick, onClose]);
|
|
6330
|
+
if (!state) return null;
|
|
6331
|
+
const menuList = /*#__PURE__*/jsx(SettingsContext.Provider, {
|
|
6332
|
+
value: settings,
|
|
6333
|
+
children: /*#__PURE__*/jsx(EventHandlersContext.Provider, {
|
|
6334
|
+
value: eventHandlers,
|
|
6335
|
+
children: /*#__PURE__*/jsx(MenuList, {
|
|
6336
|
+
...restProps,
|
|
6337
|
+
ariaLabel: ariaLabel || 'Menu',
|
|
6338
|
+
externalRef: externalRef,
|
|
6339
|
+
containerRef: containerRef,
|
|
6340
|
+
containerProps: {
|
|
6341
|
+
className,
|
|
6342
|
+
containerRef,
|
|
6343
|
+
containerProps,
|
|
6344
|
+
theming,
|
|
6345
|
+
transition,
|
|
6346
|
+
onClose
|
|
6347
|
+
}
|
|
6348
|
+
})
|
|
6349
|
+
})
|
|
6350
|
+
});
|
|
6351
|
+
if (portal === true && typeof document !== 'undefined') {
|
|
6352
|
+
return /*#__PURE__*/createPortal(menuList, document.body);
|
|
6353
|
+
} else if (portal) {
|
|
6354
|
+
return portal.target ? /*#__PURE__*/createPortal(menuList, portal.target) : portal.stablePosition ? null : menuList;
|
|
6355
|
+
}
|
|
6356
|
+
return menuList;
|
|
6357
|
+
});
|
|
6358
|
+
process.env.NODE_ENV !== "production" ? ControlledMenu.propTypes = {
|
|
6359
|
+
...rootMenuPropTypes,
|
|
6360
|
+
state: /*#__PURE__*/propTypes.exports.oneOf( /*#__PURE__*/values(MenuStateMap)),
|
|
6361
|
+
anchorPoint: /*#__PURE__*/propTypes.exports.exact({
|
|
6362
|
+
x: propTypes.exports.number,
|
|
6363
|
+
y: propTypes.exports.number
|
|
6364
|
+
}),
|
|
6365
|
+
anchorRef: propTypes.exports.object,
|
|
6366
|
+
captureFocus: propTypes.exports.bool,
|
|
6367
|
+
menuItemFocus: /*#__PURE__*/propTypes.exports.exact({
|
|
6368
|
+
position: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
|
|
6369
|
+
alwaysUpdate: propTypes.exports.bool
|
|
6370
|
+
}),
|
|
6371
|
+
onClose: propTypes.exports.func
|
|
6372
|
+
} : void 0;
|
|
6373
|
+
|
|
6374
|
+
const PRE_ENTER = 0;
|
|
6375
|
+
const ENTERING = 1;
|
|
6376
|
+
const ENTERED = 2;
|
|
6377
|
+
const PRE_EXIT = 3;
|
|
6378
|
+
const EXITING = 4;
|
|
6379
|
+
const EXITED = 5;
|
|
6380
|
+
const UNMOUNTED = 6;
|
|
6381
|
+
const STATUS = ['preEnter', 'entering', 'entered', 'preExit', 'exiting', 'exited', 'unmounted'];
|
|
6382
|
+
const getState = status => ({
|
|
6383
|
+
_s: status,
|
|
6384
|
+
status: STATUS[status],
|
|
6385
|
+
isEnter: status < PRE_EXIT,
|
|
6386
|
+
isMounted: status !== UNMOUNTED,
|
|
6387
|
+
isResolved: status === ENTERED || status > EXITING
|
|
6388
|
+
});
|
|
6389
|
+
const startOrEnd = unmounted => unmounted ? UNMOUNTED : EXITED;
|
|
6390
|
+
const getEndStatus = (status, unmountOnExit) => {
|
|
6391
|
+
switch (status) {
|
|
6392
|
+
case ENTERING:
|
|
6393
|
+
case PRE_ENTER:
|
|
6394
|
+
return ENTERED;
|
|
6395
|
+
case EXITING:
|
|
6396
|
+
case PRE_EXIT:
|
|
6397
|
+
return startOrEnd(unmountOnExit);
|
|
6398
|
+
}
|
|
6399
|
+
};
|
|
6400
|
+
const getTimeout = timeout => typeof timeout === 'object' ? [timeout.enter, timeout.exit] : [timeout, timeout];
|
|
6401
|
+
const nextTick = (transitState, status) => setTimeout(() => {
|
|
6402
|
+
// Reading document.body.offsetTop can force browser to repaint before transition to the next state
|
|
6403
|
+
isNaN(document.body.offsetTop) || transitState(status + 1);
|
|
6404
|
+
}, 0);
|
|
6405
|
+
|
|
6406
|
+
const updateState = (status, setState, latestState, timeoutId, onChange) => {
|
|
6407
|
+
clearTimeout(timeoutId.current);
|
|
6408
|
+
const state = getState(status);
|
|
6409
|
+
setState(state);
|
|
6410
|
+
latestState.current = state;
|
|
6411
|
+
onChange && onChange({
|
|
6412
|
+
current: state
|
|
6413
|
+
});
|
|
6414
|
+
};
|
|
6415
|
+
const useTransition = ({
|
|
6416
|
+
enter = true,
|
|
6417
|
+
exit = true,
|
|
6418
|
+
preEnter,
|
|
6419
|
+
preExit,
|
|
6420
|
+
timeout,
|
|
6421
|
+
initialEntered,
|
|
6422
|
+
mountOnEnter,
|
|
6423
|
+
unmountOnExit,
|
|
6424
|
+
onStateChange: onChange
|
|
6425
|
+
} = {}) => {
|
|
6426
|
+
const [state, setState] = useState(() => getState(initialEntered ? ENTERED : startOrEnd(mountOnEnter)));
|
|
6427
|
+
const latestState = useRef(state);
|
|
6428
|
+
const timeoutId = useRef();
|
|
6429
|
+
const [enterTimeout, exitTimeout] = getTimeout(timeout);
|
|
6430
|
+
const endTransition = useCallback(() => {
|
|
6431
|
+
const status = getEndStatus(latestState.current._s, unmountOnExit);
|
|
6432
|
+
status && updateState(status, setState, latestState, timeoutId, onChange);
|
|
6433
|
+
}, [onChange, unmountOnExit]);
|
|
6434
|
+
const toggle = useCallback(toEnter => {
|
|
6435
|
+
const transitState = status => {
|
|
6436
|
+
updateState(status, setState, latestState, timeoutId, onChange);
|
|
6437
|
+
switch (status) {
|
|
6438
|
+
case ENTERING:
|
|
6439
|
+
if (enterTimeout >= 0) timeoutId.current = setTimeout(endTransition, enterTimeout);
|
|
6440
|
+
break;
|
|
6441
|
+
case EXITING:
|
|
6442
|
+
if (exitTimeout >= 0) timeoutId.current = setTimeout(endTransition, exitTimeout);
|
|
6443
|
+
break;
|
|
6444
|
+
case PRE_ENTER:
|
|
6445
|
+
case PRE_EXIT:
|
|
6446
|
+
timeoutId.current = nextTick(transitState, status);
|
|
6447
|
+
break;
|
|
6448
|
+
}
|
|
6449
|
+
};
|
|
6450
|
+
const enterStage = latestState.current.isEnter;
|
|
6451
|
+
if (typeof toEnter !== 'boolean') toEnter = !enterStage;
|
|
6452
|
+
if (toEnter) {
|
|
6453
|
+
!enterStage && transitState(enter ? preEnter ? PRE_ENTER : ENTERING : ENTERED);
|
|
6454
|
+
} else {
|
|
6455
|
+
enterStage && transitState(exit ? preExit ? PRE_EXIT : EXITING : startOrEnd(unmountOnExit));
|
|
6456
|
+
}
|
|
6457
|
+
}, [endTransition, onChange, enter, exit, preEnter, preExit, enterTimeout, exitTimeout, unmountOnExit]);
|
|
6458
|
+
useEffect(() => () => clearTimeout(timeoutId.current), []);
|
|
6459
|
+
return [state, toggle, endTransition];
|
|
6460
|
+
};
|
|
6461
|
+
|
|
6462
|
+
const useMenuState = ({
|
|
6463
|
+
initialOpen,
|
|
6464
|
+
initialMounted,
|
|
6465
|
+
unmountOnClose,
|
|
6466
|
+
transition,
|
|
6467
|
+
transitionTimeout = 500
|
|
6468
|
+
} = {}) => {
|
|
6469
|
+
const [{
|
|
6470
|
+
status
|
|
6471
|
+
}, toggleMenu, endTransition] = useTransition({
|
|
6472
|
+
initialEntered: initialOpen,
|
|
6473
|
+
mountOnEnter: !initialMounted,
|
|
6474
|
+
unmountOnExit: unmountOnClose,
|
|
6475
|
+
timeout: transitionTimeout,
|
|
6476
|
+
enter: getTransition(transition, 'open'),
|
|
6477
|
+
exit: getTransition(transition, 'close')
|
|
6478
|
+
});
|
|
6479
|
+
return [{
|
|
6480
|
+
state: MenuStateMap[status],
|
|
6481
|
+
endTransition
|
|
6482
|
+
}, toggleMenu];
|
|
6483
|
+
};
|
|
6484
|
+
|
|
6485
|
+
const useMenuStateAndFocus = options => {
|
|
6486
|
+
const [menuProps, toggleMenu] = useMenuState(options);
|
|
6487
|
+
const [menuItemFocus, setMenuItemFocus] = useState();
|
|
6488
|
+
const openMenu = (position, alwaysUpdate) => {
|
|
6489
|
+
setMenuItemFocus({
|
|
6490
|
+
position,
|
|
6491
|
+
alwaysUpdate
|
|
6492
|
+
});
|
|
6493
|
+
toggleMenu(true);
|
|
6494
|
+
};
|
|
6495
|
+
return [{
|
|
6496
|
+
menuItemFocus,
|
|
6497
|
+
...menuProps
|
|
6498
|
+
}, toggleMenu, openMenu];
|
|
6499
|
+
};
|
|
6500
|
+
|
|
6501
|
+
const useClick = (state, onToggle) => {
|
|
6502
|
+
if (process.env.NODE_ENV !== 'production' && typeof onToggle !== 'function') {
|
|
6503
|
+
throw new Error('[React-Menu] useClick/useHover requires a function in the second parameter.');
|
|
6504
|
+
}
|
|
6505
|
+
const [skipOpen] = useState({});
|
|
6506
|
+
return {
|
|
6507
|
+
onMouseDown: () => {
|
|
6508
|
+
skipOpen.v = state && state !== 'closed';
|
|
6509
|
+
},
|
|
6510
|
+
onClick: e => skipOpen.v ? skipOpen.v = false : onToggle(true, e)
|
|
6511
|
+
};
|
|
6512
|
+
};
|
|
6513
|
+
|
|
6514
|
+
const useMenuChange = (onMenuChange, isOpen) => {
|
|
6515
|
+
const prevOpen = useRef(isOpen);
|
|
6516
|
+
useEffect(() => {
|
|
6517
|
+
if (prevOpen.current !== isOpen) safeCall(onMenuChange, {
|
|
6518
|
+
open: isOpen
|
|
6519
|
+
});
|
|
6520
|
+
prevOpen.current = isOpen;
|
|
6521
|
+
}, [onMenuChange, isOpen]);
|
|
6522
|
+
};
|
|
6523
|
+
|
|
6524
|
+
const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
6525
|
+
'aria-label': ariaLabel,
|
|
6526
|
+
captureFocus: _,
|
|
6527
|
+
initialOpen: _1,
|
|
6528
|
+
menuButton,
|
|
6529
|
+
instanceRef,
|
|
6530
|
+
onMenuChange,
|
|
6531
|
+
...restProps
|
|
6532
|
+
}, externalRef) {
|
|
6533
|
+
const [stateProps, toggleMenu, openMenu] = useMenuStateAndFocus(restProps);
|
|
6534
|
+
const {
|
|
6535
|
+
state
|
|
6536
|
+
} = stateProps;
|
|
6537
|
+
const isOpen = isMenuOpen(state);
|
|
6538
|
+
const buttonRef = useRef(null);
|
|
6539
|
+
const anchorProps = useClick(state, (_, e) => openMenu(!e.detail ? FocusPositions.FIRST : undefined));
|
|
6540
|
+
const handleClose = useCallback(e => {
|
|
6541
|
+
toggleMenu(false);
|
|
6542
|
+
if (e.key) buttonRef.current.focus();
|
|
6543
|
+
}, [toggleMenu]);
|
|
6544
|
+
const onKeyDown = e => {
|
|
6545
|
+
switch (e.key) {
|
|
6546
|
+
case Keys.UP:
|
|
6547
|
+
openMenu(FocusPositions.LAST);
|
|
6548
|
+
break;
|
|
6549
|
+
case Keys.DOWN:
|
|
6550
|
+
openMenu(FocusPositions.FIRST);
|
|
6551
|
+
break;
|
|
6552
|
+
default:
|
|
6553
|
+
return;
|
|
6554
|
+
}
|
|
6555
|
+
e.preventDefault();
|
|
6556
|
+
};
|
|
6557
|
+
const button = safeCall(menuButton, {
|
|
6558
|
+
open: isOpen
|
|
6559
|
+
});
|
|
6560
|
+
if (!button || !button.type) throw new Error('Menu requires a menuButton prop.');
|
|
6561
|
+
const buttonProps = {
|
|
6562
|
+
ref: useCombinedRef(button.ref, buttonRef),
|
|
6563
|
+
...mergeProps({
|
|
6564
|
+
onKeyDown,
|
|
6565
|
+
...anchorProps
|
|
6566
|
+
}, button.props)
|
|
6567
|
+
};
|
|
6568
|
+
if (getName(button.type) === 'MenuButton') {
|
|
6569
|
+
buttonProps.isOpen = isOpen;
|
|
6570
|
+
}
|
|
6571
|
+
const renderButton = /*#__PURE__*/cloneElement(button, buttonProps);
|
|
6572
|
+
useMenuChange(onMenuChange, isOpen);
|
|
6573
|
+
useImperativeHandle(instanceRef, () => ({
|
|
6574
|
+
openMenu,
|
|
6575
|
+
closeMenu: () => toggleMenu(false)
|
|
6576
|
+
}));
|
|
6577
|
+
return /*#__PURE__*/jsxs(Fragment$1, {
|
|
6578
|
+
children: [renderButton, /*#__PURE__*/jsx(ControlledMenu, {
|
|
6579
|
+
...restProps,
|
|
6580
|
+
...stateProps,
|
|
6581
|
+
"aria-label": ariaLabel || (typeof button.props.children === 'string' ? button.props.children : 'Menu'),
|
|
6582
|
+
anchorRef: buttonRef,
|
|
6583
|
+
ref: externalRef,
|
|
6584
|
+
onClose: handleClose
|
|
6585
|
+
})]
|
|
6586
|
+
});
|
|
6587
|
+
});
|
|
6588
|
+
process.env.NODE_ENV !== "production" ? Menu.propTypes = {
|
|
6589
|
+
...rootMenuPropTypes,
|
|
6590
|
+
...uncontrolledMenuPropTypes,
|
|
6591
|
+
menuButton: propTypes.exports.oneOfType([propTypes.exports.element, propTypes.exports.func]).isRequired
|
|
6592
|
+
} : void 0;
|
|
6593
|
+
|
|
6594
|
+
const withHovering = (name, WrappedComponent) => {
|
|
6595
|
+
const Component = /*#__PURE__*/memo(WrappedComponent);
|
|
6596
|
+
const WithHovering = /*#__PURE__*/forwardRef((props, ref) => {
|
|
6597
|
+
const itemRef = useRef(null);
|
|
6598
|
+
return /*#__PURE__*/jsx(Component, {
|
|
6599
|
+
...props,
|
|
6600
|
+
itemRef: itemRef,
|
|
6601
|
+
externalRef: ref,
|
|
6602
|
+
isHovering: useContext(HoverItemContext) === itemRef.current
|
|
6603
|
+
});
|
|
6604
|
+
});
|
|
6605
|
+
WithHovering.displayName = `WithHovering(${name})`;
|
|
6606
|
+
return WithHovering;
|
|
6607
|
+
};
|
|
6608
|
+
|
|
6609
|
+
const useItemEffect = (isDisabled, itemRef, updateItems) => {
|
|
6610
|
+
useIsomorphicLayoutEffect$2(() => {
|
|
6611
|
+
if (process.env.NODE_ENV !== 'production' && !updateItems) {
|
|
6612
|
+
throw new Error(`[React-Menu] This menu item or submenu should be rendered under a menu: ${itemRef.current.outerHTML}`);
|
|
6613
|
+
}
|
|
6614
|
+
if (isDisabled) return;
|
|
6615
|
+
const item = itemRef.current;
|
|
6616
|
+
updateItems(item, true);
|
|
6617
|
+
return () => {
|
|
6618
|
+
updateItems(item);
|
|
6619
|
+
};
|
|
6620
|
+
}, [isDisabled, itemRef, updateItems]);
|
|
6621
|
+
};
|
|
6622
|
+
|
|
6623
|
+
const useItemState = (itemRef, focusRef, isHovering, isDisabled) => {
|
|
6624
|
+
const {
|
|
6625
|
+
submenuCloseDelay
|
|
6626
|
+
} = useContext(SettingsContext);
|
|
6627
|
+
const {
|
|
6628
|
+
isParentOpen,
|
|
6629
|
+
submenuCtx,
|
|
6630
|
+
dispatch,
|
|
6631
|
+
updateItems
|
|
6632
|
+
} = useContext(MenuListItemContext);
|
|
6633
|
+
const setHover = () => {
|
|
6634
|
+
!isHovering && !isDisabled && dispatch(HoverActionTypes.SET, itemRef.current);
|
|
6635
|
+
};
|
|
6636
|
+
const unsetHover = () => {
|
|
6637
|
+
!isDisabled && dispatch(HoverActionTypes.UNSET, itemRef.current);
|
|
6638
|
+
};
|
|
6639
|
+
const onBlur = e => {
|
|
6640
|
+
if (isHovering && !e.currentTarget.contains(e.relatedTarget)) unsetHover();
|
|
6641
|
+
};
|
|
6642
|
+
const onPointerMove = e => {
|
|
6643
|
+
if (!isDisabled) {
|
|
6644
|
+
e.stopPropagation();
|
|
6645
|
+
submenuCtx.on(submenuCloseDelay, setHover, setHover);
|
|
6646
|
+
}
|
|
6647
|
+
};
|
|
6648
|
+
const onPointerLeave = (_, keepHover) => {
|
|
6649
|
+
submenuCtx.off();
|
|
6650
|
+
!keepHover && unsetHover();
|
|
6651
|
+
};
|
|
6652
|
+
useItemEffect(isDisabled, itemRef, updateItems);
|
|
6653
|
+
useEffect(() => {
|
|
6654
|
+
if (isHovering && isParentOpen) {
|
|
6655
|
+
focusRef.current && focusRef.current.focus();
|
|
6656
|
+
}
|
|
6657
|
+
}, [focusRef, isHovering, isParentOpen]);
|
|
6658
|
+
return {
|
|
6659
|
+
setHover,
|
|
6660
|
+
onBlur,
|
|
6661
|
+
onPointerMove,
|
|
6662
|
+
onPointerLeave
|
|
6663
|
+
};
|
|
6664
|
+
};
|
|
6665
|
+
|
|
6666
|
+
const MenuItem = /*#__PURE__*/withHovering('MenuItem', function MenuItem({
|
|
6667
|
+
className,
|
|
6668
|
+
value,
|
|
6669
|
+
href,
|
|
6670
|
+
type,
|
|
6671
|
+
checked,
|
|
6672
|
+
disabled,
|
|
6673
|
+
children,
|
|
6674
|
+
onClick,
|
|
6675
|
+
isHovering,
|
|
6676
|
+
itemRef,
|
|
6677
|
+
externalRef,
|
|
6678
|
+
...restProps
|
|
6679
|
+
}) {
|
|
6680
|
+
const isDisabled = !!disabled;
|
|
6681
|
+
const {
|
|
6682
|
+
setHover,
|
|
6683
|
+
...restStateProps
|
|
6684
|
+
} = useItemState(itemRef, itemRef, isHovering, isDisabled);
|
|
6685
|
+
const eventHandlers = useContext(EventHandlersContext);
|
|
6686
|
+
const radioGroup = useContext(RadioGroupContext);
|
|
6687
|
+
const isRadio = type === 'radio';
|
|
6688
|
+
const isCheckBox = type === 'checkbox';
|
|
6689
|
+
const isAnchor = !!href && !isDisabled && !isRadio && !isCheckBox;
|
|
6690
|
+
const isChecked = isRadio ? radioGroup.value === value : isCheckBox ? !!checked : false;
|
|
6691
|
+
const handleClick = e => {
|
|
6692
|
+
if (isDisabled) {
|
|
6693
|
+
e.stopPropagation();
|
|
6694
|
+
e.preventDefault();
|
|
6695
|
+
return;
|
|
6696
|
+
}
|
|
6697
|
+
const event = {
|
|
6698
|
+
value,
|
|
6699
|
+
syntheticEvent: e
|
|
6700
|
+
};
|
|
6701
|
+
if (e.key !== undefined) event.key = e.key;
|
|
6702
|
+
if (isCheckBox) event.checked = !isChecked;
|
|
6703
|
+
if (isRadio) event.name = radioGroup.name;
|
|
6704
|
+
safeCall(onClick, event);
|
|
6705
|
+
if (isRadio) safeCall(radioGroup.onRadioChange, event);
|
|
6706
|
+
eventHandlers.handleClick(event, isCheckBox || isRadio);
|
|
6707
|
+
};
|
|
6708
|
+
const handleKeyDown = e => {
|
|
6709
|
+
if (!isHovering) return;
|
|
6710
|
+
switch (e.key) {
|
|
6711
|
+
case Keys.ENTER:
|
|
6712
|
+
e.preventDefault();
|
|
6713
|
+
case Keys.SPACE:
|
|
6714
|
+
isAnchor ? itemRef.current.click() : handleClick(e);
|
|
6715
|
+
}
|
|
6716
|
+
};
|
|
6717
|
+
const modifiers = useMemo(() => ({
|
|
6718
|
+
type,
|
|
6719
|
+
disabled: isDisabled,
|
|
6720
|
+
hover: isHovering,
|
|
6721
|
+
checked: isChecked,
|
|
6722
|
+
anchor: isAnchor
|
|
6723
|
+
}), [type, isDisabled, isHovering, isChecked, isAnchor]);
|
|
6724
|
+
const mergedProps = mergeProps({
|
|
6725
|
+
...restStateProps,
|
|
6726
|
+
onPointerDown: setHover,
|
|
6727
|
+
onKeyDown: handleKeyDown,
|
|
6728
|
+
onClick: handleClick
|
|
6729
|
+
}, restProps);
|
|
6730
|
+
const menuItemProps = {
|
|
6731
|
+
role: isRadio ? 'menuitemradio' : isCheckBox ? 'menuitemcheckbox' : roleMenuitem,
|
|
6732
|
+
'aria-checked': isRadio || isCheckBox ? isChecked : undefined,
|
|
6733
|
+
...commonProps(isDisabled, isHovering),
|
|
6734
|
+
...mergedProps,
|
|
6735
|
+
ref: useCombinedRef(externalRef, itemRef),
|
|
6736
|
+
className: useBEM({
|
|
6737
|
+
block: menuClass,
|
|
6738
|
+
element: menuItemClass,
|
|
6739
|
+
modifiers,
|
|
6740
|
+
className
|
|
6741
|
+
}),
|
|
6742
|
+
children: useMemo(() => safeCall(children, modifiers), [children, modifiers])
|
|
6743
|
+
};
|
|
6744
|
+
return isAnchor ? /*#__PURE__*/jsx("li", {
|
|
6745
|
+
role: roleNone,
|
|
6746
|
+
children: /*#__PURE__*/jsx("a", {
|
|
6747
|
+
href: href,
|
|
6748
|
+
...menuItemProps
|
|
6749
|
+
})
|
|
6750
|
+
}) : /*#__PURE__*/jsx("li", {
|
|
6751
|
+
...menuItemProps
|
|
6752
|
+
});
|
|
6753
|
+
});
|
|
6754
|
+
process.env.NODE_ENV !== "production" ? MenuItem.propTypes = {
|
|
6755
|
+
...stylePropTypes(),
|
|
6756
|
+
value: propTypes.exports.any,
|
|
6757
|
+
href: propTypes.exports.string,
|
|
6758
|
+
type: /*#__PURE__*/propTypes.exports.oneOf(['checkbox', 'radio']),
|
|
6759
|
+
checked: propTypes.exports.bool,
|
|
6760
|
+
disabled: propTypes.exports.bool,
|
|
6761
|
+
children: /*#__PURE__*/propTypes.exports.oneOfType([propTypes.exports.node, propTypes.exports.func]),
|
|
6762
|
+
onClick: propTypes.exports.func
|
|
6763
|
+
} : void 0;
|
|
6764
|
+
|
|
6765
|
+
function Navbar(props) {
|
|
6766
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5177
6767
|
const {
|
|
5178
6768
|
navbarOpened,
|
|
5179
6769
|
appMenu
|
|
@@ -5184,26 +6774,112 @@ function Navbar() {
|
|
|
5184
6774
|
return !a.hasPermissions || FluxoClientSys.Instance.security.currentUser.hasPermissions((_a = a.permissions) !== null && _a !== void 0 ? _a : []);
|
|
5185
6775
|
});
|
|
5186
6776
|
};
|
|
5187
|
-
return
|
|
5188
|
-
children: jsx(AppShell.
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
6777
|
+
return jsxs(Fragment, {
|
|
6778
|
+
children: [props.shellUi.navigation === ShellUINavigation.Sidebar && jsx(AppShell.Navbar, {
|
|
6779
|
+
children: jsx(AppShell.Section, {
|
|
6780
|
+
grow: true,
|
|
6781
|
+
my: "md",
|
|
6782
|
+
component: ScrollArea,
|
|
6783
|
+
children: jsx(Stack, {
|
|
6784
|
+
justify: "center",
|
|
6785
|
+
align: 'center',
|
|
6786
|
+
gap: 8,
|
|
6787
|
+
children: getPermittedNavBarItems().map((e, i) => {
|
|
6788
|
+
const IconComponent = e.icon ? IconFactory.getIcon(e.icon) : IconFactory.getIcon('Dashboard');
|
|
6789
|
+
return jsx(NavBarItem, {
|
|
6790
|
+
level: 0,
|
|
6791
|
+
routerLink: e.routerLink,
|
|
6792
|
+
icon: IconComponent,
|
|
6793
|
+
label: e.label,
|
|
6794
|
+
links: e.children && e.children.length > 0 ? e.children : undefined
|
|
6795
|
+
}, i);
|
|
6796
|
+
})
|
|
6797
|
+
})
|
|
6798
|
+
})
|
|
6799
|
+
}), props.shellUi.navigation === ShellUINavigation.Topbar && jsx(AppShell.Header, {
|
|
6800
|
+
style: {
|
|
6801
|
+
top: 48,
|
|
6802
|
+
height: 40,
|
|
6803
|
+
background: '#fff',
|
|
6804
|
+
boxShadow: 'rgba(33, 33, 33, 0.1) 2px 1px 1px'
|
|
6805
|
+
},
|
|
6806
|
+
children: jsx(Group, {
|
|
5194
6807
|
align: 'center',
|
|
5195
|
-
gap:
|
|
6808
|
+
gap: 0,
|
|
5196
6809
|
children: getPermittedNavBarItems().map((e, i) => {
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
level: 0,
|
|
5200
|
-
routerLink: e.routerLink,
|
|
5201
|
-
icon: IconComponent,
|
|
5202
|
-
label: e.label,
|
|
5203
|
-
links: e.children && e.children.length > 0 ? e.children : undefined
|
|
6810
|
+
return jsx(HorizontalRecursiveMenuItem, {
|
|
6811
|
+
item: e
|
|
5204
6812
|
}, i);
|
|
5205
6813
|
})
|
|
5206
6814
|
})
|
|
6815
|
+
})]
|
|
6816
|
+
});
|
|
6817
|
+
}
|
|
6818
|
+
function HorizontalRecursiveMenuItem(props) {
|
|
6819
|
+
var _a;
|
|
6820
|
+
const theme = useMantineTheme();
|
|
6821
|
+
const colorScheme = useMantineColorScheme();
|
|
6822
|
+
const IconComponent = props.item.icon ? IconFactory.getIcon(props.item.icon) : IconFactory.getIcon('Dashboard');
|
|
6823
|
+
const InnerMenuItemComponent = props => {
|
|
6824
|
+
const InnerIconComponent = props.item.icon ? IconFactory.getIcon(props.item.icon) : IconFactory.getIcon('Dashboard');
|
|
6825
|
+
if (props.item.children && props.item.children.length > 0) {
|
|
6826
|
+
return jsxs(Group, {
|
|
6827
|
+
pl: props.withPaddingLR ? 12 : 'inherit',
|
|
6828
|
+
pr: props.withPaddingLR ? 12 : 'inherit',
|
|
6829
|
+
children: [InnerIconComponent, jsx(Text, {
|
|
6830
|
+
size: 'sm',
|
|
6831
|
+
children: props.item.label
|
|
6832
|
+
})]
|
|
6833
|
+
});
|
|
6834
|
+
} else {
|
|
6835
|
+
return jsx(Link, {
|
|
6836
|
+
style: {
|
|
6837
|
+
color: colorScheme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.colors.gray[7],
|
|
6838
|
+
textDecoration: 'none'
|
|
6839
|
+
},
|
|
6840
|
+
state: {
|
|
6841
|
+
title: props.item.label
|
|
6842
|
+
},
|
|
6843
|
+
to: '/' + props.item.routerLink,
|
|
6844
|
+
children: jsxs(Group, {
|
|
6845
|
+
children: [InnerIconComponent, jsx(Text, {
|
|
6846
|
+
size: 'sm',
|
|
6847
|
+
children: props.item.label
|
|
6848
|
+
})]
|
|
6849
|
+
})
|
|
6850
|
+
}, props.item.label + '_' + props.item);
|
|
6851
|
+
}
|
|
6852
|
+
};
|
|
6853
|
+
if (props.item.children && props.item.children.length === 0) {
|
|
6854
|
+
return jsx(InnerMenuItemComponent, {
|
|
6855
|
+
withPaddingLR: true,
|
|
6856
|
+
item: props.item
|
|
6857
|
+
});
|
|
6858
|
+
}
|
|
6859
|
+
return jsx(Menu, {
|
|
6860
|
+
align: 'start',
|
|
6861
|
+
arrow: true,
|
|
6862
|
+
gap: -12,
|
|
6863
|
+
menuButton: jsxs(Group, {
|
|
6864
|
+
h: 40,
|
|
6865
|
+
style: {
|
|
6866
|
+
paddingLeft: 12,
|
|
6867
|
+
cursor: 'pointer'
|
|
6868
|
+
},
|
|
6869
|
+
children: [IconComponent, jsx(Text, {
|
|
6870
|
+
size: 'sm',
|
|
6871
|
+
children: props.item.label
|
|
6872
|
+
}), jsx(Divider, {
|
|
6873
|
+
orientation: 'vertical'
|
|
6874
|
+
})]
|
|
6875
|
+
}),
|
|
6876
|
+
children: (_a = props.item.children) === null || _a === void 0 ? void 0 : _a.map((e, i) => {
|
|
6877
|
+
return jsx(MenuItem, {
|
|
6878
|
+
children: jsx(InnerMenuItemComponent, {
|
|
6879
|
+
withPaddingLR: false,
|
|
6880
|
+
item: e
|
|
6881
|
+
})
|
|
6882
|
+
}, i);
|
|
5207
6883
|
})
|
|
5208
6884
|
});
|
|
5209
6885
|
}
|
|
@@ -5313,11 +6989,18 @@ function AppLayout(props) {
|
|
|
5313
6989
|
transitionDuration: 0,
|
|
5314
6990
|
layout: 'default',
|
|
5315
6991
|
children: [jsx(AppBar, {
|
|
6992
|
+
shellUi: props.ui,
|
|
5316
6993
|
brandName: props.brandName
|
|
5317
|
-
}), jsx(Navbar, {
|
|
6994
|
+
}), jsx(Navbar, {
|
|
6995
|
+
shellUi: props.ui
|
|
6996
|
+
}), jsx(AppShell.Main, {
|
|
6997
|
+
style: {
|
|
6998
|
+
paddingTop: props.ui.navigation === ShellUINavigation.Topbar ? 88 : 'inherit'
|
|
6999
|
+
},
|
|
5318
7000
|
children: jsx(Suspense, {
|
|
5319
7001
|
fallback: jsx(Loader, {}),
|
|
5320
7002
|
children: jsx(AppContent, {
|
|
7003
|
+
shellUi: props.ui,
|
|
5321
7004
|
withMultipleSessions: props.withMultipleSessions
|
|
5322
7005
|
})
|
|
5323
7006
|
})
|
|
@@ -5737,6 +7420,9 @@ function Ui() {
|
|
|
5737
7420
|
},
|
|
5738
7421
|
p: 0,
|
|
5739
7422
|
children: jsx(AppBar, {
|
|
7423
|
+
shellUi: {
|
|
7424
|
+
navigation: ShellUINavigation.Sidebar
|
|
7425
|
+
},
|
|
5740
7426
|
previewMode: {
|
|
5741
7427
|
logo: newLogoBase64,
|
|
5742
7428
|
logoHeight: newLogoHeight,
|
|
@@ -7339,7 +9025,7 @@ var ResizeObserverController = (function () {
|
|
|
7339
9025
|
return ResizeObserverController;
|
|
7340
9026
|
}());
|
|
7341
9027
|
|
|
7342
|
-
var ResizeObserver = (function () {
|
|
9028
|
+
var ResizeObserver$1 = (function () {
|
|
7343
9029
|
function ResizeObserver(callback) {
|
|
7344
9030
|
if (arguments.length === 0) {
|
|
7345
9031
|
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
@@ -19539,7 +21225,7 @@ function AnimateHeight(props) {
|
|
|
19539
21225
|
open: { opacity: 1, height: "auto" },
|
|
19540
21226
|
close: { opacity: 0, height: 0 },
|
|
19541
21227
|
} : _b, children = props.children;
|
|
19542
|
-
var _c = useMeasure({ polyfill: ResizeObserver }), ref = _c[0], height = _c[1].height;
|
|
21228
|
+
var _c = useMeasure({ polyfill: ResizeObserver$1 }), ref = _c[0], height = _c[1].height;
|
|
19543
21229
|
var _d = useState(isVisible), isVisibleChildren = _d[0], setIsVisibleChildren = _d[1];
|
|
19544
21230
|
var _e = useState(isVisible), isVisibleContainer = _e[0], setIsVisibleContainer = _e[1];
|
|
19545
21231
|
var _f = useState(false), transition = _f[0], setTransition = _f[1];
|
|
@@ -21495,6 +23181,9 @@ function MenuDesigner(props) {
|
|
|
21495
23181
|
});
|
|
21496
23182
|
};
|
|
21497
23183
|
const isModuleAttachedToFrontend = (module, frontend) => {
|
|
23184
|
+
// workaround momentaneo. Bisogna capire come eventualmente
|
|
23185
|
+
// abbinare le app dinamiche ai frontend. Per ora, tutte quelle che non sono fluxo, vengono abbinate
|
|
23186
|
+
if (module.key !== 'fluxo') return true;
|
|
21498
23187
|
const shellFrontend = props.frontends.find(a => a.id === (currentWebMenu === null || currentWebMenu === void 0 ? void 0 : currentWebMenu.frontend));
|
|
21499
23188
|
if ((shellFrontend === null || shellFrontend === void 0 ? void 0 : shellFrontend.modules.filter(a => a.scope === module.key).length) === 0) return false;
|
|
21500
23189
|
return true;
|
|
@@ -27789,30 +29478,30 @@ function AppItem(props) {
|
|
|
27789
29478
|
}), jsx(Badge, {
|
|
27790
29479
|
color: 'gray',
|
|
27791
29480
|
children: moment(props.app.installationDate).format("DD/MM/yyyy")
|
|
27792
|
-
}), jsxs(Menu, {
|
|
29481
|
+
}), jsxs(Menu$1, {
|
|
27793
29482
|
shadow: "md",
|
|
27794
29483
|
width: 200,
|
|
27795
|
-
children: [jsx(Menu.Target, {
|
|
29484
|
+
children: [jsx(Menu$1.Target, {
|
|
27796
29485
|
children: jsx(ActionIcon, {
|
|
27797
29486
|
children: jsx(IconDotsVertical, {
|
|
27798
29487
|
size: 18
|
|
27799
29488
|
})
|
|
27800
29489
|
})
|
|
27801
|
-
}), jsxs(Menu.Dropdown, {
|
|
27802
|
-
children: [jsx(Menu.Item, {
|
|
29490
|
+
}), jsxs(Menu$1.Dropdown, {
|
|
29491
|
+
children: [jsx(Menu$1.Item, {
|
|
27803
29492
|
leftSection: jsx(IconCircleOff, {
|
|
27804
29493
|
size: 14
|
|
27805
29494
|
}),
|
|
27806
29495
|
onClick: props.app.state == AppState.Active ? disable : enable,
|
|
27807
29496
|
children: props.app.state == AppState.Active ? 'Disattiva' : 'Attiva'
|
|
27808
|
-
}), jsx(Menu.Item, {
|
|
29497
|
+
}), jsx(Menu$1.Item, {
|
|
27809
29498
|
onClick: () => setShowUpgradeAppModal(true),
|
|
27810
29499
|
leftSection: jsx(IconArrowUp, {
|
|
27811
29500
|
color: 'green',
|
|
27812
29501
|
size: 14
|
|
27813
29502
|
}),
|
|
27814
29503
|
children: "Aggiorna"
|
|
27815
|
-
}), jsx(Menu.Divider, {}), jsx(Menu.Item, {
|
|
29504
|
+
}), jsx(Menu$1.Divider, {}), jsx(Menu$1.Item, {
|
|
27816
29505
|
color: 'red',
|
|
27817
29506
|
onClick: () => setShowDeleteModal(true),
|
|
27818
29507
|
leftSection: jsx(IconTrash, {
|
|
@@ -28000,23 +29689,23 @@ function AppJitItem(props) {
|
|
|
28000
29689
|
}), jsx(Badge, {
|
|
28001
29690
|
color: 'gray',
|
|
28002
29691
|
children: moment(props.app.installationDate).format("DD/MM/yyyy")
|
|
28003
|
-
}), jsxs(Menu, {
|
|
29692
|
+
}), jsxs(Menu$1, {
|
|
28004
29693
|
shadow: "md",
|
|
28005
29694
|
width: 200,
|
|
28006
|
-
children: [jsx(Menu.Target, {
|
|
29695
|
+
children: [jsx(Menu$1.Target, {
|
|
28007
29696
|
children: jsx(ActionIcon, {
|
|
28008
29697
|
children: jsx(IconDotsVertical, {
|
|
28009
29698
|
size: 18
|
|
28010
29699
|
})
|
|
28011
29700
|
})
|
|
28012
|
-
}), jsxs(Menu.Dropdown, {
|
|
28013
|
-
children: [jsx(Menu.Item, {
|
|
29701
|
+
}), jsxs(Menu$1.Dropdown, {
|
|
29702
|
+
children: [jsx(Menu$1.Item, {
|
|
28014
29703
|
leftSection: jsx(IconCircleOff, {
|
|
28015
29704
|
size: 14
|
|
28016
29705
|
}),
|
|
28017
29706
|
onClick: props.app.state == AppState.Active ? disable : enable,
|
|
28018
29707
|
children: props.app.state == AppState.Active ? 'Disattiva' : 'Attiva'
|
|
28019
|
-
}), jsx(Menu.Divider, {}), jsx(Menu.Item, {
|
|
29708
|
+
}), jsx(Menu$1.Divider, {}), jsx(Menu$1.Item, {
|
|
28020
29709
|
color: 'red',
|
|
28021
29710
|
onClick: () => setShowDeleteModal(true),
|
|
28022
29711
|
leftSection: jsx(IconTrash, {
|
|
@@ -29059,17 +30748,17 @@ function DomainRoleGrid() {
|
|
|
29059
30748
|
}), jsx(Table.Td, {
|
|
29060
30749
|
w: 100,
|
|
29061
30750
|
align: "right",
|
|
29062
|
-
children: jsxs(Menu, {
|
|
30751
|
+
children: jsxs(Menu$1, {
|
|
29063
30752
|
shadow: "md",
|
|
29064
30753
|
width: 200,
|
|
29065
|
-
children: [jsx(Menu.Target, {
|
|
30754
|
+
children: [jsx(Menu$1.Target, {
|
|
29066
30755
|
children: jsx(ActionIcon, {
|
|
29067
30756
|
children: jsx(IconDotsVertical, {
|
|
29068
30757
|
size: 18
|
|
29069
30758
|
})
|
|
29070
30759
|
})
|
|
29071
|
-
}), jsxs(Menu.Dropdown, {
|
|
29072
|
-
children: [jsx(Menu.Item, {
|
|
30760
|
+
}), jsxs(Menu$1.Dropdown, {
|
|
30761
|
+
children: [jsx(Menu$1.Item, {
|
|
29073
30762
|
leftSection: jsx(IconGridDots, {
|
|
29074
30763
|
size: 14
|
|
29075
30764
|
}),
|
|
@@ -29078,7 +30767,7 @@ function DomainRoleGrid() {
|
|
|
29078
30767
|
setUpdateDomainFrontendsModal(true);
|
|
29079
30768
|
},
|
|
29080
30769
|
children: "Aree funzionali"
|
|
29081
|
-
}), jsx(Menu.Item, {
|
|
30770
|
+
}), jsx(Menu$1.Item, {
|
|
29082
30771
|
leftSection: jsx(IconLock, {
|
|
29083
30772
|
size: 14
|
|
29084
30773
|
}),
|
|
@@ -29087,7 +30776,7 @@ function DomainRoleGrid() {
|
|
|
29087
30776
|
setUpdateDomainRolePermissionsModal(true);
|
|
29088
30777
|
},
|
|
29089
30778
|
children: "Permessi"
|
|
29090
|
-
}), jsx(Menu.Item, {
|
|
30779
|
+
}), jsx(Menu$1.Item, {
|
|
29091
30780
|
onClick: () => {
|
|
29092
30781
|
setCurrentDomainRole(element);
|
|
29093
30782
|
setDomainRoleModalOpen(true);
|
|
@@ -29096,7 +30785,7 @@ function DomainRoleGrid() {
|
|
|
29096
30785
|
size: 14
|
|
29097
30786
|
}),
|
|
29098
30787
|
children: "Modifica"
|
|
29099
|
-
}), jsx(Menu.Divider, {}), jsx(Menu.Item, {
|
|
30788
|
+
}), jsx(Menu$1.Divider, {}), jsx(Menu$1.Item, {
|
|
29100
30789
|
color: 'red',
|
|
29101
30790
|
onClick: () => deleteDomainRole(element.id),
|
|
29102
30791
|
leftSection: jsx(IconTrash, {
|
|
@@ -29420,17 +31109,17 @@ function UsersGrid() {
|
|
|
29420
31109
|
})
|
|
29421
31110
|
}), jsx(Table.Td, {
|
|
29422
31111
|
align: "right",
|
|
29423
|
-
children: jsxs(Menu, {
|
|
31112
|
+
children: jsxs(Menu$1, {
|
|
29424
31113
|
shadow: "md",
|
|
29425
31114
|
width: 200,
|
|
29426
|
-
children: [jsx(Menu.Target, {
|
|
31115
|
+
children: [jsx(Menu$1.Target, {
|
|
29427
31116
|
children: jsx(ActionIcon, {
|
|
29428
31117
|
children: jsx(IconDotsVertical, {
|
|
29429
31118
|
size: 18
|
|
29430
31119
|
})
|
|
29431
31120
|
})
|
|
29432
|
-
}), jsxs(Menu.Dropdown, {
|
|
29433
|
-
children: [jsx(Menu.Item, {
|
|
31121
|
+
}), jsxs(Menu$1.Dropdown, {
|
|
31122
|
+
children: [jsx(Menu$1.Item, {
|
|
29434
31123
|
onClick: () => {
|
|
29435
31124
|
setCurrentUser(element);
|
|
29436
31125
|
setNewUserModalOpen(true);
|
|
@@ -29439,7 +31128,7 @@ function UsersGrid() {
|
|
|
29439
31128
|
size: 14
|
|
29440
31129
|
}),
|
|
29441
31130
|
children: "Modifica"
|
|
29442
|
-
}), jsx(Menu.Item, {
|
|
31131
|
+
}), jsx(Menu$1.Item, {
|
|
29443
31132
|
color: 'red',
|
|
29444
31133
|
onClick: () => deletion(element.id),
|
|
29445
31134
|
leftSection: jsx(IconTrash, {
|
|
@@ -30476,6 +32165,11 @@ function FrontendSwitcher(props) {
|
|
|
30476
32165
|
});
|
|
30477
32166
|
}
|
|
30478
32167
|
|
|
32168
|
+
var ShellUINavigation;
|
|
32169
|
+
(function (ShellUINavigation) {
|
|
32170
|
+
ShellUINavigation[ShellUINavigation["Sidebar"] = 1] = "Sidebar";
|
|
32171
|
+
ShellUINavigation[ShellUINavigation["Topbar"] = 2] = "Topbar";
|
|
32172
|
+
})(ShellUINavigation || (ShellUINavigation = {}));
|
|
30479
32173
|
function FluxoShell(props) {
|
|
30480
32174
|
const [initialOperationsFinished, setInitialOperationsFinished] = useState(false);
|
|
30481
32175
|
const [router, setRouter] = useState();
|
|
@@ -30654,6 +32348,7 @@ function FluxoShell(props) {
|
|
|
30654
32348
|
const FrontendLayout = () => {
|
|
30655
32349
|
var _a, _b;
|
|
30656
32350
|
return (_a = frontendByRender === null || frontendByRender === void 0 ? void 0 : frontendByRender.layout) !== null && _a !== void 0 ? _a : jsx(AppLayout, {
|
|
32351
|
+
ui: props.ui,
|
|
30657
32352
|
withMultipleSessions: props.withMultipleSessions,
|
|
30658
32353
|
brandName: (_b = props.brandName) !== null && _b !== void 0 ? _b : 'Fluxo',
|
|
30659
32354
|
appVersion: props.appVersion
|
|
@@ -30876,4 +32571,4 @@ function AppInner(props) {
|
|
|
30876
32571
|
});
|
|
30877
32572
|
}
|
|
30878
32573
|
|
|
30879
|
-
export { FluxoShell, FrontendSwitch };
|
|
32574
|
+
export { FluxoShell, FrontendSwitch, ShellUINavigation };
|