@learningpool/ui 1.15.4 → 1.16.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/assets/Images.js +7 -18
- package/components/atoms/Autocomplete/Autocomplete.js +3 -14
- package/components/atoms/Button/Button.js +2 -13
- package/components/atoms/Checkbox/Checkbox.js +3 -26
- package/components/atoms/IconButton/IconButton.js +2 -13
- package/components/atoms/Radio/Radio.js +3 -26
- package/components/atoms/Select/Select.js +3 -26
- package/components/atoms/Slider/Slider.js +3 -26
- package/components/atoms/Switch/Switch.js +3 -26
- package/components/atoms/TextField/TextField.js +2 -13
- package/components/atoms/ToggleButton/ToggleButton.js +3 -26
- package/components/datadisplay/Avatar/Avatar.js +13 -28
- package/components/datadisplay/Chip/Chip.js +3 -26
- package/components/datadisplay/List/List.js +2 -13
- package/components/feedback/Alert/Alert.js +3 -26
- package/components/landmarks/Header/Header.js +15 -41
- package/components/landmarks/Header/HeaderActionButtons.d.ts +1 -2
- package/components/landmarks/Header/HeaderActionButtons.js +22 -33
- package/components/landmarks/Header/HeaderStyles.js +54 -11
- package/components/navigation/Drawer/Drawer.js +5 -31
- package/components/navigation/MobileNavigation/MobileNavigation.js +70 -82
- package/components/navigation/MobileNavigation/MobileNavigationAvatar.js +75 -83
- package/components/navigation/MobileNavigation/MobileNavigationAvatarStyles.d.ts +102 -52
- package/components/navigation/MobileNavigation/MobileNavigationAvatarStyles.js +71 -13
- package/components/navigation/MobileNavigation/MobileNavigationDrawer.d.ts +1 -1
- package/components/navigation/MobileNavigation/MobileNavigationDrawer.js +41 -68
- package/components/navigation/MobileNavigation/MobileNavigationDrawerStyles.d.ts +34 -18
- package/components/navigation/MobileNavigation/MobileNavigationDrawerStyles.js +133 -20
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItem.js +22 -45
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemFlyoutMenu.js +8 -19
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemFlyoutMenuStyles.js +151 -52
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemStyles.js +171 -50
- package/components/navigation/MobileNavigation/MobileNavigationMotion.js +11 -11
- package/components/navigation/MobileNavigation/MobileNavigationNotchIndicator.js +11 -15
- package/components/navigation/MobileNavigation/MobileNavigationSearch.d.ts +1 -2
- package/components/navigation/MobileNavigation/MobileNavigationSearch.js +25 -34
- package/components/navigation/MobileNavigation/MobileNavigationSearchStyles.d.ts +34 -18
- package/components/navigation/MobileNavigation/MobileNavigationSearchStyles.js +47 -9
- package/components/navigation/MobileNavigation/MobileNavigationStyles.js +262 -66
- package/components/navigation/MobileNavigation/MobileNavigationToggleSearchX.js +21 -20
- package/components/navigation/MobileNavigation/MobileNavigationToggleX.js +21 -20
- package/components/navigation/VerticalNavigation/VerticalNavigation.js +150 -185
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatar.js +50 -61
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.d.ts +102 -52
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.js +86 -14
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItem.js +27 -51
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenu.js +15 -28
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenuStyles.js +135 -39
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemStyles.js +167 -29
- package/components/navigation/VerticalNavigation/VerticalNavigationMotion.js +11 -11
- package/components/navigation/VerticalNavigation/VerticalNavigationStyles.d.ts +34 -18
- package/components/navigation/VerticalNavigation/VerticalNavigationStyles.js +236 -42
- package/components/navigation/helpers.d.ts +1 -2
- package/components/navigation/helpers.js +28 -32
- package/components/pages/ErrorPage/ErrorPage.js +6 -17
- package/components/pages/ErrorPage/ErrorPageStyles.js +13 -18
- package/components/pages/SideInSide/SideInSide.js +12 -23
- package/components/pages/SideInSide/SideInSideStyles.js +6 -6
- package/components/stream/AppHub/AppHub.js +13 -42
- package/components/stream/AppHub/AppHubAdvertStyles.js +24 -8
- package/components/stream/AppHub/AppHubBannerAdvert.d.ts +1 -2
- package/components/stream/AppHub/AppHubBannerAdvert.js +10 -20
- package/components/stream/AppHub/AppHubCustom.js +8 -19
- package/components/stream/AppHub/AppHubCustomStyles.d.ts +1 -1
- package/components/stream/AppHub/AppHubCustomStyles.js +78 -18
- package/components/stream/AppHub/AppHubProduct.js +26 -48
- package/components/stream/AppHub/AppHubProductStyles.js +104 -19
- package/components/stream/AppHub/AppHubStyles.js +31 -11
- package/components/stream/AppHub/constants.d.ts +1 -2
- package/components/stream/AppHub/constants.js +14 -14
- package/components/stream/AppSwitcher/AppSwitcher.js +225 -316
- package/components/stream/AppSwitcher/AppSwitcherItem.js +11 -22
- package/components/stream/AppSwitcher/AppSwitcherStyles.js +337 -42
- package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.js +255 -21
- package/components/stream/AppSwitcher/PromotionalCampaignItem.js +7 -19
- package/components/stream/AppSwitcher/constants.d.ts +1 -0
- package/components/stream/AppSwitcher/constants.js +6 -5
- package/lang/en-us.d.ts +1 -0
- package/lang/en-us.js +2 -1
- package/package.json +7 -2
- package/utils/constants.d.ts +7 -0
- package/utils/constants.js +11 -4
- package/utils/dataAttributes.js +1 -1
- package/utils/helpers.js +33 -40
- package/utils/hooks.js +10 -11
- package/utils/theme.js +26 -19
|
@@ -1,20 +1,92 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
/* eslint-disable indent */
|
|
6
2
|
import { Avatar, Button, ButtonGroup, ListItemButton, Typography } from '../../../index';
|
|
7
3
|
import Drawer from '@mui/material/Drawer';
|
|
8
4
|
import { styled } from '@mui/material/styles';
|
|
9
5
|
import { animated } from '@react-spring/web';
|
|
10
6
|
import { getNavigationBackground, getNavigationContrastText, getOffsetNavigationBackground, getOffsetNavigationContrastText } from '../helpers';
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
export const StyledSwipeableAvatar = styled(Drawer) `
|
|
8
|
+
.MuiPaper-root {
|
|
9
|
+
height: 100vh;
|
|
10
|
+
border: none;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export const StyledButton = styled(Button) `
|
|
15
|
+
/* Fix for RTL issue */
|
|
16
|
+
.MuiButton-startIcon {
|
|
17
|
+
margin-inline-start: -${props => props.theme.spacing(0.5)};
|
|
18
|
+
margin-inline-end: ${props => props.theme.spacing(1)};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.MuiButton-endIcon {
|
|
22
|
+
margin-inline-start: ${props => props.theme.spacing(1)};
|
|
23
|
+
margin-inline-end: -${props => props.theme.spacing(0.5)};
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
export const StyledBox = styled(animated.div) `
|
|
27
|
+
align-items: center;
|
|
28
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme)};
|
|
29
|
+
color: ${props => props.theme.palette.navigation?.contrastText || getOffsetNavigationContrastText(props.theme)};
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
font-family: ${props => props.theme.typography.fontFamily};
|
|
33
|
+
height: 100%;
|
|
34
|
+
justify-content: flex-start;
|
|
35
|
+
overflow: auto;
|
|
36
|
+
padding: 15vh ${props => props.theme.spacing(2)};
|
|
37
|
+
position: relative;
|
|
38
|
+
`;
|
|
39
|
+
export const StyledBoxProfile = styled(animated.div) `
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: row;
|
|
42
|
+
align-items: center;
|
|
43
|
+
margin-bottom: 2rem;
|
|
44
|
+
`;
|
|
45
|
+
export const StyledBoxProfileEdit = styled(animated.div) `
|
|
46
|
+
display: flex;
|
|
47
|
+
`;
|
|
48
|
+
export const StyledAvatarName = styled(Typography) `
|
|
49
|
+
font-size: 1.75rem;
|
|
50
|
+
`;
|
|
51
|
+
export const StyledButtonGroup = styled(ButtonGroup) `
|
|
52
|
+
/* Fix for RTL issue */
|
|
53
|
+
.MuiButtonGroup-grouped:not(:first-of-type) {
|
|
54
|
+
border-bottom-left-radius: ${props => props.theme.direction === 'ltr' ? 0 : `${props.theme.shape.borderRadius}px`};
|
|
55
|
+
border-bottom-right-radius: ${props => props.theme.direction === 'ltr' ? `${props.theme.shape.borderRadius}px` : 0};
|
|
56
|
+
border-top-left-radius: ${props => props.theme.direction === 'ltr' ? 0 : `${props.theme.shape.borderRadius}px`};
|
|
57
|
+
border-top-right-radius: ${props => props.theme.direction === 'ltr' ? `${props.theme.shape.borderRadius}px` : 0};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.MuiButtonGroup-grouped:not(:last-of-type) {
|
|
61
|
+
border-bottom-left-radius: ${props => props.theme.direction === 'ltr' ? `${props.theme.shape.borderRadius}px` : 0};
|
|
62
|
+
border-bottom-right-radius: ${props => props.theme.direction === 'ltr' ? 0 : `${props.theme.shape.borderRadius}px`};
|
|
63
|
+
border-top-left-radius: ${props => props.theme.direction === 'ltr' ? `${props.theme.shape.borderRadius}px` : 0};
|
|
64
|
+
border-top-right-radius: ${props => props.theme.direction === 'ltr' ? 0 : `${props.theme.shape.borderRadius}px`};
|
|
65
|
+
border-style: solid;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
export const StyledAvatar = styled(Avatar) `
|
|
69
|
+
background-color: ${props => getNavigationBackground(props.theme)};
|
|
70
|
+
color: ${props => getNavigationContrastText(props.theme)};
|
|
71
|
+
font-size: 0.85rem;
|
|
72
|
+
`;
|
|
73
|
+
export const StyledListItemButton = styled(ListItemButton) `
|
|
74
|
+
border-radius: 50px;
|
|
75
|
+
white-space: normal;
|
|
76
|
+
box-shadow: 0 0 0 0 transparent;
|
|
77
|
+
transition: all 0.2s ease;
|
|
78
|
+
|
|
79
|
+
& .MuiListItemIcon-root {
|
|
80
|
+
color: ${props => props.theme.palette.navigation?.contrastText || getOffsetNavigationContrastText(props.theme)};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:hover {
|
|
84
|
+
color: ${props => getOffsetNavigationContrastText(props.theme, 0.15)};
|
|
85
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme, 0.15)};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:focus-visible {
|
|
89
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme, 0.133)};
|
|
90
|
+
box-shadow: 0 0 0 3px ${props => getOffsetNavigationContrastText(props.theme, 0.133)};
|
|
91
|
+
}
|
|
92
|
+
`;
|
package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItem.js
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
24
2
|
import React, { useEffect } from 'react';
|
|
25
3
|
import { useTheme } from '@mui/material/styles';
|
|
26
4
|
import { Link, List, Tooltip, Collapse } from '../../../../index';
|
|
@@ -29,31 +7,30 @@ import { ListItem, ListItemButton, ListItemButtonChild, ListItemIcon, ListItemTe
|
|
|
29
7
|
import { tooltipDelay } from '../../../../utils/theme';
|
|
30
8
|
import VerticalNavigationItemFlyoutMenu from './VerticalNavigationItemFlyoutMenu';
|
|
31
9
|
import { animated } from '@react-spring/web';
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
useEffect(function () {
|
|
10
|
+
const VerticalNavigationItem = (props) => {
|
|
11
|
+
const theme = useTheme();
|
|
12
|
+
const { label, icon, onClick, isActive, children, isDrawerOpen, index, hasFlyout, fullHeightFlyout, isSecondary, isContentOpen, content, style, hasCustomContent, id, ...rest } = props;
|
|
13
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
14
|
+
const [isFlyoutHovered, setIsFlyoutHovered] = React.useState(false);
|
|
15
|
+
const open = isFlyoutHovered || Boolean(anchorEl);
|
|
16
|
+
useEffect(() => {
|
|
40
17
|
if (!isContentOpen && open) {
|
|
41
18
|
handlePopoverClose();
|
|
42
19
|
}
|
|
43
20
|
}, [isContentOpen]);
|
|
44
|
-
|
|
21
|
+
const handlePopoverOpen = (event) => {
|
|
45
22
|
if (open) {
|
|
46
23
|
handlePopoverClose();
|
|
47
24
|
return;
|
|
48
25
|
}
|
|
49
26
|
if (!isDrawerOpen || fullHeightFlyout) {
|
|
50
|
-
setAnchorEl(event
|
|
27
|
+
setAnchorEl(event?.currentTarget);
|
|
51
28
|
}
|
|
52
29
|
};
|
|
53
|
-
|
|
30
|
+
const handlePopoverClose = () => {
|
|
54
31
|
setAnchorEl(null);
|
|
55
32
|
};
|
|
56
|
-
|
|
33
|
+
const handleClick = (event) => {
|
|
57
34
|
if ((children && children.length > 0) || fullHeightFlyout || hasCustomContent) {
|
|
58
35
|
handlePopoverOpen(event);
|
|
59
36
|
onClick && onClick(event);
|
|
@@ -70,7 +47,7 @@ var VerticalNavigationItem = function (props) {
|
|
|
70
47
|
// Set open to false / Close sub menu
|
|
71
48
|
setAnchorEl(null);
|
|
72
49
|
};
|
|
73
|
-
|
|
50
|
+
const handleChildItemClick = (event, item) => {
|
|
74
51
|
if (!event) {
|
|
75
52
|
return;
|
|
76
53
|
}
|
|
@@ -79,20 +56,19 @@ var VerticalNavigationItem = function (props) {
|
|
|
79
56
|
item.onClick(event);
|
|
80
57
|
}
|
|
81
58
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
const ref = React.useRef(null);
|
|
60
|
+
const flyoutRef = React.useRef(null);
|
|
61
|
+
const handleKeyDown = (event) => {
|
|
85
62
|
if (!event) {
|
|
86
63
|
return;
|
|
87
64
|
}
|
|
88
65
|
// This should only be triggered for items with a sub nav
|
|
89
66
|
if (flyoutRef && flyoutRef.current) {
|
|
90
|
-
|
|
67
|
+
const CLOSE_SUBMENU_DELAY = 200;
|
|
91
68
|
if (event.type === 'blur') {
|
|
92
|
-
setTimeout(
|
|
93
|
-
var _a;
|
|
69
|
+
setTimeout(() => {
|
|
94
70
|
// @ts-expect-error
|
|
95
|
-
|
|
71
|
+
const isMenuFocus = flyoutRef.current?.contains(window.document.activeElement) || ref.current === window.document.activeElement;
|
|
96
72
|
if (!isMenuFocus) {
|
|
97
73
|
handlePopoverClose();
|
|
98
74
|
}
|
|
@@ -100,22 +76,22 @@ var VerticalNavigationItem = function (props) {
|
|
|
100
76
|
}
|
|
101
77
|
}
|
|
102
78
|
};
|
|
103
|
-
return (_jsxs(ListItem,
|
|
79
|
+
return (_jsxs(ListItem, { disablePadding: true,
|
|
104
80
|
// @ts-expect-error
|
|
105
|
-
component: animated.li, style: style
|
|
81
|
+
component: animated.li, style: style, ...rest, isDrawerOpen: isDrawerOpen, children: [_jsxs(ListItemButton, { ref: ref, id: id,
|
|
106
82
|
// @ts-expect-error
|
|
107
|
-
component: Link, onClick: handleClick, isDrawerOpen: isDrawerOpen, onMouseEnter:
|
|
83
|
+
component: Link, onClick: handleClick, isDrawerOpen: isDrawerOpen, onMouseEnter: event => (hasCustomContent || fullHeightFlyout || isDrawerOpen)
|
|
108
84
|
? null
|
|
109
|
-
: handlePopoverOpen(event)
|
|
85
|
+
: handlePopoverOpen(event), onMouseLeave: () => (hasCustomContent || fullHeightFlyout || isDrawerOpen)
|
|
110
86
|
? null
|
|
111
|
-
: handlePopoverClose()
|
|
87
|
+
: handlePopoverClose(), onFocus: event => handleKeyDown(event), onBlur: event => handleKeyDown(event), "aria-current": isActive ? 'page' : null, "aria-expanded": (children && children.length > 0) || fullHeightFlyout || hasCustomContent ? open : null, role: (children && children.length > 0) || fullHeightFlyout || hasCustomContent ? 'button' : 'link', children: [_jsx(Tooltip, { disableHoverListener: (children && children.length > 0) ?? isDrawerOpen, disableFocusListener: (children && children.length > 0) ?? isDrawerOpen, disableTouchListener: (children && children.length > 0) ?? isDrawerOpen, title: label, placement: theme.direction === 'rtl' ? 'left' : 'right', enterDelay: tooltipDelay.start, leaveDelay: tooltipDelay.end, children: _jsx(ListItemIcon, { "aria-hidden": true, children: icon ?? _jsx(MailIcon, {}) }) }), _jsx(ListItemText, { primary: label, isDrawerOpen: isDrawerOpen, index: index })] }, label), children && children.length > 0 && isDrawerOpen && (_jsx(Collapse, { component: 'div', in: isDrawerOpen, children: _jsx(List, { "aria-label": label, disablePadding: true, children: children.map((childItem, index) => (_jsx(ListItem, { disablePadding: true, isDrawerOpen: isDrawerOpen, children: _jsxs(ListItemButtonChild
|
|
112
88
|
// @ts-expect-error
|
|
113
|
-
,
|
|
89
|
+
, {
|
|
114
90
|
// @ts-expect-error
|
|
115
|
-
component: Link, role: 'link', index: index, isDrawerOpen: isDrawerOpen, onClick:
|
|
91
|
+
component: Link, role: 'link', index: index, isDrawerOpen: isDrawerOpen, onClick: event => handleChildItemClick(event, childItem), children: [_jsx(ListItemIcon, { children: childItem.icon }), _jsx(ListItemText, { primary: childItem.label, isDrawerOpen: isDrawerOpen, sx: {
|
|
116
92
|
'& .MuiTypography-root': {
|
|
117
93
|
fontSize: '14px !important'
|
|
118
94
|
}
|
|
119
|
-
} })] }
|
|
95
|
+
} })] }, label) }, `${childItem.label} - ${index}`))) }) })), hasCustomContent && content, !fullHeightFlyout && children && children.length > 0 && !isDrawerOpen && (_jsx(VerticalNavigationItemFlyoutMenu, { ref: flyoutRef, isDrawerOpen: isDrawerOpen, anchorEl: anchorEl, setAnchorEl: setAnchorEl, parentItemRef: ref.current, open: open, children: children, label: label, setIsFlyoutHovered: setIsFlyoutHovered })), fullHeightFlyout && content && (_jsx(VerticalNavigationItemFlyoutMenu, { isDrawerOpen: isDrawerOpen, fullHeightFlyout: true, anchorEl: anchorEl, open: open, content: content }))] }));
|
|
120
96
|
};
|
|
121
97
|
export default VerticalNavigationItem;
|
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
13
2
|
import { forwardRef } from 'react';
|
|
14
3
|
import { Link } from '../../../../index';
|
|
15
4
|
import { FullHeightFlyoutMenuPaper, FullHeightFlyoutMenuWrapper, FlyoutNotchMask, NotchMini, FlyoutMenuHeader, FlyoutMenuPaper, FlyoutMenuWrap, FlyoutMenuList, FlyoutMenuButton, FlyoutMenuItem, FlyoutMenuItemText } from './VerticalNavigationItemFlyoutMenuStyles';
|
|
16
5
|
import { defaultAttributes } from '../../../../utils/dataAttributes';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var dataIds = __assign(__assign({}, defaultAttributes), dataAttributes);
|
|
6
|
+
const VerticalNavigationItemFlyoutMenu = forwardRef((props, ref) => {
|
|
7
|
+
const { label, children, isDrawerOpen, fullHeightFlyout, open, parentItemRef, dataAttributes, content, anchorEl, setAnchorEl, setIsFlyoutHovered } = props;
|
|
8
|
+
const dataIds = { ...defaultAttributes, ...dataAttributes };
|
|
21
9
|
if (fullHeightFlyout && content) {
|
|
22
|
-
return (_jsx(FullHeightFlyoutMenuPaper,
|
|
10
|
+
return (_jsx(FullHeightFlyoutMenuPaper, { isDrawerOpen: isDrawerOpen, open: open, id: "avatar-panel", "data-id": dataIds.VerticalNavigationAvatarPanel, children: _jsxs(FullHeightFlyoutMenuWrapper, { open: open, children: [_jsx(FlyoutNotchMask, {}), _jsx(NotchMini, { tabIndex: -1, style: { bottom: '24px' } }), content] }) }));
|
|
23
11
|
}
|
|
24
|
-
|
|
12
|
+
const handleKeyDown = (event) => {
|
|
25
13
|
if (!event) {
|
|
26
14
|
return;
|
|
27
15
|
}
|
|
28
|
-
|
|
16
|
+
const CLOSE_SUBMENU_DELAY = 200;
|
|
29
17
|
if (event.type === 'blur') {
|
|
30
|
-
setTimeout(
|
|
31
|
-
|
|
32
|
-
var isMenuFocus = ((_a = ref === null || ref === void 0 ? void 0 : ref.current) === null || _a === void 0 ? void 0 : _a.contains(window.document.activeElement)) || parentItemRef.current === window.document.activeElement;
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
const isMenuFocus = ref?.current?.contains(window.document.activeElement) || parentItemRef.current === window.document.activeElement;
|
|
33
20
|
if (!isMenuFocus) {
|
|
34
21
|
setAnchorEl(null);
|
|
35
22
|
}
|
|
36
23
|
}, CLOSE_SUBMENU_DELAY);
|
|
37
24
|
}
|
|
38
25
|
};
|
|
39
|
-
|
|
40
|
-
return (_jsx(FlyoutMenuPaper,
|
|
26
|
+
const isBottomHalfOfScreen = ref?.current?.getBoundingClientRect().y > window.innerHeight / 2;
|
|
27
|
+
return (_jsx(FlyoutMenuPaper, { ref: ref, "data-id": dataIds.VerticalNavigationFlyout, isDrawerOpen: isDrawerOpen, open: open, anchorEl: anchorEl ?? undefined, onMouseEnter: () => setIsFlyoutHovered(true), onMouseLeave: () => setIsFlyoutHovered(false), onFocus: () => setIsFlyoutHovered(true), onBlur: () => setIsFlyoutHovered(false), sx: {
|
|
41
28
|
transform: isBottomHalfOfScreen ? 'translateY(calc(-100% + 48px))' : ''
|
|
42
|
-
}
|
|
29
|
+
}, children: _jsxs(FlyoutMenuWrap, { open: open, children: [_jsx(NotchMini, { sx: {
|
|
43
30
|
bottom: isBottomHalfOfScreen ? '12px' : 'auto',
|
|
44
31
|
top: isBottomHalfOfScreen ? 'auto' : '12px'
|
|
45
|
-
} }), _jsx(FlyoutMenuHeader, { children: label }), _jsx(FlyoutMenuList,
|
|
32
|
+
} }), _jsx(FlyoutMenuHeader, { children: label }), _jsx(FlyoutMenuList, { "data-id": dataIds.VerticalNavigationFlyoutList, "aria-label": label, open: open, children: children?.map((childItem, index) => (_jsx(FlyoutMenuItem, { "data-id": dataIds.VerticalNavigationFlyoutListItem, children: _jsx(FlyoutMenuButton
|
|
46
33
|
// @ts-expect-error
|
|
47
|
-
,
|
|
34
|
+
, {
|
|
48
35
|
// @ts-expect-error
|
|
49
|
-
component: Link, role: 'link', onClick: childItem.onClick, onFocus:
|
|
36
|
+
component: Link, role: 'link', onClick: childItem.onClick, onFocus: event => handleKeyDown(event), onBlur: event => handleKeyDown(event), children: _jsx(FlyoutMenuItemText, { primary: childItem.label }) }, childItem.label) }, `${childItem.label} - ${index}`))) })] }) }));
|
|
50
37
|
});
|
|
51
38
|
export default VerticalNavigationItemFlyoutMenu;
|
|
@@ -1,48 +1,144 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
/* eslint-disable indent */
|
|
6
2
|
import { List, ListItem, ListItemButton as SSListItemButton, Paper, Typography, ListItemText } from '../../../../index';
|
|
7
3
|
import { styled } from '@mui/material/styles';
|
|
8
4
|
import { NotchMiniSVG } from '../../../../assets/Images';
|
|
9
5
|
import { getOffsetNavigationBackground, getOffsetNavigationContrastText } from '../../helpers';
|
|
10
|
-
export
|
|
6
|
+
export const DRAWER_WIDTH = {
|
|
11
7
|
Collapsed: 60,
|
|
12
8
|
Expanded: 300
|
|
13
9
|
};
|
|
14
|
-
export
|
|
15
|
-
shouldForwardProp:
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
export const FlyoutMenuPaper = styled(Paper, {
|
|
11
|
+
shouldForwardProp: (prop) => prop !== 'isDrawerOpen' && prop !== 'open' && prop !== 'anchorEl'
|
|
12
|
+
}) `
|
|
13
|
+
background: transparent none;
|
|
14
|
+
box-shadow: none;
|
|
15
|
+
left: ${props => props.theme.direction === 'ltr' ? props.isDrawerOpen ? `${DRAWER_WIDTH.Expanded}px` : `${DRAWER_WIDTH.Collapsed - 3}px` : 'auto'};
|
|
16
|
+
right: ${props => props.theme.direction === 'rtl' ? props.isDrawerOpen ? `${DRAWER_WIDTH.Expanded}px` : `${DRAWER_WIDTH.Collapsed - 3}px` : 'auto'};
|
|
17
|
+
perspective: 800px;
|
|
18
|
+
pointer-events: ${props => props.open ? 'auto' : 'none'};
|
|
19
|
+
position: fixed;
|
|
20
|
+
/* Check against height of browser should be top or bottom positioned */
|
|
21
|
+
top: ${props => props.anchorEl
|
|
22
|
+
? `${props.anchorEl.getBoundingClientRect().top}px`
|
|
23
|
+
: 'auto'};
|
|
24
|
+
min-width: 200px;
|
|
25
|
+
z-index: 2;
|
|
26
|
+
`;
|
|
27
|
+
export const FlyoutMenuWrap = styled('div', {
|
|
28
|
+
shouldForwardProp: (prop) => prop !== 'open'
|
|
29
|
+
}) `
|
|
30
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme)};
|
|
31
|
+
color: ${props => props.theme.palette.navigation?.contrastText || getOffsetNavigationContrastText(props.theme)};
|
|
32
|
+
border-radius: 0 8px 8px 0;
|
|
33
|
+
box-shadow: 5px 7px 8px -10px rgb(0 0 0 / 20%), 5px 12px 17px -10px rgb(0 0 0 / 14%), 5px 5px 22px -10px rgb(0 0 0 / 12%);
|
|
34
|
+
opacity: ${props => props.open ? 1 : 0};
|
|
35
|
+
visibility: ${props => props.open ? 'visible' : 'hidden'};
|
|
36
|
+
transform: ${props => props.open ? 'rotateY(0deg) scale(1)' : 'rotateY(15deg) scale(.97)'};
|
|
37
|
+
transform-origin: left center;
|
|
38
|
+
transition: ${props => props.open
|
|
39
|
+
? `all ${props.theme.transitions.duration.enteringScreen}ms ${props.theme.transitions.easing.easeOut}`
|
|
40
|
+
: `all ${props.theme.transitions.duration.leavingScreen}ms ${props.theme.transitions.easing.easeIn}`};
|
|
41
|
+
`;
|
|
42
|
+
export const FlyoutMenuList = styled(List, {
|
|
43
|
+
shouldForwardProp: (prop) => prop !== 'open'
|
|
44
|
+
}) `
|
|
45
|
+
padding: ${props => props.theme.spacing(1, 2)};
|
|
46
|
+
pointer-events: ${props => props.open ? 'auto' : 'none'};
|
|
47
|
+
`;
|
|
48
|
+
export const FlyoutMenuHeader = styled(Typography) `
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
padding: 12px 0 0;
|
|
51
|
+
padding-inline-end: ${props => props.theme.spacing(2)};
|
|
52
|
+
padding-inline-start: ${props => props.theme.spacing(3)};
|
|
53
|
+
text-align: ${props => props.theme.direction === 'ltr' ? 'left' : 'right'};
|
|
54
|
+
`;
|
|
55
|
+
export const FlyoutMenuItem = styled(ListItem) `
|
|
56
|
+
background: transparent !important;
|
|
57
|
+
font-size: 14px;
|
|
58
|
+
padding: 0;
|
|
59
|
+
white-space: normal;
|
|
60
|
+
`;
|
|
61
|
+
export const FlyoutMenuItemText = styled(ListItemText) `
|
|
62
|
+
color: ${props => props.theme.palette.navigation?.contrastText || getOffsetNavigationContrastText(props.theme)};
|
|
63
|
+
text-align: ${props => props.theme.direction === 'ltr' ? 'left' : 'right'};
|
|
64
|
+
`;
|
|
65
|
+
export const FlyoutMenuButton = styled(SSListItemButton, {
|
|
66
|
+
shouldForwardProp: (prop) => prop !== 'isDrawerOpen' && prop !== 'isExpanded'
|
|
67
|
+
}) `
|
|
68
|
+
align-items: flex-start;
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
border-radius: 5px;
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
text-transform: none;
|
|
75
|
+
transition: all ${props => props.theme.transitions.duration.enteringScreen}ms ${props => props.theme.transitions.easing.easeOut};
|
|
76
|
+
padding: ${props => props.theme.spacing(1, 2)};
|
|
77
|
+
width: 100%;
|
|
78
|
+
|
|
79
|
+
:hover {
|
|
80
|
+
color: ${props => getOffsetNavigationContrastText(props.theme, 0.15)};
|
|
81
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme, 0.15)};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:focus-visible {
|
|
85
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme, 0.133)};
|
|
86
|
+
box-shadow: 0 0 0 3px ${props => getOffsetNavigationContrastText(props.theme, 0.133)};
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
35
89
|
// FullHeight
|
|
36
|
-
export
|
|
37
|
-
shouldForwardProp:
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
90
|
+
export const FullHeightFlyoutMenuPaper = styled(Paper, {
|
|
91
|
+
shouldForwardProp: (prop) => prop !== 'isDrawerOpen' && prop !== 'open'
|
|
92
|
+
}) `
|
|
93
|
+
background: transparent none;
|
|
94
|
+
box-shadow: none;
|
|
95
|
+
height: 100%;
|
|
96
|
+
left: ${props => props.theme.direction === 'ltr' ? props.isDrawerOpen ? `${DRAWER_WIDTH.Expanded}px` : `${DRAWER_WIDTH.Collapsed - 3}px` : 'auto'};
|
|
97
|
+
right: ${props => props.theme.direction === 'rtl' ? props.isDrawerOpen ? `${DRAWER_WIDTH.Expanded}px` : `${DRAWER_WIDTH.Collapsed - 3}px` : 'auto'};
|
|
98
|
+
perspective: 800px;
|
|
99
|
+
pointer-events: ${props => props.open ? 'auto' : 'none'};
|
|
100
|
+
position: fixed;
|
|
101
|
+
top: 0;
|
|
102
|
+
transition: ${props => props.open
|
|
103
|
+
? `all ${props.theme.transitions.duration.enteringScreen}ms ${props.theme.transitions.easing.easeOut}`
|
|
104
|
+
: `all ${props.theme.transitions.duration.leavingScreen}ms ${props.theme.transitions.easing.easeIn}`};
|
|
105
|
+
z-index: 1;
|
|
106
|
+
`;
|
|
107
|
+
export const FullHeightFlyoutMenuWrapper = styled('div', {
|
|
108
|
+
shouldForwardProp: (prop) => prop !== 'open'
|
|
109
|
+
}) `
|
|
110
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme)};
|
|
111
|
+
color: ${props => props.theme.palette.navigation?.contrastText || getOffsetNavigationContrastText(props.theme)};
|
|
112
|
+
box-shadow: ${props => props.theme.direction === 'ltr' ? '35px' : '-35px'} 0 15px 0 rgb(0 0 0 / 10%);
|
|
113
|
+
height: 100%;
|
|
114
|
+
max-width: 300px;
|
|
115
|
+
min-width: 300px;
|
|
116
|
+
opacity: ${props => props.open ? 1 : 0};
|
|
117
|
+
pointer-events: ${props => props.open ? 'auto' : 'none'};
|
|
118
|
+
transform: ${props => props.open ? 'rotateY(0deg) scale(1)' : 'rotateY(8deg) scale(.98)'};
|
|
119
|
+
transform-origin: left center;
|
|
120
|
+
transition: ${props => props.open
|
|
121
|
+
? `all ${props.theme.transitions.duration.enteringScreen}ms ${props.theme.transitions.easing.easeOut}`
|
|
122
|
+
: `all ${props.theme.transitions.duration.leavingScreen}ms ${props.theme.transitions.easing.easeIn}`};
|
|
123
|
+
visibility: ${props => props.open ? 'visible' : 'hidden'};
|
|
124
|
+
width: ${props => props.open ? '300' : 0};
|
|
125
|
+
`;
|
|
126
|
+
export const FlyoutNotchMask = styled('div') `
|
|
127
|
+
background-color: ${props => getOffsetNavigationBackground(props.theme)};
|
|
128
|
+
content: '';
|
|
129
|
+
display: block;
|
|
130
|
+
height: 82px;
|
|
131
|
+
left: ${props => props.theme.direction === 'ltr' ? '-40px' : 'auto'};
|
|
132
|
+
right: ${props => props.theme.direction === 'rtl' ? '-40px' : 'auto'};
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: 63px;
|
|
135
|
+
width: 80px;
|
|
136
|
+
z-index: -1;
|
|
137
|
+
`;
|
|
138
|
+
export const NotchMini = styled(NotchMiniSVG) `
|
|
139
|
+
fill: ${props => getOffsetNavigationBackground(props.theme)};
|
|
140
|
+
left: ${props => props.theme.direction === 'ltr' ? '-12px' : 0};
|
|
141
|
+
right: ${props => props.theme.direction === 'rtl' ? '-12px' : 0};
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
position: absolute;
|
|
144
|
+
`;
|