@wealthx/shadcn 1.3.0 → 1.3.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.
@@ -1,388 +0,0 @@
1
- import {
2
- Tooltip,
3
- TooltipContent,
4
- TooltipProvider,
5
- TooltipTrigger
6
- } from "./chunk-6JQFUE5I.mjs";
7
- import {
8
- formatCurrency
9
- } from "./chunk-MN5NYQCL.mjs";
10
- import {
11
- Button
12
- } from "./chunk-XREGSKX3.mjs";
13
- import {
14
- cn
15
- } from "./chunk-VLQZANBF.mjs";
16
-
17
- // src/components/ui/sidebar-nav.tsx
18
- import * as React from "react";
19
- import {
20
- ChevronDown,
21
- ChevronRight,
22
- Info,
23
- LogOut,
24
- PanelLeftClose,
25
- PanelLeftOpen
26
- } from "lucide-react";
27
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
28
- function getInitials(name) {
29
- return name.split(" ").filter(Boolean).map((word) => word[0]).join("").toUpperCase().slice(0, 2);
30
- }
31
- function navIconCn(isActive) {
32
- return cn(
33
- "shrink-0 transition-colors",
34
- isActive ? "text-primary" : "text-brand-secondary-foreground/50 group-hover:text-brand-secondary-foreground"
35
- );
36
- }
37
- function NavTooltip({ label, collapsed, children }) {
38
- if (!collapsed) return children;
39
- return /* @__PURE__ */ jsxs(Tooltip, { children: [
40
- /* @__PURE__ */ jsx(TooltipTrigger, { render: children }),
41
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: label })
42
- ] });
43
- }
44
- function MetricsGroup({ group }) {
45
- return /* @__PURE__ */ jsx("div", { className: "border-b border-white/15 py-4 px-5 flex flex-col gap-1.5", children: group.items.map((item) => /* @__PURE__ */ jsxs(
46
- "div",
47
- {
48
- className: "flex items-center justify-between gap-2",
49
- children: [
50
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 min-w-0", children: [
51
- /* @__PURE__ */ jsx(
52
- "span",
53
- {
54
- className: cn(
55
- "text-sm truncate text-brand-secondary-foreground/80",
56
- item.isNetItem && "font-semibold text-brand-secondary-foreground border-b-2 border-primary pb-px"
57
- ),
58
- children: item.name
59
- }
60
- ),
61
- item.info && /* @__PURE__ */ jsx(
62
- Info,
63
- {
64
- size: 11,
65
- strokeWidth: 2,
66
- className: "shrink-0 text-brand-secondary-foreground/50"
67
- }
68
- )
69
- ] }),
70
- /* @__PURE__ */ jsx(
71
- "span",
72
- {
73
- className: cn(
74
- "text-sm font-semibold tabular-nums shrink-0 text-brand-secondary-foreground",
75
- item.isNetItem && item.value < 0 && "text-destructive"
76
- ),
77
- children: formatCurrency(item.value, { showSign: item.isNetItem })
78
- }
79
- )
80
- ]
81
- },
82
- item.name
83
- )) });
84
- }
85
- function SidebarNavItemView({
86
- item,
87
- collapsed,
88
- onNavigate
89
- }) {
90
- var _a;
91
- const Icon = item.icon;
92
- return /* @__PURE__ */ jsx(NavTooltip, { label: item.title, collapsed, children: /* @__PURE__ */ jsxs(
93
- Button,
94
- {
95
- type: "button",
96
- variant: "ghost",
97
- onClick: () => onNavigate == null ? void 0 : onNavigate(item.href),
98
- className: cn(
99
- "group h-auto w-full items-center gap-3 py-2.5 text-base font-medium transition-colors",
100
- "text-brand-secondary-foreground/70 hover:bg-white/10 hover:text-brand-secondary-foreground",
101
- collapsed ? "justify-center px-2" : cn(
102
- "justify-start px-3 border-l-4",
103
- item.isActive ? "bg-white/15 text-brand-secondary-foreground border-primary" : "border-transparent"
104
- )
105
- ),
106
- children: [
107
- /* @__PURE__ */ jsx(
108
- Icon,
109
- {
110
- className: navIconCn((_a = item.isActive) != null ? _a : false),
111
- size: 18,
112
- strokeWidth: 1.75
113
- }
114
- ),
115
- !collapsed && /* @__PURE__ */ jsx("span", { className: "truncate", children: item.title })
116
- ]
117
- }
118
- ) });
119
- }
120
- function CollapsibleNavItem({
121
- item,
122
- collapsed,
123
- onNavigate
124
- }) {
125
- var _a, _b;
126
- const Icon = item.icon;
127
- const hasActiveChild = (_b = (_a = item.subItems) == null ? void 0 : _a.some((sub) => sub.isActive)) != null ? _b : false;
128
- const [open, setOpen] = React.useState(hasActiveChild);
129
- React.useEffect(() => {
130
- if (hasActiveChild) setOpen(true);
131
- }, [hasActiveChild]);
132
- if (collapsed) {
133
- return /* @__PURE__ */ jsx(NavTooltip, { label: item.title, collapsed, children: /* @__PURE__ */ jsx(
134
- Button,
135
- {
136
- type: "button",
137
- variant: "ghost",
138
- onClick: () => onNavigate == null ? void 0 : onNavigate(item.href),
139
- className: cn(
140
- "group h-auto w-full justify-center px-2 py-2.5 transition-colors",
141
- "text-brand-secondary-foreground/70 hover:bg-white/10 hover:text-brand-secondary-foreground",
142
- hasActiveChild && "bg-white/15 text-brand-secondary-foreground"
143
- ),
144
- children: /* @__PURE__ */ jsx(
145
- Icon,
146
- {
147
- className: navIconCn(hasActiveChild),
148
- size: 18,
149
- strokeWidth: 1.75
150
- }
151
- )
152
- }
153
- ) });
154
- }
155
- return /* @__PURE__ */ jsxs("div", { children: [
156
- /* @__PURE__ */ jsxs(
157
- Button,
158
- {
159
- type: "button",
160
- variant: "ghost",
161
- onClick: () => setOpen((prev) => !prev),
162
- className: cn(
163
- "group h-auto w-full justify-start gap-3 px-3 py-2.5 text-base font-medium transition-colors",
164
- "text-brand-secondary-foreground/70 hover:bg-white/10 hover:text-brand-secondary-foreground",
165
- "border-l-4 border-transparent",
166
- hasActiveChild && "bg-white/15 text-brand-secondary-foreground border-primary"
167
- ),
168
- children: [
169
- /* @__PURE__ */ jsx(
170
- Icon,
171
- {
172
- className: navIconCn(hasActiveChild),
173
- size: 18,
174
- strokeWidth: 1.75
175
- }
176
- ),
177
- /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-left", children: item.title }),
178
- /* @__PURE__ */ jsx(
179
- ChevronDown,
180
- {
181
- className: cn(
182
- "ml-auto shrink-0 text-brand-secondary-foreground/40 transition-transform duration-200",
183
- open && "rotate-180"
184
- ),
185
- size: 14,
186
- strokeWidth: 2
187
- }
188
- )
189
- ]
190
- }
191
- ),
192
- open && item.subItems && /* @__PURE__ */ jsx("div", { className: "ml-9 border-l border-white/15 pl-3", children: item.subItems.map((sub) => /* @__PURE__ */ jsxs(
193
- Button,
194
- {
195
- type: "button",
196
- variant: "ghost",
197
- onClick: () => onNavigate == null ? void 0 : onNavigate(sub.href),
198
- className: cn(
199
- "h-auto w-full justify-start gap-2 py-1.5 pl-1 text-sm transition-colors",
200
- "text-brand-secondary-foreground/50 hover:text-brand-secondary-foreground",
201
- sub.isActive && "text-primary font-medium"
202
- ),
203
- children: [
204
- /* @__PURE__ */ jsx(
205
- ChevronRight,
206
- {
207
- size: 11,
208
- strokeWidth: 2,
209
- className: cn(
210
- "shrink-0",
211
- sub.isActive ? "text-primary" : "text-brand-secondary-foreground/30"
212
- )
213
- }
214
- ),
215
- /* @__PURE__ */ jsx("span", { className: "truncate", children: sub.title })
216
- ]
217
- },
218
- sub.href
219
- )) })
220
- ] });
221
- }
222
- function SidebarNav({
223
- items,
224
- userName = "Anonymous User",
225
- collapsed = false,
226
- logo,
227
- logoCollapsed,
228
- metricsGroups,
229
- onNavigate,
230
- onLogout,
231
- onCollapsedChange,
232
- className
233
- }) {
234
- const [userMenuOpen, setUserMenuOpen] = React.useState(false);
235
- return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(
236
- "nav",
237
- {
238
- "data-slot": "sidebar-nav",
239
- "data-collapsed": collapsed,
240
- className: cn(
241
- // Force dark-mode CSS variable resolution — sidebar is always dark-backgrounded
242
- // regardless of system theme, so semantic tokens (destructive, success, etc.)
243
- // must use their dark-mode values to maintain WCAG contrast.
244
- "dark flex h-full flex-col bg-brand-secondary text-brand-secondary-foreground",
245
- "transition-all duration-200 ease-in-out",
246
- collapsed ? "w-14" : "w-[279px]",
247
- className
248
- ),
249
- children: [
250
- !collapsed && logo && /* @__PURE__ */ jsx("div", { className: "flex items-center border-b border-white/15 px-5 py-4", children: /* @__PURE__ */ jsx(
251
- "img",
252
- {
253
- src: logo,
254
- alt: "Logo",
255
- className: "h-8 w-auto object-contain object-left",
256
- style: { filter: "brightness(0) invert(1)" }
257
- }
258
- ) }),
259
- collapsed && logoCollapsed && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center border-b border-white/15 py-4", children: /* @__PURE__ */ jsx(
260
- "img",
261
- {
262
- src: logoCollapsed,
263
- alt: "Logo",
264
- className: "h-8 w-8 object-contain",
265
- style: { filter: "brightness(0) invert(1)" }
266
- }
267
- ) }),
268
- /* @__PURE__ */ jsxs("div", { className: "border-b border-white/15", children: [
269
- /* @__PURE__ */ jsx(NavTooltip, { label: userName, collapsed, children: /* @__PURE__ */ jsxs(
270
- Button,
271
- {
272
- type: "button",
273
- variant: "ghost",
274
- onClick: () => !collapsed && setUserMenuOpen((prev) => !prev),
275
- className: cn(
276
- "group h-auto w-full justify-start gap-3 px-5 py-5 text-base transition-colors",
277
- "text-brand-secondary-foreground hover:bg-white/10",
278
- collapsed && "justify-center px-2 py-4"
279
- ),
280
- children: [
281
- /* @__PURE__ */ jsx("div", { className: "flex h-8 w-8 shrink-0 items-center justify-center font-semibold text-xs bg-primary text-primary-foreground", children: getInitials(userName) }),
282
- !collapsed && /* @__PURE__ */ jsxs(Fragment, { children: [
283
- /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-left font-medium text-brand-secondary-foreground", children: userName }),
284
- /* @__PURE__ */ jsx(
285
- ChevronDown,
286
- {
287
- className: cn(
288
- "shrink-0 text-brand-secondary-foreground/50 transition-transform duration-200",
289
- userMenuOpen && "rotate-180"
290
- ),
291
- size: 16,
292
- strokeWidth: 2
293
- }
294
- )
295
- ] })
296
- ]
297
- }
298
- ) }),
299
- !collapsed && userMenuOpen && /* @__PURE__ */ jsx("div", { className: "border-t border-white/15 bg-black/20", children: /* @__PURE__ */ jsxs(
300
- Button,
301
- {
302
- type: "button",
303
- variant: "ghost",
304
- onClick: onLogout,
305
- className: cn(
306
- "h-auto w-full justify-start gap-3 px-5 py-3 text-base",
307
- "text-brand-secondary-foreground/70 hover:bg-white/10 hover:text-brand-secondary-foreground transition-colors"
308
- ),
309
- children: [
310
- /* @__PURE__ */ jsx(
311
- LogOut,
312
- {
313
- size: 16,
314
- strokeWidth: 1.75,
315
- className: "shrink-0 text-destructive"
316
- }
317
- ),
318
- /* @__PURE__ */ jsx("span", { children: "Logout" })
319
- ]
320
- }
321
- ) })
322
- ] }),
323
- !collapsed && !!(metricsGroups == null ? void 0 : metricsGroups.length) && /* @__PURE__ */ jsx("div", { children: metricsGroups.map((group, i) => /* @__PURE__ */ jsx(MetricsGroup, { group }, i)) }),
324
- /* @__PURE__ */ jsx("div", { className: "flex flex-col overflow-y-auto py-3", children: items.map(
325
- (item) => item.isCollapsible ? /* @__PURE__ */ jsx(
326
- CollapsibleNavItem,
327
- {
328
- item,
329
- collapsed,
330
- onNavigate
331
- },
332
- item.href
333
- ) : /* @__PURE__ */ jsx(
334
- SidebarNavItemView,
335
- {
336
- item,
337
- collapsed,
338
- onNavigate
339
- },
340
- item.href
341
- )
342
- ) }),
343
- onCollapsedChange && /* @__PURE__ */ jsx("div", { className: "mt-auto border-t border-white/15 bg-white/8", children: /* @__PURE__ */ jsx(
344
- NavTooltip,
345
- {
346
- label: collapsed ? "Expand" : "Collapse",
347
- collapsed,
348
- children: /* @__PURE__ */ jsxs(
349
- Button,
350
- {
351
- type: "button",
352
- variant: "ghost",
353
- onClick: () => onCollapsedChange(!collapsed),
354
- className: cn(
355
- "h-auto w-full justify-start gap-3 px-3 py-3 transition-colors",
356
- "text-brand-secondary-foreground/80 hover:bg-white/10 hover:text-brand-secondary-foreground",
357
- collapsed && "justify-center px-2"
358
- ),
359
- children: [
360
- collapsed ? /* @__PURE__ */ jsx(
361
- PanelLeftOpen,
362
- {
363
- size: 18,
364
- strokeWidth: 1.75,
365
- className: "shrink-0"
366
- }
367
- ) : /* @__PURE__ */ jsx(
368
- PanelLeftClose,
369
- {
370
- size: 18,
371
- strokeWidth: 1.75,
372
- className: "shrink-0"
373
- }
374
- ),
375
- !collapsed && /* @__PURE__ */ jsx("span", { className: "text-sm", children: "Collapse" })
376
- ]
377
- }
378
- )
379
- }
380
- ) })
381
- ]
382
- }
383
- ) });
384
- }
385
-
386
- export {
387
- SidebarNav
388
- };