@pactor-app/ui 1.0.0 → 1.2.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 +25 -31
- package/dist/{chunk-D6G4J5XS.js → chunk-22TEN3ER.js} +169 -38
- package/dist/{chunk-GL7IO22L.js → chunk-2LYMCWEJ.js} +65 -1
- package/dist/chunk-HJPHJKVA.js +671 -0
- package/dist/{chunk-BZSRLTQQ.js → chunk-L45CSL6I.js} +5 -5
- package/dist/{chunk-FVZMNP5P.js → chunk-LMEJ242M.js} +357 -442
- package/dist/{chunk-TUXCPXPA.js → chunk-Q5NUGUJG.js} +195 -259
- package/dist/components/index.cjs +1123 -796
- package/dist/components/index.d.cts +105 -21
- package/dist/components/index.d.ts +105 -21
- package/dist/components/index.js +18 -14
- package/dist/index.cjs +1433 -988
- package/dist/index.d.cts +3 -36
- package/dist/index.d.ts +3 -36
- package/dist/index.js +38 -43
- package/dist/interaction/index.cjs +7 -7
- package/dist/interaction/index.d.cts +13 -16
- package/dist/interaction/index.d.ts +13 -16
- package/dist/interaction/index.js +5 -5
- package/dist/layout/index.cjs +655 -52
- package/dist/layout/index.d.cts +97 -19
- package/dist/layout/index.d.ts +97 -19
- package/dist/layout/index.js +17 -15
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +7 -7
- package/package.json +5 -5
- package/styles.css +88 -7
- package/dist/chunk-UR3I4WXQ.js +0 -236
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Tooltip,
|
|
3
|
+
TooltipContent,
|
|
4
|
+
TooltipTrigger
|
|
5
|
+
} from "./chunk-2LYMCWEJ.js";
|
|
6
|
+
import {
|
|
7
|
+
cn
|
|
8
|
+
} from "./chunk-RQHJBTEU.js";
|
|
9
|
+
|
|
10
|
+
// src/components/components/Icon/index.tsx
|
|
11
|
+
import {
|
|
12
|
+
ArrowDown,
|
|
13
|
+
ArrowLeft,
|
|
14
|
+
ArrowRight,
|
|
15
|
+
ArrowUp,
|
|
16
|
+
Bell,
|
|
17
|
+
Bookmark,
|
|
18
|
+
Brain,
|
|
19
|
+
Briefcase,
|
|
20
|
+
Building2,
|
|
21
|
+
Calendar,
|
|
22
|
+
Camera,
|
|
23
|
+
ChartColumn,
|
|
24
|
+
Check,
|
|
25
|
+
ChevronDown,
|
|
26
|
+
ChevronLeft,
|
|
27
|
+
ChevronRight,
|
|
28
|
+
ChevronsUpDown,
|
|
29
|
+
ChevronUp,
|
|
30
|
+
CircleAlert,
|
|
31
|
+
CircleCheck,
|
|
32
|
+
CircleQuestionMark,
|
|
33
|
+
CircleX,
|
|
34
|
+
Clock,
|
|
35
|
+
Cloud,
|
|
36
|
+
Code,
|
|
37
|
+
Copy,
|
|
38
|
+
CreditCard,
|
|
39
|
+
Database,
|
|
40
|
+
Download,
|
|
41
|
+
Ellipsis,
|
|
42
|
+
EllipsisVertical,
|
|
43
|
+
ExternalLink,
|
|
44
|
+
Eye,
|
|
45
|
+
File,
|
|
46
|
+
FileText,
|
|
47
|
+
Flag,
|
|
48
|
+
Folder,
|
|
49
|
+
Funnel,
|
|
50
|
+
Globe,
|
|
51
|
+
Heart,
|
|
52
|
+
History,
|
|
53
|
+
House,
|
|
54
|
+
Image,
|
|
55
|
+
Info,
|
|
56
|
+
Key,
|
|
57
|
+
Languages,
|
|
58
|
+
LayoutGrid,
|
|
59
|
+
Link,
|
|
60
|
+
List,
|
|
61
|
+
ListFilter,
|
|
62
|
+
LoaderCircle,
|
|
63
|
+
Lock,
|
|
64
|
+
LockOpen,
|
|
65
|
+
LogIn,
|
|
66
|
+
LogOut,
|
|
67
|
+
Mail,
|
|
68
|
+
MapPin,
|
|
69
|
+
Menu,
|
|
70
|
+
MessageCircle,
|
|
71
|
+
MessageSquare,
|
|
72
|
+
Minus,
|
|
73
|
+
Moon,
|
|
74
|
+
Package,
|
|
75
|
+
PanelLeft,
|
|
76
|
+
PanelRightOpen,
|
|
77
|
+
Paperclip,
|
|
78
|
+
Pencil,
|
|
79
|
+
Phone,
|
|
80
|
+
Plus,
|
|
81
|
+
Quote,
|
|
82
|
+
RefreshCcw,
|
|
83
|
+
RotateCcw,
|
|
84
|
+
Save,
|
|
85
|
+
Search,
|
|
86
|
+
Send,
|
|
87
|
+
Settings,
|
|
88
|
+
Share2,
|
|
89
|
+
Shield,
|
|
90
|
+
ShoppingCart,
|
|
91
|
+
Square,
|
|
92
|
+
SquarePen,
|
|
93
|
+
Star,
|
|
94
|
+
Sun,
|
|
95
|
+
Table,
|
|
96
|
+
Tag,
|
|
97
|
+
Terminal,
|
|
98
|
+
ThumbsDown,
|
|
99
|
+
ThumbsUp,
|
|
100
|
+
Trash2,
|
|
101
|
+
TriangleAlert,
|
|
102
|
+
Upload,
|
|
103
|
+
User,
|
|
104
|
+
Users,
|
|
105
|
+
X,
|
|
106
|
+
Zap
|
|
107
|
+
} from "lucide-react";
|
|
108
|
+
import { jsx } from "react/jsx-runtime";
|
|
109
|
+
var ICONS = {
|
|
110
|
+
"arrow-left": ArrowLeft,
|
|
111
|
+
"arrow-right": ArrowRight,
|
|
112
|
+
"arrow-up": ArrowUp,
|
|
113
|
+
"arrow-down": ArrowDown,
|
|
114
|
+
"chevron-left": ChevronLeft,
|
|
115
|
+
"chevron-right": ChevronRight,
|
|
116
|
+
"chevron-up": ChevronUp,
|
|
117
|
+
"chevron-down": ChevronDown,
|
|
118
|
+
check: Check,
|
|
119
|
+
x: X,
|
|
120
|
+
plus: Plus,
|
|
121
|
+
minus: Minus,
|
|
122
|
+
search: Search,
|
|
123
|
+
settings: Settings,
|
|
124
|
+
user: User,
|
|
125
|
+
users: Users,
|
|
126
|
+
home: House,
|
|
127
|
+
menu: Menu,
|
|
128
|
+
bell: Bell,
|
|
129
|
+
calendar: Calendar,
|
|
130
|
+
clock: Clock,
|
|
131
|
+
download: Download,
|
|
132
|
+
upload: Upload,
|
|
133
|
+
pencil: Pencil,
|
|
134
|
+
edit: SquarePen,
|
|
135
|
+
trash: Trash2,
|
|
136
|
+
eye: Eye,
|
|
137
|
+
info: Info,
|
|
138
|
+
warning: TriangleAlert,
|
|
139
|
+
error: CircleAlert,
|
|
140
|
+
"check-circle": CircleCheck,
|
|
141
|
+
"x-circle": CircleX,
|
|
142
|
+
"help-circle": CircleQuestionMark,
|
|
143
|
+
loading: LoaderCircle,
|
|
144
|
+
spinner: LoaderCircle,
|
|
145
|
+
star: Star,
|
|
146
|
+
heart: Heart,
|
|
147
|
+
bookmark: Bookmark,
|
|
148
|
+
share: Share2,
|
|
149
|
+
copy: Copy,
|
|
150
|
+
"external-link": ExternalLink,
|
|
151
|
+
link: Link,
|
|
152
|
+
mail: Mail,
|
|
153
|
+
phone: Phone,
|
|
154
|
+
lock: Lock,
|
|
155
|
+
unlock: LockOpen,
|
|
156
|
+
"log-in": LogIn,
|
|
157
|
+
"log-out": LogOut,
|
|
158
|
+
sun: Sun,
|
|
159
|
+
moon: Moon,
|
|
160
|
+
globe: Globe,
|
|
161
|
+
filter: Funnel,
|
|
162
|
+
"list-filter": ListFilter,
|
|
163
|
+
"more-horizontal": Ellipsis,
|
|
164
|
+
"more-vertical": EllipsisVertical,
|
|
165
|
+
refresh: RefreshCcw,
|
|
166
|
+
save: Save,
|
|
167
|
+
file: File,
|
|
168
|
+
folder: Folder,
|
|
169
|
+
image: Image,
|
|
170
|
+
camera: Camera,
|
|
171
|
+
chart: ChartColumn,
|
|
172
|
+
table: Table,
|
|
173
|
+
list: List,
|
|
174
|
+
grid: LayoutGrid,
|
|
175
|
+
tag: Tag,
|
|
176
|
+
"shopping-cart": ShoppingCart,
|
|
177
|
+
"credit-card": CreditCard,
|
|
178
|
+
package: Package,
|
|
179
|
+
"map-pin": MapPin,
|
|
180
|
+
building: Building2,
|
|
181
|
+
briefcase: Briefcase,
|
|
182
|
+
send: Send,
|
|
183
|
+
message: MessageCircle,
|
|
184
|
+
"message-square": MessageSquare,
|
|
185
|
+
paperclip: Paperclip,
|
|
186
|
+
"thumbs-up": ThumbsUp,
|
|
187
|
+
"thumbs-down": ThumbsDown,
|
|
188
|
+
zap: Zap,
|
|
189
|
+
flag: Flag,
|
|
190
|
+
key: Key,
|
|
191
|
+
shield: Shield,
|
|
192
|
+
terminal: Terminal,
|
|
193
|
+
code: Code,
|
|
194
|
+
database: Database,
|
|
195
|
+
cloud: Cloud,
|
|
196
|
+
languages: Languages,
|
|
197
|
+
// @pactor-app/chat 收敛(spec: chat-icon-convergence):chat 既有图标与
|
|
198
|
+
// 契约图标名(menu.icon / messageActions[].icon 的既有取值)直通
|
|
199
|
+
"chevrons-up-down": ChevronsUpDown,
|
|
200
|
+
"file-text": FileText,
|
|
201
|
+
"panel-left": PanelLeft,
|
|
202
|
+
"panel-right-open": PanelRightOpen,
|
|
203
|
+
square: Square,
|
|
204
|
+
history: History,
|
|
205
|
+
"rotate-ccw": RotateCcw,
|
|
206
|
+
quote: Quote,
|
|
207
|
+
chat: MessageSquare,
|
|
208
|
+
brain: Brain
|
|
209
|
+
};
|
|
210
|
+
function normalizeIconName(name) {
|
|
211
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
|
|
212
|
+
}
|
|
213
|
+
var sizePx = {
|
|
214
|
+
sm: 16,
|
|
215
|
+
default: 20,
|
|
216
|
+
lg: 24
|
|
217
|
+
};
|
|
218
|
+
function Icon({
|
|
219
|
+
name,
|
|
220
|
+
size = "default",
|
|
221
|
+
color,
|
|
222
|
+
strokeWidth,
|
|
223
|
+
className,
|
|
224
|
+
style
|
|
225
|
+
}) {
|
|
226
|
+
const key = name ? normalizeIconName(name) : "";
|
|
227
|
+
const Lucide = ICONS[key];
|
|
228
|
+
const px = typeof size === "number" ? size : sizePx[size];
|
|
229
|
+
if (!Lucide) {
|
|
230
|
+
return /* @__PURE__ */ jsx(
|
|
231
|
+
CircleQuestionMark,
|
|
232
|
+
{
|
|
233
|
+
"data-slot": "icon",
|
|
234
|
+
"data-unknown": name,
|
|
235
|
+
size: px,
|
|
236
|
+
color,
|
|
237
|
+
strokeWidth,
|
|
238
|
+
className: cn("shrink-0 text-muted-foreground", className),
|
|
239
|
+
style,
|
|
240
|
+
"aria-hidden": "true"
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return /* @__PURE__ */ jsx(
|
|
245
|
+
Lucide,
|
|
246
|
+
{
|
|
247
|
+
"data-slot": "icon",
|
|
248
|
+
size: px,
|
|
249
|
+
color,
|
|
250
|
+
strokeWidth,
|
|
251
|
+
className: cn("shrink-0", className),
|
|
252
|
+
style,
|
|
253
|
+
"aria-hidden": "true"
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// src/components/components/Sidebar/rail-tooltip.tsx
|
|
259
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
260
|
+
function RailTooltip({
|
|
261
|
+
label,
|
|
262
|
+
children
|
|
263
|
+
}) {
|
|
264
|
+
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
265
|
+
/* @__PURE__ */ jsx2(TooltipTrigger, { render: children }),
|
|
266
|
+
/* @__PURE__ */ jsx2(TooltipContent, { side: "right", sideOffset: 8, children: label })
|
|
267
|
+
] });
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/components/components/Sidebar/index.tsx
|
|
271
|
+
import { useI18n, useRenderer } from "@pactor-app/runtime";
|
|
272
|
+
import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2 } from "lucide-react";
|
|
273
|
+
import {
|
|
274
|
+
createContext,
|
|
275
|
+
useCallback,
|
|
276
|
+
useContext,
|
|
277
|
+
useEffect,
|
|
278
|
+
useState
|
|
279
|
+
} from "react";
|
|
280
|
+
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
281
|
+
var SidebarDrawerContext = createContext(null);
|
|
282
|
+
function useSidebarDrawer() {
|
|
283
|
+
return useContext(SidebarDrawerContext);
|
|
284
|
+
}
|
|
285
|
+
var MOBILE_MEDIA_QUERY = "(max-width: 767px)";
|
|
286
|
+
function useIsMobileViewport() {
|
|
287
|
+
const [isMobile, setIsMobile] = useState(
|
|
288
|
+
() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(MOBILE_MEDIA_QUERY).matches
|
|
289
|
+
);
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (typeof window.matchMedia !== "function") {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const media = window.matchMedia(MOBILE_MEDIA_QUERY);
|
|
295
|
+
const onChange = (event) => {
|
|
296
|
+
setIsMobile(event.matches);
|
|
297
|
+
};
|
|
298
|
+
setIsMobile(media.matches);
|
|
299
|
+
media.addEventListener("change", onChange);
|
|
300
|
+
return () => media.removeEventListener("change", onChange);
|
|
301
|
+
}, []);
|
|
302
|
+
return isMobile;
|
|
303
|
+
}
|
|
304
|
+
function useOptionalRenderer() {
|
|
305
|
+
try {
|
|
306
|
+
return useRenderer();
|
|
307
|
+
} catch {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function SidebarContent({ content }) {
|
|
312
|
+
const renderer = useOptionalRenderer();
|
|
313
|
+
if (renderer !== null && typeof content === "object" && content !== null && !("$$typeof" in content) && "type" in content) {
|
|
314
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: renderer.renderChildren([content]) });
|
|
315
|
+
}
|
|
316
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: content });
|
|
317
|
+
}
|
|
318
|
+
function isBrandObject(brand) {
|
|
319
|
+
return typeof brand === "object" && brand !== null && !("$$typeof" in brand) && "title" in brand;
|
|
320
|
+
}
|
|
321
|
+
function Sidebar({
|
|
322
|
+
brand,
|
|
323
|
+
items = [],
|
|
324
|
+
content,
|
|
325
|
+
sidebarFooter,
|
|
326
|
+
collapsible,
|
|
327
|
+
onCollapse,
|
|
328
|
+
locationKey,
|
|
329
|
+
drawer = true,
|
|
330
|
+
className,
|
|
331
|
+
style,
|
|
332
|
+
children
|
|
333
|
+
}) {
|
|
334
|
+
const { t } = useI18n();
|
|
335
|
+
const isMobile = useIsMobileViewport();
|
|
336
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
337
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
338
|
+
const collapsedEffective = collapsible === true && collapsed && !isMobile;
|
|
339
|
+
const close = useCallback(() => setDrawerOpen(false), []);
|
|
340
|
+
const toggleCollapsed = () => {
|
|
341
|
+
const next = !collapsed;
|
|
342
|
+
setCollapsed(next);
|
|
343
|
+
onCollapse?.(next);
|
|
344
|
+
};
|
|
345
|
+
const [trackedLocationKey, setTrackedLocationKey] = useState(locationKey);
|
|
346
|
+
if (trackedLocationKey !== locationKey) {
|
|
347
|
+
setTrackedLocationKey(locationKey);
|
|
348
|
+
setDrawerOpen(false);
|
|
349
|
+
}
|
|
350
|
+
useEffect(() => {
|
|
351
|
+
if (!drawerOpen) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const onKeyDown = (event) => {
|
|
355
|
+
if (event.key === "Escape") {
|
|
356
|
+
setDrawerOpen(false);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
window.addEventListener("keydown", onKeyDown);
|
|
360
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
361
|
+
}, [drawerOpen]);
|
|
362
|
+
const brandNode = isBrandObject(brand) ? /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
363
|
+
brand.logo ? /* @__PURE__ */ jsx3(
|
|
364
|
+
"img",
|
|
365
|
+
{
|
|
366
|
+
"data-slot": "sidebar-brand-logo",
|
|
367
|
+
src: brand.logo,
|
|
368
|
+
alt: brand.title,
|
|
369
|
+
className: "size-6 shrink-0"
|
|
370
|
+
}
|
|
371
|
+
) : null,
|
|
372
|
+
collapsedEffective ? null : /* @__PURE__ */ jsx3("span", { className: "truncate text-sm font-semibold", children: brand.title })
|
|
373
|
+
] }) : brand;
|
|
374
|
+
const collapseTrigger = collapsible && !isMobile ? /* @__PURE__ */ jsx3(
|
|
375
|
+
"button",
|
|
376
|
+
{
|
|
377
|
+
type: "button",
|
|
378
|
+
"data-slot": "sidebar-collapse-trigger",
|
|
379
|
+
"aria-label": collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
380
|
+
"aria-expanded": !collapsedEffective,
|
|
381
|
+
title: collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
|
|
382
|
+
className: cn(
|
|
383
|
+
"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"
|
|
384
|
+
),
|
|
385
|
+
onClick: toggleCollapsed,
|
|
386
|
+
children: collapsedEffective ? /* @__PURE__ */ jsx3(ChevronRight2, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ jsx3(ChevronLeft2, { "aria-hidden": true, className: "size-4" })
|
|
387
|
+
}
|
|
388
|
+
) : null;
|
|
389
|
+
return /* @__PURE__ */ jsx3(
|
|
390
|
+
SidebarDrawerContext.Provider,
|
|
391
|
+
{
|
|
392
|
+
value: { close, collapsed: collapsedEffective },
|
|
393
|
+
children: /* @__PURE__ */ jsxs2(
|
|
394
|
+
"div",
|
|
395
|
+
{
|
|
396
|
+
"data-slot": "sidebar-layout",
|
|
397
|
+
className: cn("flex min-h-screen w-full", className),
|
|
398
|
+
style,
|
|
399
|
+
children: [
|
|
400
|
+
drawer && drawerOpen ? /* @__PURE__ */ jsx3(
|
|
401
|
+
"div",
|
|
402
|
+
{
|
|
403
|
+
"data-slot": "sidebar-scrim",
|
|
404
|
+
"aria-hidden": true,
|
|
405
|
+
className: "fixed inset-0 z-40 bg-black/40 md:hidden",
|
|
406
|
+
onClick: close
|
|
407
|
+
}
|
|
408
|
+
) : null,
|
|
409
|
+
/* @__PURE__ */ jsxs2(
|
|
410
|
+
"aside",
|
|
411
|
+
{
|
|
412
|
+
"data-slot": "sidebar",
|
|
413
|
+
"data-collapsed": collapsedEffective || void 0,
|
|
414
|
+
"data-open": drawerOpen ? "true" : "false",
|
|
415
|
+
inert: drawer && isMobile && !drawerOpen ? true : void 0,
|
|
416
|
+
className: cn(
|
|
417
|
+
"flex shrink-0 flex-col border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-[width,transform]",
|
|
418
|
+
collapsedEffective ? "w-16" : "w-60",
|
|
419
|
+
// 移动端覆盖抽屉:退出文档流,关闭时移出屏幕
|
|
420
|
+
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"
|
|
421
|
+
),
|
|
422
|
+
children: [
|
|
423
|
+
brand !== void 0 || collapseTrigger !== null ? /* @__PURE__ */ jsxs2(
|
|
424
|
+
"div",
|
|
425
|
+
{
|
|
426
|
+
"data-slot": "sidebar-brand",
|
|
427
|
+
className: cn(
|
|
428
|
+
"flex h-14 shrink-0 items-center gap-2 border-b border-sidebar-border px-4",
|
|
429
|
+
// 移动端品牌维持顶栏现状:抽屉内不重复渲染品牌行
|
|
430
|
+
"max-md:hidden",
|
|
431
|
+
collapsedEffective && "justify-center px-2"
|
|
432
|
+
),
|
|
433
|
+
children: [
|
|
434
|
+
collapsedEffective ? null : /* @__PURE__ */ jsx3("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: brandNode }),
|
|
435
|
+
collapseTrigger
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
) : null,
|
|
439
|
+
/* @__PURE__ */ jsx3(
|
|
440
|
+
"nav",
|
|
441
|
+
{
|
|
442
|
+
"data-slot": "sidebar-nav",
|
|
443
|
+
className: "min-h-0 flex-1 overflow-auto p-2",
|
|
444
|
+
children: content !== void 0 && content !== null ? /* @__PURE__ */ jsx3(SidebarContent, { content }) : items.map((item, index) => /* @__PURE__ */ jsx3(
|
|
445
|
+
SidebarEntry,
|
|
446
|
+
{
|
|
447
|
+
item,
|
|
448
|
+
depth: 0,
|
|
449
|
+
collapsed: collapsedEffective
|
|
450
|
+
},
|
|
451
|
+
item.href ?? item.label ?? index
|
|
452
|
+
))
|
|
453
|
+
}
|
|
454
|
+
),
|
|
455
|
+
sidebarFooter !== void 0 && sidebarFooter !== null && !collapsedEffective ? /* @__PURE__ */ jsx3(
|
|
456
|
+
"div",
|
|
457
|
+
{
|
|
458
|
+
"data-slot": "sidebar-footer",
|
|
459
|
+
className: "shrink-0 border-t border-sidebar-border p-2",
|
|
460
|
+
children: sidebarFooter
|
|
461
|
+
}
|
|
462
|
+
) : null
|
|
463
|
+
]
|
|
464
|
+
}
|
|
465
|
+
),
|
|
466
|
+
/* @__PURE__ */ jsxs2(
|
|
467
|
+
"main",
|
|
468
|
+
{
|
|
469
|
+
"data-slot": "sidebar-content",
|
|
470
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
471
|
+
children: [
|
|
472
|
+
drawer ? /* @__PURE__ */ jsxs2(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
"data-slot": "sidebar-topbar",
|
|
476
|
+
className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
|
|
477
|
+
children: [
|
|
478
|
+
/* @__PURE__ */ jsx3(
|
|
479
|
+
"button",
|
|
480
|
+
{
|
|
481
|
+
type: "button",
|
|
482
|
+
"data-slot": "sidebar-menu-trigger",
|
|
483
|
+
"aria-label": t("pactor.layout.openNavigation"),
|
|
484
|
+
"aria-expanded": drawerOpen,
|
|
485
|
+
className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
|
|
486
|
+
onClick: () => setDrawerOpen(true),
|
|
487
|
+
children: /* @__PURE__ */ jsx3(Icon, { name: "menu", size: 18 })
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
brandNode
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
) : null,
|
|
494
|
+
children
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
)
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
function SidebarEntry({
|
|
505
|
+
item,
|
|
506
|
+
depth,
|
|
507
|
+
collapsed
|
|
508
|
+
}) {
|
|
509
|
+
const entryClass = cn(
|
|
510
|
+
"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors",
|
|
511
|
+
"text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
512
|
+
collapsed && "justify-center px-0"
|
|
513
|
+
);
|
|
514
|
+
const indentStyle = !collapsed && depth > 0 ? { paddingLeft: 12 + depth * 16 } : void 0;
|
|
515
|
+
const labelNode = collapsed ? null : item.label;
|
|
516
|
+
const iconNode = item.icon ? /* @__PURE__ */ jsx3(Icon, { name: item.icon, size: "sm" }) : null;
|
|
517
|
+
const entry = item.href ? /* @__PURE__ */ jsxs2(
|
|
518
|
+
"a",
|
|
519
|
+
{
|
|
520
|
+
"data-slot": "sidebar-item",
|
|
521
|
+
href: item.href,
|
|
522
|
+
className: entryClass,
|
|
523
|
+
style: indentStyle,
|
|
524
|
+
children: [
|
|
525
|
+
iconNode,
|
|
526
|
+
labelNode
|
|
527
|
+
]
|
|
528
|
+
}
|
|
529
|
+
) : /* @__PURE__ */ jsxs2("span", { "data-slot": "sidebar-item", className: entryClass, style: indentStyle, children: [
|
|
530
|
+
iconNode,
|
|
531
|
+
labelNode
|
|
532
|
+
] });
|
|
533
|
+
return /* @__PURE__ */ jsxs2("div", { "data-slot": "sidebar-entry", children: [
|
|
534
|
+
collapsed ? /* @__PURE__ */ jsx3(RailTooltip, { label: item.label, children: entry }) : entry,
|
|
535
|
+
item.children?.map((child, index) => /* @__PURE__ */ jsx3(
|
|
536
|
+
SidebarEntry,
|
|
537
|
+
{
|
|
538
|
+
item: child,
|
|
539
|
+
depth: depth + 1,
|
|
540
|
+
collapsed
|
|
541
|
+
},
|
|
542
|
+
child.href ?? child.label ?? index
|
|
543
|
+
))
|
|
544
|
+
] });
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/components/components/Menu/index.tsx
|
|
548
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
549
|
+
function Menu2({
|
|
550
|
+
items = [],
|
|
551
|
+
mode = "inline",
|
|
552
|
+
selectedKey,
|
|
553
|
+
onSelect,
|
|
554
|
+
className,
|
|
555
|
+
style
|
|
556
|
+
}) {
|
|
557
|
+
const drawer = useSidebarDrawer();
|
|
558
|
+
const collapsed = mode === "inline" && drawer?.collapsed === true;
|
|
559
|
+
let previousGroup;
|
|
560
|
+
return /* @__PURE__ */ jsx4(
|
|
561
|
+
"nav",
|
|
562
|
+
{
|
|
563
|
+
"data-slot": "menu",
|
|
564
|
+
"data-mode": mode,
|
|
565
|
+
"data-collapsed": collapsed || void 0,
|
|
566
|
+
className: cn(
|
|
567
|
+
mode === "horizontal" ? "flex items-center gap-1" : "flex flex-col gap-0.5 p-2",
|
|
568
|
+
className
|
|
569
|
+
),
|
|
570
|
+
style,
|
|
571
|
+
children: items.map((item) => {
|
|
572
|
+
let groupLabel;
|
|
573
|
+
if (!collapsed && mode === "inline" && item.group !== void 0 && item.group !== previousGroup) {
|
|
574
|
+
groupLabel = item.group;
|
|
575
|
+
}
|
|
576
|
+
previousGroup = item.group;
|
|
577
|
+
return /* @__PURE__ */ jsxs3("div", { "data-slot": "menu-group-entry", children: [
|
|
578
|
+
groupLabel !== void 0 && /* @__PURE__ */ jsx4(
|
|
579
|
+
"div",
|
|
580
|
+
{
|
|
581
|
+
"data-slot": "menu-group",
|
|
582
|
+
className: "px-3 pb-1 pt-3 text-xs font-medium text-muted-foreground first:pt-1",
|
|
583
|
+
children: groupLabel
|
|
584
|
+
}
|
|
585
|
+
),
|
|
586
|
+
/* @__PURE__ */ jsx4(
|
|
587
|
+
MenuEntry,
|
|
588
|
+
{
|
|
589
|
+
item,
|
|
590
|
+
mode,
|
|
591
|
+
depth: 0,
|
|
592
|
+
selectedKey,
|
|
593
|
+
onSelect,
|
|
594
|
+
collapsed
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
] }, item.key);
|
|
598
|
+
})
|
|
599
|
+
}
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
function MenuEntry({
|
|
603
|
+
item,
|
|
604
|
+
mode,
|
|
605
|
+
depth,
|
|
606
|
+
selectedKey,
|
|
607
|
+
onSelect,
|
|
608
|
+
collapsed = false
|
|
609
|
+
}) {
|
|
610
|
+
const selected = item.key === selectedKey;
|
|
611
|
+
const button = /* @__PURE__ */ jsxs3(
|
|
612
|
+
"button",
|
|
613
|
+
{
|
|
614
|
+
type: "button",
|
|
615
|
+
"data-slot": "menu-item",
|
|
616
|
+
"aria-current": selected ? "page" : void 0,
|
|
617
|
+
disabled: item.disabled,
|
|
618
|
+
className: cn(
|
|
619
|
+
"flex w-full items-center gap-2 rounded-md text-sm transition-colors",
|
|
620
|
+
mode === "horizontal" ? "px-3 py-2" : "px-3 py-2 text-left",
|
|
621
|
+
collapsed && "justify-center px-0",
|
|
622
|
+
selected ? "bg-accent font-medium text-accent-foreground" : "cursor-pointer text-muted-foreground hover:bg-accent/50 hover:text-foreground",
|
|
623
|
+
item.disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground"
|
|
624
|
+
),
|
|
625
|
+
style: mode === "inline" && depth > 0 && !collapsed ? { paddingLeft: 12 + depth * 16 } : void 0,
|
|
626
|
+
onClick: () => {
|
|
627
|
+
if (!item.disabled) {
|
|
628
|
+
onSelect?.(item.key);
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
children: [
|
|
632
|
+
item.icon ? /* @__PURE__ */ jsx4(Icon, { name: item.icon, size: "sm" }) : null,
|
|
633
|
+
collapsed ? null : /* @__PURE__ */ jsx4("span", { className: "min-w-0 flex-1 truncate text-left", children: item.label }),
|
|
634
|
+
item.dot && !collapsed ? /* @__PURE__ */ jsx4("span", { "data-slot": "menu-item-dot", className: "size-1.5 shrink-0 rounded-full bg-destructive" }) : null,
|
|
635
|
+
item.badge !== void 0 && !collapsed ? /* @__PURE__ */ jsx4(
|
|
636
|
+
"span",
|
|
637
|
+
{
|
|
638
|
+
"data-slot": "menu-item-badge",
|
|
639
|
+
className: "shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",
|
|
640
|
+
children: item.badge
|
|
641
|
+
}
|
|
642
|
+
) : null
|
|
643
|
+
]
|
|
644
|
+
}
|
|
645
|
+
);
|
|
646
|
+
return /* @__PURE__ */ jsxs3("div", { "data-slot": "menu-entry", "data-key": item.key, children: [
|
|
647
|
+
collapsed ? /* @__PURE__ */ jsx4(RailTooltip, { label: item.label, children: button }) : button,
|
|
648
|
+
item.children?.map((child) => /* @__PURE__ */ jsx4(
|
|
649
|
+
MenuEntry,
|
|
650
|
+
{
|
|
651
|
+
item: child,
|
|
652
|
+
mode,
|
|
653
|
+
depth: depth + 1,
|
|
654
|
+
selectedKey,
|
|
655
|
+
onSelect,
|
|
656
|
+
collapsed
|
|
657
|
+
},
|
|
658
|
+
child.key
|
|
659
|
+
))
|
|
660
|
+
] });
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export {
|
|
664
|
+
ICONS,
|
|
665
|
+
normalizeIconName,
|
|
666
|
+
Icon,
|
|
667
|
+
RailTooltip,
|
|
668
|
+
useSidebarDrawer,
|
|
669
|
+
Sidebar,
|
|
670
|
+
Menu2 as Menu
|
|
671
|
+
};
|
|
@@ -196,7 +196,7 @@ var toastTypeClass = {
|
|
|
196
196
|
info: "border-l-4 border-l-info",
|
|
197
197
|
warning: "border-l-4 border-l-warning"
|
|
198
198
|
};
|
|
199
|
-
function
|
|
199
|
+
function InteractionProvider({
|
|
200
200
|
bridge,
|
|
201
201
|
children
|
|
202
202
|
}) {
|
|
@@ -315,7 +315,7 @@ function toCssWidth(width) {
|
|
|
315
315
|
}
|
|
316
316
|
return typeof width === "number" ? `${width}px` : width;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function OverlayHost({ manager, resolvePage }) {
|
|
319
319
|
const renderer = useRenderer();
|
|
320
320
|
const stack = useSyncExternalStore(
|
|
321
321
|
(onChange) => manager.subscribe(onChange),
|
|
@@ -474,7 +474,7 @@ function PageOverlayBody({
|
|
|
474
474
|
if (!resolvePage) {
|
|
475
475
|
setError(
|
|
476
476
|
new Error(
|
|
477
|
-
`[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981
|
|
477
|
+
`[@pactor-app/ui] page overlay\uFF08pageId: "${entry.page?.pageId}"\uFF09\u9700\u8981 OverlayHost \u6CE8\u5165 resolvePage`
|
|
478
478
|
)
|
|
479
479
|
);
|
|
480
480
|
return;
|
|
@@ -525,6 +525,6 @@ export {
|
|
|
525
525
|
OverlayManager,
|
|
526
526
|
createUiBridge,
|
|
527
527
|
registerInteractionActions,
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
InteractionProvider,
|
|
529
|
+
OverlayHost
|
|
530
530
|
};
|