@learningpool/ui 1.7.1 → 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
|
|
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
|
-
|
|
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
|
|
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,
|
|
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
|