@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.
Files changed (84) hide show
  1. package/assets/Images.js +7 -18
  2. package/components/atoms/Autocomplete/Autocomplete.js +3 -14
  3. package/components/atoms/Button/Button.js +2 -13
  4. package/components/atoms/Checkbox/Checkbox.js +3 -26
  5. package/components/atoms/IconButton/IconButton.js +2 -13
  6. package/components/atoms/Radio/Radio.js +3 -26
  7. package/components/atoms/Select/Select.js +3 -26
  8. package/components/atoms/Slider/Slider.js +3 -26
  9. package/components/atoms/Switch/Switch.js +3 -26
  10. package/components/atoms/TextField/TextField.js +2 -13
  11. package/components/atoms/ToggleButton/ToggleButton.js +3 -26
  12. package/components/datadisplay/Avatar/Avatar.js +13 -28
  13. package/components/datadisplay/Chip/Chip.js +3 -26
  14. package/components/datadisplay/List/List.js +2 -13
  15. package/components/feedback/Alert/Alert.js +3 -26
  16. package/components/landmarks/Header/Header.js +15 -41
  17. package/components/landmarks/Header/HeaderActionButtons.d.ts +1 -2
  18. package/components/landmarks/Header/HeaderActionButtons.js +22 -33
  19. package/components/landmarks/Header/HeaderStyles.js +54 -11
  20. package/components/navigation/Drawer/Drawer.js +5 -31
  21. package/components/navigation/MobileNavigation/MobileNavigation.js +70 -82
  22. package/components/navigation/MobileNavigation/MobileNavigationAvatar.js +75 -83
  23. package/components/navigation/MobileNavigation/MobileNavigationAvatarStyles.d.ts +102 -52
  24. package/components/navigation/MobileNavigation/MobileNavigationAvatarStyles.js +71 -13
  25. package/components/navigation/MobileNavigation/MobileNavigationDrawer.d.ts +1 -1
  26. package/components/navigation/MobileNavigation/MobileNavigationDrawer.js +41 -68
  27. package/components/navigation/MobileNavigation/MobileNavigationDrawerStyles.d.ts +34 -18
  28. package/components/navigation/MobileNavigation/MobileNavigationDrawerStyles.js +133 -20
  29. package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItem.js +22 -45
  30. package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemFlyoutMenu.js +8 -19
  31. package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemFlyoutMenuStyles.js +151 -52
  32. package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemStyles.js +171 -50
  33. package/components/navigation/MobileNavigation/MobileNavigationMotion.js +11 -11
  34. package/components/navigation/MobileNavigation/MobileNavigationNotchIndicator.js +11 -15
  35. package/components/navigation/MobileNavigation/MobileNavigationSearch.d.ts +1 -2
  36. package/components/navigation/MobileNavigation/MobileNavigationSearch.js +25 -34
  37. package/components/navigation/MobileNavigation/MobileNavigationSearchStyles.d.ts +34 -18
  38. package/components/navigation/MobileNavigation/MobileNavigationSearchStyles.js +47 -9
  39. package/components/navigation/MobileNavigation/MobileNavigationStyles.js +262 -66
  40. package/components/navigation/MobileNavigation/MobileNavigationToggleSearchX.js +21 -20
  41. package/components/navigation/MobileNavigation/MobileNavigationToggleX.js +21 -20
  42. package/components/navigation/VerticalNavigation/VerticalNavigation.js +150 -185
  43. package/components/navigation/VerticalNavigation/VerticalNavigationAvatar.js +50 -61
  44. package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.d.ts +102 -52
  45. package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.js +86 -14
  46. package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItem.js +27 -51
  47. package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenu.js +15 -28
  48. package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenuStyles.js +135 -39
  49. package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemStyles.js +167 -29
  50. package/components/navigation/VerticalNavigation/VerticalNavigationMotion.js +11 -11
  51. package/components/navigation/VerticalNavigation/VerticalNavigationStyles.d.ts +34 -18
  52. package/components/navigation/VerticalNavigation/VerticalNavigationStyles.js +236 -42
  53. package/components/navigation/helpers.d.ts +1 -2
  54. package/components/navigation/helpers.js +28 -32
  55. package/components/pages/ErrorPage/ErrorPage.js +6 -17
  56. package/components/pages/ErrorPage/ErrorPageStyles.js +13 -18
  57. package/components/pages/SideInSide/SideInSide.js +12 -23
  58. package/components/pages/SideInSide/SideInSideStyles.js +6 -6
  59. package/components/stream/AppHub/AppHub.js +13 -42
  60. package/components/stream/AppHub/AppHubAdvertStyles.js +24 -8
  61. package/components/stream/AppHub/AppHubBannerAdvert.d.ts +1 -2
  62. package/components/stream/AppHub/AppHubBannerAdvert.js +9 -20
  63. package/components/stream/AppHub/AppHubCustom.js +8 -19
  64. package/components/stream/AppHub/AppHubCustomStyles.d.ts +1 -1
  65. package/components/stream/AppHub/AppHubCustomStyles.js +78 -18
  66. package/components/stream/AppHub/AppHubProduct.js +26 -48
  67. package/components/stream/AppHub/AppHubProductStyles.js +104 -19
  68. package/components/stream/AppHub/AppHubStyles.js +31 -11
  69. package/components/stream/AppHub/constants.d.ts +1 -2
  70. package/components/stream/AppHub/constants.js +14 -14
  71. package/components/stream/AppSwitcher/AppSwitcher.js +225 -316
  72. package/components/stream/AppSwitcher/AppSwitcherItem.js +11 -22
  73. package/components/stream/AppSwitcher/AppSwitcherStyles.js +337 -42
  74. package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.js +255 -21
  75. package/components/stream/AppSwitcher/PromotionalCampaignItem.js +7 -19
  76. package/components/stream/AppSwitcher/constants.js +3 -3
  77. package/lang/en-us.js +1 -1
  78. package/package.json +7 -2
  79. package/utils/constants.d.ts +7 -0
  80. package/utils/constants.js +11 -4
  81. package/utils/dataAttributes.js +1 -1
  82. package/utils/helpers.js +33 -40
  83. package/utils/hooks.js +10 -11
  84. package/utils/theme.js +26 -19
