xertica-ui 2.2.0 → 2.2.1
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/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/dist/ThemeContext-BgclCB35.js +1856 -0
- package/dist/ThemeContext-DQUOeziy.cjs +1855 -0
- package/dist/VerifyEmailPage-RrUApqBN.js +3214 -0
- package/dist/VerifyEmailPage-VoMI7MYH.cjs +3213 -0
- package/dist/XerticaProvider-BSyFrmC0.js +49 -0
- package/dist/XerticaProvider-CiNKjMx1.cjs +48 -0
- package/dist/XerticaXLogo-B2svDGZh.cjs +251 -0
- package/dist/XerticaXLogo-CowGv7BC.js +252 -0
- package/dist/brand.cjs.js +2 -2
- package/dist/brand.es.js +2 -2
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +1 -1
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +5 -5
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.es.js +1 -1
- package/dist/pages.cjs.js +1 -1
- package/dist/pages.es.js +1 -1
- package/dist/sidebar-CRMiBtAi.js +801 -0
- package/dist/sidebar-CZ2mWaMM.cjs +800 -0
- package/dist/xertica-ui.css +1 -1
- package/package.json +1 -1
- package/templates/CLAUDE.md +165 -180
- package/templates/package.json +2 -2
- package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +9 -7
- package/templates/src/features/auth/ui/LoginContent.tsx +10 -8
- package/templates/src/features/auth/ui/ResetPasswordContent.tsx +179 -177
- package/templates/src/features/auth/ui/SocialLoginButtons.tsx +9 -4
- package/templates/src/features/auth/ui/VerifyEmailContent.tsx +84 -82
- package/templates/src/features/template/ui/TemplateContent.tsx +1 -1
- package/templates/src/locales/en/components/assistant.json +14 -0
- package/templates/src/locales/en/pages/forgotPassword.json +10 -0
- package/templates/src/locales/en/pages/templates.json +1 -1
- package/templates/src/locales/es/components/assistant.json +14 -0
- package/templates/src/locales/es/pages/forgotPassword.json +10 -0
- package/templates/src/locales/es/pages/templates.json +1 -1
- package/templates/src/locales/pt-BR/components/assistant.json +14 -0
- package/templates/src/locales/pt-BR/pages/forgotPassword.json +10 -0
- package/templates/src/locales/pt-BR/pages/templates.json +1 -1
- package/templates/src/pages/AssistantPage.tsx +464 -463
|
@@ -0,0 +1,800 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const lucideReact = require("lucide-react");
|
|
5
|
+
const button = require("./button-Bnv9SvYK.cjs");
|
|
6
|
+
const XerticaXLogo = require("./XerticaXLogo-B2svDGZh.cjs");
|
|
7
|
+
const breadcrumb = require("./breadcrumb-DjSxkjlQ.cjs");
|
|
8
|
+
const dropdownMenu = require("./dropdown-menu-B_uEXNc4.cjs");
|
|
9
|
+
const avatar = require("./avatar-CuYu2MKt.cjs");
|
|
10
|
+
const LayoutContext = require("./LayoutContext-C4kKN9RV.cjs");
|
|
11
|
+
const framerMotion = require("framer-motion");
|
|
12
|
+
const reactI18next = require("react-i18next");
|
|
13
|
+
const input = require("./input-CNFHVKvo.cjs");
|
|
14
|
+
const tooltip = require("./tooltip-CwgSdy3h.cjs");
|
|
15
|
+
const CustomTooltipContent = require("./CustomTooltipContent-BT6brkVJ.cjs");
|
|
16
|
+
function Header({
|
|
17
|
+
title,
|
|
18
|
+
breadcrumbs,
|
|
19
|
+
showLanguageSelector = true,
|
|
20
|
+
showThemeToggle = true,
|
|
21
|
+
className,
|
|
22
|
+
user,
|
|
23
|
+
actions,
|
|
24
|
+
showSettings,
|
|
25
|
+
onSettingsClick,
|
|
26
|
+
showLogout,
|
|
27
|
+
onLogoutClick,
|
|
28
|
+
renderLink,
|
|
29
|
+
breadcrumbSlot
|
|
30
|
+
}) {
|
|
31
|
+
var _a;
|
|
32
|
+
const layout = LayoutContext.useOptionalLayout();
|
|
33
|
+
const toggleSidebar = (layout == null ? void 0 : layout.toggleSidebar) ?? (() => {
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
36
|
+
"header",
|
|
37
|
+
{
|
|
38
|
+
className: `bg-card text-foreground shadow-sm border-b border-border px-[24px] h-[64px] flex-shrink-0 flex items-center ${className || ""}`,
|
|
39
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between w-full p-[0px]", children: [
|
|
40
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-muted-foreground w-full overflow-x-auto", children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
button.Button,
|
|
43
|
+
{
|
|
44
|
+
variant: "ghost",
|
|
45
|
+
size: "sm",
|
|
46
|
+
onClick: toggleSidebar,
|
|
47
|
+
className: "md:hidden mr-2 p-2 shrink-0",
|
|
48
|
+
"aria-label": "Abrir menu lateral",
|
|
49
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { className: "w-5 h-5" })
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
breadcrumbs && breadcrumbs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.Breadcrumb, { children: /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbList, { className: "flex-nowrap whitespace-nowrap", children: breadcrumbs.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbItem, { children: item.href ? renderLink ? /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbLink, { asChild: true, className: "flex items-center gap-1.5", children: renderLink(item.href, {
|
|
54
|
+
className: "flex items-center gap-1.5",
|
|
55
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
56
|
+
item.icon,
|
|
57
|
+
item.label
|
|
58
|
+
] })
|
|
59
|
+
}) }) : /* @__PURE__ */ jsxRuntime.jsxs(breadcrumb.BreadcrumbLink, { href: item.href, className: "flex items-center gap-1.5", children: [
|
|
60
|
+
item.icon,
|
|
61
|
+
item.label
|
|
62
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(breadcrumb.BreadcrumbPage, { className: "flex items-center gap-1.5", children: [
|
|
63
|
+
item.icon,
|
|
64
|
+
item.label
|
|
65
|
+
] }) }),
|
|
66
|
+
index < breadcrumbs.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbSeparator, {})
|
|
67
|
+
] }, index)) }) }) : title ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-foreground font-medium shrink-0", children: title }) : /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.Breadcrumb, { children: /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbList, { className: "flex-nowrap whitespace-nowrap", children: /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntime.jsx(breadcrumb.BreadcrumbPage, { className: "text-foreground font-medium shrink-0", children: "Xertica.ai" }) }) }) }),
|
|
68
|
+
breadcrumbSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center shrink-0", children: breadcrumbSlot })
|
|
69
|
+
] }),
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 shrink-0 ml-4", children: [
|
|
71
|
+
showLanguageSelector && /* @__PURE__ */ jsxRuntime.jsx(XerticaXLogo.LanguageSelector, { variant: "minimal", showIcon: false, className: "hidden sm:flex" }),
|
|
72
|
+
showThemeToggle && /* @__PURE__ */ jsxRuntime.jsx(XerticaXLogo.ThemeToggle, { className: "hover:bg-accent" }),
|
|
73
|
+
actions == null ? void 0 : actions.map((action) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
74
|
+
button.Button,
|
|
75
|
+
{
|
|
76
|
+
variant: "ghost",
|
|
77
|
+
size: action.label ? "sm" : "icon",
|
|
78
|
+
onClick: action.onClick,
|
|
79
|
+
className: `hover:bg-accent ${action.className || ""}`,
|
|
80
|
+
"aria-label": action.label || action.id,
|
|
81
|
+
children: [
|
|
82
|
+
action.icon,
|
|
83
|
+
action.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 hidden md:inline", children: action.label })
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
action.id
|
|
87
|
+
)),
|
|
88
|
+
showSettings && /* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
+
button.Button,
|
|
90
|
+
{
|
|
91
|
+
variant: "ghost",
|
|
92
|
+
size: "icon",
|
|
93
|
+
onClick: onSettingsClick,
|
|
94
|
+
className: "hover:bg-accent",
|
|
95
|
+
"aria-label": "Configurações",
|
|
96
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "w-5 h-5" })
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
user && /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
+
button.Button,
|
|
102
|
+
{
|
|
103
|
+
variant: "ghost",
|
|
104
|
+
className: "relative h-8 w-8 rounded-full p-0 overflow-hidden border border-border/50 hover:border-primary/30 transition-colors",
|
|
105
|
+
"aria-label": "Menu do usuário",
|
|
106
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(avatar.Avatar, { className: "h-8 w-8", children: [
|
|
107
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarImage, { src: user.avatar, alt: user.name || "User" }),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { className: "bg-primary/10 text-primary text-xs font-medium", children: user.name ? user.name.charAt(0).toUpperCase() : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "w-4 h-4" }) })
|
|
109
|
+
] })
|
|
110
|
+
}
|
|
111
|
+
) }),
|
|
112
|
+
/* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuContent, { className: "w-56", align: "end", forceMount: true, children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuLabel, { className: "font-normal", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-1", children: [
|
|
114
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium leading-none", children: user.name || "User" }),
|
|
115
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-none text-muted-foreground", children: user.email || "user@example.com" })
|
|
116
|
+
] }) }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuSeparator, {}),
|
|
118
|
+
(_a = user.menuItems) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuItem, { onClick: item.onClick, className: item.className, children: [
|
|
119
|
+
item.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-2", children: item.icon }),
|
|
120
|
+
item.label
|
|
121
|
+
] }, item.id)),
|
|
122
|
+
!user.menuItems && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
123
|
+
/* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuItem, { onClick: onSettingsClick, children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "mr-2 h-4 w-4" }),
|
|
125
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Settings" })
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
128
|
+
dropdownMenu.DropdownMenuItem,
|
|
129
|
+
{
|
|
130
|
+
onClick: onLogoutClick,
|
|
131
|
+
className: "text-destructive focus:text-destructive",
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "mr-2 h-4 w-4" }),
|
|
134
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Logout" })
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] })
|
|
139
|
+
] })
|
|
140
|
+
] }),
|
|
141
|
+
showLogout && /* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
+
button.Button,
|
|
143
|
+
{
|
|
144
|
+
variant: "ghost",
|
|
145
|
+
size: "icon",
|
|
146
|
+
onClick: onLogoutClick,
|
|
147
|
+
className: "hover:bg-accent text-muted-foreground hover:text-foreground",
|
|
148
|
+
"aria-label": "Sair",
|
|
149
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "w-5 h-5" })
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] })
|
|
153
|
+
] })
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
const SidebarContext = React.createContext(null);
|
|
158
|
+
function useSidebarContext() {
|
|
159
|
+
const ctx = React.useContext(SidebarContext);
|
|
160
|
+
if (!ctx) {
|
|
161
|
+
throw new Error("Sidebar compound components must be used within <Sidebar.Root>");
|
|
162
|
+
}
|
|
163
|
+
return ctx;
|
|
164
|
+
}
|
|
165
|
+
function SidebarRoot({
|
|
166
|
+
expanded: expandedProp,
|
|
167
|
+
onToggle: onToggleProp,
|
|
168
|
+
navigate: navigateProp,
|
|
169
|
+
location: locationProp,
|
|
170
|
+
width: widthProp,
|
|
171
|
+
children,
|
|
172
|
+
className
|
|
173
|
+
}) {
|
|
174
|
+
const layoutContext = LayoutContext.useOptionalLayout();
|
|
175
|
+
const [localExpanded, setLocalExpanded] = React.useState(false);
|
|
176
|
+
const [isMobileViewport, setIsMobileViewport] = React.useState(false);
|
|
177
|
+
const expanded = expandedProp !== void 0 ? expandedProp : (layoutContext == null ? void 0 : layoutContext.sidebarExpanded) ?? localExpanded;
|
|
178
|
+
const onToggle = onToggleProp || (layoutContext == null ? void 0 : layoutContext.toggleSidebar) || (() => setLocalExpanded((prev) => !prev));
|
|
179
|
+
const width = widthProp !== void 0 ? widthProp : (layoutContext == null ? void 0 : layoutContext.sidebarWidth) ?? 280;
|
|
180
|
+
const navigate = navigateProp || ((path) => {
|
|
181
|
+
if (typeof window !== "undefined") window.location.href = path;
|
|
182
|
+
});
|
|
183
|
+
const location = locationProp || (typeof window !== "undefined" ? window.location : { pathname: "/" });
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
const checkViewport = () => setIsMobileViewport(window.innerWidth < 768);
|
|
186
|
+
checkViewport();
|
|
187
|
+
window.addEventListener("resize", checkViewport);
|
|
188
|
+
return () => window.removeEventListener("resize", checkViewport);
|
|
189
|
+
}, []);
|
|
190
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
191
|
+
SidebarContext.Provider,
|
|
192
|
+
{
|
|
193
|
+
value: { expanded, isMobileViewport, onToggle, navigate, location, width },
|
|
194
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(tooltip.TooltipProvider, { delayDuration: 300, children: [
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
196
|
+
@media (max-width: 767px) {
|
|
197
|
+
[style*="padding-left"].flex-1,
|
|
198
|
+
[style*="paddingLeft"].flex-1 {
|
|
199
|
+
padding-left: 0 !important;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
` }),
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: button.cn(
|
|
207
|
+
"bg-sidebar text-sidebar-foreground transition-all duration-300 ease-in-out flex flex-col z-50",
|
|
208
|
+
expanded ? "fixed inset-0 md:fixed md:inset-y-0 md:left-0" : "fixed inset-y-0 left-0 w-20 -translate-x-full md:translate-x-0",
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
style: expanded && !isMobileViewport ? { width: `${width}px` } : void 0,
|
|
212
|
+
children
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] })
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
function SidebarHeader({
|
|
220
|
+
logo,
|
|
221
|
+
logoCollapsed
|
|
222
|
+
}) {
|
|
223
|
+
const { expanded, onToggle } = useSidebarContext();
|
|
224
|
+
const { t } = reactI18next.useTranslation();
|
|
225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
226
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 p-[14px] pt-[13px] pr-[14px] pb-[12px] pl-[14px]", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
227
|
+
"button",
|
|
228
|
+
{
|
|
229
|
+
onClick: onToggle,
|
|
230
|
+
className: "w-full h-10 flex items-center gap-3 px-3 justify-center rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
231
|
+
"aria-label": expanded ? t("sidebar.collapse") : t("sidebar.expand"),
|
|
232
|
+
"aria-expanded": expanded,
|
|
233
|
+
"aria-controls": "sidebar-nav",
|
|
234
|
+
children: expanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "w-5 h-5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { className: "w-5 h-5" })
|
|
235
|
+
}
|
|
236
|
+
) }),
|
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center h-10 justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center flex-shrink-0", children: expanded ? logo || /* @__PURE__ */ jsxRuntime.jsx(XerticaXLogo.XerticaLogo, { className: "h-5 w-auto", variant: "white" }) : logoCollapsed || /* @__PURE__ */ jsxRuntime.jsx(XerticaXLogo.XerticaXLogo, { className: "h-5 w-auto", variant: "white" }) }) }) })
|
|
238
|
+
] });
|
|
239
|
+
}
|
|
240
|
+
function SidebarNav({
|
|
241
|
+
navigationGroups = [],
|
|
242
|
+
routes = [],
|
|
243
|
+
variant = "default"
|
|
244
|
+
}) {
|
|
245
|
+
const { expanded, navigate, location, onToggle } = useSidebarContext();
|
|
246
|
+
const { t } = reactI18next.useTranslation();
|
|
247
|
+
const navRef = React.useRef(null);
|
|
248
|
+
const [localActiveItem, setLocalActiveItem] = React.useState(null);
|
|
249
|
+
const [hasOverflow, setHasOverflow] = React.useState(false);
|
|
250
|
+
const [visibleItems, setVisibleItems] = React.useState([]);
|
|
251
|
+
const [overflowItems, setOverflowItems] = React.useState([]);
|
|
252
|
+
const labelTranslations = React.useMemo(
|
|
253
|
+
() => ({
|
|
254
|
+
home: "Início",
|
|
255
|
+
dashboard: "Painel",
|
|
256
|
+
components: "Componentes"
|
|
257
|
+
}),
|
|
258
|
+
[]
|
|
259
|
+
);
|
|
260
|
+
const navigationItems = React.useMemo(
|
|
261
|
+
() => (routes || []).map((route) => ({
|
|
262
|
+
...route,
|
|
263
|
+
label: labelTranslations[route.label.toLowerCase()] || route.label,
|
|
264
|
+
active: location.pathname === route.path || location.pathname.startsWith(route.path + "/"),
|
|
265
|
+
children: route.children
|
|
266
|
+
})),
|
|
267
|
+
[routes, location.pathname, labelTranslations]
|
|
268
|
+
);
|
|
269
|
+
React.useEffect(() => {
|
|
270
|
+
if (typeof window === "undefined") return;
|
|
271
|
+
const checkOverflow = () => {
|
|
272
|
+
if (!navRef.current) return;
|
|
273
|
+
if (variant === "assistant") return;
|
|
274
|
+
const navHeight = navRef.current.clientHeight;
|
|
275
|
+
const itemHeight = 44;
|
|
276
|
+
const maxVisibleItems = Math.floor(navHeight / itemHeight);
|
|
277
|
+
if (navigationItems.length > maxVisibleItems) {
|
|
278
|
+
setHasOverflow(true);
|
|
279
|
+
setVisibleItems(navigationItems.slice(0, maxVisibleItems - 1));
|
|
280
|
+
setOverflowItems(navigationItems.slice(maxVisibleItems - 1));
|
|
281
|
+
} else {
|
|
282
|
+
setHasOverflow(false);
|
|
283
|
+
setVisibleItems(navigationItems);
|
|
284
|
+
setOverflowItems([]);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
checkOverflow();
|
|
288
|
+
window.addEventListener("resize", checkOverflow);
|
|
289
|
+
return () => window.removeEventListener("resize", checkOverflow);
|
|
290
|
+
}, [navigationItems.length, variant]);
|
|
291
|
+
const handleNavigate = (path) => {
|
|
292
|
+
setLocalActiveItem(path);
|
|
293
|
+
navigate(path);
|
|
294
|
+
if (typeof window !== "undefined" && window.innerWidth < 768) {
|
|
295
|
+
onToggle();
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const toNavItem = (route) => ({
|
|
299
|
+
path: route.path,
|
|
300
|
+
label: labelTranslations[route.label.toLowerCase()] || route.label,
|
|
301
|
+
icon: route.icon,
|
|
302
|
+
active: location.pathname === route.path || location.pathname.startsWith(route.path + "/"),
|
|
303
|
+
children: route.children,
|
|
304
|
+
actions: route.actions
|
|
305
|
+
});
|
|
306
|
+
const renderActionItems = (actions) => {
|
|
307
|
+
return actions.map((action, idx) => {
|
|
308
|
+
const Icon = action.icon;
|
|
309
|
+
if (action.children && action.children.length > 0) {
|
|
310
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuSub, { children: [
|
|
311
|
+
/* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenuSubTrigger, { children: [
|
|
312
|
+
Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "mr-2 h-4 w-4" }),
|
|
313
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: action.label })
|
|
314
|
+
] }),
|
|
315
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuSubContent, { className: "w-48 bg-popover border-border", children: renderActionItems(action.children) }) })
|
|
316
|
+
] }, idx);
|
|
317
|
+
}
|
|
318
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
319
|
+
dropdownMenu.DropdownMenuItem,
|
|
320
|
+
{
|
|
321
|
+
className: button.cn(
|
|
322
|
+
"flex items-center gap-2",
|
|
323
|
+
action.variant === "destructive" ? "text-destructive focus:text-destructive" : ""
|
|
324
|
+
),
|
|
325
|
+
onClick: (e) => {
|
|
326
|
+
var _a;
|
|
327
|
+
e.stopPropagation();
|
|
328
|
+
(_a = action.onClick) == null ? void 0 : _a.call(action, null);
|
|
329
|
+
},
|
|
330
|
+
children: [
|
|
331
|
+
Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "h-4 w-4 flex-shrink-0" }),
|
|
332
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: action.label })
|
|
333
|
+
]
|
|
334
|
+
},
|
|
335
|
+
idx
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
const renderAssistantActionMenu = (actions, isHeader = false) => {
|
|
340
|
+
if (!actions || actions.length === 0) return null;
|
|
341
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
|
|
342
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
343
|
+
button.Button,
|
|
344
|
+
{
|
|
345
|
+
variant: "ghost",
|
|
346
|
+
size: "icon",
|
|
347
|
+
className: button.cn(
|
|
348
|
+
"h-8 w-8 text-sidebar-foreground/80 hover:bg-sidebar-foreground/20 hover:text-sidebar-foreground rounded-full transition-all",
|
|
349
|
+
!isHeader && "opacity-0 group-hover/item:opacity-100"
|
|
350
|
+
),
|
|
351
|
+
"aria-label": t("sidebar.moreOptions"),
|
|
352
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { className: "h-4 w-4" })
|
|
353
|
+
}
|
|
354
|
+
) }),
|
|
355
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuContent, { align: "end", className: "w-48 bg-popover border-border p-1", children: renderActionItems(actions) })
|
|
356
|
+
] });
|
|
357
|
+
};
|
|
358
|
+
const renderDefaultItem = (item) => {
|
|
359
|
+
const Icon = item.icon;
|
|
360
|
+
const hasChildren = item.children && item.children.length > 0;
|
|
361
|
+
const activeClass = item.active ? "bg-sidebar-foreground/15 text-sidebar-foreground shadow-sm" : "text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground";
|
|
362
|
+
if (!expanded) {
|
|
363
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
364
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
365
|
+
"button",
|
|
366
|
+
{
|
|
367
|
+
onClick: () => handleNavigate(item.path),
|
|
368
|
+
className: button.cn(
|
|
369
|
+
"w-full h-10 flex items-center justify-center px-0 rounded-[var(--radius-button)] transition-all duration-200",
|
|
370
|
+
activeClass
|
|
371
|
+
),
|
|
372
|
+
"aria-label": item.label,
|
|
373
|
+
children: Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-5 h-5 flex-shrink-0" })
|
|
374
|
+
}
|
|
375
|
+
) }),
|
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", sideOffset: 0, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: item.label }) })
|
|
377
|
+
] }, item.path);
|
|
378
|
+
}
|
|
379
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
380
|
+
"div",
|
|
381
|
+
{
|
|
382
|
+
className: button.cn(
|
|
383
|
+
"group/item flex items-center w-full h-10 rounded-[var(--radius-button)] transition-all duration-200",
|
|
384
|
+
activeClass
|
|
385
|
+
),
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
388
|
+
"button",
|
|
389
|
+
{
|
|
390
|
+
onClick: () => handleNavigate(item.path),
|
|
391
|
+
className: "flex items-center gap-3 px-3 flex-1 h-full min-w-0 text-left",
|
|
392
|
+
children: [
|
|
393
|
+
Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-5 h-5 flex-shrink-0" }),
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate flex-1", children: item.label })
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
hasChildren && /* @__PURE__ */ jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
400
|
+
"button",
|
|
401
|
+
{
|
|
402
|
+
onClick: (e) => e.stopPropagation(),
|
|
403
|
+
className: "h-full px-2 pr-2.5 flex items-center justify-center text-sidebar-foreground/40 hover:text-sidebar-foreground transition-colors",
|
|
404
|
+
"aria-label": t("sidebar.submenu", { label: item.label }),
|
|
405
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "w-4 h-4" })
|
|
406
|
+
}
|
|
407
|
+
) }),
|
|
408
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
409
|
+
dropdownMenu.DropdownMenuContent,
|
|
410
|
+
{
|
|
411
|
+
side: "right",
|
|
412
|
+
align: "start",
|
|
413
|
+
className: "w-48 bg-popover border-border p-1",
|
|
414
|
+
children: item.children.map((child) => {
|
|
415
|
+
const ChildIcon = child.icon;
|
|
416
|
+
const isChildActive = location.pathname === child.path || location.pathname.startsWith(child.path + "/");
|
|
417
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
418
|
+
dropdownMenu.DropdownMenuItem,
|
|
419
|
+
{
|
|
420
|
+
onClick: () => handleNavigate(child.path),
|
|
421
|
+
className: button.cn(
|
|
422
|
+
"flex items-center gap-2 cursor-pointer",
|
|
423
|
+
isChildActive && "bg-accent text-accent-foreground"
|
|
424
|
+
),
|
|
425
|
+
children: [
|
|
426
|
+
ChildIcon && /* @__PURE__ */ jsxRuntime.jsx(ChildIcon, { className: "h-4 w-4 flex-shrink-0" }),
|
|
427
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: child.label })
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
child.path
|
|
431
|
+
);
|
|
432
|
+
})
|
|
433
|
+
}
|
|
434
|
+
)
|
|
435
|
+
] })
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
item.path
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
const renderDefaultGroup = (group) => {
|
|
442
|
+
const GroupIcon = group.icon;
|
|
443
|
+
if (!expanded) {
|
|
444
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: group.items.map((item) => renderDefaultItem(toNavItem(item))) }, group.id);
|
|
445
|
+
}
|
|
446
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
447
|
+
(group.label || GroupIcon) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 mb-1 flex items-center gap-2", children: [
|
|
448
|
+
GroupIcon && (React.isValidElement(GroupIcon) ? GroupIcon : /* @__PURE__ */ jsxRuntime.jsx(GroupIcon, { className: "h-3 w-3 text-sidebar-foreground/80" })),
|
|
449
|
+
group.label && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/80", children: group.label })
|
|
450
|
+
] }),
|
|
451
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: group.items.map((item) => renderDefaultItem(toNavItem(item))) })
|
|
452
|
+
] }, group.id);
|
|
453
|
+
};
|
|
454
|
+
const renderAssistantGroup = (group) => {
|
|
455
|
+
const isAnyItemActive = group.items.some(
|
|
456
|
+
(item) => location.pathname === item.path || location.pathname.startsWith(item.path + "/")
|
|
457
|
+
);
|
|
458
|
+
const GroupIcon = group.icon;
|
|
459
|
+
if (!expanded) {
|
|
460
|
+
if (!GroupIcon) return null;
|
|
461
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
462
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
463
|
+
"button",
|
|
464
|
+
{
|
|
465
|
+
onClick: () => onToggle(),
|
|
466
|
+
"aria-label": group.label,
|
|
467
|
+
className: button.cn(
|
|
468
|
+
"h-10 w-10 flex items-center justify-center rounded-[var(--radius-button)] transition-all duration-200",
|
|
469
|
+
isAnyItemActive ? "bg-sidebar-foreground/15 text-sidebar-foreground shadow-sm" : "text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground"
|
|
470
|
+
),
|
|
471
|
+
children: React.isValidElement(GroupIcon) ? GroupIcon : /* @__PURE__ */ jsxRuntime.jsx(GroupIcon, { className: "h-5 w-5" })
|
|
472
|
+
}
|
|
473
|
+
) }),
|
|
474
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: group.label }) })
|
|
475
|
+
] }) }, group.id);
|
|
476
|
+
}
|
|
477
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-2 group", children: [
|
|
478
|
+
(group.label || group.icon) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-3 mb-1", children: [
|
|
479
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sidebar-foreground/80 text-xs font-semibold uppercase tracking-wider", children: [
|
|
480
|
+
GroupIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: React.isValidElement(GroupIcon) ? GroupIcon : /* @__PURE__ */ jsxRuntime.jsx(GroupIcon, { className: "h-4 w-4" }) }),
|
|
481
|
+
group.label && /* @__PURE__ */ jsxRuntime.jsx("span", { children: group.label })
|
|
482
|
+
] }),
|
|
483
|
+
renderAssistantActionMenu(group.actions, true)
|
|
484
|
+
] }),
|
|
485
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: group.items.map((item) => {
|
|
486
|
+
const isRouteActive = location.pathname === item.path || location.pathname.startsWith(item.path + "/");
|
|
487
|
+
const isActive = isRouteActive || localActiveItem === item.path;
|
|
488
|
+
const Icon = item.icon;
|
|
489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
className: `group/item flex items-start justify-between px-3 min-h-[36px] py-2.5 rounded-[var(--radius-button)] cursor-pointer transition-all duration-200 ${isActive ? "bg-sidebar-foreground/15 text-sidebar-foreground" : "text-sidebar-foreground/80 hover:bg-sidebar-foreground/10 hover:text-sidebar-foreground"}`,
|
|
493
|
+
onClick: () => handleNavigate(item.path),
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0 flex-1", children: [
|
|
496
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 overflow-hidden h-5", children: [
|
|
497
|
+
Icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-4 h-4 flex-shrink-0 flex items-center justify-center", children: React.isValidElement(Icon) ? Icon : /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-4 h-4" }) }),
|
|
498
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium leading-none", children: item.label })
|
|
499
|
+
] }),
|
|
500
|
+
isActive && item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] text-sidebar-foreground/60 mt-1.5 animate-in fade-in slide-in-from-top-1 duration-200", children: item.description })
|
|
501
|
+
] }),
|
|
502
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-5 flex items-center ml-1", children: renderAssistantActionMenu(item.actions) })
|
|
503
|
+
]
|
|
504
|
+
},
|
|
505
|
+
item.path
|
|
506
|
+
);
|
|
507
|
+
}) })
|
|
508
|
+
] }, group.id);
|
|
509
|
+
};
|
|
510
|
+
if (variant === "assistant") {
|
|
511
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(input.ScrollArea, { className: "h-full px-4", children: navigationGroups.map((group) => renderAssistantGroup(group)) }) });
|
|
512
|
+
}
|
|
513
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
514
|
+
"nav",
|
|
515
|
+
{
|
|
516
|
+
id: "sidebar-nav",
|
|
517
|
+
"aria-label": t("sidebar.mainNavigation"),
|
|
518
|
+
className: "h-full px-4 py-4 overflow-hidden",
|
|
519
|
+
ref: navRef,
|
|
520
|
+
children: navigationGroups && navigationGroups.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: navigationGroups.map((group) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: renderDefaultGroup(group) }, group.id)) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
521
|
+
(hasOverflow ? visibleItems : navigationItems).map((item) => renderDefaultItem(item)),
|
|
522
|
+
hasOverflow && /* @__PURE__ */ jsxRuntime.jsxs(input.Popover, { children: [
|
|
523
|
+
/* @__PURE__ */ jsxRuntime.jsx(input.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
524
|
+
"button",
|
|
525
|
+
{
|
|
526
|
+
className: expanded ? "w-full h-10 flex items-center gap-3 px-3 justify-start rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground" : "w-full h-10 flex items-center justify-center px-0 rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
527
|
+
"aria-label": t("sidebar.moreOptions"),
|
|
528
|
+
children: [
|
|
529
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { className: "w-5 h-5 flex-shrink-0" }),
|
|
530
|
+
expanded && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sidebar-foreground", children: t("sidebar.moreOptions") })
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
) }),
|
|
534
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
535
|
+
input.PopoverContent,
|
|
536
|
+
{
|
|
537
|
+
side: "right",
|
|
538
|
+
align: "start",
|
|
539
|
+
className: "w-56 p-2 bg-popover border border-border rounded-[var(--radius-card)] shadow-lg",
|
|
540
|
+
sideOffset: 8,
|
|
541
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1", children: overflowItems.map((item) => {
|
|
542
|
+
const Icon = item.icon;
|
|
543
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
544
|
+
"button",
|
|
545
|
+
{
|
|
546
|
+
onClick: () => handleNavigate(item.path),
|
|
547
|
+
className: "w-full h-9 flex items-center gap-2 px-3 rounded-[var(--radius-button)] transition-all duration-200 text-popover-foreground/80 hover:bg-accent hover:text-accent-foreground text-left",
|
|
548
|
+
children: [
|
|
549
|
+
Icon && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-4 h-4 flex-shrink-0" }),
|
|
550
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: item.label })
|
|
551
|
+
]
|
|
552
|
+
},
|
|
553
|
+
item.path
|
|
554
|
+
);
|
|
555
|
+
}) })
|
|
556
|
+
}
|
|
557
|
+
)
|
|
558
|
+
] })
|
|
559
|
+
] })
|
|
560
|
+
}
|
|
561
|
+
) });
|
|
562
|
+
}
|
|
563
|
+
function SidebarSearch({
|
|
564
|
+
fixedArea,
|
|
565
|
+
search
|
|
566
|
+
}) {
|
|
567
|
+
var _a, _b;
|
|
568
|
+
const { expanded } = useSidebarContext();
|
|
569
|
+
const { t } = reactI18next.useTranslation();
|
|
570
|
+
const [isFilterOpen, setIsFilterOpen] = React.useState(false);
|
|
571
|
+
if (!(fixedArea && fixedArea.show || search && search.show)) return null;
|
|
572
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-shrink-0 px-4 pb-4 space-y-4 border-b border-sidebar-border/30 mb-2", children: [
|
|
573
|
+
(fixedArea == null ? void 0 : fixedArea.show) && fixedArea.content && expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-in fade-in slide-in-from-top-1 duration-300", children: fixedArea.content }),
|
|
574
|
+
(search == null ? void 0 : search.show) && expanded && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
575
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1", children: [
|
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-sidebar-foreground/50" }),
|
|
578
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
579
|
+
input.Input,
|
|
580
|
+
{
|
|
581
|
+
type: "text",
|
|
582
|
+
placeholder: search.placeholder || t("sidebar.searchPlaceholder"),
|
|
583
|
+
"aria-label": search.placeholder || t("sidebar.searchPlaceholder"),
|
|
584
|
+
value: search.value,
|
|
585
|
+
onChange: (e) => {
|
|
586
|
+
var _a2;
|
|
587
|
+
return (_a2 = search.onChange) == null ? void 0 : _a2.call(search, e.target.value);
|
|
588
|
+
},
|
|
589
|
+
className: "w-full h-9 bg-sidebar-foreground/10 border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50 pl-9 focus-visible:ring-1 focus-visible:ring-sidebar-foreground/30 focus-visible:ring-offset-0"
|
|
590
|
+
}
|
|
591
|
+
)
|
|
592
|
+
] }),
|
|
593
|
+
((_a = search.filter) == null ? void 0 : _a.show) && search.filter.content && /* @__PURE__ */ jsxRuntime.jsx(
|
|
594
|
+
button.Button,
|
|
595
|
+
{
|
|
596
|
+
variant: "ghost",
|
|
597
|
+
size: "icon",
|
|
598
|
+
onClick: () => setIsFilterOpen(!isFilterOpen),
|
|
599
|
+
className: button.cn(
|
|
600
|
+
"h-9 w-9 text-sidebar-foreground transition-all duration-200",
|
|
601
|
+
isFilterOpen ? "bg-sidebar-foreground/20" : "hover:bg-sidebar-foreground/15"
|
|
602
|
+
),
|
|
603
|
+
"aria-label": isFilterOpen ? t("sidebar.closeFilters") : t("sidebar.openFilters"),
|
|
604
|
+
children: search.filter.icon || /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-4 w-4" })
|
|
605
|
+
}
|
|
606
|
+
)
|
|
607
|
+
] }),
|
|
608
|
+
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isFilterOpen && ((_b = search.filter) == null ? void 0 : _b.show) && search.filter.content && /* @__PURE__ */ jsxRuntime.jsx(
|
|
609
|
+
framerMotion.motion.div,
|
|
610
|
+
{
|
|
611
|
+
initial: { height: 0, opacity: 0 },
|
|
612
|
+
animate: { height: "auto", opacity: 1 },
|
|
613
|
+
exit: { height: 0, opacity: 0 },
|
|
614
|
+
transition: { duration: 0.2 },
|
|
615
|
+
className: "overflow-hidden",
|
|
616
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-2 border-t border-sidebar-border/20", children: search.filter.content })
|
|
617
|
+
}
|
|
618
|
+
) })
|
|
619
|
+
] }),
|
|
620
|
+
!expanded && ((fixedArea == null ? void 0 : fixedArea.show) || (search == null ? void 0 : search.show)) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4 py-2", children: [
|
|
621
|
+
(fixedArea == null ? void 0 : fixedArea.show) && fixedArea.icon && /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
622
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
623
|
+
"button",
|
|
624
|
+
{
|
|
625
|
+
onClick: () => {
|
|
626
|
+
var _a2;
|
|
627
|
+
return (_a2 = fixedArea.onClick) == null ? void 0 : _a2.call(fixedArea);
|
|
628
|
+
},
|
|
629
|
+
className: "h-10 w-10 flex items-center justify-center rounded-[var(--radius-button)] bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 transition-all",
|
|
630
|
+
"aria-label": t("assistant.newConversation"),
|
|
631
|
+
children: React.isValidElement(fixedArea.icon) ? fixedArea.icon : /* @__PURE__ */ jsxRuntime.jsx(fixedArea.icon, { className: "h-5 w-5" })
|
|
632
|
+
}
|
|
633
|
+
) }),
|
|
634
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", children: t("assistant.newConversation") })
|
|
635
|
+
] }),
|
|
636
|
+
(search == null ? void 0 : search.show) && /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
637
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
638
|
+
"button",
|
|
639
|
+
{
|
|
640
|
+
className: "h-10 w-10 flex items-center justify-center rounded-[var(--radius-button)] text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
641
|
+
"aria-label": t("sidebar.search"),
|
|
642
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-5 w-5" })
|
|
643
|
+
}
|
|
644
|
+
) }),
|
|
645
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", children: t("sidebar.search") })
|
|
646
|
+
] })
|
|
647
|
+
] })
|
|
648
|
+
] });
|
|
649
|
+
}
|
|
650
|
+
function SidebarFooter({
|
|
651
|
+
user,
|
|
652
|
+
onLogout = () => {
|
|
653
|
+
},
|
|
654
|
+
onSettingsClick,
|
|
655
|
+
showUser = true,
|
|
656
|
+
showSettings = true,
|
|
657
|
+
showLogout = true
|
|
658
|
+
}) {
|
|
659
|
+
const { expanded, navigate, location, onToggle } = useSidebarContext();
|
|
660
|
+
const { t } = reactI18next.useTranslation();
|
|
661
|
+
const isSettingsActive = location.pathname === "/settings";
|
|
662
|
+
const handleSettingsClick = () => {
|
|
663
|
+
if (onSettingsClick) {
|
|
664
|
+
onSettingsClick();
|
|
665
|
+
} else {
|
|
666
|
+
navigate("/settings");
|
|
667
|
+
}
|
|
668
|
+
if (typeof window !== "undefined" && window.innerWidth < 768) {
|
|
669
|
+
onToggle();
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-shrink-0 p-4 space-y-2", children: [
|
|
673
|
+
showUser && (!expanded ? /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
674
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
675
|
+
"button",
|
|
676
|
+
{
|
|
677
|
+
className: "w-full h-10 flex items-center justify-center px-0 rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
678
|
+
"aria-label": t("sidebar.userProfile"),
|
|
679
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(avatar.Avatar, { className: "w-7 h-7 flex-shrink-0", children: [
|
|
680
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarImage, { src: user == null ? void 0 : user.avatar, alt: (user == null ? void 0 : user.name) || "User" }),
|
|
681
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { className: "bg-sidebar-foreground/15 text-sidebar-foreground text-xs", children: (user == null ? void 0 : user.name) ? user.name.charAt(0).toUpperCase() : "U" })
|
|
682
|
+
] })
|
|
683
|
+
}
|
|
684
|
+
) }),
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", sideOffset: 0, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: (user == null ? void 0 : user.name) || t("sidebar.profile") }) })
|
|
686
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "w-full h-10 flex items-center gap-3 px-3 justify-start rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground", children: [
|
|
687
|
+
/* @__PURE__ */ jsxRuntime.jsxs(avatar.Avatar, { className: "w-7 h-7 flex-shrink-0", children: [
|
|
688
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarImage, { src: user == null ? void 0 : user.avatar, alt: (user == null ? void 0 : user.name) || "User" }),
|
|
689
|
+
/* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { className: "bg-sidebar-foreground/15 text-sidebar-foreground text-xs", children: (user == null ? void 0 : user.name) ? user.name.charAt(0).toUpperCase() : "U" })
|
|
690
|
+
] }),
|
|
691
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sidebar-foreground truncate", children: (user == null ? void 0 : user.name) || t("sidebar.profile") })
|
|
692
|
+
] })),
|
|
693
|
+
showSettings && (!expanded ? /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
694
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
onClick: handleSettingsClick,
|
|
698
|
+
className: button.cn(
|
|
699
|
+
"w-full h-10 flex items-center justify-center px-0 rounded-[var(--radius-button)] transition-all duration-200",
|
|
700
|
+
isSettingsActive ? "bg-sidebar-foreground/15 text-sidebar-foreground shadow-sm" : "text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground"
|
|
701
|
+
),
|
|
702
|
+
"aria-label": t("nav.settings"),
|
|
703
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "w-5 h-5 flex-shrink-0" })
|
|
704
|
+
}
|
|
705
|
+
) }),
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", sideOffset: 0, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: t("nav.settings") }) })
|
|
707
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
708
|
+
"button",
|
|
709
|
+
{
|
|
710
|
+
onClick: handleSettingsClick,
|
|
711
|
+
className: button.cn(
|
|
712
|
+
"w-full h-10 flex items-center gap-3 px-3 justify-start rounded-[var(--radius-button)] transition-all duration-200",
|
|
713
|
+
isSettingsActive ? "bg-sidebar-foreground/15 text-sidebar-foreground shadow-sm" : "text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground"
|
|
714
|
+
),
|
|
715
|
+
children: [
|
|
716
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "w-5 h-5 flex-shrink-0" }),
|
|
717
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sidebar-foreground", children: t("nav.settings") })
|
|
718
|
+
]
|
|
719
|
+
}
|
|
720
|
+
)),
|
|
721
|
+
showLogout && (!expanded ? /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
723
|
+
"button",
|
|
724
|
+
{
|
|
725
|
+
onClick: onLogout,
|
|
726
|
+
className: "w-full h-10 flex items-center justify-center px-0 rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
727
|
+
"aria-label": t("sidebar.logout"),
|
|
728
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "w-5 h-5 flex-shrink-0" })
|
|
729
|
+
}
|
|
730
|
+
) }),
|
|
731
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomTooltipContent.CustomTooltipContent, { side: "right", sideOffset: 0, children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: t("sidebar.logout") }) })
|
|
732
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
733
|
+
"button",
|
|
734
|
+
{
|
|
735
|
+
onClick: onLogout,
|
|
736
|
+
className: "w-full h-10 flex items-center gap-3 px-3 justify-start rounded-[var(--radius-button)] transition-all duration-200 text-sidebar-foreground/80 hover:bg-sidebar-foreground/15 hover:text-sidebar-foreground",
|
|
737
|
+
children: [
|
|
738
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "w-5 h-5 flex-shrink-0" }),
|
|
739
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sidebar-foreground", children: t("sidebar.logout") })
|
|
740
|
+
]
|
|
741
|
+
}
|
|
742
|
+
))
|
|
743
|
+
] });
|
|
744
|
+
}
|
|
745
|
+
function Sidebar({
|
|
746
|
+
expanded: expandedProp,
|
|
747
|
+
onToggle: onToggleProp,
|
|
748
|
+
user,
|
|
749
|
+
onLogout = () => {
|
|
750
|
+
},
|
|
751
|
+
onSettingsClick,
|
|
752
|
+
location: locationProp,
|
|
753
|
+
navigate: navigateProp,
|
|
754
|
+
routes,
|
|
755
|
+
logo,
|
|
756
|
+
logoCollapsed,
|
|
757
|
+
variant = "default",
|
|
758
|
+
fixedArea,
|
|
759
|
+
search,
|
|
760
|
+
navigationGroups = [],
|
|
761
|
+
footer,
|
|
762
|
+
showFooter,
|
|
763
|
+
width: widthProp
|
|
764
|
+
}) {
|
|
765
|
+
const { showUser = true, showSettings = true, showLogout = true } = footer || {};
|
|
766
|
+
const displayFooter = showFooter !== void 0 ? showFooter : variant === "default";
|
|
767
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
768
|
+
SidebarRoot,
|
|
769
|
+
{
|
|
770
|
+
expanded: expandedProp,
|
|
771
|
+
onToggle: onToggleProp,
|
|
772
|
+
navigate: navigateProp,
|
|
773
|
+
location: locationProp,
|
|
774
|
+
width: widthProp,
|
|
775
|
+
children: [
|
|
776
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { logo, logoCollapsed }),
|
|
777
|
+
variant === "assistant" && /* @__PURE__ */ jsxRuntime.jsx(SidebarSearch, { fixedArea, search }),
|
|
778
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarNav, { navigationGroups, routes, variant }),
|
|
779
|
+
displayFooter && (showUser || showSettings || showLogout) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
780
|
+
SidebarFooter,
|
|
781
|
+
{
|
|
782
|
+
user,
|
|
783
|
+
onLogout,
|
|
784
|
+
onSettingsClick,
|
|
785
|
+
showUser,
|
|
786
|
+
showSettings,
|
|
787
|
+
showLogout
|
|
788
|
+
}
|
|
789
|
+
)
|
|
790
|
+
]
|
|
791
|
+
}
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
Sidebar.Root = SidebarRoot;
|
|
795
|
+
Sidebar.Header = SidebarHeader;
|
|
796
|
+
Sidebar.Search = SidebarSearch;
|
|
797
|
+
Sidebar.Nav = SidebarNav;
|
|
798
|
+
Sidebar.Footer = SidebarFooter;
|
|
799
|
+
exports.Header = Header;
|
|
800
|
+
exports.Sidebar = Sidebar;
|