@pactor-app/ui 1.2.0 → 1.7.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/README.md +2 -0
- package/dist/{chunk-L45CSL6I.js → chunk-7KC6DMKH.js} +3 -3
- package/dist/{chunk-Q5NUGUJG.js → chunk-E2TD6JD2.js} +205 -414
- package/dist/{chunk-F3H23KYG.js → chunk-F42SGQNW.js} +31 -93
- package/dist/{chunk-22TEN3ER.js → chunk-FJPRXEKQ.js} +13 -13
- package/dist/chunk-L4Z7MNYY.js +1197 -0
- package/dist/{chunk-LMEJ242M.js → chunk-PMYLC26E.js} +615 -307
- package/dist/chunk-WKJUCGV4.js +78 -0
- package/dist/chunk-ZM3WJZZ7.js +727 -0
- package/dist/components/index.cjs +1694 -969
- package/dist/components/index.d.cts +115 -13
- package/dist/components/index.d.ts +115 -13
- package/dist/components/index.js +10 -6
- package/dist/index.cjs +1889 -1164
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -8
- package/dist/interaction/index.cjs +10 -6
- package/dist/interaction/index.js +3 -3
- package/dist/layout/index.cjs +811 -269
- package/dist/layout/index.d.cts +1 -1
- package/dist/layout/index.d.ts +1 -1
- package/dist/layout/index.js +4 -4
- package/dist/ui/index.cjs +1689 -534
- package/dist/ui/index.d.cts +130 -16
- package/dist/ui/index.d.ts +130 -16
- package/dist/ui/index.js +481 -22
- package/package.json +6 -5
- package/styles.css +975 -114
- package/dist/chunk-2LYMCWEJ.js +0 -289
- package/dist/chunk-HJPHJKVA.js +0 -671
- package/dist/chunk-RQHJBTEU.js +0 -10
package/dist/layout/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/layout/index.ts
|
|
@@ -203,7 +213,7 @@ function PopoverContent({
|
|
|
203
213
|
{
|
|
204
214
|
"data-slot": "popover-content",
|
|
205
215
|
className: cn(
|
|
206
|
-
"z-50 w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none duration-200 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
216
|
+
"z-50 w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md shadow-(color:--shadow-color) outline-none duration-200 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
207
217
|
className
|
|
208
218
|
),
|
|
209
219
|
...props
|
|
@@ -414,7 +424,7 @@ function navigateMenuItem(menu, bridge) {
|
|
|
414
424
|
}
|
|
415
425
|
bridge.push(menu.path);
|
|
416
426
|
}
|
|
417
|
-
var menuItemClass = "flex w-full cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-
|
|
427
|
+
var menuItemClass = "flex w-full cursor-pointer items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-(--menu-hover-background) hover:text-(--menu-hover-foreground) disabled:pointer-events-none disabled:opacity-50";
|
|
418
428
|
function CollapsedGroupFlyout({
|
|
419
429
|
menu,
|
|
420
430
|
registry,
|
|
@@ -520,7 +530,7 @@ function MenuTree({
|
|
|
520
530
|
className: cn(
|
|
521
531
|
menuItemClass,
|
|
522
532
|
"mx-auto size-10 justify-center px-0 font-semibold",
|
|
523
|
-
menu.id === activeMenuId && "bg-
|
|
533
|
+
menu.id === activeMenuId && "bg-(--menu-active-background) font-semibold text-(--menu-active-foreground)"
|
|
524
534
|
),
|
|
525
535
|
disabled: menu.disabled,
|
|
526
536
|
title: menu.title,
|
|
@@ -583,7 +593,7 @@ function MenuTree({
|
|
|
583
593
|
"data-active": menu.id === activeMenuId || void 0,
|
|
584
594
|
className: cn(
|
|
585
595
|
menuItemClass,
|
|
586
|
-
menu.id === activeMenuId && "bg-
|
|
596
|
+
menu.id === activeMenuId && "bg-(--menu-active-background) font-semibold text-(--menu-active-foreground)"
|
|
587
597
|
),
|
|
588
598
|
disabled: menu.disabled,
|
|
589
599
|
title: menu.title,
|
|
@@ -689,7 +699,7 @@ function AdminLayout({
|
|
|
689
699
|
{
|
|
690
700
|
"data-slot": "admin-header",
|
|
691
701
|
className: cn(
|
|
692
|
-
"flex h-14 items-center gap-4 border-b border-border bg-
|
|
702
|
+
"flex h-14 items-center gap-4 border-b border-border bg-card px-6",
|
|
693
703
|
fixedHeader && "sticky top-0 z-20"
|
|
694
704
|
),
|
|
695
705
|
children: [
|
|
@@ -716,7 +726,7 @@ function AdminLayout({
|
|
|
716
726
|
className: cn(
|
|
717
727
|
menuItemClass,
|
|
718
728
|
"size-10 justify-center px-0 font-semibold",
|
|
719
|
-
(menu.id === secondaryTopId || menu.id === activeTopId) && "bg-
|
|
729
|
+
(menu.id === secondaryTopId || menu.id === activeTopId) && "bg-(--menu-active-background) text-(--menu-active-foreground)"
|
|
720
730
|
),
|
|
721
731
|
disabled: menu.disabled,
|
|
722
732
|
title: menu.title,
|
|
@@ -740,7 +750,7 @@ function AdminLayout({
|
|
|
740
750
|
"data-slot": "admin-sidebar",
|
|
741
751
|
"data-collapsed": effectiveCollapsed || void 0,
|
|
742
752
|
className: cn(
|
|
743
|
-
"shrink-0 overflow-auto border-r border-border bg-
|
|
753
|
+
"shrink-0 overflow-auto border-r border-border bg-sidebar py-2",
|
|
744
754
|
effectiveCollapsed ? "w-16 px-1.5" : "w-52",
|
|
745
755
|
fixedSider && (mode === "side-full" ? "sticky top-0 h-screen" : "sticky top-14 h-[calc(100vh-3.5rem)]")
|
|
746
756
|
),
|
|
@@ -787,7 +797,7 @@ function AdminLayout({
|
|
|
787
797
|
"data-slot": "admin-collapse-trigger",
|
|
788
798
|
"aria-label": effectiveCollapsed ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
789
799
|
"aria-expanded": !effectiveCollapsed,
|
|
790
|
-
className: "sticky bottom-0 flex w-full cursor-pointer items-center justify-center border-t border-border bg-
|
|
800
|
+
className: "sticky bottom-0 flex w-full cursor-pointer items-center justify-center border-t border-border bg-sidebar py-2 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
|
|
791
801
|
onClick: () => setCollapsed((value) => !value),
|
|
792
802
|
children: effectiveCollapsed ? "\xBB" : "\xAB"
|
|
793
803
|
}
|
|
@@ -801,7 +811,7 @@ function AdminLayout({
|
|
|
801
811
|
{
|
|
802
812
|
"data-slot": "admin-tabs",
|
|
803
813
|
role: "tablist",
|
|
804
|
-
className: "flex items-center gap-1 border-b border-border bg-
|
|
814
|
+
className: "flex items-center gap-1 border-b border-border bg-card px-4 pt-2",
|
|
805
815
|
children: tabs.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
806
816
|
"div",
|
|
807
817
|
{
|
|
@@ -810,7 +820,7 @@ function AdminLayout({
|
|
|
810
820
|
role: "presentation",
|
|
811
821
|
className: cn(
|
|
812
822
|
"inline-flex items-center gap-1 rounded-t-md border border-b-0 border-border px-3 py-1.5 text-sm",
|
|
813
|
-
tab.key === currentPath ? "bg-
|
|
823
|
+
tab.key === currentPath ? "bg-card font-medium text-foreground" : "bg-muted text-muted-foreground"
|
|
814
824
|
),
|
|
815
825
|
children: [
|
|
816
826
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -921,7 +931,10 @@ function BlankLayout({ children }) {
|
|
|
921
931
|
|
|
922
932
|
// src/layout/chat/ChatLayout.tsx
|
|
923
933
|
var import_permission2 = require("@pactor-app/permission");
|
|
924
|
-
var
|
|
934
|
+
var import_react6 = require("react");
|
|
935
|
+
|
|
936
|
+
// src/components/components/Menu/index.tsx
|
|
937
|
+
var import_react5 = require("react");
|
|
925
938
|
|
|
926
939
|
// src/ui/tooltip.tsx
|
|
927
940
|
var import_tooltip = require("@base-ui/react/tooltip");
|
|
@@ -997,15 +1010,17 @@ function RailTooltip({
|
|
|
997
1010
|
|
|
998
1011
|
// src/components/components/Sidebar/index.tsx
|
|
999
1012
|
var import_runtime2 = require("@pactor-app/runtime");
|
|
1000
|
-
var
|
|
1013
|
+
var import_react4 = require("react");
|
|
1014
|
+
|
|
1015
|
+
// src/ui/sidebar.tsx
|
|
1016
|
+
var React = __toESM(require("react"), 1);
|
|
1017
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1018
|
+
var import_lucide_react4 = require("lucide-react");
|
|
1019
|
+
|
|
1020
|
+
// src/hooks/use-mobile.ts
|
|
1001
1021
|
var import_react3 = require("react");
|
|
1002
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1003
|
-
var SidebarDrawerContext = (0, import_react3.createContext)(null);
|
|
1004
|
-
function useSidebarDrawer() {
|
|
1005
|
-
return (0, import_react3.useContext)(SidebarDrawerContext);
|
|
1006
|
-
}
|
|
1007
1022
|
var MOBILE_MEDIA_QUERY = "(max-width: 767px)";
|
|
1008
|
-
function
|
|
1023
|
+
function useIsMobile() {
|
|
1009
1024
|
const [isMobile, setIsMobile] = (0, import_react3.useState)(
|
|
1010
1025
|
() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(MOBILE_MEDIA_QUERY).matches
|
|
1011
1026
|
);
|
|
@@ -1023,6 +1038,476 @@ function useIsMobileViewport() {
|
|
|
1023
1038
|
}, []);
|
|
1024
1039
|
return isMobile;
|
|
1025
1040
|
}
|
|
1041
|
+
|
|
1042
|
+
// src/ui/sheet.tsx
|
|
1043
|
+
var import_dialog = require("@base-ui/react/dialog");
|
|
1044
|
+
var import_lucide_react3 = require("lucide-react");
|
|
1045
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
1046
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1047
|
+
function Sheet({
|
|
1048
|
+
...props
|
|
1049
|
+
}) {
|
|
1050
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog.Dialog.Root, { "data-slot": "sheet", ...props });
|
|
1051
|
+
}
|
|
1052
|
+
function SheetPortal({
|
|
1053
|
+
...props
|
|
1054
|
+
}) {
|
|
1055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dialog.Dialog.Portal, { "data-slot": "sheet-portal", ...props });
|
|
1056
|
+
}
|
|
1057
|
+
function SheetOverlay({
|
|
1058
|
+
className,
|
|
1059
|
+
...props
|
|
1060
|
+
}) {
|
|
1061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1062
|
+
import_dialog.Dialog.Backdrop,
|
|
1063
|
+
{
|
|
1064
|
+
"data-slot": "sheet-overlay",
|
|
1065
|
+
className: cn(
|
|
1066
|
+
"fixed inset-0 z-50 bg-(--overlay-background) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
1067
|
+
className
|
|
1068
|
+
),
|
|
1069
|
+
...props
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
var sheetVariants = (0, import_class_variance_authority.cva)(
|
|
1074
|
+
"fixed z-50 flex flex-col gap-4 border-border bg-popover shadow-lg shadow-(color:--shadow-color) transition ease-in-out data-open:animate-in data-open:duration-300 data-closed:animate-out data-closed:duration-200",
|
|
1075
|
+
{
|
|
1076
|
+
variants: {
|
|
1077
|
+
side: {
|
|
1078
|
+
right: "inset-y-0 right-0 h-full w-3/4 border-l data-open:slide-in-from-right data-closed:slide-out-to-right sm:max-w-sm",
|
|
1079
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r data-open:slide-in-from-left data-closed:slide-out-to-left sm:max-w-sm",
|
|
1080
|
+
top: "inset-x-0 top-0 border-b data-open:slide-in-from-top data-closed:slide-out-to-top",
|
|
1081
|
+
bottom: "inset-x-0 bottom-0 border-t data-open:slide-in-from-bottom data-closed:slide-out-to-bottom"
|
|
1082
|
+
}
|
|
1083
|
+
},
|
|
1084
|
+
defaultVariants: {
|
|
1085
|
+
side: "right"
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
);
|
|
1089
|
+
function SheetContent({
|
|
1090
|
+
className,
|
|
1091
|
+
children,
|
|
1092
|
+
side = "right",
|
|
1093
|
+
...props
|
|
1094
|
+
}) {
|
|
1095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(SheetPortal, { "data-slot": "sheet-portal", children: [
|
|
1096
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SheetOverlay, {}),
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1098
|
+
import_dialog.Dialog.Popup,
|
|
1099
|
+
{
|
|
1100
|
+
"data-slot": "sheet-content",
|
|
1101
|
+
className: cn(sheetVariants({ side }), className),
|
|
1102
|
+
...props,
|
|
1103
|
+
children: [
|
|
1104
|
+
children,
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1106
|
+
import_dialog.Dialog.Close,
|
|
1107
|
+
{
|
|
1108
|
+
"data-slot": "sheet-close",
|
|
1109
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1110
|
+
"button",
|
|
1111
|
+
{
|
|
1112
|
+
type: "button",
|
|
1113
|
+
className: "absolute top-4 right-4 cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
1114
|
+
}
|
|
1115
|
+
),
|
|
1116
|
+
children: [
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.XIcon, {}),
|
|
1118
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sr-only", children: "Close" })
|
|
1119
|
+
]
|
|
1120
|
+
}
|
|
1121
|
+
)
|
|
1122
|
+
]
|
|
1123
|
+
}
|
|
1124
|
+
)
|
|
1125
|
+
] });
|
|
1126
|
+
}
|
|
1127
|
+
function SheetHeader({ className, ...props }) {
|
|
1128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1129
|
+
"div",
|
|
1130
|
+
{
|
|
1131
|
+
"data-slot": "sheet-header",
|
|
1132
|
+
className: cn("flex flex-col gap-1.5 p-4", className),
|
|
1133
|
+
...props
|
|
1134
|
+
}
|
|
1135
|
+
);
|
|
1136
|
+
}
|
|
1137
|
+
function SheetTitle({
|
|
1138
|
+
className,
|
|
1139
|
+
...props
|
|
1140
|
+
}) {
|
|
1141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1142
|
+
import_dialog.Dialog.Title,
|
|
1143
|
+
{
|
|
1144
|
+
"data-slot": "sheet-title",
|
|
1145
|
+
className: cn("font-semibold text-foreground", className),
|
|
1146
|
+
...props
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
function SheetDescription({
|
|
1151
|
+
className,
|
|
1152
|
+
...props
|
|
1153
|
+
}) {
|
|
1154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1155
|
+
import_dialog.Dialog.Description,
|
|
1156
|
+
{
|
|
1157
|
+
"data-slot": "sheet-description",
|
|
1158
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
1159
|
+
...props
|
|
1160
|
+
}
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// src/ui/sidebar.tsx
|
|
1165
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1166
|
+
var SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
1167
|
+
var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
1168
|
+
var SIDEBAR_WIDTH = "16rem";
|
|
1169
|
+
var SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
1170
|
+
var SIDEBAR_WIDTH_ICON = "3rem";
|
|
1171
|
+
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
1172
|
+
var SidebarContext = React.createContext(null);
|
|
1173
|
+
function useSidebar() {
|
|
1174
|
+
const context = React.useContext(SidebarContext);
|
|
1175
|
+
if (!context) {
|
|
1176
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
1177
|
+
}
|
|
1178
|
+
return context;
|
|
1179
|
+
}
|
|
1180
|
+
function SidebarProvider({
|
|
1181
|
+
defaultOpen = true,
|
|
1182
|
+
open: openProp,
|
|
1183
|
+
onOpenChange: setOpenProp,
|
|
1184
|
+
className,
|
|
1185
|
+
style,
|
|
1186
|
+
children,
|
|
1187
|
+
...props
|
|
1188
|
+
}) {
|
|
1189
|
+
const isMobile = useIsMobile();
|
|
1190
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
1191
|
+
const [_open, _setOpen] = React.useState(defaultOpen);
|
|
1192
|
+
const open = openProp ?? _open;
|
|
1193
|
+
const setOpen = React.useCallback(
|
|
1194
|
+
(value) => {
|
|
1195
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
1196
|
+
if (setOpenProp) {
|
|
1197
|
+
setOpenProp(openState);
|
|
1198
|
+
} else {
|
|
1199
|
+
_setOpen(openState);
|
|
1200
|
+
}
|
|
1201
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
1202
|
+
},
|
|
1203
|
+
[setOpenProp, open]
|
|
1204
|
+
);
|
|
1205
|
+
const toggleSidebar = React.useCallback(() => {
|
|
1206
|
+
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
1207
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
1208
|
+
React.useEffect(() => {
|
|
1209
|
+
const handleKeyDown = (event) => {
|
|
1210
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
1211
|
+
event.preventDefault();
|
|
1212
|
+
toggleSidebar();
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1216
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1217
|
+
}, [toggleSidebar]);
|
|
1218
|
+
const state = open ? "expanded" : "collapsed";
|
|
1219
|
+
const contextValue = React.useMemo(
|
|
1220
|
+
() => ({
|
|
1221
|
+
state,
|
|
1222
|
+
open,
|
|
1223
|
+
setOpen,
|
|
1224
|
+
isMobile,
|
|
1225
|
+
openMobile,
|
|
1226
|
+
setOpenMobile,
|
|
1227
|
+
toggleSidebar
|
|
1228
|
+
}),
|
|
1229
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
1230
|
+
);
|
|
1231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipProvider, { delay: 0, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1232
|
+
"div",
|
|
1233
|
+
{
|
|
1234
|
+
"data-slot": "sidebar-wrapper",
|
|
1235
|
+
style: {
|
|
1236
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
1237
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
1238
|
+
...style
|
|
1239
|
+
},
|
|
1240
|
+
className: cn(
|
|
1241
|
+
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
|
1242
|
+
className
|
|
1243
|
+
),
|
|
1244
|
+
...props,
|
|
1245
|
+
children
|
|
1246
|
+
}
|
|
1247
|
+
) }) });
|
|
1248
|
+
}
|
|
1249
|
+
function SidebarRoot({
|
|
1250
|
+
side = "left",
|
|
1251
|
+
variant = "sidebar",
|
|
1252
|
+
collapsible = "offcanvas",
|
|
1253
|
+
className,
|
|
1254
|
+
children,
|
|
1255
|
+
...props
|
|
1256
|
+
}) {
|
|
1257
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
1258
|
+
if (collapsible === "none") {
|
|
1259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1260
|
+
"div",
|
|
1261
|
+
{
|
|
1262
|
+
"data-slot": "sidebar",
|
|
1263
|
+
className: cn(
|
|
1264
|
+
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
1265
|
+
className
|
|
1266
|
+
),
|
|
1267
|
+
...props,
|
|
1268
|
+
children
|
|
1269
|
+
}
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
if (isMobile) {
|
|
1273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1274
|
+
SheetContent,
|
|
1275
|
+
{
|
|
1276
|
+
"data-sidebar": "sidebar",
|
|
1277
|
+
"data-slot": "sidebar",
|
|
1278
|
+
"data-mobile": "true",
|
|
1279
|
+
className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
|
|
1280
|
+
style: {
|
|
1281
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
1282
|
+
},
|
|
1283
|
+
side,
|
|
1284
|
+
children: [
|
|
1285
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(SheetHeader, { className: "sr-only", children: [
|
|
1286
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SheetTitle, { children: "Sidebar" }),
|
|
1287
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SheetDescription, { children: "Displays the mobile sidebar." })
|
|
1288
|
+
] }),
|
|
1289
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex h-full w-full flex-col", children })
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
) });
|
|
1293
|
+
}
|
|
1294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1295
|
+
"div",
|
|
1296
|
+
{
|
|
1297
|
+
className: "group peer hidden text-sidebar-foreground md:block",
|
|
1298
|
+
"data-state": state,
|
|
1299
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
1300
|
+
"data-variant": variant,
|
|
1301
|
+
"data-side": side,
|
|
1302
|
+
"data-slot": "sidebar",
|
|
1303
|
+
children: [
|
|
1304
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1305
|
+
"div",
|
|
1306
|
+
{
|
|
1307
|
+
"data-slot": "sidebar-gap",
|
|
1308
|
+
className: cn(
|
|
1309
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
1310
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
1311
|
+
"group-data-[side=right]:rotate-180",
|
|
1312
|
+
variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
1313
|
+
)
|
|
1314
|
+
}
|
|
1315
|
+
),
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1317
|
+
"div",
|
|
1318
|
+
{
|
|
1319
|
+
"data-slot": "sidebar-container",
|
|
1320
|
+
className: cn(
|
|
1321
|
+
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
1322
|
+
side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
1323
|
+
variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
1324
|
+
className
|
|
1325
|
+
),
|
|
1326
|
+
...props,
|
|
1327
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1328
|
+
"div",
|
|
1329
|
+
{
|
|
1330
|
+
"data-sidebar": "sidebar",
|
|
1331
|
+
"data-slot": "sidebar-inner",
|
|
1332
|
+
className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm",
|
|
1333
|
+
children
|
|
1334
|
+
}
|
|
1335
|
+
)
|
|
1336
|
+
}
|
|
1337
|
+
)
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1342
|
+
function SidebarInset({ className, ...props }) {
|
|
1343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1344
|
+
"main",
|
|
1345
|
+
{
|
|
1346
|
+
"data-slot": "sidebar-inset",
|
|
1347
|
+
className: cn(
|
|
1348
|
+
"relative flex w-full flex-1 flex-col bg-background",
|
|
1349
|
+
"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
1350
|
+
className
|
|
1351
|
+
),
|
|
1352
|
+
...props
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
function SidebarHeader({ className, ...props }) {
|
|
1357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1358
|
+
"div",
|
|
1359
|
+
{
|
|
1360
|
+
"data-slot": "sidebar-header",
|
|
1361
|
+
"data-sidebar": "header",
|
|
1362
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
1363
|
+
...props
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
function SidebarFooter({ className, ...props }) {
|
|
1368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1369
|
+
"div",
|
|
1370
|
+
{
|
|
1371
|
+
"data-slot": "sidebar-footer",
|
|
1372
|
+
"data-sidebar": "footer",
|
|
1373
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
1374
|
+
...props
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
function SidebarContent({ className, ...props }) {
|
|
1379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1380
|
+
"div",
|
|
1381
|
+
{
|
|
1382
|
+
"data-slot": "sidebar-content",
|
|
1383
|
+
"data-sidebar": "content",
|
|
1384
|
+
className: cn(
|
|
1385
|
+
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
1386
|
+
className
|
|
1387
|
+
),
|
|
1388
|
+
...props
|
|
1389
|
+
}
|
|
1390
|
+
);
|
|
1391
|
+
}
|
|
1392
|
+
function renderAsChild(children, dataSlot, className, rest) {
|
|
1393
|
+
if (!React.isValidElement(children)) {
|
|
1394
|
+
return null;
|
|
1395
|
+
}
|
|
1396
|
+
return React.cloneElement(children, {
|
|
1397
|
+
"data-slot": dataSlot,
|
|
1398
|
+
className: cn(
|
|
1399
|
+
className,
|
|
1400
|
+
children.props.className
|
|
1401
|
+
),
|
|
1402
|
+
...rest
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
function SidebarMenu({ className, ...props }) {
|
|
1406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1407
|
+
"ul",
|
|
1408
|
+
{
|
|
1409
|
+
"data-slot": "sidebar-menu",
|
|
1410
|
+
"data-sidebar": "menu",
|
|
1411
|
+
className: cn("flex w-full min-w-0 flex-col gap-1", className),
|
|
1412
|
+
...props
|
|
1413
|
+
}
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
1417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1418
|
+
"li",
|
|
1419
|
+
{
|
|
1420
|
+
"data-slot": "sidebar-menu-item",
|
|
1421
|
+
"data-sidebar": "menu-item",
|
|
1422
|
+
className: cn("group/menu-item relative", className),
|
|
1423
|
+
...props
|
|
1424
|
+
}
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
var sidebarMenuButtonVariants = (0, import_class_variance_authority2.cva)(
|
|
1428
|
+
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
1429
|
+
{
|
|
1430
|
+
variants: {
|
|
1431
|
+
variant: {
|
|
1432
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
1433
|
+
outline: "bg-sidebar shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"
|
|
1434
|
+
},
|
|
1435
|
+
size: {
|
|
1436
|
+
default: "h-8 text-sm",
|
|
1437
|
+
sm: "h-7 text-xs",
|
|
1438
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
defaultVariants: {
|
|
1442
|
+
variant: "default",
|
|
1443
|
+
size: "default"
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
);
|
|
1447
|
+
function SidebarMenuButton({
|
|
1448
|
+
asChild = false,
|
|
1449
|
+
isActive = false,
|
|
1450
|
+
variant = "default",
|
|
1451
|
+
size = "default",
|
|
1452
|
+
tooltip,
|
|
1453
|
+
className,
|
|
1454
|
+
children,
|
|
1455
|
+
...props
|
|
1456
|
+
}) {
|
|
1457
|
+
const { isMobile, state } = useSidebar();
|
|
1458
|
+
const cls = cn(sidebarMenuButtonVariants({ variant, size }), className);
|
|
1459
|
+
const button = asChild ? renderAsChild(children, "sidebar-menu-button", cls, {
|
|
1460
|
+
"data-sidebar": "menu-button",
|
|
1461
|
+
"data-size": size,
|
|
1462
|
+
"data-active": isActive,
|
|
1463
|
+
...props
|
|
1464
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1465
|
+
"button",
|
|
1466
|
+
{
|
|
1467
|
+
"data-slot": "sidebar-menu-button",
|
|
1468
|
+
"data-sidebar": "menu-button",
|
|
1469
|
+
"data-size": size,
|
|
1470
|
+
"data-active": isActive,
|
|
1471
|
+
className: cls,
|
|
1472
|
+
...props,
|
|
1473
|
+
children
|
|
1474
|
+
}
|
|
1475
|
+
);
|
|
1476
|
+
if (!tooltip) {
|
|
1477
|
+
return button;
|
|
1478
|
+
}
|
|
1479
|
+
if (typeof tooltip === "string") {
|
|
1480
|
+
tooltip = {
|
|
1481
|
+
children: tooltip
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Tooltip, { children: [
|
|
1485
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipTrigger, { render: button }),
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1487
|
+
TooltipContent,
|
|
1488
|
+
{
|
|
1489
|
+
side: "right",
|
|
1490
|
+
align: "center",
|
|
1491
|
+
hidden: state !== "collapsed" || isMobile,
|
|
1492
|
+
...tooltip
|
|
1493
|
+
}
|
|
1494
|
+
)
|
|
1495
|
+
] });
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
// src/components/components/Sidebar/index.tsx
|
|
1499
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1500
|
+
function useSidebarDrawer() {
|
|
1501
|
+
try {
|
|
1502
|
+
const ctx = useSidebar();
|
|
1503
|
+
return {
|
|
1504
|
+
close: () => ctx.setOpenMobile(false),
|
|
1505
|
+
collapsed: ctx.state === "collapsed"
|
|
1506
|
+
};
|
|
1507
|
+
} catch {
|
|
1508
|
+
return null;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1026
1511
|
function useOptionalRenderer() {
|
|
1027
1512
|
try {
|
|
1028
1513
|
return (0, import_runtime2.useRenderer)();
|
|
@@ -1030,16 +1515,61 @@ function useOptionalRenderer() {
|
|
|
1030
1515
|
return null;
|
|
1031
1516
|
}
|
|
1032
1517
|
}
|
|
1033
|
-
function
|
|
1518
|
+
function SidebarContentSlot({ content }) {
|
|
1034
1519
|
const renderer = useOptionalRenderer();
|
|
1035
1520
|
if (renderer !== null && typeof content === "object" && content !== null && !("$$typeof" in content) && "type" in content) {
|
|
1036
|
-
return /* @__PURE__ */ (0,
|
|
1521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: renderer.renderChildren([content]) });
|
|
1037
1522
|
}
|
|
1038
|
-
return /* @__PURE__ */ (0,
|
|
1523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: content });
|
|
1039
1524
|
}
|
|
1040
1525
|
function isBrandObject(brand) {
|
|
1041
1526
|
return typeof brand === "object" && brand !== null && !("$$typeof" in brand) && "title" in brand;
|
|
1042
1527
|
}
|
|
1528
|
+
function BrandNode({ brand, collapsed }) {
|
|
1529
|
+
if (brand === void 0 || brand === null) {
|
|
1530
|
+
return null;
|
|
1531
|
+
}
|
|
1532
|
+
if (isBrandObject(brand)) {
|
|
1533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1534
|
+
brand.logo ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1535
|
+
"img",
|
|
1536
|
+
{
|
|
1537
|
+
"data-slot": "sidebar-brand-logo",
|
|
1538
|
+
src: brand.logo,
|
|
1539
|
+
alt: brand.title,
|
|
1540
|
+
className: "size-6 shrink-0"
|
|
1541
|
+
}
|
|
1542
|
+
) : null,
|
|
1543
|
+
collapsed ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "truncate text-sm font-semibold", children: brand.title })
|
|
1544
|
+
] });
|
|
1545
|
+
}
|
|
1546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: brand });
|
|
1547
|
+
}
|
|
1548
|
+
function SidebarNavItems({ items }) {
|
|
1549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarMenu, { children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarNavEntry, { item, depth: 0 }, item.href ?? item.label ?? index)) });
|
|
1550
|
+
}
|
|
1551
|
+
function SidebarNavEntry({ item, depth }) {
|
|
1552
|
+
const iconNode = item.icon ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: item.icon, size: "sm" }) : null;
|
|
1553
|
+
const labelNode = item.label;
|
|
1554
|
+
const button = item.href ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarMenuButton, { asChild: true, tooltip: item.label, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("a", { href: item.href, children: [
|
|
1555
|
+
iconNode,
|
|
1556
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: labelNode })
|
|
1557
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SidebarMenuButton, { tooltip: item.label, children: [
|
|
1558
|
+
iconNode,
|
|
1559
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: labelNode })
|
|
1560
|
+
] });
|
|
1561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SidebarMenuItem, { children: [
|
|
1562
|
+
button,
|
|
1563
|
+
item.children && item.children.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("ml-4"), children: item.children.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1564
|
+
SidebarNavEntry,
|
|
1565
|
+
{
|
|
1566
|
+
item: child,
|
|
1567
|
+
depth: depth + 1
|
|
1568
|
+
},
|
|
1569
|
+
child.href ?? child.label ?? index
|
|
1570
|
+
)) })
|
|
1571
|
+
] });
|
|
1572
|
+
}
|
|
1043
1573
|
function Sidebar({
|
|
1044
1574
|
brand,
|
|
1045
1575
|
items = [],
|
|
@@ -1052,234 +1582,170 @@ function Sidebar({
|
|
|
1052
1582
|
className,
|
|
1053
1583
|
style,
|
|
1054
1584
|
children
|
|
1585
|
+
}) {
|
|
1586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1587
|
+
SidebarProvider,
|
|
1588
|
+
{
|
|
1589
|
+
defaultOpen: true,
|
|
1590
|
+
className,
|
|
1591
|
+
style,
|
|
1592
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1593
|
+
SidebarInner,
|
|
1594
|
+
{
|
|
1595
|
+
brand,
|
|
1596
|
+
items,
|
|
1597
|
+
content,
|
|
1598
|
+
sidebarFooter,
|
|
1599
|
+
collapsible,
|
|
1600
|
+
onCollapse,
|
|
1601
|
+
locationKey,
|
|
1602
|
+
drawer,
|
|
1603
|
+
children
|
|
1604
|
+
}
|
|
1605
|
+
)
|
|
1606
|
+
}
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
function SidebarInner({
|
|
1610
|
+
brand,
|
|
1611
|
+
items = [],
|
|
1612
|
+
content,
|
|
1613
|
+
sidebarFooter,
|
|
1614
|
+
collapsible,
|
|
1615
|
+
onCollapse,
|
|
1616
|
+
locationKey,
|
|
1617
|
+
drawer = true,
|
|
1618
|
+
children
|
|
1055
1619
|
}) {
|
|
1056
1620
|
const { t } = (0, import_runtime2.useI18n)();
|
|
1057
|
-
const isMobile =
|
|
1058
|
-
const
|
|
1059
|
-
const
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
onCollapse?.(next);
|
|
1066
|
-
};
|
|
1067
|
-
const [trackedLocationKey, setTrackedLocationKey] = (0, import_react3.useState)(locationKey);
|
|
1068
|
-
if (trackedLocationKey !== locationKey) {
|
|
1069
|
-
setTrackedLocationKey(locationKey);
|
|
1070
|
-
setDrawerOpen(false);
|
|
1071
|
-
}
|
|
1072
|
-
(0, import_react3.useEffect)(() => {
|
|
1073
|
-
if (!drawerOpen) {
|
|
1074
|
-
return;
|
|
1621
|
+
const isMobile = useIsMobile();
|
|
1622
|
+
const { state, setOpenMobile, toggleSidebar } = useSidebar();
|
|
1623
|
+
const collapsed = state === "collapsed";
|
|
1624
|
+
const prevCollapsed = (0, import_react4.useRef)(collapsed);
|
|
1625
|
+
(0, import_react4.useEffect)(() => {
|
|
1626
|
+
if (prevCollapsed.current !== collapsed) {
|
|
1627
|
+
prevCollapsed.current = collapsed;
|
|
1628
|
+
onCollapse?.(collapsed);
|
|
1075
1629
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
|
|
1630
|
+
}, [collapsed, onCollapse]);
|
|
1631
|
+
(0, import_react4.useEffect)(() => {
|
|
1632
|
+
if (locationKey !== void 0) {
|
|
1633
|
+
setOpenMobile(false);
|
|
1634
|
+
}
|
|
1635
|
+
}, [locationKey, setOpenMobile]);
|
|
1636
|
+
const collapsedEffective = collapsible === true && collapsed && !isMobile;
|
|
1637
|
+
const brandNode = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BrandNode, { brand, collapsed: collapsedEffective });
|
|
1638
|
+
const sidebarContent = content !== void 0 && content !== null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarContentSlot, { content }) : items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarNavItems, { items }) : null;
|
|
1639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1641
|
+
SidebarRoot,
|
|
1087
1642
|
{
|
|
1088
|
-
"
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1643
|
+
collapsible: collapsible ? "icon" : "offcanvas",
|
|
1644
|
+
children: [
|
|
1645
|
+
(brand !== void 0 || collapsible) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1646
|
+
"div",
|
|
1647
|
+
{
|
|
1648
|
+
"data-slot": "sidebar-brand",
|
|
1649
|
+
className: cn(
|
|
1650
|
+
"flex h-14 shrink-0 items-center gap-2 px-2",
|
|
1651
|
+
collapsedEffective && "justify-center px-0"
|
|
1652
|
+
),
|
|
1653
|
+
children: [
|
|
1654
|
+
collapsedEffective ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: brandNode }),
|
|
1655
|
+
collapsible && !isMobile && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1656
|
+
"button",
|
|
1657
|
+
{
|
|
1658
|
+
type: "button",
|
|
1659
|
+
"data-slot": "sidebar-collapse-trigger",
|
|
1660
|
+
"aria-label": collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
1661
|
+
"aria-expanded": !collapsedEffective,
|
|
1662
|
+
className: "flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
|
|
1663
|
+
onClick: toggleSidebar,
|
|
1664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: collapsedEffective ? "chevron-right" : "chevron-left", size: 16 })
|
|
1665
|
+
}
|
|
1666
|
+
)
|
|
1667
|
+
]
|
|
1668
|
+
}
|
|
1669
|
+
) }),
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarContent, { children: sidebarContent }),
|
|
1671
|
+
sidebarFooter !== void 0 && sidebarFooter !== null && !collapsedEffective && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SidebarFooter, { children: sidebarFooter })
|
|
1672
|
+
]
|
|
1092
1673
|
}
|
|
1093
|
-
)
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
const collapseTrigger = collapsible && !isMobile ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1097
|
-
"button",
|
|
1098
|
-
{
|
|
1099
|
-
type: "button",
|
|
1100
|
-
"data-slot": "sidebar-collapse-trigger",
|
|
1101
|
-
"aria-label": collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
1102
|
-
"aria-expanded": !collapsedEffective,
|
|
1103
|
-
title: collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
1104
|
-
className: cn(
|
|
1105
|
-
"cursor-pointer flex size-8 shrink-0 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground"
|
|
1106
|
-
),
|
|
1107
|
-
onClick: toggleCollapsed,
|
|
1108
|
-
children: collapsedEffective ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronRight, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.ChevronLeft, { "aria-hidden": true, className: "size-4" })
|
|
1109
|
-
}
|
|
1110
|
-
) : null;
|
|
1111
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1112
|
-
SidebarDrawerContext.Provider,
|
|
1113
|
-
{
|
|
1114
|
-
value: { close, collapsed: collapsedEffective },
|
|
1115
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1674
|
+
),
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SidebarInset, { children: [
|
|
1676
|
+
drawer && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1116
1677
|
"div",
|
|
1117
1678
|
{
|
|
1118
|
-
"data-slot": "sidebar-
|
|
1119
|
-
className:
|
|
1120
|
-
style,
|
|
1679
|
+
"data-slot": "sidebar-topbar",
|
|
1680
|
+
className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
|
|
1121
1681
|
children: [
|
|
1122
|
-
|
|
1123
|
-
"
|
|
1682
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1683
|
+
"button",
|
|
1124
1684
|
{
|
|
1125
|
-
|
|
1126
|
-
"
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1132
|
-
"aside",
|
|
1133
|
-
{
|
|
1134
|
-
"data-slot": "sidebar",
|
|
1135
|
-
"data-collapsed": collapsedEffective || void 0,
|
|
1136
|
-
"data-open": drawerOpen ? "true" : "false",
|
|
1137
|
-
inert: drawer && isMobile && !drawerOpen ? true : void 0,
|
|
1138
|
-
className: cn(
|
|
1139
|
-
"flex shrink-0 flex-col border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-[width,transform]",
|
|
1140
|
-
collapsedEffective ? "w-16" : "w-60",
|
|
1141
|
-
// 移动端覆盖抽屉:退出文档流,关闭时移出屏幕
|
|
1142
|
-
drawer && "max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:z-50 max-md:w-60 max-md:-translate-x-full max-md:data-[open=true]:translate-x-0"
|
|
1143
|
-
),
|
|
1144
|
-
children: [
|
|
1145
|
-
brand !== void 0 || collapseTrigger !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1146
|
-
"div",
|
|
1147
|
-
{
|
|
1148
|
-
"data-slot": "sidebar-brand",
|
|
1149
|
-
className: cn(
|
|
1150
|
-
"flex h-14 shrink-0 items-center gap-2 border-b border-sidebar-border px-4",
|
|
1151
|
-
// 移动端品牌维持顶栏现状:抽屉内不重复渲染品牌行
|
|
1152
|
-
"max-md:hidden",
|
|
1153
|
-
collapsedEffective && "justify-center px-2"
|
|
1154
|
-
),
|
|
1155
|
-
children: [
|
|
1156
|
-
collapsedEffective ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: brandNode }),
|
|
1157
|
-
collapseTrigger
|
|
1158
|
-
]
|
|
1159
|
-
}
|
|
1160
|
-
) : null,
|
|
1161
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1162
|
-
"nav",
|
|
1163
|
-
{
|
|
1164
|
-
"data-slot": "sidebar-nav",
|
|
1165
|
-
className: "min-h-0 flex-1 overflow-auto p-2",
|
|
1166
|
-
children: content !== void 0 && content !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SidebarContent, { content }) : items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1167
|
-
SidebarEntry,
|
|
1168
|
-
{
|
|
1169
|
-
item,
|
|
1170
|
-
depth: 0,
|
|
1171
|
-
collapsed: collapsedEffective
|
|
1172
|
-
},
|
|
1173
|
-
item.href ?? item.label ?? index
|
|
1174
|
-
))
|
|
1175
|
-
}
|
|
1176
|
-
),
|
|
1177
|
-
sidebarFooter !== void 0 && sidebarFooter !== null && !collapsedEffective ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1178
|
-
"div",
|
|
1179
|
-
{
|
|
1180
|
-
"data-slot": "sidebar-footer",
|
|
1181
|
-
className: "shrink-0 border-t border-sidebar-border p-2",
|
|
1182
|
-
children: sidebarFooter
|
|
1183
|
-
}
|
|
1184
|
-
) : null
|
|
1185
|
-
]
|
|
1685
|
+
type: "button",
|
|
1686
|
+
"data-slot": "sidebar-menu-trigger",
|
|
1687
|
+
"aria-label": t("pactor.layout.openNavigation"),
|
|
1688
|
+
className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
|
|
1689
|
+
onClick: toggleSidebar,
|
|
1690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "menu", size: 18 })
|
|
1186
1691
|
}
|
|
1187
1692
|
),
|
|
1188
|
-
|
|
1189
|
-
"main",
|
|
1190
|
-
{
|
|
1191
|
-
"data-slot": "sidebar-content",
|
|
1192
|
-
className: "flex min-w-0 flex-1 flex-col",
|
|
1193
|
-
children: [
|
|
1194
|
-
drawer ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1195
|
-
"div",
|
|
1196
|
-
{
|
|
1197
|
-
"data-slot": "sidebar-topbar",
|
|
1198
|
-
className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
|
|
1199
|
-
children: [
|
|
1200
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1201
|
-
"button",
|
|
1202
|
-
{
|
|
1203
|
-
type: "button",
|
|
1204
|
-
"data-slot": "sidebar-menu-trigger",
|
|
1205
|
-
"aria-label": t("pactor.layout.openNavigation"),
|
|
1206
|
-
"aria-expanded": drawerOpen,
|
|
1207
|
-
className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
|
|
1208
|
-
onClick: () => setDrawerOpen(true),
|
|
1209
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "menu", size: 18 })
|
|
1210
|
-
}
|
|
1211
|
-
),
|
|
1212
|
-
brandNode
|
|
1213
|
-
]
|
|
1214
|
-
}
|
|
1215
|
-
) : null,
|
|
1216
|
-
children
|
|
1217
|
-
]
|
|
1218
|
-
}
|
|
1219
|
-
)
|
|
1693
|
+
brandNode
|
|
1220
1694
|
]
|
|
1221
1695
|
}
|
|
1222
|
-
)
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
}
|
|
1226
|
-
function SidebarEntry({
|
|
1227
|
-
item,
|
|
1228
|
-
depth,
|
|
1229
|
-
collapsed
|
|
1230
|
-
}) {
|
|
1231
|
-
const entryClass = cn(
|
|
1232
|
-
"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors",
|
|
1233
|
-
"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
1234
|
-
collapsed && "justify-center px-0"
|
|
1235
|
-
);
|
|
1236
|
-
const indentStyle = !collapsed && depth > 0 ? { paddingLeft: 12 + depth * 16 } : void 0;
|
|
1237
|
-
const labelNode = collapsed ? null : item.label;
|
|
1238
|
-
const iconNode = item.icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: item.icon, size: "sm" }) : null;
|
|
1239
|
-
const entry = item.href ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1240
|
-
"a",
|
|
1241
|
-
{
|
|
1242
|
-
"data-slot": "sidebar-item",
|
|
1243
|
-
href: item.href,
|
|
1244
|
-
className: entryClass,
|
|
1245
|
-
style: indentStyle,
|
|
1246
|
-
children: [
|
|
1247
|
-
iconNode,
|
|
1248
|
-
labelNode
|
|
1249
|
-
]
|
|
1250
|
-
}
|
|
1251
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { "data-slot": "sidebar-item", className: entryClass, style: indentStyle, children: [
|
|
1252
|
-
iconNode,
|
|
1253
|
-
labelNode
|
|
1254
|
-
] });
|
|
1255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-slot": "sidebar-entry", children: [
|
|
1256
|
-
collapsed ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RailTooltip, { label: item.label, children: entry }) : entry,
|
|
1257
|
-
item.children?.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1258
|
-
SidebarEntry,
|
|
1259
|
-
{
|
|
1260
|
-
item: child,
|
|
1261
|
-
depth: depth + 1,
|
|
1262
|
-
collapsed
|
|
1263
|
-
},
|
|
1264
|
-
child.href ?? child.label ?? index
|
|
1265
|
-
))
|
|
1696
|
+
),
|
|
1697
|
+
children
|
|
1698
|
+
] })
|
|
1266
1699
|
] });
|
|
1267
1700
|
}
|
|
1268
1701
|
|
|
1269
1702
|
// src/components/components/Menu/index.tsx
|
|
1270
|
-
var
|
|
1703
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1704
|
+
function collectAncestors(items, target, into, trail = []) {
|
|
1705
|
+
for (const item of items) {
|
|
1706
|
+
if (item.key === target) {
|
|
1707
|
+
for (const key of trail) into.add(key);
|
|
1708
|
+
return true;
|
|
1709
|
+
}
|
|
1710
|
+
if (item.children?.length && collectAncestors(item.children, target, into, [...trail, item.key])) {
|
|
1711
|
+
return true;
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
return false;
|
|
1715
|
+
}
|
|
1271
1716
|
function Menu2({
|
|
1272
1717
|
items = [],
|
|
1273
1718
|
mode = "inline",
|
|
1274
1719
|
selectedKey,
|
|
1720
|
+
collapsible = false,
|
|
1721
|
+
defaultExpandedKeys,
|
|
1275
1722
|
onSelect,
|
|
1276
1723
|
className,
|
|
1277
1724
|
style
|
|
1278
1725
|
}) {
|
|
1279
1726
|
const drawer = useSidebarDrawer();
|
|
1280
1727
|
const collapsed = mode === "inline" && drawer?.collapsed === true;
|
|
1728
|
+
const collapsibleOn = collapsible && mode === "inline" && !collapsed;
|
|
1729
|
+
const [expandedKeys, setExpandedKeys] = (0, import_react5.useState)(() => {
|
|
1730
|
+
const initial = new Set(defaultExpandedKeys ?? []);
|
|
1731
|
+
if (selectedKey !== void 0) {
|
|
1732
|
+
collectAncestors(items, selectedKey, initial);
|
|
1733
|
+
}
|
|
1734
|
+
return initial;
|
|
1735
|
+
});
|
|
1736
|
+
const toggleExpanded = (key) => {
|
|
1737
|
+
setExpandedKeys((prev) => {
|
|
1738
|
+
const next = new Set(prev);
|
|
1739
|
+
if (next.has(key)) {
|
|
1740
|
+
next.delete(key);
|
|
1741
|
+
} else {
|
|
1742
|
+
next.add(key);
|
|
1743
|
+
}
|
|
1744
|
+
return next;
|
|
1745
|
+
});
|
|
1746
|
+
};
|
|
1281
1747
|
let previousGroup;
|
|
1282
|
-
return /* @__PURE__ */ (0,
|
|
1748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1283
1749
|
"nav",
|
|
1284
1750
|
{
|
|
1285
1751
|
"data-slot": "menu",
|
|
@@ -1296,8 +1762,8 @@ function Menu2({
|
|
|
1296
1762
|
groupLabel = item.group;
|
|
1297
1763
|
}
|
|
1298
1764
|
previousGroup = item.group;
|
|
1299
|
-
return /* @__PURE__ */ (0,
|
|
1300
|
-
groupLabel !== void 0 && /* @__PURE__ */ (0,
|
|
1765
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { "data-slot": "menu-group-entry", children: [
|
|
1766
|
+
groupLabel !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1301
1767
|
"div",
|
|
1302
1768
|
{
|
|
1303
1769
|
"data-slot": "menu-group",
|
|
@@ -1305,7 +1771,7 @@ function Menu2({
|
|
|
1305
1771
|
children: groupLabel
|
|
1306
1772
|
}
|
|
1307
1773
|
),
|
|
1308
|
-
/* @__PURE__ */ (0,
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1309
1775
|
MenuEntry,
|
|
1310
1776
|
{
|
|
1311
1777
|
item,
|
|
@@ -1313,7 +1779,10 @@ function Menu2({
|
|
|
1313
1779
|
depth: 0,
|
|
1314
1780
|
selectedKey,
|
|
1315
1781
|
onSelect,
|
|
1316
|
-
collapsed
|
|
1782
|
+
collapsed,
|
|
1783
|
+
collapsible: collapsibleOn,
|
|
1784
|
+
expandedKeys,
|
|
1785
|
+
onToggle: toggleExpanded
|
|
1317
1786
|
}
|
|
1318
1787
|
)
|
|
1319
1788
|
] }, item.key);
|
|
@@ -1327,47 +1796,117 @@ function MenuEntry({
|
|
|
1327
1796
|
depth,
|
|
1328
1797
|
selectedKey,
|
|
1329
1798
|
onSelect,
|
|
1330
|
-
collapsed = false
|
|
1799
|
+
collapsed = false,
|
|
1800
|
+
collapsible = false,
|
|
1801
|
+
expandedKeys,
|
|
1802
|
+
onToggle
|
|
1331
1803
|
}) {
|
|
1332
1804
|
const selected = item.key === selectedKey;
|
|
1333
|
-
const
|
|
1805
|
+
const hasChildren = (item.children?.length ?? 0) > 0;
|
|
1806
|
+
const isDirectory = collapsible && hasChildren;
|
|
1807
|
+
const expanded = isDirectory && expandedKeys?.has(item.key) === true;
|
|
1808
|
+
const railDirectory = collapsed && hasChildren;
|
|
1809
|
+
const [flyoutOpen, setFlyoutOpen] = (0, import_react5.useState)(false);
|
|
1810
|
+
const flyoutTimer = (0, import_react5.useRef)(void 0);
|
|
1811
|
+
const flyoutOpenNow = () => {
|
|
1812
|
+
window.clearTimeout(flyoutTimer.current);
|
|
1813
|
+
setFlyoutOpen(true);
|
|
1814
|
+
};
|
|
1815
|
+
const flyoutCloseLater = () => {
|
|
1816
|
+
window.clearTimeout(flyoutTimer.current);
|
|
1817
|
+
flyoutTimer.current = window.setTimeout(() => setFlyoutOpen(false), 200);
|
|
1818
|
+
};
|
|
1819
|
+
(0, import_react5.useEffect)(() => () => window.clearTimeout(flyoutTimer.current), []);
|
|
1820
|
+
const button = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1334
1821
|
"button",
|
|
1335
1822
|
{
|
|
1336
1823
|
type: "button",
|
|
1337
1824
|
"data-slot": "menu-item",
|
|
1338
1825
|
"aria-current": selected ? "page" : void 0,
|
|
1826
|
+
"aria-expanded": isDirectory ? expanded : railDirectory ? flyoutOpen : void 0,
|
|
1339
1827
|
disabled: item.disabled,
|
|
1340
1828
|
className: cn(
|
|
1341
1829
|
"flex w-full items-center gap-2 rounded-md text-sm transition-colors",
|
|
1342
1830
|
mode === "horizontal" ? "px-3 py-2" : "px-3 py-2 text-left",
|
|
1343
1831
|
collapsed && "justify-center px-0",
|
|
1344
|
-
selected ? "bg-
|
|
1832
|
+
selected ? "bg-(--menu-active-background) font-medium text-(--menu-active-foreground)" : "cursor-pointer text-muted-foreground hover:bg-(--menu-hover-background)/50 hover:text-foreground",
|
|
1345
1833
|
item.disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground"
|
|
1346
1834
|
),
|
|
1347
1835
|
style: mode === "inline" && depth > 0 && !collapsed ? { paddingLeft: 12 + depth * 16 } : void 0,
|
|
1836
|
+
onMouseEnter: railDirectory ? flyoutOpenNow : void 0,
|
|
1837
|
+
onMouseLeave: railDirectory ? flyoutCloseLater : void 0,
|
|
1348
1838
|
onClick: () => {
|
|
1349
|
-
if (
|
|
1839
|
+
if (item.disabled) return;
|
|
1840
|
+
if (railDirectory) return;
|
|
1841
|
+
if (isDirectory) {
|
|
1842
|
+
onToggle?.(item.key);
|
|
1843
|
+
} else {
|
|
1350
1844
|
onSelect?.(item.key);
|
|
1351
1845
|
}
|
|
1352
1846
|
},
|
|
1353
1847
|
children: [
|
|
1354
|
-
item.icon ? /* @__PURE__ */ (0,
|
|
1355
|
-
collapsed ? null : /* @__PURE__ */ (0,
|
|
1356
|
-
item.dot && !collapsed ? /* @__PURE__ */ (0,
|
|
1357
|
-
item.badge !== void 0 && !collapsed ? /* @__PURE__ */ (0,
|
|
1848
|
+
item.icon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: item.icon, size: "sm" }) : null,
|
|
1849
|
+
collapsed ? null : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "min-w-0 flex-1 truncate text-left", children: item.label }),
|
|
1850
|
+
item.dot && !collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-slot": "menu-item-dot", className: "size-1.5 shrink-0 rounded-full bg-destructive" }) : null,
|
|
1851
|
+
item.badge !== void 0 && !collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1358
1852
|
"span",
|
|
1359
1853
|
{
|
|
1360
1854
|
"data-slot": "menu-item-badge",
|
|
1361
1855
|
className: "shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",
|
|
1362
1856
|
children: item.badge
|
|
1363
1857
|
}
|
|
1858
|
+
) : null,
|
|
1859
|
+
isDirectory ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1860
|
+
"span",
|
|
1861
|
+
{
|
|
1862
|
+
"data-slot": "menu-item-chevron",
|
|
1863
|
+
className: cn(
|
|
1864
|
+
"shrink-0 transition-transform",
|
|
1865
|
+
expanded && "rotate-180"
|
|
1866
|
+
),
|
|
1867
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: "chevron-down", size: "sm" })
|
|
1868
|
+
}
|
|
1364
1869
|
) : null
|
|
1365
1870
|
]
|
|
1366
1871
|
}
|
|
1367
1872
|
);
|
|
1368
|
-
return /* @__PURE__ */ (0,
|
|
1369
|
-
|
|
1370
|
-
|
|
1873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { "data-slot": "menu-entry", "data-key": item.key, children: [
|
|
1874
|
+
railDirectory ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Popover, { open: flyoutOpen, onOpenChange: setFlyoutOpen, children: [
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PopoverTrigger, { render: button }),
|
|
1876
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1877
|
+
PopoverContent,
|
|
1878
|
+
{
|
|
1879
|
+
"data-slot": "menu-flyout",
|
|
1880
|
+
side: "right",
|
|
1881
|
+
align: "start",
|
|
1882
|
+
sideOffset: 8,
|
|
1883
|
+
className: "max-h-[70vh] w-48 overflow-auto p-1",
|
|
1884
|
+
initialFocus: false,
|
|
1885
|
+
onMouseEnter: flyoutOpenNow,
|
|
1886
|
+
onMouseLeave: flyoutCloseLater,
|
|
1887
|
+
onClick: (event) => {
|
|
1888
|
+
if (event.target.closest("[data-slot=menu-item]")) {
|
|
1889
|
+
setFlyoutOpen(false);
|
|
1890
|
+
}
|
|
1891
|
+
},
|
|
1892
|
+
children: [
|
|
1893
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "px-3 pt-2 pb-1 text-xs font-semibold text-muted-foreground", children: item.label }),
|
|
1894
|
+
item.children?.map((child) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1895
|
+
MenuEntry,
|
|
1896
|
+
{
|
|
1897
|
+
item: child,
|
|
1898
|
+
mode: "inline",
|
|
1899
|
+
depth: 0,
|
|
1900
|
+
selectedKey,
|
|
1901
|
+
onSelect
|
|
1902
|
+
},
|
|
1903
|
+
child.key
|
|
1904
|
+
))
|
|
1905
|
+
]
|
|
1906
|
+
}
|
|
1907
|
+
)
|
|
1908
|
+
] }) : collapsed ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(RailTooltip, { label: item.label, children: button }) : button,
|
|
1909
|
+
railDirectory || isDirectory && !expanded ? null : item.children?.map((child) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1371
1910
|
MenuEntry,
|
|
1372
1911
|
{
|
|
1373
1912
|
item: child,
|
|
@@ -1375,7 +1914,10 @@ function MenuEntry({
|
|
|
1375
1914
|
depth: depth + 1,
|
|
1376
1915
|
selectedKey,
|
|
1377
1916
|
onSelect,
|
|
1378
|
-
collapsed
|
|
1917
|
+
collapsed,
|
|
1918
|
+
collapsible,
|
|
1919
|
+
expandedKeys,
|
|
1920
|
+
onToggle
|
|
1379
1921
|
},
|
|
1380
1922
|
child.key
|
|
1381
1923
|
))
|
|
@@ -1383,7 +1925,7 @@ function MenuEntry({
|
|
|
1383
1925
|
}
|
|
1384
1926
|
|
|
1385
1927
|
// src/layout/chat/ChatLayout.tsx
|
|
1386
|
-
var
|
|
1928
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1387
1929
|
function ChatLayout({
|
|
1388
1930
|
brand,
|
|
1389
1931
|
menu,
|
|
@@ -1398,7 +1940,7 @@ function ChatLayout({
|
|
|
1398
1940
|
sidebarFooter,
|
|
1399
1941
|
children
|
|
1400
1942
|
}) {
|
|
1401
|
-
const registryMenus = (0,
|
|
1943
|
+
const registryMenus = (0, import_react6.useMemo)(() => {
|
|
1402
1944
|
if (menu !== void 0 || registry === void 0) {
|
|
1403
1945
|
return [];
|
|
1404
1946
|
}
|
|
@@ -1407,10 +1949,10 @@ function ChatLayout({
|
|
|
1407
1949
|
return visible.flatMap((item) => menuItemToMenuData(item));
|
|
1408
1950
|
}, [menu, registry, permissionChecker]);
|
|
1409
1951
|
const menuItems = menu ?? registryMenus;
|
|
1410
|
-
const [bridgePath, setBridgePath] = (0,
|
|
1952
|
+
const [bridgePath, setBridgePath] = (0, import_react6.useState)(
|
|
1411
1953
|
() => bridge?.getLocation().pathname ?? "/"
|
|
1412
1954
|
);
|
|
1413
|
-
(0,
|
|
1955
|
+
(0, import_react6.useEffect)(() => {
|
|
1414
1956
|
if (bridge === void 0) {
|
|
1415
1957
|
return;
|
|
1416
1958
|
}
|
|
@@ -1418,7 +1960,7 @@ function ChatLayout({
|
|
|
1418
1960
|
setBridgePath(location.pathname);
|
|
1419
1961
|
});
|
|
1420
1962
|
}, [bridge]);
|
|
1421
|
-
const activeKey = (0,
|
|
1963
|
+
const activeKey = (0, import_react6.useMemo)(() => {
|
|
1422
1964
|
if (activeMenuKey !== void 0) {
|
|
1423
1965
|
return activeMenuKey;
|
|
1424
1966
|
}
|
|
@@ -1438,7 +1980,7 @@ function ChatLayout({
|
|
|
1438
1980
|
bridge.push(item.path);
|
|
1439
1981
|
}
|
|
1440
1982
|
};
|
|
1441
|
-
const sidebarContent = sidebar !== void 0 && sidebar !== null ? sidebar : menuItems.length > 0 ? /* @__PURE__ */ (0,
|
|
1983
|
+
const sidebarContent = sidebar !== void 0 && sidebar !== null ? sidebar : menuItems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1442
1984
|
Menu2,
|
|
1443
1985
|
{
|
|
1444
1986
|
items: menuItems.map((item) => chatMenuItemToUiMenuItem(item)),
|
|
@@ -1446,7 +1988,7 @@ function ChatLayout({
|
|
|
1446
1988
|
onSelect: handleSelect
|
|
1447
1989
|
}
|
|
1448
1990
|
) : void 0;
|
|
1449
|
-
return /* @__PURE__ */ (0,
|
|
1991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1450
1992
|
Sidebar,
|
|
1451
1993
|
{
|
|
1452
1994
|
brand,
|
|
@@ -1454,7 +1996,7 @@ function ChatLayout({
|
|
|
1454
1996
|
sidebarFooter,
|
|
1455
1997
|
collapsible,
|
|
1456
1998
|
locationKey: routeProp?.path ?? bridgePath,
|
|
1457
|
-
children: /* @__PURE__ */ (0,
|
|
1999
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1458
2000
|
"div",
|
|
1459
2001
|
{
|
|
1460
2002
|
"data-slot": "chat-layout-content",
|
|
@@ -1508,14 +2050,14 @@ function menuItemToMenuData(item) {
|
|
|
1508
2050
|
}
|
|
1509
2051
|
|
|
1510
2052
|
// src/ui/card.tsx
|
|
1511
|
-
var
|
|
2053
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1512
2054
|
function Card({ className, ...props }) {
|
|
1513
|
-
return /* @__PURE__ */ (0,
|
|
2055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1514
2056
|
"div",
|
|
1515
2057
|
{
|
|
1516
2058
|
"data-slot": "card",
|
|
1517
2059
|
className: cn(
|
|
1518
|
-
"flex flex-col gap-6 rounded-xl border border-border bg-card py-6 text-card-foreground shadow-
|
|
2060
|
+
"flex flex-col gap-6 rounded-xl border border-border bg-card py-6 text-card-foreground shadow-(--card-shadow)",
|
|
1519
2061
|
className
|
|
1520
2062
|
),
|
|
1521
2063
|
...props
|
|
@@ -1523,7 +2065,7 @@ function Card({ className, ...props }) {
|
|
|
1523
2065
|
);
|
|
1524
2066
|
}
|
|
1525
2067
|
function CardHeader({ className, ...props }) {
|
|
1526
|
-
return /* @__PURE__ */ (0,
|
|
2068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1527
2069
|
"div",
|
|
1528
2070
|
{
|
|
1529
2071
|
"data-slot": "card-header",
|
|
@@ -1536,7 +2078,7 @@ function CardHeader({ className, ...props }) {
|
|
|
1536
2078
|
);
|
|
1537
2079
|
}
|
|
1538
2080
|
function CardTitle({ className, ...props }) {
|
|
1539
|
-
return /* @__PURE__ */ (0,
|
|
2081
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1540
2082
|
"div",
|
|
1541
2083
|
{
|
|
1542
2084
|
"data-slot": "card-title",
|
|
@@ -1546,7 +2088,7 @@ function CardTitle({ className, ...props }) {
|
|
|
1546
2088
|
);
|
|
1547
2089
|
}
|
|
1548
2090
|
function CardContent({ className, ...props }) {
|
|
1549
|
-
return /* @__PURE__ */ (0,
|
|
2091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1550
2092
|
"div",
|
|
1551
2093
|
{
|
|
1552
2094
|
"data-slot": "card-content",
|
|
@@ -1557,26 +2099,26 @@ function CardContent({ className, ...props }) {
|
|
|
1557
2099
|
}
|
|
1558
2100
|
|
|
1559
2101
|
// src/layout/basic/LoginLayout.tsx
|
|
1560
|
-
var
|
|
2102
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1561
2103
|
function LoginLayout({
|
|
1562
2104
|
variant = "center",
|
|
1563
2105
|
brand,
|
|
1564
2106
|
children
|
|
1565
2107
|
}) {
|
|
1566
|
-
const brandBlock = /* @__PURE__ */ (0,
|
|
2108
|
+
const brandBlock = /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { "data-slot": "login-brand", className: "flex flex-col items-center gap-2", children: [
|
|
1567
2109
|
brand.logo,
|
|
1568
|
-
/* @__PURE__ */ (0,
|
|
1569
|
-
brand.description !== void 0 && /* @__PURE__ */ (0,
|
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h1", { className: "text-xl font-semibold", children: brand.title }),
|
|
2111
|
+
brand.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "text-sm text-muted-foreground", children: brand.description })
|
|
1570
2112
|
] });
|
|
1571
2113
|
if (variant === "split") {
|
|
1572
|
-
return /* @__PURE__ */ (0,
|
|
2114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1573
2115
|
"div",
|
|
1574
2116
|
{
|
|
1575
2117
|
"data-slot": "login-layout",
|
|
1576
2118
|
"data-variant": "split",
|
|
1577
2119
|
className: "grid min-h-screen grid-cols-2 bg-background text-foreground",
|
|
1578
2120
|
children: [
|
|
1579
|
-
/* @__PURE__ */ (0,
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1580
2122
|
"div",
|
|
1581
2123
|
{
|
|
1582
2124
|
"data-slot": "login-brand-panel",
|
|
@@ -1584,7 +2126,7 @@ function LoginLayout({
|
|
|
1584
2126
|
children: brandBlock
|
|
1585
2127
|
}
|
|
1586
2128
|
),
|
|
1587
|
-
/* @__PURE__ */ (0,
|
|
2129
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1588
2130
|
"div",
|
|
1589
2131
|
{
|
|
1590
2132
|
"data-slot": "login-form-panel",
|
|
@@ -1596,46 +2138,46 @@ function LoginLayout({
|
|
|
1596
2138
|
}
|
|
1597
2139
|
);
|
|
1598
2140
|
}
|
|
1599
|
-
return /* @__PURE__ */ (0,
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1600
2142
|
"div",
|
|
1601
2143
|
{
|
|
1602
2144
|
"data-slot": "login-layout",
|
|
1603
2145
|
"data-variant": "center",
|
|
1604
2146
|
className: "flex min-h-screen items-center justify-center bg-muted/40 text-foreground",
|
|
1605
|
-
children: /* @__PURE__ */ (0,
|
|
1606
|
-
/* @__PURE__ */ (0,
|
|
1607
|
-
/* @__PURE__ */ (0,
|
|
2147
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Card, { "data-slot": "login-card", className: "w-full max-w-sm gap-4 py-6", children: [
|
|
2148
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(CardHeader, { className: "px-6", children: [
|
|
2149
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CardTitle, { className: "sr-only", children: brand.title }),
|
|
1608
2150
|
brandBlock
|
|
1609
2151
|
] }),
|
|
1610
|
-
/* @__PURE__ */ (0,
|
|
2152
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CardContent, { className: "flex flex-col gap-4 px-6", children })
|
|
1611
2153
|
] })
|
|
1612
2154
|
}
|
|
1613
2155
|
);
|
|
1614
2156
|
}
|
|
1615
2157
|
|
|
1616
2158
|
// src/layout/basic/LandingLayout.tsx
|
|
1617
|
-
var
|
|
2159
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1618
2160
|
function LandingLayout({
|
|
1619
2161
|
navbar,
|
|
1620
2162
|
footer,
|
|
1621
2163
|
children
|
|
1622
2164
|
}) {
|
|
1623
|
-
return /* @__PURE__ */ (0,
|
|
2165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1624
2166
|
"div",
|
|
1625
2167
|
{
|
|
1626
2168
|
"data-slot": "landing-layout",
|
|
1627
2169
|
className: "flex min-h-screen flex-col bg-background text-foreground",
|
|
1628
2170
|
children: [
|
|
1629
|
-
navbar !== void 0 && /* @__PURE__ */ (0,
|
|
2171
|
+
navbar !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1630
2172
|
"header",
|
|
1631
2173
|
{
|
|
1632
2174
|
"data-slot": "landing-navbar",
|
|
1633
|
-
className: "border-b border-border bg-
|
|
2175
|
+
className: "border-b border-border bg-card",
|
|
1634
2176
|
children: navbar
|
|
1635
2177
|
}
|
|
1636
2178
|
),
|
|
1637
|
-
/* @__PURE__ */ (0,
|
|
1638
|
-
footer !== void 0 && /* @__PURE__ */ (0,
|
|
2179
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("main", { "data-slot": "landing-content", className: "flex-1", children }),
|
|
2180
|
+
footer !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1639
2181
|
"footer",
|
|
1640
2182
|
{
|
|
1641
2183
|
"data-slot": "landing-footer",
|