@learningpool/ui 1.7.0 → 1.7.2

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.
@@ -58,16 +58,42 @@ var MobileNavigation = function (props) {
58
58
  Height: 50,
59
59
  Width: 50
60
60
  };
61
- var BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS = document.querySelectorAll('.MuiBottomNavigationAction-root, .bottom-navigation-item');
61
+ var BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS = Array.from(document.querySelectorAll('.MuiBottomNavigationAction-root'));
62
62
  var positionMobileNotch = function () {
63
63
  var _a;
64
64
  var selectedDOMRect = (_a = BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
65
65
  setMobileNotchPosition(selectedDOMRect ? selectedDOMRect.left + (selectedDOMRect.width / 2) - (NOTCH.Width / 2) : mobileNotchPosition);
66
66
  };
67
- useEffect(function () { return positionMobileNotch(); }, [
67
+ // Set index value for nav items
68
+ BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS.forEach(function (e, i) {
69
+ e.addEventListener('click', function () {
70
+ setValue(i);
71
+ });
72
+ });
73
+ // Watch for changes to the navbar width anytime a drawer is opened/closed
74
+ var navBarRef = React.useRef(null);
75
+ var _k = React.useState(0), navBarWidth = _k[0], setNavBarWidth = _k[1];
76
+ useEffect(function () {
77
+ var handleResize = function () {
78
+ if (navBarRef.current) {
79
+ setNavBarWidth(navBarRef.current.offsetWidth);
80
+ }
81
+ };
82
+ var resizeObserver = new ResizeObserver(handleResize);
83
+ if (navBarRef.current) {
84
+ resizeObserver.observe(navBarRef.current);
85
+ handleResize();
86
+ }
87
+ return function () {
88
+ if (navBarRef.current) {
89
+ resizeObserver.unobserve(navBarRef.current);
90
+ }
91
+ };
92
+ }, [value]);
93
+ useEffect(function () { positionMobileNotch(); }, [
68
94
  value,
95
+ navBarWidth,
69
96
  windowWidth,
70
- // Fix notch position if scrollbar is hidden/shown
71
97
  (_b = BOTTOM_NAVIGATION_ITEM_DOM_ELEMENTS[value]) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()
72
98
  ]);
73
99
  useEffect(function () { return setIsDrawerOpen(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false); }, [propIsDrawerOpen]);
@@ -83,7 +109,7 @@ var MobileNavigation = function (props) {
83
109
  }
84
110
  hideNotch();
85
111
  }, [isDrawerOpen, isSearchOpen, isAvatarOpen]);
86
- var _k = React.useState((_c = handleAvatarInitials(avatarName)) !== null && _c !== void 0 ? _c : 'AN'), avatarInitials = _k[0], setAvatarInitials = _k[1];
112
+ var _l = React.useState((_c = handleAvatarInitials(avatarName)) !== null && _c !== void 0 ? _c : 'AN'), avatarInitials = _l[0], setAvatarInitials = _l[1];
87
113
  var toggleDrawer = function (open, action) { return function (event) {
88
114
  event === null || event === void 0 ? void 0 : event.stopPropagation();
89
115
  if (event.type === 'keydown') {
@@ -99,17 +125,14 @@ var MobileNavigation = function (props) {
99
125
  switch (action) {
100
126
  case MOBILE_NAV_PANEL_TYPES.SEARCH: {
101
127
  setIsSearchOpen(open !== null && open !== void 0 ? open : !isSearchOpen);
102
- setValue(1);
103
128
  break;
104
129
  }
105
130
  case MOBILE_NAV_PANEL_TYPES.AVATAR: {
106
131
  setIsAvatarOpen(open !== null && open !== void 0 ? open : !isAvatarOpen);
107
- setValue(2);
108
132
  break;
109
133
  }
110
134
  default: {
111
135
  setIsDrawerOpen(open !== null && open !== void 0 ? open : !isDrawerOpen);
112
- setValue(0);
113
136
  break;
114
137
  }
115
138
  }
@@ -140,7 +163,7 @@ var MobileNavigation = function (props) {
140
163
  var MobileNavigationButtonAnimation = useSpring(animationConfig.MobileNavigationButton);
141
164
  return (_jsxs(_Fragment, { children: [_jsx(SwipeableTemporaryDrawer, __assign({ isDrawerOpen: isDrawerOpen, setIsDrawerOpen: setIsDrawerOpen, items: items, secondaryItems: secondaryItems, label: 'Primary' }, rest)), hasSearch && (_jsx(SwipeableTemporarySearch, __assign({ isSearchOpen: isSearchOpen, setIsSearchOpen: setIsSearchOpen }, rest))), hasAvatar && (_jsx(SwipeableTemporaryAvatar, __assign({ isAvatarOpen: isAvatarOpen, setIsAvatarOpen: setIsAvatarOpen, avatarName: avatarName, mobileNavDirection: mobileNavDirection, setMobileNavDirection: setMobileNavDirection }, rest))), _jsxs(StyledPaper, __assign({ elevation: 3,
142
165
  // @ts-expect-error
143
- component: animated.div, style: MobileNavigationPaperAnimation }, { children: [showNotchIndicator && _jsx(NotchIndicator, __assign({}, animationConfig.MobileNavigationNotch)), _jsxs(StyledBottomNavigation, __assign({ value: value, onChange: function (event, newValue) { return setValue(newValue); },
166
+ component: animated.div, style: MobileNavigationPaperAnimation, ref: navBarRef }, { children: [showNotchIndicator && _jsx(NotchIndicator, __assign({}, animationConfig.MobileNavigationNotch)), _jsxs(StyledBottomNavigation, __assign({ value: value,
144
167
  // @ts-expect-error
145
168
  component: animated.div, style: __assign({ flexDirection: mobileNavDirection && mobileNavDirection === 'rtl' ? 'row-reverse' : 'row' }, MobileNavigationAnimation) }, { children: [_jsx(StyledBottomNavigationAction, { icon: _jsx(ToggleX, { isOpen: isDrawerOpen }), onClick: toggleDrawer(!isDrawerOpen, MOBILE_NAV_PANEL_TYPES.DRAWER),
146
169
  // @ts-expect-error
@@ -6,7 +6,7 @@ import { Avatar, Button, ListItemButton, Typography } from '../../../index';
6
6
  import { Drawer } from '@mui/material';
7
7
  import { styled } from '@mui/material/styles';
8
8
  import { animated } from '@react-spring/web';
9
- export var StyledSwipeableAvatar = styled(Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .MuiPaper-root {\n color: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"], ["\n .MuiPaper-root {\n color: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
9
+ export var StyledSwipeableAvatar = styled(Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n color: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"], ["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n color: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"])), function (props) { return props.theme.zIndex.appBar - 1; }, function (props) { return props.theme.palette.mode === 'dark'
10
10
  ? props.theme.palette.primary.contrastText
11
11
  : props.theme.palette.text.primary; });
12
12
  export var StyledBox = styled(animated.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n background-image: ", ";\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n height: 100%;\n overflow: auto;\n padding: 15vh ", ";\n position: relative;\n"], ["\n background-color: ", ";\n background-image: ", ";\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n height: 100%;\n overflow: auto;\n padding: 15vh ", ";\n position: relative;\n"])), function (props) { return props.theme.palette.mode === 'dark'
@@ -6,7 +6,7 @@ import { Box, List, ListItem, ListItemText, ListItemButton, Typography } from '.
6
6
  import { Drawer } from '@mui/material';
7
7
  import { styled } from '@mui/material/styles';
8
8
  import { animated } from '@react-spring/web';
9
- export var StyledSwipeableDrawer = styled(Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .MuiPaper-root {\n background-color: ", ";\n background-image: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"], ["\n .MuiPaper-root {\n background-color: ", ";\n background-image: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"])), function (props) { return props.theme.palette.mode === 'dark'
9
+ export var StyledSwipeableDrawer = styled(Drawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n background-color: ", ";\n background-image: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"], ["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n background-color: ", ";\n background-image: ", ";\n height: 100vh;\n border: none;\n z-index: 1;\n }\n"])), function (props) { return props.theme.zIndex.appBar - 1; }, function (props) { return props.theme.palette.mode === 'dark'
10
10
  ? '#003366'
11
11
  : props.theme.palette.background.paper; }, function (props) { return props.theme.palette.mode === 'dark'
12
12
  ? 'none'
@@ -5,7 +5,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
5
5
  import { SwipeableDrawer, OutlinedInput, InputLabel } from '../../../index';
6
6
  import { styled } from '@mui/material/styles';
7
7
  import { animated } from '@react-spring/web';
8
- export var StyledSwipeableSearch = styled(SwipeableDrawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .MuiPaper-root {\n box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2),\n 0px 5px 8px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 14px 0px rgba(0, 0, 0, 0.12);\n border: none;\n border-radius: 20px 20px 0 0;\n z-index: 1;\n }\n"], ["\n .MuiPaper-root {\n box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2),\n 0px 5px 8px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 14px 0px rgba(0, 0, 0, 0.12);\n border: none;\n border-radius: 20px 20px 0 0;\n z-index: 1;\n }\n"])));
8
+ export var StyledSwipeableSearch = styled(SwipeableDrawer)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2),\n 0px 5px 8px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 14px 0px rgba(0, 0, 0, 0.12);\n border: none;\n border-radius: 20px 20px 0 0;\n z-index: 1;\n }\n"], ["\n // Override the MUI default z-index of the Drawer component\n // to ensure that the drawer is always below the AppBar.\n z-index: ", ";\n\n .MuiPaper-root {\n box-shadow: 0px 3px 5px -1px rgba(0, 0, 0, 0.2),\n 0px 5px 8px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 14px 0px rgba(0, 0, 0, 0.12);\n border: none;\n border-radius: 20px 20px 0 0;\n z-index: 1;\n }\n"])), function (props) { return props.theme.zIndex.appBar - 1; });
9
9
  export var StyledBox = styled(animated.div)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n background-image: ", ";\n padding: ", ";\n height: 100%;\n"], ["\n background-color: ", ";\n background-image: ", ";\n padding: ", ";\n height: 100%;\n"])), function (props) { return props.theme.palette.mode === 'dark'
10
10
  ? '#003366'
11
11
  : props.theme.palette.background.paper; }, function (props) { return props.theme.palette.mode === 'dark'
@@ -10,9 +10,9 @@ export var DRAWER_WIDTH = {
10
10
  Collapsed: 60,
11
11
  Expanded: 300
12
12
  };
13
- export var StyledPaper = styled(Paper)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n background-image: none;\n border-radius: 0;\n bottom: 0;\n left: 0;\n position: fixed;\n right: 0;\n z-index: 1000000000;\n"], ["\n background-color: ", ";\n background-image: none;\n border-radius: 0;\n bottom: 0;\n left: 0;\n position: fixed;\n right: 0;\n z-index: 1000000000;\n"])), function (props) { return props.theme.palette.mode === 'dark'
13
+ export var StyledPaper = styled(Paper)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n background-image: none;\n border-radius: 0;\n bottom: 0;\n left: 0;\n position: fixed;\n right: 0;\n z-index: ", ";\n"], ["\n background-color: ", ";\n background-image: none;\n border-radius: 0;\n bottom: 0;\n left: 0;\n position: fixed;\n right: 0;\n z-index: ", ";\n"])), function (props) { return props.theme.palette.mode === 'dark'
14
14
  ? props.theme.palette.primary.main
15
- : props.theme.palette.background.paper; });
15
+ : props.theme.palette.background.paper; }, function (props) { return props.theme.zIndex.appBar; });
16
16
  export var StyledNotchSVG = styled('svg', {
17
17
  shouldForwardProp: function (prop) { return prop !== 'mobileNotchPosition'; }
18
18
  })(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: block;\n fill: ", ";\n height: 50px;\n left: 0;\n padding: 0;\n position: absolute;\n stroke: transparent;\n top: -29px;\n transform: rotate(270deg);\n width: 50px;\n z-index: -1;\n"], ["\n display: block;\n fill: ", ";\n height: 50px;\n left: 0;\n padding: 0;\n position: absolute;\n stroke: transparent;\n top: -29px;\n transform: rotate(270deg);\n width: 50px;\n z-index: -1;\n"])), function (props) { return props.theme.palette.mode === 'dark'
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "components",
10
10
  "ui"
11
11
  ],
12
- "version": "1.7.0",
12
+ "version": "1.7.2",
13
13
  "private": false,
14
14
  "main": "index.js",
15
15
  "module": "index.js",