@learningpool/ui 1.8.7 → 1.9.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/components/atoms/Button/Button.d.ts +1 -1
- package/components/landmarks/Header/HeaderStyles.d.ts +1 -1
- package/components/navigation/Drawer/Drawer.d.ts +1 -1
- package/components/navigation/MobileNavigation/MobileNavigationAvatar.js +46 -31
- package/components/navigation/MobileNavigation/MobileNavigationAvatarStyles.d.ts +207 -141
- package/components/navigation/MobileNavigation/MobileNavigationDrawer.js +39 -27
- package/components/navigation/MobileNavigation/MobileNavigationDrawerStyles.d.ts +75 -53
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemFlyoutMenuStyles.d.ts +4 -4
- package/components/navigation/MobileNavigation/MobileNavigationItem/MobileNavigationItemStyles.d.ts +6 -6
- package/components/navigation/MobileNavigation/MobileNavigationSearchStyles.d.ts +68 -46
- package/components/navigation/MobileNavigation/MobileNavigationStyles.d.ts +1 -1
- package/components/navigation/VerticalNavigation/VerticalNavigation.js +131 -105
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatar.js +42 -18
- package/components/navigation/VerticalNavigation/VerticalNavigationAvatarStyles.d.ts +207 -141
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemFlyoutMenuStyles.d.ts +4 -4
- package/components/navigation/VerticalNavigation/VerticalNavigationItem/VerticalNavigationItemStyles.d.ts +6 -6
- package/components/navigation/VerticalNavigation/VerticalNavigationStyles.d.ts +69 -47
- package/components/stream/AppHub/AppHubCustomStyles.d.ts +4 -4
- package/components/stream/AppHub/AppHubProductStyles.d.ts +3 -3
- package/components/stream/AppHub/AppHubStyles.d.ts +2 -2
- package/components/stream/AppSwitcher/AppSwitcher.d.ts +10 -2
- package/components/stream/AppSwitcher/AppSwitcher.js +9 -7
- package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.d.ts +16 -0
- package/components/stream/AppSwitcher/AppSwitcherStylesStandalone.js +22 -0
- package/components/stream/AppSwitcher/constants.d.ts +19 -0
- package/components/stream/AppSwitcher/constants.js +19 -0
- package/package.json +4 -3
- package/utils/helpers.d.ts +12 -9
- package/utils/helpers.js +41 -21
|
@@ -20,6 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
31
|
+
};
|
|
23
32
|
import { createElement as _createElement } from "react";
|
|
24
33
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
34
|
import React, { useEffect } from 'react';
|
|
@@ -64,6 +73,11 @@ var VerticalNavigation = function (props) {
|
|
|
64
73
|
var logoWidth = 38;
|
|
65
74
|
useEffect(function () { return setIsDrawerOpen(propIsDrawerOpen !== null && propIsDrawerOpen !== void 0 ? propIsDrawerOpen : false); }, [propIsDrawerOpen]);
|
|
66
75
|
useEffect(function () { return setIsDrawerOpen(propIsPersistent !== null && propIsPersistent !== void 0 ? propIsPersistent : false); }, [propIsPersistent]);
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (!avatarName || !hasAvatar) {
|
|
78
|
+
setIsAvatarOpen(false);
|
|
79
|
+
}
|
|
80
|
+
}, [avatarName, hasAvatar]);
|
|
67
81
|
// This fixes an issue with how MUI handles the modal and aria-hidden.
|
|
68
82
|
// When open, the Modal adds aria-hidden="true" to a top-level element,
|
|
69
83
|
// which causes some screen readers to annouce the elements as "blank".
|
|
@@ -95,113 +109,125 @@ var VerticalNavigation = function (props) {
|
|
|
95
109
|
setIsAppSwitcherOpen(false);
|
|
96
110
|
setIsDrawerOpen(open !== null && open !== void 0 ? open : !isDrawerOpen);
|
|
97
111
|
}; };
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
// Workaround to handle the react-spring calls without
|
|
113
|
+
// adding additional hook calls on prop or state changes
|
|
114
|
+
// --
|
|
115
|
+
// Store the total possible number of animations in a ref
|
|
116
|
+
// this way the number of hook calls never changes
|
|
117
|
+
// --
|
|
118
|
+
// First item starts at 70ms, see STAGGER_ITEMS_DELAY in helpers.js
|
|
119
|
+
var additionalItems = ['hasStreamHome', 'hasAvatar', 'avatarName'];
|
|
120
|
+
var totalItems = __spreadArray(__spreadArray(__spreadArray([], items !== null && items !== void 0 ? items : [], true), secondaryItems !== null && secondaryItems !== void 0 ? secondaryItems : [], true), additionalItems, true);
|
|
121
|
+
var animationRefs = React.useRef(totalItems && totalItems.map(function (item, index) { return useFadeIn(index); }));
|
|
122
|
+
var listContent = function () {
|
|
123
|
+
var _a, _b, _c;
|
|
124
|
+
return (_jsxs(Box, __assign({ sx: {
|
|
108
125
|
display: 'flex',
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
height: "".concat(logoHeight, "px"),
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
width: '1.75rem'
|
|
142
|
-
} })) }) })), _jsx(Box, { style: {
|
|
143
|
-
borderRadius: '50%',
|
|
144
|
-
boxShadow: '5px 0 15px 0 rgb(0 0 0 / 10%)',
|
|
145
|
-
display: 'none',
|
|
146
|
-
height: '50px',
|
|
147
|
-
left: '12px',
|
|
148
|
-
position: 'fixed',
|
|
149
|
-
right: 'auto !important',
|
|
150
|
-
top: '50%',
|
|
151
|
-
transform: 'translate(50%, -50%)',
|
|
152
|
-
width: '50px'
|
|
153
|
-
} }), _jsxs(DrawerToggle, __assign({ onClick: handleIsPersistent, "aria-label": isDrawerOpen ? messages['close-navigation'] : messages['open-navigation'], "aria-expanded": isDrawerOpen ? 'true' : 'false', "aria-controls": "vertical-navigation", style: {
|
|
154
|
-
display: 'none',
|
|
155
|
-
position: 'fixed',
|
|
156
|
-
top: '50%',
|
|
157
|
-
transform: 'translate(50%, -50%)',
|
|
158
|
-
zIndex: 10
|
|
159
|
-
} }, { children: [_jsx(NotchExtendSVG, { style: {
|
|
160
|
-
display: 'block',
|
|
161
|
-
fill: getNavigationBackground(theme),
|
|
162
|
-
height: '165px',
|
|
163
|
-
left: '-12px',
|
|
164
|
-
padding: '0',
|
|
165
|
-
position: 'absolute',
|
|
166
|
-
top: '-61px',
|
|
167
|
-
transition: 'none',
|
|
168
|
-
width: '90px',
|
|
169
|
-
zIndex: '-1'
|
|
170
|
-
} }), _jsx(DrawerToggleHitboxContent, __assign({ style: {
|
|
171
|
-
background: 'transparent',
|
|
172
|
-
boxShadow: 'none',
|
|
173
|
-
fontSize: '1.3rem',
|
|
174
|
-
height: '1.3rem',
|
|
175
|
-
padding: theme.spacing(1),
|
|
176
|
-
width: '1.3rem'
|
|
177
|
-
} }, { children: isPersistent
|
|
178
|
-
? (_jsx(PushPin, { style: {
|
|
179
|
-
fontSize: '1.3rem',
|
|
180
|
-
height: '1.3rem',
|
|
181
|
-
width: '1.3rem'
|
|
126
|
+
flex: '1 auto',
|
|
127
|
+
flexDirection: 'column',
|
|
128
|
+
justifyContent: 'flex-start',
|
|
129
|
+
'.wrapper': {
|
|
130
|
+
display: 'flex',
|
|
131
|
+
position: 'relative'
|
|
132
|
+
},
|
|
133
|
+
'.wrapper > :not(:first-of-type)': {
|
|
134
|
+
position: 'absolute',
|
|
135
|
+
right: 0,
|
|
136
|
+
background: 'transparent',
|
|
137
|
+
fontSize: 0
|
|
138
|
+
}
|
|
139
|
+
}, className: 'grid-container' }, { children: [_jsx("div", __assign({ className: 'wrapper', style: { backgroundColor: getNavigationBackground(theme) }, "data-id": dataIds.VerticalNavigationBrand }, { children: _jsxs(DrawerHeader, __assign({ onClick: logoOnClick !== null && logoOnClick !== void 0 ? logoOnClick : null, isDrawerOpen: isDrawerOpen || isPersistent, style: animationRefs.current[0] }, { children: [_jsx(Tooltip, __assign({ disableHoverListener: isDrawerOpen || isPersistent, disableFocusListener: isDrawerOpen || isPersistent, disableTouchListener: isDrawerOpen || isPersistent, title: logoText !== null && logoText !== void 0 ? logoText : '', placement: theme.direction === 'rtl' ? 'left' : 'right' }, { children: logo
|
|
140
|
+
? typeof logo === 'string'
|
|
141
|
+
? (_jsx("img", { src: logo, height: "".concat(logoHeight, "px"), width: "".concat(logoWidth, "px"), style: {
|
|
142
|
+
marginInlineEnd: '16px'
|
|
143
|
+
}, alt: logoText !== null && logoText !== void 0 ? logoText : messages['site-logo'] }))
|
|
144
|
+
: logo
|
|
145
|
+
: (_jsx(StreamSuiteLogo, { style: {
|
|
146
|
+
height: "".concat(logoHeight, "px"),
|
|
147
|
+
width: "".concat(logoWidth, "px"),
|
|
148
|
+
marginInlineEnd: '16px',
|
|
149
|
+
fill: getNavigationContrastText(theme)
|
|
150
|
+
} })) })), _jsx(ListItemText, { primary: logoText !== null && logoText !== void 0 ? logoText : '', isDrawerOpen: isDrawerOpen || isPersistent })] })) })), _jsxs("div", __assign({ className: 'wrapper', "data-id": dataIds.VerticalNavigationToggle }, { children: [_jsxs(NotchContainer, __assign({ sx: { height: '85px', position: 'relative !important' } }, { children: [_jsx(NotchBackground, {}), !isPersistent && _jsx(NotchBackgroundClip, {}), _jsx(NotchSeemMask, {})] })), !isPersistent && _jsx(DrawerToggle, __assign({ onClick: toggleDrawer(!isDrawerOpen), "aria-label": isDrawerOpen ? messages['close-navigation'] : messages['open-navigation'], "aria-expanded": isDrawerOpen ? 'true' : 'false', "aria-controls": "vertical-navigation", isDrawerOpen: isDrawerOpen,
|
|
151
|
+
// @ts-expect-error
|
|
152
|
+
component: animated.button, style: animationRefs.current[0] }, { children: _jsx(DrawerToggleHitboxContent, { children: isDrawerOpen
|
|
153
|
+
? (_jsx(ChevronLeft, { style: {
|
|
154
|
+
fill: getNavigationContrastText(theme),
|
|
155
|
+
fontSize: '1.75rem',
|
|
156
|
+
height: '1.75rem',
|
|
157
|
+
width: '1.75rem'
|
|
182
158
|
} }))
|
|
183
|
-
: (_jsx(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
159
|
+
: (_jsx(ChevronRight, { style: {
|
|
160
|
+
fill: getNavigationContrastText(theme),
|
|
161
|
+
fontSize: '1.75rem',
|
|
162
|
+
height: '1.75rem',
|
|
163
|
+
width: '1.75rem'
|
|
164
|
+
} })) }) })), _jsx(Box, { style: {
|
|
165
|
+
borderRadius: '50%',
|
|
166
|
+
boxShadow: '5px 0 15px 0 rgb(0 0 0 / 10%)',
|
|
167
|
+
display: 'none',
|
|
168
|
+
height: '50px',
|
|
169
|
+
left: '12px',
|
|
170
|
+
position: 'fixed',
|
|
171
|
+
right: 'auto !important',
|
|
172
|
+
top: '50%',
|
|
173
|
+
transform: 'translate(50%, -50%)',
|
|
174
|
+
width: '50px'
|
|
175
|
+
} }), _jsxs(DrawerToggle, __assign({ onClick: handleIsPersistent, "aria-label": isDrawerOpen ? messages['close-navigation'] : messages['open-navigation'], "aria-expanded": isDrawerOpen ? 'true' : 'false', "aria-controls": "vertical-navigation", style: {
|
|
176
|
+
display: 'none',
|
|
177
|
+
position: 'fixed',
|
|
178
|
+
top: '50%',
|
|
179
|
+
transform: 'translate(50%, -50%)',
|
|
180
|
+
zIndex: 10
|
|
181
|
+
} }, { children: [_jsx(NotchExtendSVG, { style: {
|
|
182
|
+
display: 'block',
|
|
183
|
+
fill: getNavigationBackground(theme),
|
|
184
|
+
height: '165px',
|
|
185
|
+
left: '-12px',
|
|
186
|
+
padding: '0',
|
|
187
|
+
position: 'absolute',
|
|
188
|
+
top: '-61px',
|
|
189
|
+
transition: 'none',
|
|
190
|
+
width: '90px',
|
|
191
|
+
zIndex: '-1'
|
|
192
|
+
} }), _jsx(DrawerToggleHitboxContent, __assign({ style: {
|
|
193
|
+
background: 'transparent',
|
|
194
|
+
boxShadow: 'none',
|
|
195
|
+
fontSize: '1.3rem',
|
|
196
|
+
height: '1.3rem',
|
|
197
|
+
padding: theme.spacing(1),
|
|
198
|
+
width: '1.3rem'
|
|
199
|
+
} }, { children: isPersistent
|
|
200
|
+
? (_jsx(PushPin, { style: {
|
|
201
|
+
fontSize: '1.3rem',
|
|
202
|
+
height: '1.3rem',
|
|
203
|
+
width: '1.3rem'
|
|
204
|
+
} }))
|
|
205
|
+
: (_jsx(PushPin, { style: {
|
|
206
|
+
fontSize: '1.3rem',
|
|
207
|
+
height: '1.3rem',
|
|
208
|
+
width: '1.3rem'
|
|
209
|
+
} })) }))] }))] })), _jsx(NotchSVG, { style: { height: '0', position: 'absolute', width: '0' } }), _jsx("div", __assign({ className: 'wrapper', "data-id": dataIds.VerticalNavigationPrimary, style: {
|
|
210
|
+
backgroundColor: getNavigationBackground(theme),
|
|
211
|
+
flex: '1 1px',
|
|
212
|
+
marginTop: '-1px',
|
|
213
|
+
overflow: 'auto',
|
|
214
|
+
position: 'relative',
|
|
215
|
+
zIndex: 10
|
|
216
|
+
} }, { children: _jsx(StyledNav, __assign({ tabIndex: -1, "aria-label": 'Primary' }, { children: _jsx(List, __assign({ "data-id": dataIds.VerticalNavigationPrimaryList, style: {
|
|
217
|
+
height: '100%',
|
|
218
|
+
width: DRAWER_WIDTH.Expanded,
|
|
219
|
+
marginTop: "-".concat(theme.spacing(0.5), " !important")
|
|
220
|
+
} }, { children: items && items.length > 0 && items.map(function (item, index) { return (_createElement(VerticalNavigationItem, __assign({}, item, { "data-id": dataIds.VerticalNavigationPrimaryListItem, key: "".concat(item.label, " - ").concat(index), index: index, isDrawerOpen: isDrawerOpen || isPersistent, style: animationRefs.current[index] }))); }) })) })) })), _jsx("div", __assign({ className: 'wrapper', "data-id": dataIds.VerticalNavigationSecondary, style: { backgroundColor: getNavigationBackground(theme) } }, { children: _jsxs(StyledNavSecondary, __assign({ "aria-label": 'Secondary' }, { children: [_jsx(StyledDivider, { isDrawerOpen: isDrawerOpen || isPersistent }), _jsxs(List, __assign({ "data-id": dataIds.VerticalNavigationSecondaryList, style: { width: DRAWER_WIDTH.Expanded } }, { children: [hasStreamHome
|
|
221
|
+
? (_jsx(VerticalNavigationItem, { "data-id": dataIds.VerticalNavigationAppSwitcherToggle, label: messages['app-switcher'], icon: _jsx(Apps, {}), onClick: handleToggleAppsClick, content: (_jsx(AppSwitcher, { isAppSwitcherOpen: isAppSwitcherOpen, setIsAppSwitcherOpen: setIsAppSwitcherOpen, applications: streamHomeApplications, apiKey: streamHomeApiKey !== null && streamHomeApiKey !== void 0 ? streamHomeApiKey : '', baseUrl: streamHomeBaseUrl !== null && streamHomeBaseUrl !== void 0 ? streamHomeBaseUrl : '', token: streamHomeAccessToken !== null && streamHomeAccessToken !== void 0 ? streamHomeAccessToken : '', isDrawerOpen: isDrawerOpen })), isDrawerOpen: isDrawerOpen || isPersistent, isSecondary: true, hasCustomContent: true, style: animationRefs.current[((_a = items === null || items === void 0 ? void 0 : items.length) !== null && _a !== void 0 ? _a : 0) + 1] }))
|
|
222
|
+
: null, secondaryItems && secondaryItems.length > 0 && secondaryItems.map(function (item, index) {
|
|
223
|
+
var _a;
|
|
224
|
+
return (_createElement(VerticalNavigationItem, __assign({}, item, { "data-id": dataIds.VerticalNavigationSecondaryListItem, key: "".concat(item.label, " - ").concat(index), index: index, isDrawerOpen: isDrawerOpen || isPersistent, isSecondary: true, style: animationRefs.current[((_a = items === null || items === void 0 ? void 0 : items.length) !== null && _a !== void 0 ? _a : 0) + index + 1] })));
|
|
225
|
+
}), hasAvatar && avatarName && (_jsx(VerticalNavigationItem, { label: avatarName, "data-id": dataIds.VerticalNavigationAvatarToggle, "aria-controls": 'avatar-panel', icon: _jsx(Avatar, __assign({ style: {
|
|
226
|
+
fontSize: '0.75rem',
|
|
227
|
+
height: 32,
|
|
228
|
+
width: 32
|
|
229
|
+
} }, { children: handleAvatarInitials(avatarName) })), style: __assign({ maxHeight: isDrawerOpen ? '200px' : '48px', overflow: 'hidden', padding: 0, minHeight: 52, transition: "max-height 225ms ".concat(motion.easeInOut, " 0ms !important") }, animationRefs.current[((_b = items === null || items === void 0 ? void 0 : items.length) !== null && _b !== void 0 ? _b : 0) + ((_c = secondaryItems === null || secondaryItems === void 0 ? void 0 : secondaryItems.length) !== null && _c !== void 0 ? _c : 0) + 2]), onClick: function () { return setIsAvatarOpen(!isAvatarOpen); }, hasFlyout: true, fullHeightFlyout: true, content: _jsx(AvatarPanel, __assign({ avatarName: avatarName, isAvatarOpen: isAvatarOpen, localization: localization }, rest)), isDrawerOpen: isDrawerOpen }))] }))] })) }))] })));
|
|
230
|
+
};
|
|
205
231
|
return (_jsxs(StyledAside, __assign({ "aria-label": messages['site-navigation'], "data-id": dataIds.VerticalNavigationContainer }, { children: [_jsx(DrawerShadow, { className: 'drawerShadow', "aria-hidden": 'true', isDrawerOpen: isDrawerOpen || isPersistent, style: {
|
|
206
232
|
display: isPersistent ? 'none' : 'block'
|
|
207
233
|
} }), _jsx(Modal, __assign({ "aria-hidden": false, keepMounted: true, disablePortal: true, open: isDrawerOpen, onClose: toggleDrawer(false) }, { children: _jsx(StyledDrawer, __assign({ id: 'vertical-navigation', anchor: 'left', open: isDrawerOpen || isPersistent, onClose: toggleDrawer(false), variant: 'permanent' }, { children: listContent() })) }))] })));
|
|
@@ -9,6 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
22
|
import React, { useEffect } from 'react';
|
|
14
23
|
import { Box, Link, List, ListItem, ListItemIcon, ListItemText } from '../../../index';
|
|
@@ -16,14 +25,14 @@ import { StyledBox, StyledBoxProfile, StyledButton, StyledAvatarName, StyledAvat
|
|
|
16
25
|
import { useTheme } from '@mui/material/styles';
|
|
17
26
|
import EditIcon from '@mui/icons-material/Edit';
|
|
18
27
|
import LogoutIcon from '@mui/icons-material/Logout';
|
|
19
|
-
import { handleAvatarInitials,
|
|
28
|
+
import { handleAvatarInitials, useFadeIn } from '../../../utils/helpers';
|
|
20
29
|
import { Person, Settings } from '@mui/icons-material';
|
|
21
30
|
import { animated } from '@react-spring/web';
|
|
22
31
|
import { FlyoutMenuItemText } from './VerticalNavigationItem/VerticalNavigationItemFlyoutMenuStyles';
|
|
23
32
|
import { defaultMessages } from '../../../lang/en-us';
|
|
24
33
|
import { defaultAttributes } from '../../../utils/dataAttributes';
|
|
25
34
|
var AvatarPanel = function (props) {
|
|
26
|
-
var _a;
|
|
35
|
+
var _a, _b, _c, _d;
|
|
27
36
|
var theme = useTheme();
|
|
28
37
|
var avatarName = props.avatarName, avatarPanelOnClickLogout = props.avatarPanelOnClickLogout, avatarPanelLogoutString = props.avatarPanelLogoutString, avatarPanelOnClickViewProfile = props.avatarPanelOnClickViewProfile, avatarPanelViewProfileString = props.avatarPanelViewProfileString, avatarPanelOnClickEditProfile = props.avatarPanelOnClickEditProfile, avatarPanelEditProfileString = props.avatarPanelEditProfileString, avatarPanelMenuItems = props.avatarPanelMenuItems, avatarPanelOnClickMainAction = props.avatarPanelOnClickMainAction, avatarPanelMainActionString = props.avatarPanelMainActionString, avatarPanelSettingItems = props.avatarPanelSettingItems, avatarPanelFootnote = props.avatarPanelFootnote, isAvatarOpen = props.isAvatarOpen, localization = props.localization, dataAttributes = props.dataAttributes;
|
|
29
38
|
var messages = __assign(__assign({}, defaultMessages), localization);
|
|
@@ -31,27 +40,39 @@ var AvatarPanel = function (props) {
|
|
|
31
40
|
useEffect(function () {
|
|
32
41
|
setAvatarInitials(handleAvatarInitials(avatarName));
|
|
33
42
|
}, [avatarName]);
|
|
34
|
-
var
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
var _e = React.useState((_a = handleAvatarInitials(avatarName)) !== null && _a !== void 0 ? _a : 'AN'), avatarInitials = _e[0], setAvatarInitials = _e[1];
|
|
44
|
+
// Workaround to handle the react-spring calls without
|
|
45
|
+
// adding additional hook calls on prop or state changes
|
|
46
|
+
// --
|
|
47
|
+
// Store the total possible number of animations in a ref
|
|
48
|
+
// this way the number of hook calls never changes
|
|
49
|
+
// --
|
|
50
|
+
// First item starts at 70ms, see STAGGER_ITEMS_DELAY in helpers.js
|
|
51
|
+
var additionalItems = [
|
|
52
|
+
'avatarPanelOnClickLogout',
|
|
53
|
+
'avatarName',
|
|
54
|
+
'avatarPanelOnClickViewProfile',
|
|
55
|
+
'avatarPanelOnClickMainAction',
|
|
56
|
+
'avatarPanelFootnote'
|
|
57
|
+
];
|
|
58
|
+
var totalItems = __spreadArray(__spreadArray(__spreadArray([], avatarPanelMenuItems !== null && avatarPanelMenuItems !== void 0 ? avatarPanelMenuItems : [], true), avatarPanelSettingItems !== null && avatarPanelSettingItems !== void 0 ? avatarPanelSettingItems : [], true), additionalItems, true);
|
|
59
|
+
var animationRefs = React.useRef(totalItems && totalItems.map(function (item, index) { return useFadeIn(index, !isAvatarOpen); }));
|
|
39
60
|
return (_jsxs(StyledBox, { children: [avatarPanelOnClickLogout && (_jsx(StyledButton
|
|
40
61
|
// @ts-expect-error
|
|
41
62
|
, __assign({
|
|
42
63
|
// @ts-expect-error
|
|
43
|
-
component: animated.button, style: __assign({ left: theme.direction === 'rtl' ? theme.spacing(1) : 'auto', position: 'absolute', right: theme.direction === 'rtl' ? 'auto' : theme.spacing(1), top: theme.spacing(1) },
|
|
64
|
+
component: animated.button, style: __assign({ left: theme.direction === 'rtl' ? theme.spacing(1) : 'auto', position: 'absolute', right: theme.direction === 'rtl' ? 'auto' : theme.spacing(1), top: theme.spacing(1) }, animationRefs.current[0]), onClick: avatarPanelOnClickLogout, startIcon: _jsx(LogoutIcon, {}), variant: 'text', color: 'inherit' }, { children: avatarPanelLogoutString !== null && avatarPanelLogoutString !== void 0 ? avatarPanelLogoutString : messages.logout }))), _jsxs(Box, __assign({ "data-id": dataIds.VerticalNavigationAvatarProfile, style: {
|
|
44
65
|
alignItems: 'center',
|
|
45
66
|
display: 'flex',
|
|
46
67
|
flexDirection: 'column'
|
|
47
|
-
} }, { children: [_jsxs(StyledBoxProfile, __assign({ style:
|
|
68
|
+
} }, { children: [_jsxs(StyledBoxProfile, __assign({ style: animationRefs.current[1] }, { children: [_jsx(StyledAvatar, __assign({ style: { marginInlineEnd: '0.5rem' } }, { children: avatarInitials })), _jsxs(StyledAvatarName, { children: [_jsx("span", __assign({ style: { fontWeight: 300 } }, { children: messages.greeting })), " ", _jsx("strong", { children: avatarName.split(' ')[0] })] })] })), avatarPanelOnClickViewProfile && (_jsx(StyledBoxProfileEdit, __assign({ style: __assign({ marginBottom: theme.spacing(2) }, animationRefs.current[2]) }, { children: _jsxs(StyledButtonGroup, __assign({ variant: 'outlined', "aria-label": "split button" }, { children: [_jsx(StyledButton, __assign({ variant: 'outlined', color: 'inherit', size: 'medium', onClick: avatarPanelOnClickViewProfile, startIcon: _jsx(Person, {}) }, { children: avatarPanelViewProfileString !== null && avatarPanelViewProfileString !== void 0 ? avatarPanelViewProfileString : messages['view-profile'] })), avatarPanelOnClickEditProfile && (_jsx(StyledButton, __assign({ variant: 'outlined', color: 'inherit', size: 'medium', "aria-label": avatarPanelEditProfileString !== null && avatarPanelEditProfileString !== void 0 ? avatarPanelEditProfileString : messages['edit-profile'], onClick: avatarPanelOnClickEditProfile }, { children: _jsx(EditIcon, {}) })))] })) })))] })), _jsxs(Box, __assign({ style: {
|
|
48
69
|
alignItems: 'center',
|
|
49
70
|
display: 'flex',
|
|
50
71
|
flexDirection: 'column'
|
|
51
72
|
} }, { children: [avatarPanelMenuItems && avatarPanelMenuItems.length > 0 && (_jsx(List, __assign({ "data-id": dataIds.VerticalNavigationFlyoutList, style: {
|
|
52
73
|
marginBottom: theme.spacing(2),
|
|
53
74
|
maxWidth: '14rem'
|
|
54
|
-
} }, { children: avatarPanelMenuItems.map(function (avatarMenuItem, index) { return (_jsx(ListItem, __assign({ "data-id": dataIds.VerticalNavigationFlyoutListItem, component: animated.div, style:
|
|
75
|
+
} }, { children: avatarPanelMenuItems.map(function (avatarMenuItem, index) { return (_jsx(ListItem, __assign({ "data-id": dataIds.VerticalNavigationFlyoutListItem, component: animated.div, style: animationRefs.current[index + 2], disablePadding: true }, { children: _jsxs(StyledListItemButton
|
|
55
76
|
// TODO: figure out if these are links or buttons
|
|
56
77
|
// @ts-expect-error
|
|
57
78
|
, __assign({
|
|
@@ -61,16 +82,19 @@ var AvatarPanel = function (props) {
|
|
|
61
82
|
// @ts-expect-error
|
|
62
83
|
, __assign({
|
|
63
84
|
// @ts-expect-error
|
|
64
|
-
component: animated.button, style:
|
|
85
|
+
component: animated.button, style: animationRefs.current[((_b = avatarPanelMenuItems === null || avatarPanelMenuItems === void 0 ? void 0 : avatarPanelMenuItems.length) !== null && _b !== void 0 ? _b : 0) + 3], variant: 'outlined', color: 'inherit', size: 'medium', onClick: avatarPanelOnClickMainAction, startIcon: _jsx(Settings, {}) }, { children: avatarPanelMainActionString })), _jsx(List, __assign({ "data-id": dataIds.VerticalNavigationFlyoutList, style: { marginBottom: theme.spacing(2) } }, { children: avatarPanelSettingItems &&
|
|
65
86
|
avatarPanelSettingItems.length > 0 &&
|
|
66
|
-
avatarPanelSettingItems.map(function (avatarMenuItem, index) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
, __assign({
|
|
87
|
+
avatarPanelSettingItems.map(function (avatarMenuItem, index) {
|
|
88
|
+
var _a;
|
|
89
|
+
return (_jsx(ListItem, __assign({ "data-id": dataIds.VerticalNavigationFlyoutListItem, component: animated.div, style: animationRefs.current[((_a = avatarPanelMenuItems === null || avatarPanelMenuItems === void 0 ? void 0 : avatarPanelMenuItems.length) !== null && _a !== void 0 ? _a : 0) + index + 3], disablePadding: true }, { children: _jsxs(StyledListItemButton
|
|
70
90
|
// TODO: figure out if these are links or buttons
|
|
71
91
|
// @ts-expect-error
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
, __assign({
|
|
93
|
+
// TODO: figure out if these are links or buttons
|
|
94
|
+
// @ts-expect-error
|
|
95
|
+
component: Link, role: 'link', onClick: avatarMenuItem.onClick }, { children: [_jsx(ListItemIcon, __assign({ "aria-hidden": true, style: {
|
|
96
|
+
minWidth: theme.spacing(5)
|
|
97
|
+
} }, { children: avatarMenuItem.icon })), _jsx(ListItemText, { primary: avatarMenuItem.label })] })) }), "".concat(avatarMenuItem.label, " - ").concat(index)));
|
|
98
|
+
}) }))] })), _jsx(Box, __assign({ "data-id": dataIds.VerticalNavigationFlyoutFootnote, className: 'avatar-panel-footnote', style: animationRefs.current[((_c = avatarPanelMenuItems === null || avatarPanelMenuItems === void 0 ? void 0 : avatarPanelMenuItems.length) !== null && _c !== void 0 ? _c : 0) + ((_d = avatarPanelSettingItems === null || avatarPanelSettingItems === void 0 ? void 0 : avatarPanelSettingItems.length) !== null && _d !== void 0 ? _d : 0) + 4] }, { children: avatarPanelFootnote && avatarPanelFootnote }))] }));
|
|
75
99
|
};
|
|
76
100
|
export default AvatarPanel;
|