@@ -1,15 +1,4 @@
1
- var __assign = (this && this.__assign) || function () {
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
- var MAX_ICONS = 0;
21
- var HeaderActionButtons = function (props) {
22
- var options = props.options, styles = props.styles, forceListView = props.forceListView;
23
- var _a = useState(null), anchorEl = _a[0], setAnchorEl = _a[1];
24
- var handleClick = function (event) {
25
- event === null || event === void 0 ? void 0 : event.stopPropagation();
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
- var handleClose = function (event) {
29
- event === null || event === void 0 ? void 0 : event.stopPropagation();
17
+ const handleClose = (event) => {
18
+ event?.stopPropagation();
30
19
  setAnchorEl(null);
31
20
  };
32
- var handleOptionClick = function (event, option) {
33
- event === null || event === void 0 ? void 0 : event.stopPropagation();
34
- option === null || option === void 0 ? void 0 : option.onClick();
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", __assign({ style: styles }, { children: options.map(function (option) {
44
- var label = option.label, icon = option.icon, onClick = option.onClick;
45
- var handleOptionClick = onClick;
46
- return (_jsx(Tooltip, __assign({ title: label, "aria-label": label, placement: 'bottom', enterDelay: 500, enterNextDelay: 50, leaveDelay: 50, disableInteractive: true }, { children: _jsx(IconButton, __assign({ size: 'small', "aria-label": label, onClick: handleOptionClick }, { children: _jsx(Icon, { children: icon }) })) }), label));
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", __assign({ style: styles }, { children: [_jsx(IconButton, __assign({ "aria-label": 'more', "aria-haspopup": 'true', onClick: handleClick }, { children: _jsx(MoreVertIcon, {}) })), _jsx(Menu, __assign({ id: 'actionButtonMenu', anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, anchorOrigin: {
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
- } }, { children: options.map(function (option) {
59
- var label = option.label, isDisabled = option.isDisabled, actionKey = option.actionKey, hide = option.hide;
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, __assign({ onClick: function (event) { return handleOptionClick(event, option); }, "aria-label": label, disabled: isDisabled }, { children: label }), actionKey));
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 var StyledPaper = styled(Paper)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: ", ";\n position: relative;\n width: 100%;\n\n &.is-sticky {\n position: sticky;\n top: 0;\n z-index: 1;\n }\n"], ["\n display: flex;\n flex-direction: ", ";\n position: relative;\n width: 100%;\n\n &.is-sticky {\n position: sticky;\n top: 0;\n z-index: 1;\n }\n"])), function (props) { return props.theme.direction === 'ltr' ? 'row' : 'row-reverse'; });
8
- export var StyledBreadcrumbs = styled(Breadcrumbs)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-size: ", ";\n margin-bottom: 0.5rem;\n\n ol {\n flex-direction: ", ";\n }\n"], ["\n font-size: ", ";\n margin-bottom: 0.5rem;\n\n ol {\n flex-direction: ", ";\n }\n"])), function (props) { return props.theme.typography.subtitle2.fontSize; }, function (props) { return props.theme.direction === 'ltr' ? 'row' : 'row-reverse'; });
9
- export var StyledHeaderPrimary = styled(Box)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n align-items: ", ";\n display: flex;\n flex: 1 auto;\n flex-direction: column;\n padding: 1rem;\n padding-inline-start: 2rem;\n\n h1,\n h4 {\n font-size: clamp(1.125rem, 3.25vw, 2.75rem);\n text-align: ", ";\n }\n"], ["\n align-items: ", ";\n display: flex;\n flex: 1 auto;\n flex-direction: column;\n padding: 1rem;\n padding-inline-start: 2rem;\n\n h1,\n h4 {\n font-size: clamp(1.125rem, 3.25vw, 2.75rem);\n text-align: ", ";\n }\n"])), function (props) { return props.theme.direction === 'ltr' ? 'flex-start' : 'flex-end'; }, function (props) { return props.theme.direction === 'ltr' ? 'left' : 'right'; });
10
- export var StyledHeaderSecondary = styled(Box)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n flex-direction: ", ";\n justify-content: flex-end;\n padding: 1rem;\n padding-inline-end: 2rem;\n\n button,\n a {\n white-space: nowrap;\n }\n"], ["\n align-items: center;\n display: flex;\n flex-direction: ", ";\n justify-content: flex-end;\n padding: 1rem;\n padding-inline-end: 2rem;\n\n button,\n a {\n white-space: nowrap;\n }\n"])), function (props) { return props.theme.direction === 'ltr' ? 'row' : 'row-reverse'; });
11
- export var StyledAdditionalButtonsContainer = styled(Box)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin-inline-start: ", ";\n margin-inline-end: ", ";\n"], ["\n margin-inline-start: ", ";\n margin-inline-end: ", ";\n"])), function (props) { return props.theme.direction === 'ltr' ? '0.5rem' : '0'; }, function (props) { return props.theme.direction === 'rtl' ? '0.5rem' : '0'; });
12
- export var StyledBox = styled(Box)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n background: ", ";\n"], ["\n background: ", ";\n"])), function (props) { return props.theme.palette.background.default; });
13
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
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
- var __assign = (this && this.__assign) || function () {
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
- var StyledDrawer = styled(MUIDrawer)(function (_a) {
28
- var theme = _a.theme;
29
- return ({});
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
- var __assign = (this && this.__assign) || function () {
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
- var MobileNavigation = function (props) {
39
- var _a, _b, _c;
40
- var items = props.items, secondaryItems = props.secondaryItems, hideAvatarInitials = props.hideAvatarInitials, dataAttributes = props.dataAttributes, hasSearch = props.hasSearch, hasAvatar = props.hasAvatar, showNotchIndicator = props.showNotchIndicator, rest = __rest(props, ["items", "secondaryItems", "hideAvatarInitials", "dataAttributes", "hasSearch", "hasAvatar", "showNotchIndicator"]);
41
- var propIsDrawerOpen = typeof (props === null || props === void 0 ? void 0 : props.isDrawerOpen) === 'boolean' ? props.isDrawerOpen : undefined;
42
- var propIsSearchOpen = typeof (props === null || props === void 0 ? void 0 : props.isSearchOpen) === 'boolean' ? props.isSearchOpen : undefined;
43
- var propIsAvatarOpen = typeof (props === null || props === void 0 ? void 0 : props.isAvatarOpen) === 'boolean' ? props.isAvatarOpen : undefined;
44
- var avatarName = (_a = props === null || props === void 0 ? void 0 : props.avatarName) !== null && _a !== void 0 ? _a : 'Avatar name';
45
- var _d = React.useState(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false), isDrawerOpen = _d[0], setIsDrawerOpen = _d[1];
46
- var _e = React.useState(propIsSearchOpen !== null && propIsSearchOpen !== void 0 ? propIsSearchOpen : false), isSearchOpen = _e[0], setIsSearchOpen = _e[1];
47
- var _f = React.useState(propIsAvatarOpen !== null && propIsAvatarOpen !== void 0 ? propIsAvatarOpen : false), isAvatarOpen = _f[0], setIsAvatarOpen = _f[1];
48
- var _g = React.useState(0), value = _g[0], setValue = _g[1];
49
- var dataIds = __assign(__assign({}, defaultAttributes), dataAttributes);
50
- var currentDirection = window.localStorage.getItem('@learningpool/ui/store/mobile-navigation-direction');
51
- var _h = React.useState(currentDirection !== null && currentDirection !== void 0 ? currentDirection : 'ltr'), mobileNavDirection = _h[0], setMobileNavDirection = _h[1];
52
- var _j = React.useState(0), mobileNotchPosition = _j[0], setMobileNotchPosition = _j[1];
53
- var windowWidth = useCurrentWidth();
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
- var NOTCH = {
35
+ const NOTCH = {
59
36
  Height: 50,
60
37
  Width: 50
61
38
  };
62
- var BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS = Array.from(document.querySelectorAll('.MuiBottomNavigationAction-root'));
63
- var positionMobileNotch = function () {
64
- var _a;
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(function (e, i) {
70
- e.addEventListener('click', function () {
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
- var navBarRef = React.useRef(null);
76
- var _k = React.useState(0), navBarWidth = _k[0], setNavBarWidth = _k[1];
77
- useEffect(function () {
78
- var handleResize = function () {
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
- var resizeObserver = new ResizeObserver(handleResize);
59
+ const resizeObserver = new ResizeObserver(handleResize);
84
60
  if (navBarRef.current) {
85
61
  resizeObserver.observe(navBarRef.current);
86
62
  handleResize();
87
63
  }
88
- return function () {
64
+ return () => {
89
65
  if (navBarRef.current) {
90
66
  resizeObserver.unobserve(navBarRef.current);
91
67
  }
92
68
  };
93
69
  }, [value]);
94
- useEffect(function () { positionMobileNotch(); }, [
70
+ useEffect(() => { positionMobileNotch(); }, [
95
71
  value,
96
72
  navBarWidth,
97
73
  windowWidth,
98
- (_b = BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()
74
+ BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]?.getBoundingClientRect()
99
75
  ]);
100
- useEffect(function () { return setIsDrawerOpen(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false); }, [propIsDrawerOpen]);
101
- useEffect(function () { return setIsSearchOpen(propIsSearchOpen !== null && propIsSearchOpen !== void 0 ? propIsSearchOpen : false); }, [propIsSearchOpen]);
102
- useEffect(function () { return setIsAvatarOpen(propIsAvatarOpen !== null && propIsAvatarOpen !== void 0 ? propIsAvatarOpen : false); }, [propIsAvatarOpen]);
103
- useEffect(function () { return setAvatarInitials(handleAvatarInitials(avatarName)); }, [avatarName]);
104
- useEffect(function () {
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
- var HIDE_NOTCH = -1;
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
- var _l = React.useState((_c = handleAvatarInitials(avatarName)) !== null && _c !== void 0 ? _c : 'AN'), avatarInitials = _l[0], setAvatarInitials = _l[1];
114
- var toggleDrawer = function (open, action) { return function (event) {
115
- event === null || event === void 0 ? void 0 : event.stopPropagation();
116
- if (event.type === 'keydown') {
117
- if (event.key === 'Tab' || event.key === 'Shift') {
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 !== null && open !== void 0 ? open : !isSearchOpen);
104
+ setIsSearchOpen(open ?? !isSearchOpen);
129
105
  break;
130
106
  }
131
107
  case MOBILE_NAV_PANEL_TYPES.AVATAR: {
132
- setIsAvatarOpen(open !== null && open !== void 0 ? open : !isAvatarOpen);
108
+ setIsAvatarOpen(open ?? !isAvatarOpen);
133
109
  break;
134
110
  }
135
111
  default: {
136
- setIsDrawerOpen(open !== null && open !== void 0 ? open : !isDrawerOpen);
112
+ setIsDrawerOpen(open ?? !isDrawerOpen);
137
113
  break;
138
114
  }
139
115
  }
140
- }; };
141
- var api = useSpringRef();
142
- var animationConfig = {
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: __assign(__assign({}, config.default), { mass: 1 }),
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
- var MobileNavigationPaperAnimation = useSpring(animationConfig.MobileNavigationPaper);
163
- var MobileNavigationAnimation = useSpring(animationConfig.MobileNavigation);
164
- var MobileNavigationButtonAnimation = useSpring(animationConfig.MobileNavigationButton);
165
- return (_jsxs(_Fragment, { children: [_jsx(SwipeableTemporaryDrawer, __assign({ isDrawerOpen: isDrawerOpen, setIsDrawerOpen: setIsDrawerOpen, items: items, secondaryItems: secondaryItems, label: 'Primary' }, rest)), hasSearch && (_jsx(SwipeableTemporarySearch, __assign({ "data-id": dataIds.MobileNavSearchPanel, isSearchOpen: isSearchOpen, setIsSearchOpen: setIsSearchOpen }, rest))), hasAvatar && (_jsx(SwipeableTemporaryAvatar, __assign({ "data-id": dataIds.MobileNavAvatarPanel, isAvatarOpen: isAvatarOpen, setIsAvatarOpen: setIsAvatarOpen, avatarName: avatarName, mobileNavDirection: mobileNavDirection, setMobileNavDirection: setMobileNavDirection }, rest))), _jsxs(StyledPaper, __assign({ elevation: 3,
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 }, { children: [showNotchIndicator && _jsx(NotchIndicator, __assign({}, animationConfig.MobileNavigationNotch)), _jsxs(StyledBottomNavigation, __assign({ value: value,
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: __assign({ flexDirection: mobileNavDirection && mobileNavDirection === 'rtl' ? 'row-reverse' : 'row' }, MobileNavigationAnimation) }, { children: [_jsx(StyledBottomNavigationAction, { "data-id": dataIds.MobileNavDrawerToggle, icon: _jsx(ToggleX, { isOpen: isDrawerOpen }), onClick: toggleDrawer(!isDrawerOpen, MOBILE_NAV_PANEL_TYPES.DRAWER),
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: __assign({ marginInlineStart: (hasSearch || hasAvatar) && (mobileNavDirection && mobileNavDirection === 'rtl') ? 'auto' : 'initial', marginInlineEnd: (hasSearch || hasAvatar) && (mobileNavDirection && mobileNavDirection === 'rtl') ? 'initial' : 'auto' }, MobileNavigationButtonAnimation) }), hasSearch && (_jsx(StyledBottomNavigationAction, { "data-id": dataIds.MobileNavSearchToggle, icon: _jsx(ToggleSearchX, { isOpen: isSearchOpen }), onClick: toggleDrawer(!isSearchOpen, MOBILE_NAV_PANEL_TYPES.SEARCH),
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;