cynx-lib 1.3.109 → 1.3.111
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/package.json +1 -1
- package/ui/components/Layout.jsx +6 -0
- package/ui/components/Sidebar.jsx +541 -5
package/package.json
CHANGED
package/ui/components/Layout.jsx
CHANGED
|
@@ -26,6 +26,9 @@ export default function Layout({
|
|
|
26
26
|
showLogout,
|
|
27
27
|
userSlot,
|
|
28
28
|
renderUser,
|
|
29
|
+
userMenu,
|
|
30
|
+
userMenuTheme,
|
|
31
|
+
userMenuConfig,
|
|
29
32
|
footerStyle,
|
|
30
33
|
footerClassName,
|
|
31
34
|
footerActionsLayout,
|
|
@@ -91,6 +94,9 @@ export default function Layout({
|
|
|
91
94
|
showLogout={showLogout}
|
|
92
95
|
userSlot={userSlot}
|
|
93
96
|
renderUser={renderUser}
|
|
97
|
+
userMenu={userMenu}
|
|
98
|
+
userMenuTheme={userMenuTheme}
|
|
99
|
+
userMenuConfig={userMenuConfig}
|
|
94
100
|
footerStyle={footerStyle}
|
|
95
101
|
footerClassName={footerClassName}
|
|
96
102
|
footerActionsLayout={footerActionsLayout}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
|
2
2
|
import { NavLink } from 'react-router-dom';
|
|
3
3
|
import {
|
|
4
4
|
PanelLeftClose,
|
|
5
5
|
PanelLeftOpen,
|
|
6
6
|
LogOut,
|
|
7
7
|
ChevronDown,
|
|
8
|
+
ChevronUp,
|
|
8
9
|
Lock,
|
|
9
10
|
} from 'lucide-react';
|
|
10
11
|
import Button from './Button.jsx';
|
|
12
|
+
import Toggle from './Toggle.jsx';
|
|
11
13
|
|
|
12
14
|
export function isDarkColor(color) {
|
|
13
15
|
if (!color || typeof color !== 'string') return false;
|
|
@@ -115,6 +117,9 @@ export default function Sidebar({
|
|
|
115
117
|
showLogout = true,
|
|
116
118
|
userSlot,
|
|
117
119
|
renderUser,
|
|
120
|
+
userMenu,
|
|
121
|
+
userMenuTheme = 'auto',
|
|
122
|
+
userMenuConfig,
|
|
118
123
|
footerStyle = {},
|
|
119
124
|
footerClassName = '',
|
|
120
125
|
footerActionsLayout = 'flex',
|
|
@@ -158,6 +163,49 @@ export default function Sidebar({
|
|
|
158
163
|
typeof controlledIsCollapsed === 'boolean' ? controlledIsCollapsed : internalCollapsed;
|
|
159
164
|
|
|
160
165
|
const [expandedSections, setExpandedSections] = useState({});
|
|
166
|
+
const [isUserMenuOpen, setIsUserMenuOpen] = useState(false);
|
|
167
|
+
const userMenuRef = useRef(null);
|
|
168
|
+
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!isUserMenuOpen) return;
|
|
171
|
+
const handleClickOutside = (e) => {
|
|
172
|
+
if (userMenuRef.current && !userMenuRef.current.contains(e.target)) {
|
|
173
|
+
setIsUserMenuOpen(false);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const handleKeyDown = (e) => {
|
|
177
|
+
if (e.key === 'Escape') setIsUserMenuOpen(false);
|
|
178
|
+
};
|
|
179
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
180
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
181
|
+
return () => {
|
|
182
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
183
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
184
|
+
};
|
|
185
|
+
}, [isUserMenuOpen]);
|
|
186
|
+
|
|
187
|
+
const resolvedUserMenu = useMemo(() => {
|
|
188
|
+
const raw = userMenuConfig || userMenu;
|
|
189
|
+
if (!raw) return null;
|
|
190
|
+
if (Array.isArray(raw)) {
|
|
191
|
+
return {
|
|
192
|
+
theme: userMenuTheme || 'auto',
|
|
193
|
+
sections: [{ id: 'default', items: raw }],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
if (typeof raw === 'object') {
|
|
197
|
+
return {
|
|
198
|
+
theme: raw.theme || userMenuTheme || 'auto',
|
|
199
|
+
showHeader: raw.header !== false,
|
|
200
|
+
sections: Array.isArray(raw.sections)
|
|
201
|
+
? raw.sections
|
|
202
|
+
: Array.isArray(raw.items)
|
|
203
|
+
? [{ id: 'default', items: raw.items }]
|
|
204
|
+
: [],
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}, [userMenuConfig, userMenu, userMenuTheme]);
|
|
161
209
|
|
|
162
210
|
const toggleSidebarCollapse = (e) => {
|
|
163
211
|
if (e) {
|
|
@@ -339,7 +387,9 @@ export default function Sidebar({
|
|
|
339
387
|
(act) => act && !act.hidden && act.visible !== false
|
|
340
388
|
);
|
|
341
389
|
|
|
342
|
-
const hasFooterContent = Boolean(
|
|
390
|
+
const hasFooterContent = Boolean(
|
|
391
|
+
user || finalActions.length > 0 || userSlot || renderUser || resolvedUserMenu
|
|
392
|
+
);
|
|
343
393
|
|
|
344
394
|
return (
|
|
345
395
|
<aside
|
|
@@ -354,9 +404,10 @@ export default function Sidebar({
|
|
|
354
404
|
flexDirection: 'column',
|
|
355
405
|
boxSizing: 'border-box',
|
|
356
406
|
userSelect: 'none',
|
|
407
|
+
position: 'relative',
|
|
357
408
|
transition:
|
|
358
409
|
'width 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease',
|
|
359
|
-
overflow: 'hidden',
|
|
410
|
+
overflow: resolvedUserMenu ? 'visible' : 'hidden',
|
|
360
411
|
flexShrink: 0,
|
|
361
412
|
...sidebarStyle,
|
|
362
413
|
}}
|
|
@@ -745,15 +796,500 @@ export default function Sidebar({
|
|
|
745
796
|
: footerSlot
|
|
746
797
|
) : hasFooterContent ? (
|
|
747
798
|
<div
|
|
799
|
+
ref={userMenuRef}
|
|
748
800
|
className={footerClassName}
|
|
749
801
|
style={{
|
|
750
|
-
padding:
|
|
802
|
+
padding: resolvedUserMenu
|
|
803
|
+
? (isCollapsed ? '10px 8px' : '10px 12px')
|
|
804
|
+
: (isCollapsed ? '12px 8px' : 12),
|
|
751
805
|
borderTop: effectiveSidebarBorder,
|
|
806
|
+
position: 'relative',
|
|
752
807
|
flexShrink: 0,
|
|
808
|
+
boxSizing: 'border-box',
|
|
753
809
|
...footerStyle,
|
|
754
810
|
}}
|
|
755
811
|
>
|
|
756
|
-
{
|
|
812
|
+
{resolvedUserMenu ? (
|
|
813
|
+
(() => {
|
|
814
|
+
const isMenuLight =
|
|
815
|
+
resolvedUserMenu.theme === 'light' ||
|
|
816
|
+
(resolvedUserMenu.theme === 'auto' && !isDarkSidebar);
|
|
817
|
+
|
|
818
|
+
const userObj = user || {};
|
|
819
|
+
const userDisplay =
|
|
820
|
+
userObj.fullName || userObj.full_name || userObj.username;
|
|
821
|
+
const userSub =
|
|
822
|
+
userObj.username ? `@${userObj.username}` : '';
|
|
823
|
+
const initial = (userDisplay || 'U')[0].toUpperCase();
|
|
824
|
+
|
|
825
|
+
return (
|
|
826
|
+
<>
|
|
827
|
+
{isUserMenuOpen && (
|
|
828
|
+
<div
|
|
829
|
+
style={{
|
|
830
|
+
position: 'absolute',
|
|
831
|
+
...(isCollapsed
|
|
832
|
+
? {
|
|
833
|
+
left: 'calc(100% + 12px)',
|
|
834
|
+
bottom: 4,
|
|
835
|
+
width: 240,
|
|
836
|
+
}
|
|
837
|
+
: {
|
|
838
|
+
left: 6,
|
|
839
|
+
right: 6,
|
|
840
|
+
bottom: 'calc(100% + 8px)',
|
|
841
|
+
minWidth: 236,
|
|
842
|
+
}),
|
|
843
|
+
background: isMenuLight ? '#ffffff' : '#1d2033',
|
|
844
|
+
border: isMenuLight
|
|
845
|
+
? '1px solid var(--border, #e4e4e7)'
|
|
846
|
+
: '1px solid rgba(255, 255, 255, 0.12)',
|
|
847
|
+
borderRadius: 12,
|
|
848
|
+
boxShadow: isMenuLight
|
|
849
|
+
? '0 16px 36px -4px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.06)'
|
|
850
|
+
: '0 16px 36px -4px rgba(0, 0, 0, 0.65), 0 6px 14px rgba(0, 0, 0, 0.4)',
|
|
851
|
+
padding: 6,
|
|
852
|
+
zIndex: 100,
|
|
853
|
+
display: 'flex',
|
|
854
|
+
flexDirection: 'column',
|
|
855
|
+
gap: 2,
|
|
856
|
+
boxSizing: 'border-box',
|
|
857
|
+
backdropFilter: isMenuLight ? 'none' : 'blur(12px)',
|
|
858
|
+
transition:
|
|
859
|
+
'background 160ms ease, border-color 160ms ease, box-shadow 160ms ease',
|
|
860
|
+
}}
|
|
861
|
+
>
|
|
862
|
+
{/* User Header */}
|
|
863
|
+
{userDisplay && (
|
|
864
|
+
<div
|
|
865
|
+
style={{
|
|
866
|
+
height: 48,
|
|
867
|
+
minHeight: 48,
|
|
868
|
+
padding: '0 10px',
|
|
869
|
+
borderBottom: isMenuLight
|
|
870
|
+
? '1px solid var(--border-light, #f4f4f5)'
|
|
871
|
+
: '1px solid rgba(255, 255, 255, 0.08)',
|
|
872
|
+
marginBottom: 2,
|
|
873
|
+
display: 'flex',
|
|
874
|
+
alignItems: 'center',
|
|
875
|
+
gap: 10,
|
|
876
|
+
boxSizing: 'border-box',
|
|
877
|
+
}}
|
|
878
|
+
>
|
|
879
|
+
<div
|
|
880
|
+
style={{
|
|
881
|
+
width: 32,
|
|
882
|
+
height: 32,
|
|
883
|
+
borderRadius: 8,
|
|
884
|
+
background: 'var(--sidebar-avatar-bg, var(--accent))',
|
|
885
|
+
display: 'flex',
|
|
886
|
+
alignItems: 'center',
|
|
887
|
+
justifyContent: 'center',
|
|
888
|
+
fontSize: '.78rem',
|
|
889
|
+
fontWeight: 700,
|
|
890
|
+
color: '#fff',
|
|
891
|
+
flexShrink: 0,
|
|
892
|
+
}}
|
|
893
|
+
>
|
|
894
|
+
{initial}
|
|
895
|
+
</div>
|
|
896
|
+
<div
|
|
897
|
+
style={{
|
|
898
|
+
display: 'flex',
|
|
899
|
+
flexDirection: 'column',
|
|
900
|
+
minWidth: 0,
|
|
901
|
+
overflow: 'hidden',
|
|
902
|
+
flex: 1,
|
|
903
|
+
}}
|
|
904
|
+
>
|
|
905
|
+
<div
|
|
906
|
+
style={{
|
|
907
|
+
fontSize: '.82rem',
|
|
908
|
+
fontWeight: 600,
|
|
909
|
+
color: isMenuLight
|
|
910
|
+
? 'var(--primary-text, #09090b)'
|
|
911
|
+
: 'rgba(255, 255, 255, 0.95)',
|
|
912
|
+
whiteSpace: 'nowrap',
|
|
913
|
+
overflow: 'hidden',
|
|
914
|
+
textOverflow: 'ellipsis',
|
|
915
|
+
}}
|
|
916
|
+
>
|
|
917
|
+
{userDisplay}
|
|
918
|
+
</div>
|
|
919
|
+
{userSub && (
|
|
920
|
+
<div
|
|
921
|
+
style={{
|
|
922
|
+
fontSize: '.7rem',
|
|
923
|
+
color: isMenuLight
|
|
924
|
+
? 'var(--muted, #71717a)'
|
|
925
|
+
: 'rgba(255, 255, 255, 0.45)',
|
|
926
|
+
whiteSpace: 'nowrap',
|
|
927
|
+
overflow: 'hidden',
|
|
928
|
+
textOverflow: 'ellipsis',
|
|
929
|
+
}}
|
|
930
|
+
>
|
|
931
|
+
{userSub}
|
|
932
|
+
</div>
|
|
933
|
+
)}
|
|
934
|
+
</div>
|
|
935
|
+
</div>
|
|
936
|
+
)}
|
|
937
|
+
|
|
938
|
+
{/* Sections & Items */}
|
|
939
|
+
{resolvedUserMenu.sections.map((section, sIdx) => (
|
|
940
|
+
<React.Fragment key={section.id || sIdx}>
|
|
941
|
+
{sIdx > 0 && (
|
|
942
|
+
<div
|
|
943
|
+
style={{
|
|
944
|
+
height: 1,
|
|
945
|
+
background: isMenuLight
|
|
946
|
+
? 'var(--border-light, #f4f4f5)'
|
|
947
|
+
: 'rgba(255, 255, 255, 0.08)',
|
|
948
|
+
margin: '2px 4px',
|
|
949
|
+
flexShrink: 0,
|
|
950
|
+
}}
|
|
951
|
+
/>
|
|
952
|
+
)}
|
|
953
|
+
{(section.items || []).map((item, iIdx) => {
|
|
954
|
+
const Icon = item.icon;
|
|
955
|
+
const isDanger = item.variant === 'danger' || item.danger;
|
|
956
|
+
const key = item.id || item.key || `${sIdx}-${iIdx}`;
|
|
957
|
+
|
|
958
|
+
if (item.type === 'toggle') {
|
|
959
|
+
return (
|
|
960
|
+
<div
|
|
961
|
+
key={key}
|
|
962
|
+
onClick={() => item.onChange?.(!item.checked)}
|
|
963
|
+
style={{
|
|
964
|
+
width: '100%',
|
|
965
|
+
height: 36,
|
|
966
|
+
minHeight: 36,
|
|
967
|
+
maxHeight: 36,
|
|
968
|
+
display: 'flex',
|
|
969
|
+
alignItems: 'center',
|
|
970
|
+
justifyContent: 'space-between',
|
|
971
|
+
padding: '0 10px',
|
|
972
|
+
borderRadius: 8,
|
|
973
|
+
boxSizing: 'border-box',
|
|
974
|
+
color: isMenuLight
|
|
975
|
+
? 'var(--primary-text, #09090b)'
|
|
976
|
+
: 'rgba(255, 255, 255, 0.9)',
|
|
977
|
+
fontSize: '.82rem',
|
|
978
|
+
fontWeight: 500,
|
|
979
|
+
cursor: 'pointer',
|
|
980
|
+
userSelect: 'none',
|
|
981
|
+
transition: 'background 120ms ease',
|
|
982
|
+
}}
|
|
983
|
+
onMouseEnter={(e) => {
|
|
984
|
+
e.currentTarget.style.background = isMenuLight
|
|
985
|
+
? 'var(--hover-bg, #f4f4f5)'
|
|
986
|
+
: 'rgba(255, 255, 255, 0.06)';
|
|
987
|
+
}}
|
|
988
|
+
onMouseLeave={(e) => {
|
|
989
|
+
e.currentTarget.style.background = 'transparent';
|
|
990
|
+
}}
|
|
991
|
+
>
|
|
992
|
+
<div
|
|
993
|
+
style={{
|
|
994
|
+
display: 'flex',
|
|
995
|
+
alignItems: 'center',
|
|
996
|
+
gap: 10,
|
|
997
|
+
minWidth: 0,
|
|
998
|
+
overflow: 'hidden',
|
|
999
|
+
flex: 1,
|
|
1000
|
+
}}
|
|
1001
|
+
>
|
|
1002
|
+
{Icon && (
|
|
1003
|
+
<Icon
|
|
1004
|
+
size={15}
|
|
1005
|
+
style={{
|
|
1006
|
+
flexShrink: 0,
|
|
1007
|
+
color: isMenuLight
|
|
1008
|
+
? 'var(--muted, #71717a)'
|
|
1009
|
+
: 'rgba(255, 255, 255, 0.6)',
|
|
1010
|
+
}}
|
|
1011
|
+
/>
|
|
1012
|
+
)}
|
|
1013
|
+
<span
|
|
1014
|
+
style={{
|
|
1015
|
+
whiteSpace: 'nowrap',
|
|
1016
|
+
overflow: 'hidden',
|
|
1017
|
+
textOverflow: 'ellipsis',
|
|
1018
|
+
}}
|
|
1019
|
+
>
|
|
1020
|
+
{item.label || item.text || item.title}
|
|
1021
|
+
</span>
|
|
1022
|
+
</div>
|
|
1023
|
+
<Toggle
|
|
1024
|
+
size="sm"
|
|
1025
|
+
checked={item.checked}
|
|
1026
|
+
onChange={item.onChange}
|
|
1027
|
+
style={{ flexShrink: 0, margin: 0, pointerEvents: 'none' }}
|
|
1028
|
+
/>
|
|
1029
|
+
</div>
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
return (
|
|
1034
|
+
<button
|
|
1035
|
+
key={key}
|
|
1036
|
+
type="button"
|
|
1037
|
+
onClick={(e) => {
|
|
1038
|
+
setIsUserMenuOpen(false);
|
|
1039
|
+
item.onClick?.(e);
|
|
1040
|
+
}}
|
|
1041
|
+
style={{
|
|
1042
|
+
width: '100%',
|
|
1043
|
+
height: 36,
|
|
1044
|
+
minHeight: 36,
|
|
1045
|
+
maxHeight: 36,
|
|
1046
|
+
display: 'flex',
|
|
1047
|
+
alignItems: 'center',
|
|
1048
|
+
justifyContent: 'space-between',
|
|
1049
|
+
padding: '0 10px',
|
|
1050
|
+
border: 'none',
|
|
1051
|
+
borderRadius: 8,
|
|
1052
|
+
background: 'transparent',
|
|
1053
|
+
color: isDanger
|
|
1054
|
+
? (isMenuLight ? 'var(--danger, #ef4444)' : '#f87171')
|
|
1055
|
+
: (isMenuLight ? 'var(--primary-text, #09090b)' : 'rgba(255, 255, 255, 0.9)'),
|
|
1056
|
+
fontSize: '.82rem',
|
|
1057
|
+
fontWeight: 500,
|
|
1058
|
+
cursor: 'pointer',
|
|
1059
|
+
textAlign: 'left',
|
|
1060
|
+
boxSizing: 'border-box',
|
|
1061
|
+
transition: 'background 120ms ease, color 120ms ease',
|
|
1062
|
+
}}
|
|
1063
|
+
onMouseEnter={(e) => {
|
|
1064
|
+
if (isDanger) {
|
|
1065
|
+
e.currentTarget.style.background = isMenuLight
|
|
1066
|
+
? 'var(--danger-bg, rgba(239, 68, 68, 0.08))'
|
|
1067
|
+
: 'rgba(239, 68, 68, 0.14)';
|
|
1068
|
+
e.currentTarget.style.color = isMenuLight
|
|
1069
|
+
? 'var(--danger, #ef4444)'
|
|
1070
|
+
: '#fca5a5';
|
|
1071
|
+
} else {
|
|
1072
|
+
e.currentTarget.style.background = isMenuLight
|
|
1073
|
+
? 'var(--hover-bg, #f4f4f5)'
|
|
1074
|
+
: 'var(--sidebar-active-bg, rgba(255, 255, 255, 0.08))';
|
|
1075
|
+
e.currentTarget.style.color = isMenuLight
|
|
1076
|
+
? 'var(--primary-text, #09090b)'
|
|
1077
|
+
: '#ffffff';
|
|
1078
|
+
}
|
|
1079
|
+
}}
|
|
1080
|
+
onMouseLeave={(e) => {
|
|
1081
|
+
e.currentTarget.style.background = 'transparent';
|
|
1082
|
+
e.currentTarget.style.color = isDanger
|
|
1083
|
+
? (isMenuLight ? 'var(--danger, #ef4444)' : '#f87171')
|
|
1084
|
+
: (isMenuLight ? 'var(--primary-text, #09090b)' : 'rgba(255, 255, 255, 0.9)');
|
|
1085
|
+
}}
|
|
1086
|
+
>
|
|
1087
|
+
<div
|
|
1088
|
+
style={{
|
|
1089
|
+
display: 'flex',
|
|
1090
|
+
alignItems: 'center',
|
|
1091
|
+
gap: 10,
|
|
1092
|
+
minWidth: 0,
|
|
1093
|
+
overflow: 'hidden',
|
|
1094
|
+
flex: 1,
|
|
1095
|
+
}}
|
|
1096
|
+
>
|
|
1097
|
+
{Icon && (
|
|
1098
|
+
<Icon
|
|
1099
|
+
size={15}
|
|
1100
|
+
style={{
|
|
1101
|
+
flexShrink: 0,
|
|
1102
|
+
color: isDanger
|
|
1103
|
+
? (isMenuLight ? 'var(--danger, #ef4444)' : '#f87171')
|
|
1104
|
+
: (isMenuLight ? 'var(--muted, #71717a)' : 'rgba(255, 255, 255, 0.6)'),
|
|
1105
|
+
}}
|
|
1106
|
+
/>
|
|
1107
|
+
)}
|
|
1108
|
+
<span
|
|
1109
|
+
style={{
|
|
1110
|
+
whiteSpace: 'nowrap',
|
|
1111
|
+
overflow: 'hidden',
|
|
1112
|
+
textOverflow: 'ellipsis',
|
|
1113
|
+
}}
|
|
1114
|
+
>
|
|
1115
|
+
{item.label || item.text || item.title}
|
|
1116
|
+
</span>
|
|
1117
|
+
</div>
|
|
1118
|
+
{item.badge && (
|
|
1119
|
+
<span
|
|
1120
|
+
style={{
|
|
1121
|
+
fontSize: '.65rem',
|
|
1122
|
+
padding: '2px 6px',
|
|
1123
|
+
borderRadius: 4,
|
|
1124
|
+
background: isMenuLight
|
|
1125
|
+
? 'var(--grey-1, #f4f4f5)'
|
|
1126
|
+
: 'rgba(255, 255, 255, 0.1)',
|
|
1127
|
+
color: isMenuLight
|
|
1128
|
+
? 'var(--muted, #71717a)'
|
|
1129
|
+
: 'rgba(255, 255, 255, 0.65)',
|
|
1130
|
+
fontFamily: 'var(--mono, monospace)',
|
|
1131
|
+
letterSpacing: '-.02em',
|
|
1132
|
+
flexShrink: 0,
|
|
1133
|
+
marginLeft: 8,
|
|
1134
|
+
whiteSpace: 'nowrap',
|
|
1135
|
+
}}
|
|
1136
|
+
>
|
|
1137
|
+
{item.badge}
|
|
1138
|
+
</span>
|
|
1139
|
+
)}
|
|
1140
|
+
</button>
|
|
1141
|
+
);
|
|
1142
|
+
})}
|
|
1143
|
+
</React.Fragment>
|
|
1144
|
+
))}
|
|
1145
|
+
</div>
|
|
1146
|
+
)}
|
|
1147
|
+
|
|
1148
|
+
{/* Trigger Button */}
|
|
1149
|
+
{isCollapsed ? (
|
|
1150
|
+
<button
|
|
1151
|
+
type="button"
|
|
1152
|
+
onClick={() => setIsUserMenuOpen((prev) => !prev)}
|
|
1153
|
+
title={userDisplay}
|
|
1154
|
+
aria-label={userDisplay}
|
|
1155
|
+
style={{
|
|
1156
|
+
width: 36,
|
|
1157
|
+
height: 36,
|
|
1158
|
+
borderRadius: 8,
|
|
1159
|
+
background: isUserMenuOpen
|
|
1160
|
+
? (isDarkSidebar ? 'rgba(255, 255, 255, 0.16)' : 'rgba(0, 0, 0, 0.08)')
|
|
1161
|
+
: 'var(--sidebar-avatar-bg, var(--accent))',
|
|
1162
|
+
display: 'flex',
|
|
1163
|
+
alignItems: 'center',
|
|
1164
|
+
justifyContent: 'center',
|
|
1165
|
+
fontSize: '.74rem',
|
|
1166
|
+
fontWeight: 700,
|
|
1167
|
+
color: '#fff',
|
|
1168
|
+
margin: '0 auto',
|
|
1169
|
+
border: 'none',
|
|
1170
|
+
cursor: 'pointer',
|
|
1171
|
+
transition: 'background 140ms ease',
|
|
1172
|
+
}}
|
|
1173
|
+
>
|
|
1174
|
+
{initial}
|
|
1175
|
+
</button>
|
|
1176
|
+
) : (
|
|
1177
|
+
<button
|
|
1178
|
+
type="button"
|
|
1179
|
+
onClick={() => setIsUserMenuOpen((prev) => !prev)}
|
|
1180
|
+
style={{
|
|
1181
|
+
width: '100%',
|
|
1182
|
+
display: 'flex',
|
|
1183
|
+
alignItems: 'center',
|
|
1184
|
+
justifyContent: 'space-between',
|
|
1185
|
+
padding: '7px 8px',
|
|
1186
|
+
borderRadius: 8,
|
|
1187
|
+
background: isUserMenuOpen
|
|
1188
|
+
? (isDarkSidebar ? 'rgba(255, 255, 255, 0.10)' : 'var(--hover-bg, #f4f4f5)')
|
|
1189
|
+
: 'transparent',
|
|
1190
|
+
border: 'none',
|
|
1191
|
+
cursor: 'pointer',
|
|
1192
|
+
textAlign: 'left',
|
|
1193
|
+
transition: 'background 140ms ease',
|
|
1194
|
+
}}
|
|
1195
|
+
onMouseEnter={(e) => {
|
|
1196
|
+
if (!isUserMenuOpen) {
|
|
1197
|
+
e.currentTarget.style.background = isDarkSidebar
|
|
1198
|
+
? 'rgba(255, 255, 255, 0.06)'
|
|
1199
|
+
: 'var(--hover-bg, #f4f4f5)';
|
|
1200
|
+
}
|
|
1201
|
+
}}
|
|
1202
|
+
onMouseLeave={(e) => {
|
|
1203
|
+
if (!isUserMenuOpen) e.currentTarget.style.background = 'transparent';
|
|
1204
|
+
}}
|
|
1205
|
+
>
|
|
1206
|
+
<div
|
|
1207
|
+
style={{
|
|
1208
|
+
display: 'flex',
|
|
1209
|
+
alignItems: 'center',
|
|
1210
|
+
gap: 9,
|
|
1211
|
+
minWidth: 0,
|
|
1212
|
+
overflow: 'hidden',
|
|
1213
|
+
}}
|
|
1214
|
+
>
|
|
1215
|
+
<div
|
|
1216
|
+
style={{
|
|
1217
|
+
width: 28,
|
|
1218
|
+
height: 28,
|
|
1219
|
+
borderRadius: 7,
|
|
1220
|
+
background: 'var(--sidebar-avatar-bg, var(--accent))',
|
|
1221
|
+
display: 'flex',
|
|
1222
|
+
alignItems: 'center',
|
|
1223
|
+
justifyContent: 'center',
|
|
1224
|
+
fontSize: '.72rem',
|
|
1225
|
+
fontWeight: 700,
|
|
1226
|
+
color: '#fff',
|
|
1227
|
+
flexShrink: 0,
|
|
1228
|
+
}}
|
|
1229
|
+
>
|
|
1230
|
+
{initial}
|
|
1231
|
+
</div>
|
|
1232
|
+
<div
|
|
1233
|
+
style={{
|
|
1234
|
+
display: 'flex',
|
|
1235
|
+
flexDirection: 'column',
|
|
1236
|
+
minWidth: 0,
|
|
1237
|
+
overflow: 'hidden',
|
|
1238
|
+
}}
|
|
1239
|
+
>
|
|
1240
|
+
<span
|
|
1241
|
+
style={{
|
|
1242
|
+
fontSize: '.8rem',
|
|
1243
|
+
fontWeight: 600,
|
|
1244
|
+
color: isDarkSidebar
|
|
1245
|
+
? 'rgba(255, 255, 255, 0.92)'
|
|
1246
|
+
: 'var(--primary-text, #09090b)',
|
|
1247
|
+
whiteSpace: 'nowrap',
|
|
1248
|
+
overflow: 'hidden',
|
|
1249
|
+
textOverflow: 'ellipsis',
|
|
1250
|
+
}}
|
|
1251
|
+
>
|
|
1252
|
+
{userDisplay}
|
|
1253
|
+
</span>
|
|
1254
|
+
{userSub && (
|
|
1255
|
+
<span
|
|
1256
|
+
style={{
|
|
1257
|
+
fontSize: '.66rem',
|
|
1258
|
+
color: isDarkSidebar
|
|
1259
|
+
? 'rgba(255, 255, 255, 0.45)'
|
|
1260
|
+
: 'var(--muted, #71717a)',
|
|
1261
|
+
letterSpacing: '.02em',
|
|
1262
|
+
whiteSpace: 'nowrap',
|
|
1263
|
+
overflow: 'hidden',
|
|
1264
|
+
textOverflow: 'ellipsis',
|
|
1265
|
+
}}
|
|
1266
|
+
>
|
|
1267
|
+
{userSub}
|
|
1268
|
+
</span>
|
|
1269
|
+
)}
|
|
1270
|
+
</div>
|
|
1271
|
+
</div>
|
|
1272
|
+
<div
|
|
1273
|
+
style={{
|
|
1274
|
+
color: isDarkSidebar
|
|
1275
|
+
? 'rgba(255, 255, 255, 0.55)'
|
|
1276
|
+
: 'var(--muted, #71717a)',
|
|
1277
|
+
display: 'flex',
|
|
1278
|
+
alignItems: 'center',
|
|
1279
|
+
transform: isUserMenuOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
1280
|
+
transition: 'transform 180ms cubic-bezier(0.4, 0, 0.2, 1)',
|
|
1281
|
+
flexShrink: 0,
|
|
1282
|
+
marginLeft: 6,
|
|
1283
|
+
}}
|
|
1284
|
+
>
|
|
1285
|
+
<ChevronUp size={15} />
|
|
1286
|
+
</div>
|
|
1287
|
+
</button>
|
|
1288
|
+
)}
|
|
1289
|
+
</>
|
|
1290
|
+
);
|
|
1291
|
+
})()
|
|
1292
|
+
) : !isCollapsed ? (
|
|
757
1293
|
<>
|
|
758
1294
|
{userSlot ? (
|
|
759
1295
|
typeof userSlot === 'function' ? (
|