@learningpool/ui 1.15.5 → 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 +9 -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.js +3 -3
- package/lang/en-us.js +1 -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,15 +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
|
-
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 { useState } from 'react';
|
|
14
3
|
import Icon from '@mui/material/Icon';
|
|
15
4
|
import Menu from '@mui/material/Menu';
|
|
@@ -17,21 +6,21 @@ import MenuItem from '@mui/material/MenuItem';
|
|
|
17
6
|
import IconButton from '@mui/material/IconButton';
|
|
18
7
|
import Tooltip from '@mui/material/Tooltip';
|
|
19
8
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
event
|
|
9
|
+
const MAX_ICONS = 0;
|
|
10
|
+
const HeaderActionButtons = (props) => {
|
|
11
|
+
const { options, styles, forceListView } = props;
|
|
12
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
13
|
+
const handleClick = (event) => {
|
|
14
|
+
event?.stopPropagation();
|
|
26
15
|
setAnchorEl(event.currentTarget);
|
|
27
16
|
};
|
|
28
|
-
|
|
29
|
-
event
|
|
17
|
+
const handleClose = (event) => {
|
|
18
|
+
event?.stopPropagation();
|
|
30
19
|
setAnchorEl(null);
|
|
31
20
|
};
|
|
32
|
-
|
|
33
|
-
event
|
|
34
|
-
option
|
|
21
|
+
const handleOptionClick = (event, option) => {
|
|
22
|
+
event?.stopPropagation();
|
|
23
|
+
option?.onClick();
|
|
35
24
|
handleClose(event);
|
|
36
25
|
};
|
|
37
26
|
if (!options) {
|
|
@@ -40,14 +29,14 @@ var HeaderActionButtons = function (props) {
|
|
|
40
29
|
}
|
|
41
30
|
// Show icon buttons if less than MAX_ICONS
|
|
42
31
|
if (options.length <= MAX_ICONS && !forceListView) {
|
|
43
|
-
return (_jsx("div",
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return (_jsx(Tooltip,
|
|
47
|
-
}) }))
|
|
32
|
+
return (_jsx("div", { style: styles, children: options.map((option) => {
|
|
33
|
+
const { label, icon, onClick } = option;
|
|
34
|
+
const handleOptionClick = onClick;
|
|
35
|
+
return (_jsx(Tooltip, { title: label, "aria-label": label, placement: 'bottom', enterDelay: 500, enterNextDelay: 50, leaveDelay: 50, disableInteractive: true, children: _jsx(IconButton, { size: 'small', "aria-label": label, onClick: handleOptionClick, children: _jsx(Icon, { children: icon }) }) }, label));
|
|
36
|
+
}) }));
|
|
48
37
|
}
|
|
49
38
|
// Show menu and v-ellipsis if more than MAX_ICONS
|
|
50
|
-
return (_jsxs("div",
|
|
39
|
+
return (_jsxs("div", { style: styles, children: [_jsx(IconButton, { "aria-label": 'more', "aria-haspopup": 'true', onClick: handleClick, children: _jsx(MoreVertIcon, {}) }), _jsx(Menu, { id: 'actionButtonMenu', anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, anchorOrigin: {
|
|
51
40
|
vertical: 'bottom',
|
|
52
41
|
horizontal: 'center'
|
|
53
42
|
},
|
|
@@ -55,12 +44,12 @@ var HeaderActionButtons = function (props) {
|
|
|
55
44
|
transformOrigin: {
|
|
56
45
|
vertical: 'top',
|
|
57
46
|
horizontal: 'center'
|
|
58
|
-
}
|
|
59
|
-
|
|
47
|
+
}, children: options.map((option) => {
|
|
48
|
+
const { label, isDisabled, actionKey, hide } = option;
|
|
60
49
|
if (hide) {
|
|
61
50
|
return null;
|
|
62
51
|
}
|
|
63
|
-
return (_jsx(MenuItem,
|
|
64
|
-
}) })
|
|
52
|
+
return (_jsx(MenuItem, { onClick: event => handleOptionClick(event, option), "aria-label": label, disabled: isDisabled, children: label }, actionKey));
|
|
53
|
+
}) })] }));
|
|
65
54
|
};
|
|
66
55
|
export default HeaderActionButtons;
|
|
@@ -1,13 +1,56 @@
|
|
|
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
|
import { Box, Paper } from '../../../index';
|
|
6
2
|
import { Breadcrumbs, styled } from '@mui/material';
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
export const StyledPaper = styled(Paper) `
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: ${props => props.theme.direction === 'ltr' ? 'row' : 'row-reverse'};
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 100%;
|
|
8
|
+
|
|
9
|
+
&.is-sticky {
|
|
10
|
+
position: sticky;
|
|
11
|
+
top: 0;
|
|
12
|
+
z-index: 1;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
export const StyledBreadcrumbs = styled(Breadcrumbs) `
|
|
16
|
+
font-size: ${props => props.theme.typography.subtitle2.fontSize};
|
|
17
|
+
margin-bottom: 0.5rem;
|
|
18
|
+
|
|
19
|
+
ol {
|
|
20
|
+
flex-direction: ${props => props.theme.direction === 'ltr' ? 'row' : 'row-reverse'};
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
export const StyledHeaderPrimary = styled(Box) `
|
|
24
|
+
align-items: ${props => props.theme.direction === 'ltr' ? 'flex-start' : 'flex-end'};
|
|
25
|
+
display: flex;
|
|
26
|
+
flex: 1 auto;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
padding: 1rem;
|
|
29
|
+
padding-inline-start: 2rem;
|
|
30
|
+
|
|
31
|
+
h1,
|
|
32
|
+
h4 {
|
|
33
|
+
font-size: clamp(1.125rem, 3.25vw, 2.75rem);
|
|
34
|
+
text-align: ${props => props.theme.direction === 'ltr' ? 'left' : 'right'};
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
export const StyledHeaderSecondary = styled(Box) `
|
|
38
|
+
align-items: center;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: ${props => props.theme.direction === 'ltr' ? 'row' : 'row-reverse'};
|
|
41
|
+
justify-content: flex-end;
|
|
42
|
+
padding: 1rem;
|
|
43
|
+
padding-inline-end: 2rem;
|
|
44
|
+
|
|
45
|
+
button,
|
|
46
|
+
a {
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
export const StyledAdditionalButtonsContainer = styled(Box) `
|
|
51
|
+
margin-inline-start: ${props => props.theme.direction === 'ltr' ? '0.5rem' : '0'};
|
|
52
|
+
margin-inline-end: ${props => props.theme.direction === 'rtl' ? '0.5rem' : '0'};
|
|
53
|
+
`;
|
|
54
|
+
export const StyledBox = styled(Box) `
|
|
55
|
+
background: ${props => props.theme.palette.background.default};
|
|
56
|
+
`;
|
|
@@ -1,35 +1,9 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
24
2
|
import React from 'react';
|
|
25
3
|
import MUIDrawer from '@mui/material/Drawer';
|
|
26
4
|
import { styled } from '@mui/material/styles';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
var Drawer = React.forwardRef(function (_a, ref) {
|
|
32
|
-
var rest = __rest(_a, []);
|
|
33
|
-
return (_jsx(StyledDrawer, __assign({}, rest, { ref: ref })));
|
|
34
|
-
});
|
|
5
|
+
const StyledDrawer = styled(MUIDrawer)(({ theme }) => ({}));
|
|
6
|
+
const Drawer = React.forwardRef(({ ...rest }, ref) => (
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
_jsx(StyledDrawer, { ...rest, ref: ref })));
|
|
35
9
|
export default Drawer;
|
|
@@ -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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
24
2
|
import React, { useEffect } from 'react';
|
|
25
3
|
import PersonIcon from '@mui/icons-material/Person';
|
|
26
4
|
import { StyledBottomNavigationAction, StyledPaper, StyledBottomNavigation, StyledAvatar } from './MobileNavigationStyles';
|
|
@@ -30,91 +8,89 @@ import SwipeableTemporaryAvatar from './MobileNavigationAvatar';
|
|
|
30
8
|
import NotchIndicator from './MobileNavigationNotchIndicator';
|
|
31
9
|
import ToggleX from './MobileNavigationToggleX';
|
|
32
10
|
import ToggleSearchX from './MobileNavigationToggleSearchX';
|
|
33
|
-
import { MOBILE_NAV_PANEL_TYPES } from '../../../utils/constants';
|
|
11
|
+
import { MOBILE_NAV_PANEL_TYPES, EVENT_KEYS } from '../../../utils/constants';
|
|
34
12
|
import { handleAvatarInitials } from '../../../utils/helpers';
|
|
35
13
|
import { useSpring, animated, useSpringRef, config } from '@react-spring/web';
|
|
36
14
|
import { useCurrentWidth } from '../../../utils/hooks';
|
|
37
15
|
import { defaultAttributes } from '../../../utils/dataAttributes';
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
useEffect(function () {
|
|
16
|
+
const MobileNavigation = (props) => {
|
|
17
|
+
const { items, secondaryItems, hideAvatarInitials, dataAttributes, hasSearch, hasAvatar, showNotchIndicator, ...rest } = props;
|
|
18
|
+
const propIsDrawerOpen = typeof props?.isDrawerOpen === 'boolean' ? props.isDrawerOpen : undefined;
|
|
19
|
+
const propIsSearchOpen = typeof props?.isSearchOpen === 'boolean' ? props.isSearchOpen : undefined;
|
|
20
|
+
const propIsAvatarOpen = typeof props?.isAvatarOpen === 'boolean' ? props.isAvatarOpen : undefined;
|
|
21
|
+
const avatarName = props?.avatarName ?? 'Avatar name';
|
|
22
|
+
const [isDrawerOpen, setIsDrawerOpen] = React.useState(propIsDrawerOpen ?? false);
|
|
23
|
+
const [isSearchOpen, setIsSearchOpen] = React.useState(propIsSearchOpen ?? false);
|
|
24
|
+
const [isAvatarOpen, setIsAvatarOpen] = React.useState(propIsAvatarOpen ?? false);
|
|
25
|
+
const [value, setValue] = React.useState(0);
|
|
26
|
+
const dataIds = { ...defaultAttributes, ...dataAttributes };
|
|
27
|
+
const currentDirection = window.localStorage.getItem('@learningpool/ui/store/mobile-navigation-direction');
|
|
28
|
+
const [mobileNavDirection, setMobileNavDirection] = React.useState(currentDirection ?? 'ltr');
|
|
29
|
+
const [mobileNotchPosition, setMobileNotchPosition] = React.useState(0);
|
|
30
|
+
const windowWidth = useCurrentWidth();
|
|
31
|
+
useEffect(() => {
|
|
55
32
|
window.localStorage.setItem('@learningpool/ui/store/mobile-navigation-direction', mobileNavDirection);
|
|
56
33
|
positionMobileNotch();
|
|
57
34
|
}, [mobileNavDirection]);
|
|
58
|
-
|
|
35
|
+
const NOTCH = {
|
|
59
36
|
Height: 50,
|
|
60
37
|
Width: 50
|
|
61
38
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var selectedDOMRect = (_a = BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
39
|
+
const BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS = Array.from(document.querySelectorAll('.MuiBottomNavigationAction-root'));
|
|
40
|
+
const positionMobileNotch = () => {
|
|
41
|
+
const selectedDOMRect = BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]?.getBoundingClientRect();
|
|
66
42
|
setMobileNotchPosition(selectedDOMRect ? selectedDOMRect.left + (selectedDOMRect.width / 2) - (NOTCH.Width / 2) : mobileNotchPosition);
|
|
67
43
|
};
|
|
68
44
|
// Set index value for nav items
|
|
69
|
-
BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS.forEach(
|
|
70
|
-
e.addEventListener('click',
|
|
45
|
+
BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS.forEach((e, i) => {
|
|
46
|
+
e.addEventListener('click', () => {
|
|
71
47
|
setValue(i);
|
|
72
48
|
});
|
|
73
49
|
});
|
|
74
50
|
// Watch for changes to the navbar width anytime a drawer is opened/closed
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
useEffect(
|
|
78
|
-
|
|
51
|
+
const navBarRef = React.useRef(null);
|
|
52
|
+
const [navBarWidth, setNavBarWidth] = React.useState(0);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const handleResize = () => {
|
|
79
55
|
if (navBarRef.current) {
|
|
80
56
|
setNavBarWidth(navBarRef.current.offsetWidth);
|
|
81
57
|
}
|
|
82
58
|
};
|
|
83
|
-
|
|
59
|
+
const resizeObserver = new ResizeObserver(handleResize);
|
|
84
60
|
if (navBarRef.current) {
|
|
85
61
|
resizeObserver.observe(navBarRef.current);
|
|
86
62
|
handleResize();
|
|
87
63
|
}
|
|
88
|
-
return
|
|
64
|
+
return () => {
|
|
89
65
|
if (navBarRef.current) {
|
|
90
66
|
resizeObserver.unobserve(navBarRef.current);
|
|
91
67
|
}
|
|
92
68
|
};
|
|
93
69
|
}, [value]);
|
|
94
|
-
useEffect(
|
|
70
|
+
useEffect(() => { positionMobileNotch(); }, [
|
|
95
71
|
value,
|
|
96
72
|
navBarWidth,
|
|
97
73
|
windowWidth,
|
|
98
|
-
|
|
74
|
+
BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]?.getBoundingClientRect()
|
|
99
75
|
]);
|
|
100
|
-
useEffect(
|
|
101
|
-
useEffect(
|
|
102
|
-
useEffect(
|
|
103
|
-
useEffect(
|
|
104
|
-
useEffect(
|
|
76
|
+
useEffect(() => setIsDrawerOpen(propIsDrawerOpen ?? false), [propIsDrawerOpen]);
|
|
77
|
+
useEffect(() => setIsSearchOpen(propIsSearchOpen ?? false), [propIsSearchOpen]);
|
|
78
|
+
useEffect(() => setIsAvatarOpen(propIsAvatarOpen ?? false), [propIsAvatarOpen]);
|
|
79
|
+
useEffect(() => setAvatarInitials(handleAvatarInitials(avatarName)), [avatarName]);
|
|
80
|
+
useEffect(() => {
|
|
105
81
|
function hideNotch() {
|
|
106
|
-
|
|
82
|
+
const HIDE_NOTCH = -1;
|
|
107
83
|
if (!isDrawerOpen && !isSearchOpen && !isAvatarOpen) {
|
|
108
84
|
setValue(HIDE_NOTCH);
|
|
109
85
|
}
|
|
110
86
|
}
|
|
111
87
|
hideNotch();
|
|
112
88
|
}, [isDrawerOpen, isSearchOpen, isAvatarOpen]);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
event
|
|
116
|
-
if (event.type ===
|
|
117
|
-
if (event.key ===
|
|
89
|
+
const [avatarInitials, setAvatarInitials] = React.useState(handleAvatarInitials(avatarName) ?? 'AN');
|
|
90
|
+
const toggleDrawer = (open, action) => (event) => {
|
|
91
|
+
event?.stopPropagation();
|
|
92
|
+
if (event.type === EVENT_KEYS.Keydown) {
|
|
93
|
+
if (event.key === EVENT_KEYS.Tab || event.key === EVENT_KEYS.Shift) {
|
|
118
94
|
return;
|
|
119
95
|
}
|
|
120
96
|
}
|
|
@@ -125,21 +101,21 @@ var MobileNavigation = function (props) {
|
|
|
125
101
|
// Handle drawer toggling based on 'action' or default to 'drawer'
|
|
126
102
|
switch (action) {
|
|
127
103
|
case MOBILE_NAV_PANEL_TYPES.SEARCH: {
|
|
128
|
-
setIsSearchOpen(open
|
|
104
|
+
setIsSearchOpen(open ?? !isSearchOpen);
|
|
129
105
|
break;
|
|
130
106
|
}
|
|
131
107
|
case MOBILE_NAV_PANEL_TYPES.AVATAR: {
|
|
132
|
-
setIsAvatarOpen(open
|
|
108
|
+
setIsAvatarOpen(open ?? !isAvatarOpen);
|
|
133
109
|
break;
|
|
134
110
|
}
|
|
135
111
|
default: {
|
|
136
|
-
setIsDrawerOpen(open
|
|
112
|
+
setIsDrawerOpen(open ?? !isDrawerOpen);
|
|
137
113
|
break;
|
|
138
114
|
}
|
|
139
115
|
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
};
|
|
117
|
+
const api = useSpringRef();
|
|
118
|
+
const animationConfig = {
|
|
143
119
|
MobileNavigationPaper: {
|
|
144
120
|
from: { opacity: 0 },
|
|
145
121
|
to: { opacity: 1 }
|
|
@@ -154,24 +130,36 @@ var MobileNavigation = function (props) {
|
|
|
154
130
|
},
|
|
155
131
|
MobileNavigationNotch: {
|
|
156
132
|
ref: api,
|
|
157
|
-
config:
|
|
133
|
+
config: {
|
|
134
|
+
...config.default,
|
|
135
|
+
mass: 1
|
|
136
|
+
// friction: 30,
|
|
137
|
+
// tension: 200
|
|
138
|
+
},
|
|
158
139
|
x: mobileNotchPosition,
|
|
159
140
|
y: value < 0 ? 100 : 0
|
|
160
141
|
}
|
|
161
142
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return (_jsxs(_Fragment, { children: [_jsx(SwipeableTemporaryDrawer,
|
|
143
|
+
const MobileNavigationPaperAnimation = useSpring(animationConfig.MobileNavigationPaper);
|
|
144
|
+
const MobileNavigationAnimation = useSpring(animationConfig.MobileNavigation);
|
|
145
|
+
const MobileNavigationButtonAnimation = useSpring(animationConfig.MobileNavigationButton);
|
|
146
|
+
return (_jsxs(_Fragment, { children: [_jsx(SwipeableTemporaryDrawer, { isDrawerOpen: isDrawerOpen, setIsDrawerOpen: setIsDrawerOpen, items: items, secondaryItems: secondaryItems, label: 'Primary', ...rest }), hasSearch && (_jsx(SwipeableTemporarySearch, { "data-id": dataIds.MobileNavSearchPanel, isSearchOpen: isSearchOpen, setIsSearchOpen: setIsSearchOpen, ...rest })), hasAvatar && (_jsx(SwipeableTemporaryAvatar, { "data-id": dataIds.MobileNavAvatarPanel, isAvatarOpen: isAvatarOpen, setIsAvatarOpen: setIsAvatarOpen, avatarName: avatarName, mobileNavDirection: mobileNavDirection, setMobileNavDirection: setMobileNavDirection, ...rest })), _jsxs(StyledPaper, { elevation: 3,
|
|
166
147
|
// @ts-expect-error
|
|
167
|
-
component: animated.div, style: MobileNavigationPaperAnimation, ref: navBarRef, "data-id": dataIds.MobileNavContainer
|
|
148
|
+
component: animated.div, style: MobileNavigationPaperAnimation, ref: navBarRef, "data-id": dataIds.MobileNavContainer, children: [showNotchIndicator && _jsx(NotchIndicator, { ...animationConfig.MobileNavigationNotch }), _jsxs(StyledBottomNavigation, { value: value,
|
|
168
149
|
// @ts-expect-error
|
|
169
|
-
component: animated.div, style:
|
|
150
|
+
component: animated.div, style: {
|
|
151
|
+
flexDirection: mobileNavDirection && mobileNavDirection === 'rtl' ? 'row-reverse' : 'row',
|
|
152
|
+
...MobileNavigationAnimation
|
|
153
|
+
}, children: [_jsx(StyledBottomNavigationAction, { "data-id": dataIds.MobileNavDrawerToggle, icon: _jsx(ToggleX, { isOpen: isDrawerOpen }), onClick: toggleDrawer(!isDrawerOpen, MOBILE_NAV_PANEL_TYPES.DRAWER),
|
|
170
154
|
// @ts-expect-error
|
|
171
|
-
component: animated.div, "aria-label": isDrawerOpen ? 'Close drawer panel' : 'Open drawer panel', "aria-expanded": isDrawerOpen ? 'true' : 'false', "aria-controls": 'mobile-nav-menu', style:
|
|
155
|
+
component: animated.div, "aria-label": isDrawerOpen ? 'Close drawer panel' : 'Open drawer panel', "aria-expanded": isDrawerOpen ? 'true' : 'false', "aria-controls": 'mobile-nav-menu', style: {
|
|
156
|
+
marginInlineStart: (hasSearch || hasAvatar) && (mobileNavDirection && mobileNavDirection === 'rtl') ? 'auto' : 'initial',
|
|
157
|
+
marginInlineEnd: (hasSearch || hasAvatar) && (mobileNavDirection && mobileNavDirection === 'rtl') ? 'initial' : 'auto',
|
|
158
|
+
...MobileNavigationButtonAnimation
|
|
159
|
+
} }), hasSearch && (_jsx(StyledBottomNavigationAction, { "data-id": dataIds.MobileNavSearchToggle, icon: _jsx(ToggleSearchX, { isOpen: isSearchOpen }), onClick: toggleDrawer(!isSearchOpen, MOBILE_NAV_PANEL_TYPES.SEARCH),
|
|
172
160
|
// @ts-expect-error
|
|
173
161
|
component: animated.div, "aria-label": isSearchOpen ? 'Close search panel' : 'Open search panel', "aria-expanded": isSearchOpen ? 'true' : 'false', "aria-controls": 'mobile-nav-menu', style: MobileNavigationButtonAnimation })), hasAvatar && (_jsx(StyledBottomNavigationAction, { "data-id": dataIds.MobileNavAvatarToggle, onClick: toggleDrawer(!isAvatarOpen, MOBILE_NAV_PANEL_TYPES.AVATAR), icon: !hideAvatarInitials ? _jsx(StyledAvatar, { children: avatarInitials }) : _jsx(PersonIcon, {}),
|
|
174
162
|
// @ts-expect-error
|
|
175
|
-
component: animated.button, "aria-label": isAvatarOpen ? 'Close Profile Menu' : 'Open Profile Menu', "aria-expanded": isAvatarOpen ? 'true' : 'false', "aria-controls": 'mobile-nav-menu', style: MobileNavigationButtonAnimation }))] })
|
|
163
|
+
component: animated.button, "aria-label": isAvatarOpen ? 'Close Profile Menu' : 'Open Profile Menu', "aria-expanded": isAvatarOpen ? 'true' : 'false', "aria-controls": 'mobile-nav-menu', style: MobileNavigationButtonAnimation }))] })] })] }));
|
|
176
164
|
};
|
|
177
165
|
export default MobileNavigation;
|