@pactor-app/ui 0.1.0 → 1.1.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.
@@ -0,0 +1,3537 @@
1
+ import {
2
+ Icon
3
+ } from "./chunk-6JNCDPGS.js";
4
+ import {
5
+ Alert,
6
+ AlertDescription,
7
+ AlertDialog,
8
+ AlertDialogAction,
9
+ AlertDialogCancel,
10
+ AlertDialogContent,
11
+ AlertDialogDescription,
12
+ AlertDialogFooter,
13
+ AlertDialogHeader,
14
+ AlertDialogTitle,
15
+ AlertDialogTrigger,
16
+ AlertTitle,
17
+ AspectRatio,
18
+ Avatar,
19
+ AvatarFallback,
20
+ AvatarImage,
21
+ Badge,
22
+ Breadcrumb,
23
+ BreadcrumbItem,
24
+ BreadcrumbLink,
25
+ BreadcrumbList,
26
+ BreadcrumbPage,
27
+ BreadcrumbSeparator,
28
+ ButtonGroup,
29
+ Calendar,
30
+ Carousel,
31
+ CarouselContent,
32
+ CarouselItem,
33
+ CarouselNext,
34
+ CarouselPrevious,
35
+ ChartContainer,
36
+ Checkbox,
37
+ Collapsible,
38
+ CollapsibleContent,
39
+ CollapsibleTrigger,
40
+ Combobox,
41
+ ComboboxContent,
42
+ ComboboxTrigger,
43
+ Command,
44
+ CommandEmpty,
45
+ CommandGroup,
46
+ CommandInput,
47
+ CommandItem,
48
+ CommandList,
49
+ ContextMenu,
50
+ ContextMenuContent,
51
+ ContextMenuItem,
52
+ ContextMenuTrigger,
53
+ DropdownMenu,
54
+ DropdownMenuContent,
55
+ DropdownMenuItem,
56
+ DropdownMenuSub,
57
+ DropdownMenuSubContent,
58
+ DropdownMenuSubTrigger,
59
+ DropdownMenuTrigger,
60
+ Empty,
61
+ EmptyContent,
62
+ EmptyDescription,
63
+ EmptyHeader,
64
+ EmptyTitle,
65
+ Field,
66
+ FieldDescription,
67
+ FieldError,
68
+ FieldLabel,
69
+ HoverCard,
70
+ HoverCardContent,
71
+ HoverCardTrigger,
72
+ Input,
73
+ InputGroup,
74
+ InputOTP,
75
+ InputOTPGroup,
76
+ InputOTPSlot,
77
+ Item,
78
+ ItemActions,
79
+ ItemContent,
80
+ ItemDescription,
81
+ ItemMedia,
82
+ ItemTitle,
83
+ Kbd,
84
+ Label,
85
+ Menubar,
86
+ MenubarContent,
87
+ MenubarItem,
88
+ MenubarMenu,
89
+ MenubarTrigger,
90
+ NavigationMenu,
91
+ NavigationMenuContent,
92
+ NavigationMenuItem,
93
+ NavigationMenuLink,
94
+ NavigationMenuList,
95
+ NavigationMenuTrigger,
96
+ Pagination,
97
+ PaginationContent,
98
+ PaginationEllipsis,
99
+ PaginationItem,
100
+ PaginationLink,
101
+ PaginationNext,
102
+ PaginationPrevious,
103
+ Panel,
104
+ PanelGroup,
105
+ Progress,
106
+ ProgressIndicator,
107
+ ProgressTrack,
108
+ RadioGroup,
109
+ RadioGroupItem,
110
+ ResizableHandle,
111
+ ScrollArea,
112
+ Select,
113
+ SelectContent,
114
+ SelectItem,
115
+ SelectTrigger,
116
+ SelectValue,
117
+ Separator,
118
+ Sheet,
119
+ SheetContent,
120
+ SheetHeader,
121
+ SheetTitle,
122
+ Skeleton,
123
+ Slider,
124
+ SliderControl,
125
+ SliderIndicator,
126
+ SliderThumb,
127
+ SliderTrack,
128
+ Spinner,
129
+ Switch,
130
+ Table,
131
+ TableBody,
132
+ TableCell,
133
+ TableHead,
134
+ TableHeader,
135
+ TableRow,
136
+ Tabs,
137
+ TabsContent,
138
+ TabsList,
139
+ TabsTrigger,
140
+ Textarea,
141
+ Toaster,
142
+ Toggle,
143
+ ToggleGroup,
144
+ ToggleGroupItem,
145
+ Tooltip,
146
+ TooltipContent,
147
+ TooltipTrigger,
148
+ Typography,
149
+ chartColor,
150
+ navigationMenuTriggerStyle,
151
+ toast
152
+ } from "./chunk-BVHAP22U.js";
153
+ import {
154
+ Button,
155
+ Dialog,
156
+ DialogContent,
157
+ DialogDescription,
158
+ DialogHeader,
159
+ DialogTitle,
160
+ DialogTrigger,
161
+ Drawer,
162
+ DrawerContent,
163
+ DrawerHeader,
164
+ DrawerTitle
165
+ } from "./chunk-F3H23KYG.js";
166
+ import {
167
+ Accordion,
168
+ AccordionContent,
169
+ AccordionItem,
170
+ AccordionTrigger,
171
+ Card,
172
+ CardContent,
173
+ CardHeader,
174
+ CardTitle,
175
+ Popover,
176
+ PopoverContent,
177
+ PopoverTrigger
178
+ } from "./chunk-GL7IO22L.js";
179
+ import {
180
+ cn
181
+ } from "./chunk-RQHJBTEU.js";
182
+
183
+ // src/components/register.ts
184
+ import { Registry } from "@pactor-app/core";
185
+
186
+ // src/components/components/Accordion/index.tsx
187
+ import { useRenderer } from "@pactor-app/runtime";
188
+ import { jsx, jsxs } from "react/jsx-runtime";
189
+ function Accordion2({
190
+ items = [],
191
+ multiple,
192
+ className,
193
+ style
194
+ }) {
195
+ const { renderChildren } = useRenderer();
196
+ return /* @__PURE__ */ jsx(
197
+ Accordion,
198
+ {
199
+ type: multiple ? "multiple" : "single",
200
+ className,
201
+ style,
202
+ children: items.map((item) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.key, children: [
203
+ /* @__PURE__ */ jsx(AccordionTrigger, { children: item.title }),
204
+ /* @__PURE__ */ jsx(AccordionContent, { children: renderChildren(item.children) })
205
+ ] }, item.key))
206
+ }
207
+ );
208
+ }
209
+
210
+ // src/components/components/Alert/index.tsx
211
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
212
+ var variantMap = {
213
+ success: "success",
214
+ info: "info",
215
+ warning: "warning",
216
+ error: "destructive"
217
+ };
218
+ function Alert2({ message, description, variant = "info", className, style }) {
219
+ return /* @__PURE__ */ jsxs2(Alert, { variant: variantMap[variant], className, style, children: [
220
+ message ? /* @__PURE__ */ jsx2(AlertTitle, { children: message }) : null,
221
+ description ? /* @__PURE__ */ jsx2(AlertDescription, { children: description }) : null
222
+ ] });
223
+ }
224
+
225
+ // src/components/components/AlertDialog/index.tsx
226
+ import { useI18n, useRenderer as useRenderer2 } from "@pactor-app/runtime";
227
+ import { useState } from "react";
228
+
229
+ // src/components/components/trigger-render.tsx
230
+ import { jsx as jsx3 } from "react/jsx-runtime";
231
+ function triggerWrapper(slot) {
232
+ return /* @__PURE__ */ jsx3("span", { "data-slot": slot });
233
+ }
234
+
235
+ // src/components/components/AlertDialog/index.tsx
236
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
237
+ function AlertDialog2({
238
+ title,
239
+ description,
240
+ confirmText,
241
+ cancelText,
242
+ open,
243
+ onConfirm,
244
+ onCancel,
245
+ trigger,
246
+ className,
247
+ style
248
+ }) {
249
+ const { renderChildren } = useRenderer2();
250
+ const { t } = useI18n();
251
+ const [innerOpen, setInnerOpen] = useState(false);
252
+ const controlled = open !== void 0;
253
+ const visible = controlled ? open : innerOpen;
254
+ return /* @__PURE__ */ jsxs3(
255
+ AlertDialog,
256
+ {
257
+ open: visible,
258
+ onOpenChange: (next) => {
259
+ if (!controlled) {
260
+ setInnerOpen(next);
261
+ }
262
+ },
263
+ children: [
264
+ trigger ? /* @__PURE__ */ jsx4(
265
+ AlertDialogTrigger,
266
+ {
267
+ nativeButton: false,
268
+ render: triggerWrapper("alert-dialog-trigger-wrap"),
269
+ children: renderChildren([trigger])
270
+ }
271
+ ) : null,
272
+ /* @__PURE__ */ jsxs3(AlertDialogContent, { className, style, children: [
273
+ /* @__PURE__ */ jsxs3(AlertDialogHeader, { children: [
274
+ /* @__PURE__ */ jsx4(AlertDialogTitle, { children: title ?? "" }),
275
+ description ? /* @__PURE__ */ jsx4(AlertDialogDescription, { children: description }) : null
276
+ ] }),
277
+ /* @__PURE__ */ jsxs3(AlertDialogFooter, { children: [
278
+ /* @__PURE__ */ jsx4(AlertDialogCancel, { onClick: () => onCancel?.(), children: cancelText ?? t("pactor.alertDialog.cancel") }),
279
+ /* @__PURE__ */ jsx4(AlertDialogAction, { onClick: () => onConfirm?.(), children: confirmText ?? t("pactor.alertDialog.confirm") })
280
+ ] })
281
+ ] })
282
+ ]
283
+ }
284
+ );
285
+ }
286
+
287
+ // src/components/components/AspectRatio/index.tsx
288
+ import { jsx as jsx5 } from "react/jsx-runtime";
289
+ function AspectRatio2({ ratio = 1, children, className, style }) {
290
+ return /* @__PURE__ */ jsx5(AspectRatio, { ratio, className, style, children });
291
+ }
292
+
293
+ // src/components/components/Avatar/index.tsx
294
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
295
+ function Avatar2({ src, alt, fallback, className, style }) {
296
+ return /* @__PURE__ */ jsxs4(Avatar, { className, style, children: [
297
+ src ? /* @__PURE__ */ jsx6(AvatarImage, { src, alt: alt ?? "" }) : null,
298
+ fallback ? /* @__PURE__ */ jsx6(AvatarFallback, { children: fallback }) : null
299
+ ] });
300
+ }
301
+
302
+ // src/components/components/Badge/index.tsx
303
+ import { jsx as jsx7 } from "react/jsx-runtime";
304
+ function Badge2({ text, variant = "default", className, style }) {
305
+ return /* @__PURE__ */ jsx7(Badge, { variant, className, style, children: text });
306
+ }
307
+
308
+ // src/components/components/Breadcrumb/index.tsx
309
+ import { Fragment } from "react";
310
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
311
+ function Breadcrumb2({ items = [], className, style }) {
312
+ return /* @__PURE__ */ jsx8(Breadcrumb, { className, style, children: /* @__PURE__ */ jsx8(BreadcrumbList, { children: items.map((item, index) => {
313
+ const isLast = index === items.length - 1;
314
+ return /* @__PURE__ */ jsxs5(Fragment, { children: [
315
+ index > 0 ? /* @__PURE__ */ jsx8(BreadcrumbSeparator, {}) : null,
316
+ /* @__PURE__ */ jsx8(BreadcrumbItem, { children: isLast || !item.href ? /* @__PURE__ */ jsx8(BreadcrumbPage, { children: item.label }) : /* @__PURE__ */ jsx8(BreadcrumbLink, { href: item.href, children: item.label }) })
317
+ ] }, `${item.label}-${index}`);
318
+ }) }) });
319
+ }
320
+
321
+ // src/components/components/Button/index.tsx
322
+ import { Loader2 } from "lucide-react";
323
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
324
+ var variantMap2 = {
325
+ default: "outline",
326
+ primary: "default",
327
+ dashed: "outline",
328
+ link: "link",
329
+ text: "ghost"
330
+ };
331
+ var sizeMap = {
332
+ small: "sm",
333
+ middle: "default",
334
+ large: "lg"
335
+ };
336
+ function Button2({
337
+ text,
338
+ variant = "default",
339
+ danger,
340
+ size = "middle",
341
+ loading,
342
+ disabled,
343
+ submit,
344
+ onClick,
345
+ className,
346
+ style,
347
+ children
348
+ }) {
349
+ const textual = variant === "link" || variant === "text";
350
+ return /* @__PURE__ */ jsxs6(
351
+ Button,
352
+ {
353
+ type: submit ? "submit" : "button",
354
+ variant: danger && !textual ? "destructive" : variantMap2[variant],
355
+ size: sizeMap[size],
356
+ disabled: disabled ?? loading,
357
+ "aria-busy": loading || void 0,
358
+ onClick: () => onClick?.(),
359
+ style,
360
+ className: cn(
361
+ variant === "dashed" && "border-dashed",
362
+ danger && textual && "text-destructive hover:text-destructive",
363
+ className
364
+ ),
365
+ children: [
366
+ loading ? /* @__PURE__ */ jsx9(Loader2, { "aria-hidden": true, className: "animate-spin" }) : null,
367
+ text ?? children
368
+ ]
369
+ }
370
+ );
371
+ }
372
+
373
+ // src/components/components/ButtonGroup/index.tsx
374
+ import { jsx as jsx10 } from "react/jsx-runtime";
375
+ function ButtonGroup2({ className, style, children }) {
376
+ return /* @__PURE__ */ jsx10(ButtonGroup, { className, style, children });
377
+ }
378
+
379
+ // src/components/components/Calendar/index.tsx
380
+ import { format, isValid, parseISO } from "date-fns";
381
+ import { useEffect } from "react";
382
+
383
+ // src/components/components/Form/context.ts
384
+ import { createContext, useContext } from "react";
385
+ var FormReactContext = createContext(null);
386
+ var FormContextProvider = FormReactContext.Provider;
387
+ function useFormContext() {
388
+ return useContext(FormReactContext);
389
+ }
390
+ function formItemClass(layout) {
391
+ switch (layout) {
392
+ case "horizontal":
393
+ return "mb-4 flex items-baseline gap-2";
394
+ case "inline":
395
+ return "flex items-center gap-2";
396
+ default:
397
+ return "mb-4 flex flex-col gap-1.5";
398
+ }
399
+ }
400
+
401
+ // src/components/components/Calendar/index.tsx
402
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
403
+ function parseValue(value) {
404
+ if (typeof value !== "string" || value === "") return void 0;
405
+ const date = parseISO(value);
406
+ return isValid(date) ? date : void 0;
407
+ }
408
+ function Calendar2({
409
+ name,
410
+ label,
411
+ rules,
412
+ mode = "single",
413
+ value,
414
+ disabled,
415
+ onChange,
416
+ className,
417
+ style
418
+ }) {
419
+ const form = useFormContext();
420
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
421
+ useEffect(() => {
422
+ if (inForm && form && name) {
423
+ form.registerField(name, rules, value);
424
+ return () => form.unregisterField(name);
425
+ }
426
+ return void 0;
427
+ });
428
+ const current = inForm && form && name ? form.values[name] : value;
429
+ const handleSelect = (date) => {
430
+ const next = date ? format(date, "yyyy-MM-dd") : void 0;
431
+ if (inForm && form && name) {
432
+ form.setValue(name, next);
433
+ }
434
+ onChange?.(next);
435
+ };
436
+ const calendar = /* @__PURE__ */ jsx11(
437
+ Calendar,
438
+ {
439
+ mode,
440
+ selected: parseValue(current),
441
+ onSelect: handleSelect,
442
+ disabled: disabled === true ? true : void 0,
443
+ className: cn(!inForm && className),
444
+ style: inForm ? void 0 : style
445
+ }
446
+ );
447
+ if (inForm && form && name) {
448
+ const error = form.errors[name];
449
+ return /* @__PURE__ */ jsxs7(
450
+ "div",
451
+ {
452
+ "data-slot": "form-item",
453
+ className: cn(formItemClass(form.layout), className),
454
+ style,
455
+ children: [
456
+ label ? /* @__PURE__ */ jsx11("label", { className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap", children: label }) : null,
457
+ calendar,
458
+ error ? /* @__PURE__ */ jsx11("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
459
+ ]
460
+ }
461
+ );
462
+ }
463
+ return calendar;
464
+ }
465
+
466
+ // src/components/components/Card/index.tsx
467
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
468
+ function Card2({ title, bordered = true, className, style, children }) {
469
+ return /* @__PURE__ */ jsxs8(
470
+ Card,
471
+ {
472
+ className: cn("gap-4 py-4", !bordered && "border-transparent shadow-none", className),
473
+ style,
474
+ children: [
475
+ title ? /* @__PURE__ */ jsx12(CardHeader, { className: "px-4", children: /* @__PURE__ */ jsx12(CardTitle, { children: title }) }) : null,
476
+ /* @__PURE__ */ jsx12(CardContent, { className: "px-4", children })
477
+ ]
478
+ }
479
+ );
480
+ }
481
+
482
+ // src/components/components/Carousel/index.tsx
483
+ import { useRenderer as useRenderer3 } from "@pactor-app/runtime";
484
+ import { useEffect as useEffect2, useState as useState2 } from "react";
485
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
486
+ function isDslNode(item) {
487
+ return typeof item.type === "string";
488
+ }
489
+ function Carousel2({
490
+ items = [],
491
+ loop,
492
+ autoplay,
493
+ className,
494
+ style
495
+ }) {
496
+ const { renderChildren } = useRenderer3();
497
+ const [api, setApi] = useState2();
498
+ useEffect2(() => {
499
+ if (!api || !autoplay) return;
500
+ const interval = typeof autoplay === "number" ? autoplay : 3e3;
501
+ const timer = setInterval(() => {
502
+ if (api.canScrollNext()) {
503
+ api.scrollNext();
504
+ } else if (loop) {
505
+ api.scrollTo(0);
506
+ }
507
+ }, interval);
508
+ return () => clearInterval(timer);
509
+ }, [api, autoplay, loop]);
510
+ return /* @__PURE__ */ jsxs9(
511
+ Carousel,
512
+ {
513
+ opts: { loop: loop === true },
514
+ setApi,
515
+ className,
516
+ style,
517
+ children: [
518
+ /* @__PURE__ */ jsx13(CarouselContent, { children: items.map((item, index) => /* @__PURE__ */ jsx13(CarouselItem, { children: isDslNode(item) ? renderChildren([item]) : /* @__PURE__ */ jsx13(
519
+ "img",
520
+ {
521
+ src: item.src,
522
+ alt: item.alt ?? "",
523
+ className: "w-full rounded-md object-cover"
524
+ }
525
+ ) }, index)) }),
526
+ /* @__PURE__ */ jsx13(CarouselPrevious, {}),
527
+ /* @__PURE__ */ jsx13(CarouselNext, {})
528
+ ]
529
+ }
530
+ );
531
+ }
532
+
533
+ // src/components/components/Checkbox/index.tsx
534
+ import { useEffect as useEffect3, useId } from "react";
535
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
536
+ function Checkbox2({
537
+ name,
538
+ label,
539
+ rules,
540
+ value,
541
+ disabled,
542
+ onChange,
543
+ className,
544
+ style
545
+ }) {
546
+ const form = useFormContext();
547
+ const controlId = useId();
548
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
549
+ useEffect3(() => {
550
+ if (inForm && form && name) {
551
+ form.registerField(name, rules, value);
552
+ return () => form.unregisterField(name);
553
+ }
554
+ return void 0;
555
+ });
556
+ const current = inForm && form && name ? form.values[name] : value;
557
+ const checked = current === true;
558
+ const handleChange = (next) => {
559
+ if (inForm && form && name) {
560
+ form.setValue(name, next);
561
+ }
562
+ onChange?.(next);
563
+ };
564
+ const control = /* @__PURE__ */ jsxs10(
565
+ "span",
566
+ {
567
+ className: cn("inline-flex items-center gap-2", !inForm && className),
568
+ style: inForm ? void 0 : style,
569
+ children: [
570
+ /* @__PURE__ */ jsx14(
571
+ Checkbox,
572
+ {
573
+ id: controlId,
574
+ checked,
575
+ disabled,
576
+ name: inForm ? name : void 0,
577
+ onCheckedChange: handleChange
578
+ }
579
+ ),
580
+ label ? /* @__PURE__ */ jsx14("label", { htmlFor: controlId, className: "text-sm leading-none font-medium", children: label }) : null
581
+ ]
582
+ }
583
+ );
584
+ if (inForm && form && name) {
585
+ return /* @__PURE__ */ jsxs10(
586
+ "div",
587
+ {
588
+ "data-slot": "form-item",
589
+ className: cn("mb-4", className),
590
+ style,
591
+ children: [
592
+ control,
593
+ form.errors[name] ? /* @__PURE__ */ jsx14("div", { "data-slot": "form-error", className: "mt-1.5 text-sm text-destructive", children: form.errors[name] }) : null
594
+ ]
595
+ }
596
+ );
597
+ }
598
+ return control;
599
+ }
600
+
601
+ // src/components/components/Collapsible/index.tsx
602
+ import { useState as useState3 } from "react";
603
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
604
+ function Collapsible2({
605
+ title,
606
+ open,
607
+ children,
608
+ className,
609
+ style
610
+ }) {
611
+ const [innerOpen, setInnerOpen] = useState3(false);
612
+ const controlled = open !== void 0;
613
+ return /* @__PURE__ */ jsxs11(
614
+ Collapsible,
615
+ {
616
+ open: controlled ? open : innerOpen,
617
+ onOpenChange: (next) => {
618
+ if (!controlled) {
619
+ setInnerOpen(next);
620
+ }
621
+ },
622
+ className,
623
+ style,
624
+ children: [
625
+ title ? /* @__PURE__ */ jsx15(CollapsibleTrigger, { children: title }) : null,
626
+ /* @__PURE__ */ jsx15(CollapsibleContent, { children })
627
+ ]
628
+ }
629
+ );
630
+ }
631
+
632
+ // src/components/components/Combobox/index.tsx
633
+ import { useEffect as useEffect4, useId as useId2, useState as useState4 } from "react";
634
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
635
+ function Combobox2({
636
+ name,
637
+ label,
638
+ rules,
639
+ options = [],
640
+ value,
641
+ placeholder,
642
+ searchable = true,
643
+ disabled,
644
+ onChange,
645
+ className,
646
+ style
647
+ }) {
648
+ const form = useFormContext();
649
+ const controlId = useId2();
650
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
651
+ const [open, setOpen] = useState4(false);
652
+ useEffect4(() => {
653
+ if (inForm && form && name) {
654
+ form.registerField(name, rules, value);
655
+ return () => form.unregisterField(name);
656
+ }
657
+ return void 0;
658
+ });
659
+ const [innerValue, setInnerValue] = useState4(value);
660
+ useEffect4(() => {
661
+ if (!inForm) setInnerValue(value);
662
+ }, [inForm, value]);
663
+ const current = inForm && form && name ? form.values[name] : innerValue;
664
+ const selected = options.find((option) => option.value === current);
665
+ const handleSelect = (option) => {
666
+ if (option.disabled) return;
667
+ if (inForm && form && name) {
668
+ form.setValue(name, option.value);
669
+ } else {
670
+ setInnerValue(option.value);
671
+ }
672
+ onChange?.(option.value);
673
+ setOpen(false);
674
+ };
675
+ const control = /* @__PURE__ */ jsxs12(Combobox, { open, onOpenChange: setOpen, children: [
676
+ /* @__PURE__ */ jsx16(
677
+ ComboboxTrigger,
678
+ {
679
+ id: controlId,
680
+ type: "button",
681
+ disabled,
682
+ className: cn(!selected && "text-muted-foreground", !inForm && className),
683
+ style: inForm ? void 0 : style,
684
+ children: selected ? selected.label : placeholder ?? ""
685
+ }
686
+ ),
687
+ /* @__PURE__ */ jsx16(ComboboxContent, { children: /* @__PURE__ */ jsxs12(Command, { children: [
688
+ searchable ? /* @__PURE__ */ jsx16(CommandInput, { placeholder }) : null,
689
+ /* @__PURE__ */ jsxs12(CommandList, { children: [
690
+ /* @__PURE__ */ jsx16(CommandEmpty, { children: "\u65E0\u5339\u914D\u7ED3\u679C" }),
691
+ /* @__PURE__ */ jsx16(CommandGroup, { children: options.map((option) => /* @__PURE__ */ jsx16(
692
+ CommandItem,
693
+ {
694
+ value: String(option.value),
695
+ keywords: [option.label],
696
+ disabled: option.disabled,
697
+ "data-checked": option.value === current ? "" : void 0,
698
+ onSelect: () => handleSelect(option),
699
+ children: option.label
700
+ },
701
+ String(option.value)
702
+ )) })
703
+ ] })
704
+ ] }) })
705
+ ] });
706
+ if (inForm && form && name) {
707
+ const error = form.errors[name];
708
+ return /* @__PURE__ */ jsxs12(
709
+ "div",
710
+ {
711
+ "data-slot": "form-item",
712
+ className: cn(formItemClass(form.layout), className),
713
+ style,
714
+ children: [
715
+ label ? /* @__PURE__ */ jsx16(
716
+ "label",
717
+ {
718
+ htmlFor: controlId,
719
+ className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
720
+ children: label
721
+ }
722
+ ) : null,
723
+ control,
724
+ error ? /* @__PURE__ */ jsx16("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
725
+ ]
726
+ }
727
+ );
728
+ }
729
+ return control;
730
+ }
731
+
732
+ // src/components/components/Command/index.tsx
733
+ import { useI18n as useI18n2 } from "@pactor-app/runtime";
734
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
735
+ function Command2({
736
+ groups = [],
737
+ placeholder,
738
+ emptyText,
739
+ onSelect,
740
+ className,
741
+ style
742
+ }) {
743
+ const { t } = useI18n2();
744
+ return /* @__PURE__ */ jsxs13(Command, { className, style, children: [
745
+ /* @__PURE__ */ jsx17(CommandInput, { placeholder }),
746
+ /* @__PURE__ */ jsxs13(CommandList, { children: [
747
+ /* @__PURE__ */ jsx17(CommandEmpty, { children: emptyText ?? t("pactor.command.empty") }),
748
+ groups.map((group, index) => /* @__PURE__ */ jsx17(CommandGroup, { heading: group.heading, children: group.items.map((item) => /* @__PURE__ */ jsxs13(
749
+ CommandItem,
750
+ {
751
+ value: item.value,
752
+ keywords: [item.label],
753
+ disabled: item.disabled,
754
+ onSelect: (value) => onSelect?.(value),
755
+ children: [
756
+ item.icon ? /* @__PURE__ */ jsx17(Icon, { name: item.icon, size: "sm" }) : null,
757
+ item.label
758
+ ]
759
+ },
760
+ item.value
761
+ )) }, group.heading ?? index))
762
+ ] })
763
+ ] });
764
+ }
765
+
766
+ // src/components/components/Chart/index.tsx
767
+ import {
768
+ Area,
769
+ AreaChart,
770
+ Bar,
771
+ BarChart,
772
+ CartesianGrid,
773
+ Cell,
774
+ Legend,
775
+ Line,
776
+ LineChart,
777
+ Pie,
778
+ PieChart,
779
+ Tooltip as Tooltip2,
780
+ XAxis,
781
+ YAxis
782
+ } from "recharts";
783
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
784
+ function Chart({
785
+ chartType,
786
+ data = [],
787
+ xKey,
788
+ yKeys = [],
789
+ colors,
790
+ className,
791
+ style
792
+ }) {
793
+ const series = yKeys.length > 0 ? yKeys : ["value"];
794
+ return /* @__PURE__ */ jsx18(
795
+ "div",
796
+ {
797
+ "data-slot": "chart",
798
+ "data-chart-type": chartType,
799
+ className: cn("w-full", className),
800
+ style,
801
+ children: /* @__PURE__ */ jsx18(ChartContainer, { children: chartType === "pie" ? /* @__PURE__ */ jsxs14(PieChart, { children: [
802
+ /* @__PURE__ */ jsx18(Tooltip2, {}),
803
+ /* @__PURE__ */ jsx18(Legend, {}),
804
+ /* @__PURE__ */ jsx18(
805
+ Pie,
806
+ {
807
+ data,
808
+ dataKey: series[0],
809
+ nameKey: xKey,
810
+ innerRadius: 0,
811
+ outerRadius: "80%",
812
+ isAnimationActive: false,
813
+ children: data.map((_, index) => /* @__PURE__ */ jsx18(Cell, { fill: chartColor(index, colors) }, index))
814
+ }
815
+ )
816
+ ] }) : chartType === "line" ? /* @__PURE__ */ jsxs14(LineChart, { data, children: [
817
+ /* @__PURE__ */ jsx18(CartesianGrid, { strokeDasharray: "3 3", vertical: false }),
818
+ /* @__PURE__ */ jsx18(XAxis, { dataKey: xKey }),
819
+ /* @__PURE__ */ jsx18(YAxis, {}),
820
+ /* @__PURE__ */ jsx18(Tooltip2, {}),
821
+ series.length > 1 ? /* @__PURE__ */ jsx18(Legend, {}) : null,
822
+ series.map((key, index) => /* @__PURE__ */ jsx18(
823
+ Line,
824
+ {
825
+ type: "monotone",
826
+ dataKey: key,
827
+ name: key,
828
+ stroke: chartColor(index, colors),
829
+ isAnimationActive: false
830
+ },
831
+ key
832
+ ))
833
+ ] }) : chartType === "area" ? /* @__PURE__ */ jsxs14(AreaChart, { data, children: [
834
+ /* @__PURE__ */ jsx18(CartesianGrid, { strokeDasharray: "3 3", vertical: false }),
835
+ /* @__PURE__ */ jsx18(XAxis, { dataKey: xKey }),
836
+ /* @__PURE__ */ jsx18(YAxis, {}),
837
+ /* @__PURE__ */ jsx18(Tooltip2, {}),
838
+ series.length > 1 ? /* @__PURE__ */ jsx18(Legend, {}) : null,
839
+ series.map((key, index) => /* @__PURE__ */ jsx18(
840
+ Area,
841
+ {
842
+ type: "monotone",
843
+ dataKey: key,
844
+ name: key,
845
+ stroke: chartColor(index, colors),
846
+ fill: chartColor(index, colors),
847
+ fillOpacity: 0.3,
848
+ isAnimationActive: false
849
+ },
850
+ key
851
+ ))
852
+ ] }) : /* @__PURE__ */ jsxs14(BarChart, { data, children: [
853
+ /* @__PURE__ */ jsx18(CartesianGrid, { strokeDasharray: "3 3", vertical: false }),
854
+ /* @__PURE__ */ jsx18(XAxis, { dataKey: xKey }),
855
+ /* @__PURE__ */ jsx18(YAxis, {}),
856
+ /* @__PURE__ */ jsx18(Tooltip2, {}),
857
+ series.length > 1 ? /* @__PURE__ */ jsx18(Legend, {}) : null,
858
+ series.map((key, index) => /* @__PURE__ */ jsx18(
859
+ Bar,
860
+ {
861
+ dataKey: key,
862
+ name: key,
863
+ fill: chartColor(index, colors),
864
+ isAnimationActive: false
865
+ },
866
+ key
867
+ ))
868
+ ] }) })
869
+ }
870
+ );
871
+ }
872
+
873
+ // src/components/components/ChatInput/index.tsx
874
+ import { useRenderer as useRenderer4 } from "@pactor-app/runtime";
875
+ import { ArrowUp } from "lucide-react";
876
+ import {
877
+ useRef,
878
+ useState as useState5
879
+ } from "react";
880
+ import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
881
+ function ChatInput({
882
+ value,
883
+ placeholder,
884
+ disabled,
885
+ rows = 3,
886
+ hideSend,
887
+ toolbarStart,
888
+ toolbarEnd,
889
+ header,
890
+ footer,
891
+ onChange,
892
+ onSubmit,
893
+ className,
894
+ style
895
+ }) {
896
+ const { renderChildren } = useRenderer4();
897
+ const controlled = value !== void 0;
898
+ const [draft, setDraft] = useState5("");
899
+ const text = controlled ? value : draft;
900
+ const canSubmit = !disabled && text.trim() !== "";
901
+ const composingRef = useRef(false);
902
+ const handleChange = (next) => {
903
+ if (!controlled) {
904
+ setDraft(next);
905
+ }
906
+ onChange?.(next);
907
+ };
908
+ const submit = () => {
909
+ if (!canSubmit) {
910
+ return;
911
+ }
912
+ onSubmit?.(text);
913
+ if (!controlled) {
914
+ setDraft("");
915
+ }
916
+ };
917
+ const handleKeyDown = (event) => {
918
+ if (event.key === "Enter" && !event.shiftKey && !composingRef.current && !event.nativeEvent.isComposing) {
919
+ event.preventDefault();
920
+ submit();
921
+ }
922
+ };
923
+ const handleComposition = (event) => {
924
+ composingRef.current = event.type === "compositionstart";
925
+ };
926
+ return /* @__PURE__ */ jsxs15(
927
+ "div",
928
+ {
929
+ "data-slot": "chat-input",
930
+ className: cn(
931
+ "rounded-xl border border-border bg-background transition-shadow focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50",
932
+ className
933
+ ),
934
+ style,
935
+ children: [
936
+ header ? /* @__PURE__ */ jsx19("div", { className: "px-3 pt-3", children: renderChildren([header]) }) : null,
937
+ /* @__PURE__ */ jsx19(
938
+ Textarea,
939
+ {
940
+ value: text,
941
+ placeholder,
942
+ disabled,
943
+ rows,
944
+ onChange: (event) => handleChange(event.target.value),
945
+ onKeyDown: handleKeyDown,
946
+ onCompositionStart: handleComposition,
947
+ onCompositionEnd: handleComposition,
948
+ className: "min-h-[60px] resize-none border-0 px-4 pt-3 pb-1 shadow-none focus-visible:border-transparent focus-visible:ring-0"
949
+ }
950
+ ),
951
+ toolbarStart || toolbarEnd || !hideSend ? /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1 px-2 pb-2", children: [
952
+ toolbarStart ? renderChildren([toolbarStart]) : null,
953
+ /* @__PURE__ */ jsx19("span", { className: "flex-1" }),
954
+ toolbarEnd ? renderChildren([toolbarEnd]) : null,
955
+ hideSend ? null : /* @__PURE__ */ jsx19(
956
+ Button,
957
+ {
958
+ type: "button",
959
+ size: "icon",
960
+ "aria-label": "\u53D1\u9001",
961
+ disabled: !canSubmit,
962
+ onClick: submit,
963
+ className: "size-8 rounded-full",
964
+ children: /* @__PURE__ */ jsx19(ArrowUp, {})
965
+ }
966
+ )
967
+ ] }) : null,
968
+ footer ? /* @__PURE__ */ jsx19("div", { className: "border-t border-border px-3 py-2", children: renderChildren([footer]) }) : null
969
+ ]
970
+ }
971
+ );
972
+ }
973
+
974
+ // src/components/components/Content/index.tsx
975
+ import { jsx as jsx20 } from "react/jsx-runtime";
976
+ function Content({ className, style, children }) {
977
+ return /* @__PURE__ */ jsx20(
978
+ "main",
979
+ {
980
+ "data-slot": "layout-content",
981
+ className: cn("min-h-0 min-w-0 flex-1", className),
982
+ style,
983
+ children
984
+ }
985
+ );
986
+ }
987
+
988
+ // src/components/components/ContextMenu/index.tsx
989
+ import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
990
+ function ContextMenu2({
991
+ items = [],
992
+ onSelect,
993
+ children,
994
+ className,
995
+ style
996
+ }) {
997
+ return /* @__PURE__ */ jsxs16(ContextMenu, { children: [
998
+ /* @__PURE__ */ jsx21(ContextMenuTrigger, { children }),
999
+ /* @__PURE__ */ jsx21(ContextMenuContent, { className, style, children: items.map((item) => /* @__PURE__ */ jsxs16(
1000
+ ContextMenuItem,
1001
+ {
1002
+ variant: item.danger ? "destructive" : "default",
1003
+ disabled: item.disabled,
1004
+ onClick: () => onSelect?.(item.value),
1005
+ children: [
1006
+ item.icon ? /* @__PURE__ */ jsx21(Icon, { name: item.icon, size: "sm" }) : null,
1007
+ item.label
1008
+ ]
1009
+ },
1010
+ item.value
1011
+ )) })
1012
+ ] });
1013
+ }
1014
+
1015
+ // src/components/components/DataTable/index.tsx
1016
+ import { useI18n as useI18n3, useRenderer as useRenderer5 } from "@pactor-app/runtime";
1017
+ import { ArrowDown, ArrowUp as ArrowUp2, ArrowUpDown } from "lucide-react";
1018
+ import { useMemo, useState as useState6 } from "react";
1019
+ import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
1020
+ function renderCellValue(value) {
1021
+ if (value === void 0 || value === null) {
1022
+ return "";
1023
+ }
1024
+ if (typeof value === "object") {
1025
+ return JSON.stringify(value);
1026
+ }
1027
+ return String(value);
1028
+ }
1029
+ function compareValues(a, b) {
1030
+ if (typeof a === "number" && typeof b === "number") {
1031
+ return a - b;
1032
+ }
1033
+ return String(a ?? "").localeCompare(String(b ?? ""));
1034
+ }
1035
+ function DataTable({
1036
+ columns = [],
1037
+ rows = [],
1038
+ rowKey = "id",
1039
+ pagination,
1040
+ sort,
1041
+ onSort,
1042
+ onPageChange,
1043
+ className,
1044
+ style
1045
+ }) {
1046
+ const { renderChildren } = useRenderer5();
1047
+ const { t } = useI18n3();
1048
+ const [sortState, setSortState] = useState6(sort);
1049
+ const [filters, setFilters] = useState6({});
1050
+ const [current, setCurrent] = useState6(1);
1051
+ const viewRows = useMemo(() => {
1052
+ const activeFilters = Object.entries(filters).filter(
1053
+ ([, keyword]) => keyword !== ""
1054
+ );
1055
+ const filtered = activeFilters.length === 0 ? rows : rows.filter(
1056
+ (row) => activeFilters.every(
1057
+ ([key2, keyword]) => renderCellValue(row[key2]).toLowerCase().includes(keyword.toLowerCase())
1058
+ )
1059
+ );
1060
+ if (!sortState) {
1061
+ return filtered;
1062
+ }
1063
+ const { key, order } = sortState;
1064
+ const factor = order === "asc" ? 1 : -1;
1065
+ return filtered.map((row, index) => ({ row, index })).sort(
1066
+ (a, b) => factor * compareValues(a.row[key], b.row[key]) || a.index - b.index
1067
+ ).map((entry) => entry.row);
1068
+ }, [rows, filters, sortState]);
1069
+ const pageSize = pagination === false ? void 0 : pagination?.pageSize;
1070
+ const total = viewRows.length;
1071
+ const pageCount = pageSize !== void 0 && pageSize > 0 ? Math.max(1, Math.ceil(total / pageSize)) : 1;
1072
+ const pageRows = pageSize !== void 0 && pageSize > 0 ? viewRows.slice((current - 1) * pageSize, current * pageSize) : viewRows;
1073
+ const toggleSort = (column) => {
1074
+ const order = sortState?.key === column.key && sortState.order === "asc" ? "desc" : "asc";
1075
+ const next = { key: column.key, order };
1076
+ setSortState(next);
1077
+ setCurrent(1);
1078
+ onSort?.(next);
1079
+ };
1080
+ const changeFilter = (key, keyword) => {
1081
+ setFilters((previous) => ({ ...previous, [key]: keyword }));
1082
+ setCurrent(1);
1083
+ };
1084
+ const goToPage = (page) => {
1085
+ setCurrent(page);
1086
+ onPageChange?.(page);
1087
+ };
1088
+ return /* @__PURE__ */ jsxs17("div", { "data-slot": "data-table", className: cn("relative", className), style, children: [
1089
+ /* @__PURE__ */ jsxs17(Table, { children: [
1090
+ /* @__PURE__ */ jsx22(TableHeader, { children: /* @__PURE__ */ jsx22(TableRow, { className: "hover:bg-transparent", children: columns.map((column, index) => {
1091
+ const sorted = sortState?.key === column.key;
1092
+ return /* @__PURE__ */ jsx22(TableHead, { children: /* @__PURE__ */ jsxs17("div", { className: "flex flex-col gap-1", children: [
1093
+ column.sortable ? /* @__PURE__ */ jsxs17(
1094
+ "button",
1095
+ {
1096
+ type: "button",
1097
+ "data-slot": "data-table-sort",
1098
+ "data-column": column.key,
1099
+ "aria-label": column.title ?? column.key,
1100
+ className: "inline-flex items-center gap-1 font-medium hover:text-foreground",
1101
+ onClick: () => toggleSort(column),
1102
+ children: [
1103
+ column.title,
1104
+ sorted ? sortState.order === "asc" ? /* @__PURE__ */ jsx22(ArrowUp2, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx22(ArrowDown, { "aria-hidden": true, className: "size-3.5" }) : /* @__PURE__ */ jsx22(
1105
+ ArrowUpDown,
1106
+ {
1107
+ "aria-hidden": true,
1108
+ className: "size-3.5 text-muted-foreground"
1109
+ }
1110
+ )
1111
+ ]
1112
+ }
1113
+ ) : /* @__PURE__ */ jsx22("span", { children: column.title }),
1114
+ column.filterable ? /* @__PURE__ */ jsx22(
1115
+ Input,
1116
+ {
1117
+ "data-slot": "data-table-filter",
1118
+ "data-column": column.key,
1119
+ "aria-label": column.title ?? column.key,
1120
+ value: filters[column.key] ?? "",
1121
+ className: "h-7 text-xs",
1122
+ onChange: (event) => changeFilter(column.key, event.target.value)
1123
+ }
1124
+ ) : null
1125
+ ] }) }, column.key ?? String(index));
1126
+ }) }) }),
1127
+ /* @__PURE__ */ jsx22(TableBody, { children: pageRows.length === 0 ? /* @__PURE__ */ jsx22(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx22(TableCell, { colSpan: Math.max(1, columns.length), children: /* @__PURE__ */ jsx22(
1128
+ "div",
1129
+ {
1130
+ "data-slot": "table-empty",
1131
+ className: "py-8 text-center text-muted-foreground",
1132
+ children: t("pactor.table.empty")
1133
+ }
1134
+ ) }) }) : pageRows.map((row, rowIndex) => {
1135
+ const key = row[rowKey];
1136
+ return /* @__PURE__ */ jsx22(
1137
+ TableRow,
1138
+ {
1139
+ children: columns.map((column, columnIndex) => {
1140
+ const template = column.children ?? column.renderChildren;
1141
+ return /* @__PURE__ */ jsx22(TableCell, { children: template ? renderChildren(template, { row, rowIndex }) : renderCellValue(row[column.key]) }, column.key ?? String(columnIndex));
1142
+ })
1143
+ },
1144
+ key === void 0 || key === null ? rowIndex : String(key)
1145
+ );
1146
+ }) })
1147
+ ] }),
1148
+ pageSize !== void 0 && pageSize > 0 ? /* @__PURE__ */ jsx22("div", { "data-slot": "table-pagination", className: "mt-3 flex justify-end gap-1", children: Array.from({ length: pageCount }, (_, index) => index + 1).map(
1149
+ (page) => /* @__PURE__ */ jsx22(
1150
+ Button,
1151
+ {
1152
+ type: "button",
1153
+ size: "sm",
1154
+ variant: page === current ? "default" : "outline",
1155
+ "aria-current": page === current ? "page" : void 0,
1156
+ onClick: () => goToPage(page),
1157
+ children: page
1158
+ },
1159
+ page
1160
+ )
1161
+ ) }) : null
1162
+ ] });
1163
+ }
1164
+
1165
+ // src/components/components/Dialog/index.tsx
1166
+ import { useRenderer as useRenderer6 } from "@pactor-app/runtime";
1167
+ import { useState as useState7 } from "react";
1168
+ import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
1169
+ function Dialog2({
1170
+ title,
1171
+ description,
1172
+ open,
1173
+ onClose,
1174
+ trigger,
1175
+ children,
1176
+ className,
1177
+ style
1178
+ }) {
1179
+ const { renderChildren } = useRenderer6();
1180
+ const [innerOpen, setInnerOpen] = useState7(false);
1181
+ const controlled = open !== void 0;
1182
+ const visible = controlled ? open : innerOpen;
1183
+ return /* @__PURE__ */ jsxs18(
1184
+ Dialog,
1185
+ {
1186
+ open: visible,
1187
+ onOpenChange: (next) => {
1188
+ if (!controlled) {
1189
+ setInnerOpen(next);
1190
+ }
1191
+ if (!next) {
1192
+ onClose?.();
1193
+ }
1194
+ },
1195
+ children: [
1196
+ trigger ? /* @__PURE__ */ jsx23(
1197
+ DialogTrigger,
1198
+ {
1199
+ nativeButton: false,
1200
+ render: triggerWrapper("dialog-trigger-wrap"),
1201
+ children: renderChildren([trigger])
1202
+ }
1203
+ ) : null,
1204
+ /* @__PURE__ */ jsxs18(DialogContent, { className, style, children: [
1205
+ title || description ? /* @__PURE__ */ jsxs18(DialogHeader, { children: [
1206
+ title ? /* @__PURE__ */ jsx23(DialogTitle, { children: title }) : null,
1207
+ description ? /* @__PURE__ */ jsx23(DialogDescription, { children: description }) : null
1208
+ ] }) : null,
1209
+ children
1210
+ ] })
1211
+ ]
1212
+ }
1213
+ );
1214
+ }
1215
+
1216
+ // src/components/components/Drawer/index.tsx
1217
+ import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
1218
+ function Drawer2({
1219
+ title,
1220
+ open,
1221
+ placement = "right",
1222
+ onClose,
1223
+ children,
1224
+ className,
1225
+ style
1226
+ }) {
1227
+ return /* @__PURE__ */ jsx24(
1228
+ Drawer,
1229
+ {
1230
+ direction: placement,
1231
+ open: open ?? false,
1232
+ onOpenChange: (next) => {
1233
+ if (!next) {
1234
+ onClose?.();
1235
+ }
1236
+ },
1237
+ children: /* @__PURE__ */ jsxs19(DrawerContent, { className, style, children: [
1238
+ title ? /* @__PURE__ */ jsx24(DrawerHeader, { children: /* @__PURE__ */ jsx24(DrawerTitle, { children: title }) }) : null,
1239
+ /* @__PURE__ */ jsx24("div", { className: "flex-1 overflow-auto p-4", children })
1240
+ ] })
1241
+ }
1242
+ );
1243
+ }
1244
+
1245
+ // src/components/components/DropdownMenu/index.tsx
1246
+ import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
1247
+ function DropdownMenu2({
1248
+ items = [],
1249
+ onSelect,
1250
+ children,
1251
+ className,
1252
+ style
1253
+ }) {
1254
+ return /* @__PURE__ */ jsxs20(DropdownMenu, { children: [
1255
+ /* @__PURE__ */ jsx25(
1256
+ DropdownMenuTrigger,
1257
+ {
1258
+ nativeButton: false,
1259
+ render: triggerWrapper("dropdown-menu-trigger-wrap"),
1260
+ children
1261
+ }
1262
+ ),
1263
+ /* @__PURE__ */ jsx25(DropdownMenuContent, { className, style, children: items.map((item) => /* @__PURE__ */ jsxs20(
1264
+ DropdownMenuItem,
1265
+ {
1266
+ variant: item.danger ? "destructive" : "default",
1267
+ disabled: item.disabled,
1268
+ onClick: () => onSelect?.(item.value),
1269
+ children: [
1270
+ item.icon ? /* @__PURE__ */ jsx25(Icon, { name: item.icon, size: "sm" }) : null,
1271
+ item.label
1272
+ ]
1273
+ },
1274
+ item.value
1275
+ )) })
1276
+ ] });
1277
+ }
1278
+
1279
+ // src/components/components/Empty/index.tsx
1280
+ import { jsx as jsx26, jsxs as jsxs21 } from "react/jsx-runtime";
1281
+ function Empty2({ title, description, children, className, style }) {
1282
+ return /* @__PURE__ */ jsxs21(Empty, { className, style, children: [
1283
+ /* @__PURE__ */ jsxs21(EmptyHeader, { children: [
1284
+ title ? /* @__PURE__ */ jsx26(EmptyTitle, { children: title }) : null,
1285
+ description ? /* @__PURE__ */ jsx26(EmptyDescription, { children: description }) : null
1286
+ ] }),
1287
+ children ? /* @__PURE__ */ jsx26(EmptyContent, { children }) : null
1288
+ ] });
1289
+ }
1290
+
1291
+ // src/components/components/Field/index.tsx
1292
+ import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
1293
+ function Field2({ label, description, error, children, className, style }) {
1294
+ return /* @__PURE__ */ jsxs22(Field, { className, style, children: [
1295
+ label ? /* @__PURE__ */ jsx27(FieldLabel, { children: label }) : null,
1296
+ children,
1297
+ description ? /* @__PURE__ */ jsx27(FieldDescription, { children: description }) : null,
1298
+ error ? /* @__PURE__ */ jsx27(FieldError, { match: true, children: error }) : null
1299
+ ] });
1300
+ }
1301
+
1302
+ // src/components/components/Flex/index.tsx
1303
+ import { jsx as jsx28 } from "react/jsx-runtime";
1304
+ var gapClass = {
1305
+ small: "gap-2",
1306
+ middle: "gap-4",
1307
+ large: "gap-6"
1308
+ };
1309
+ var justifyClass = {
1310
+ start: "justify-start",
1311
+ center: "justify-center",
1312
+ end: "justify-end",
1313
+ "space-between": "justify-between",
1314
+ "space-around": "justify-around",
1315
+ "space-evenly": "justify-evenly"
1316
+ };
1317
+ var alignClass = {
1318
+ start: "items-start",
1319
+ center: "items-center",
1320
+ end: "items-end",
1321
+ baseline: "items-baseline",
1322
+ stretch: "items-stretch"
1323
+ };
1324
+ function Flex({
1325
+ direction = "horizontal",
1326
+ gap,
1327
+ justify,
1328
+ align,
1329
+ className,
1330
+ style,
1331
+ children
1332
+ }) {
1333
+ return /* @__PURE__ */ jsx28(
1334
+ "div",
1335
+ {
1336
+ "data-slot": "flex",
1337
+ className: cn(
1338
+ "flex",
1339
+ direction === "vertical" && "flex-col",
1340
+ typeof gap === "string" && gapClass[gap],
1341
+ justify && justifyClass[justify],
1342
+ align && alignClass[align],
1343
+ className
1344
+ ),
1345
+ style: typeof gap === "number" || style ? { ...typeof gap === "number" ? { gap } : {}, ...style } : void 0,
1346
+ children
1347
+ }
1348
+ );
1349
+ }
1350
+
1351
+ // src/components/components/Footer/index.tsx
1352
+ import { jsx as jsx29 } from "react/jsx-runtime";
1353
+ function Footer({ className, style, children }) {
1354
+ return /* @__PURE__ */ jsx29(
1355
+ "footer",
1356
+ {
1357
+ "data-slot": "layout-footer",
1358
+ className: cn(
1359
+ "shrink-0 border-t px-4 py-3 text-center text-sm text-muted-foreground",
1360
+ className
1361
+ ),
1362
+ style,
1363
+ children
1364
+ }
1365
+ );
1366
+ }
1367
+
1368
+ // src/components/components/Form/index.tsx
1369
+ import { useRenderer as useRenderer7 } from "@pactor-app/runtime";
1370
+ import {
1371
+ useCallback,
1372
+ useEffect as useEffect5,
1373
+ useMemo as useMemo2,
1374
+ useRef as useRef2,
1375
+ useState as useState8
1376
+ } from "react";
1377
+ import { jsx as jsx30 } from "react/jsx-runtime";
1378
+ function isEmpty(value) {
1379
+ return value === void 0 || value === null || value === "";
1380
+ }
1381
+ function Form({
1382
+ name = "default",
1383
+ layout = "vertical",
1384
+ initialValues,
1385
+ className,
1386
+ style,
1387
+ children,
1388
+ onSubmit,
1389
+ onValuesChange
1390
+ }) {
1391
+ const { context } = useRenderer7();
1392
+ const [values, setValues] = useState8(() => ({
1393
+ ...initialValues
1394
+ }));
1395
+ const [errors, setErrors] = useState8({});
1396
+ const fieldRulesRef = useRef2(/* @__PURE__ */ new Map());
1397
+ const mergedInitialFieldsRef = useRef2(/* @__PURE__ */ new Set());
1398
+ const setValuesBatch = useCallback((partial) => {
1399
+ setValues((prev) => ({ ...prev, ...partial }));
1400
+ }, []);
1401
+ useEffect5(() => {
1402
+ context.forms.register(name, { setValues: setValuesBatch });
1403
+ return () => {
1404
+ context.forms.unregister(name);
1405
+ };
1406
+ }, [context, name, setValuesBatch]);
1407
+ const formContext = useMemo2(
1408
+ () => ({
1409
+ inForm: true,
1410
+ layout,
1411
+ values,
1412
+ errors,
1413
+ setValue(name2, value) {
1414
+ const next = { ...values, [name2]: value };
1415
+ setValues(next);
1416
+ setErrors((prev) => {
1417
+ if (!(name2 in prev)) {
1418
+ return prev;
1419
+ }
1420
+ const rest = { ...prev };
1421
+ delete rest[name2];
1422
+ return rest;
1423
+ });
1424
+ onValuesChange?.({ [name2]: value }, next);
1425
+ },
1426
+ setValues: setValuesBatch,
1427
+ registerField(name2, rules, initialValue) {
1428
+ fieldRulesRef.current.set(name2, rules);
1429
+ if (initialValue !== void 0 && !mergedInitialFieldsRef.current.has(name2)) {
1430
+ mergedInitialFieldsRef.current.add(name2);
1431
+ setValues((prev) => ({ ...prev, [name2]: initialValue }));
1432
+ }
1433
+ },
1434
+ unregisterField(name2) {
1435
+ fieldRulesRef.current.delete(name2);
1436
+ }
1437
+ }),
1438
+ [layout, values, errors, onValuesChange, setValuesBatch]
1439
+ );
1440
+ const handleSubmit = (event) => {
1441
+ event.preventDefault();
1442
+ const nextErrors = {};
1443
+ for (const [name2, rules] of fieldRulesRef.current) {
1444
+ for (const rule of rules ?? []) {
1445
+ if (rule.required && isEmpty(values[name2])) {
1446
+ nextErrors[name2] = rule.message ?? context.i18n.t("pactor.form.required");
1447
+ break;
1448
+ }
1449
+ }
1450
+ }
1451
+ setErrors(nextErrors);
1452
+ if (Object.keys(nextErrors).length > 0) {
1453
+ return;
1454
+ }
1455
+ context.state.set("form", values);
1456
+ onSubmit?.(values);
1457
+ };
1458
+ return /* @__PURE__ */ jsx30(FormContextProvider, { value: formContext, children: /* @__PURE__ */ jsx30(
1459
+ "form",
1460
+ {
1461
+ "data-slot": "form",
1462
+ className: cn(layout === "inline" && "flex flex-wrap items-center gap-3", className),
1463
+ style,
1464
+ onSubmit: handleSubmit,
1465
+ children
1466
+ }
1467
+ ) });
1468
+ }
1469
+
1470
+ // src/components/components/Grid/index.tsx
1471
+ import { Children } from "react";
1472
+ import { jsx as jsx31 } from "react/jsx-runtime";
1473
+ function Grid({ columns = 1, gap, className, style, children }) {
1474
+ const cols = Math.max(1, columns);
1475
+ return /* @__PURE__ */ jsx31(
1476
+ "div",
1477
+ {
1478
+ "data-slot": "grid",
1479
+ "data-columns": cols,
1480
+ className: cn("grid", className),
1481
+ style: {
1482
+ gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
1483
+ ...gap !== void 0 ? { gap } : {},
1484
+ ...style
1485
+ },
1486
+ children: Children.map(children, (child, index) => /* @__PURE__ */ jsx31("div", { "data-slot": "grid-item", children: child }, index))
1487
+ }
1488
+ );
1489
+ }
1490
+
1491
+ // src/components/components/Header/index.tsx
1492
+ import { useI18n as useI18n4 } from "@pactor-app/runtime";
1493
+ import { ChevronDownIcon } from "lucide-react";
1494
+ import { Fragment as Fragment2, jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
1495
+ var menuItemClass = "flex items-center gap-1 rounded-md px-3 py-2 text-sm transition-colors text-muted-foreground hover:bg-accent/50 hover:text-foreground";
1496
+ function Header({
1497
+ logo,
1498
+ title,
1499
+ brandPosition = "left",
1500
+ dropdown,
1501
+ menu,
1502
+ user,
1503
+ locales,
1504
+ onMenuSelect,
1505
+ onDropdownSelect,
1506
+ onUserSelect,
1507
+ onLocaleChange,
1508
+ className,
1509
+ style,
1510
+ children
1511
+ }) {
1512
+ const hasBrand = logo !== void 0 || title !== void 0;
1513
+ const brandLeft = hasBrand && brandPosition === "left";
1514
+ const brandRight = hasBrand && brandPosition === "right";
1515
+ const dropdownLeft = dropdown !== void 0 && (dropdown.position ?? "left") === "left";
1516
+ const dropdownRight = dropdown !== void 0 && dropdown.position === "right";
1517
+ const hasMenu = menu !== void 0 && menu.length > 0;
1518
+ const hasLocales = locales !== void 0 && locales.length > 0;
1519
+ const hasUser = user !== void 0;
1520
+ const rootClass = cn(
1521
+ "flex h-14 shrink-0 items-center gap-4 border-b bg-background px-4",
1522
+ className
1523
+ );
1524
+ if (!hasBrand && !dropdown && !hasMenu && !hasUser && !hasLocales) {
1525
+ return /* @__PURE__ */ jsx32("header", { "data-slot": "layout-header", className: rootClass, style, children });
1526
+ }
1527
+ const brandNode = hasBrand && /* @__PURE__ */ jsxs23("div", { "data-slot": "header-brand", className: "flex items-center gap-2", children: [
1528
+ logo !== void 0 && /* @__PURE__ */ jsx32(
1529
+ "img",
1530
+ {
1531
+ "data-slot": "header-brand-logo",
1532
+ src: logo,
1533
+ alt: title ?? "",
1534
+ className: "h-8 w-8 shrink-0 object-contain"
1535
+ }
1536
+ ),
1537
+ title !== void 0 && /* @__PURE__ */ jsx32("span", { "data-slot": "header-brand-title", className: "text-base font-semibold", children: title })
1538
+ ] });
1539
+ const dropdownNode = dropdown !== void 0 && /* @__PURE__ */ jsx32(HeaderDropdownArea, { dropdown, onSelect: onDropdownSelect });
1540
+ const showLeft = brandLeft || dropdownLeft || hasMenu;
1541
+ const showRight = dropdownRight || brandRight || hasLocales || hasUser;
1542
+ return /* @__PURE__ */ jsxs23("header", { "data-slot": "layout-header", className: rootClass, style, children: [
1543
+ showLeft && /* @__PURE__ */ jsxs23("div", { "data-slot": "header-left", className: "flex items-center gap-4", children: [
1544
+ brandLeft && brandNode,
1545
+ dropdownLeft && dropdownNode,
1546
+ hasMenu && /* @__PURE__ */ jsx32(HeaderMenuArea, { items: menu, onSelect: onMenuSelect })
1547
+ ] }),
1548
+ /* @__PURE__ */ jsx32("div", { "data-slot": "header-center", className: "flex flex-1 items-center gap-4", children }),
1549
+ showRight && /* @__PURE__ */ jsxs23("div", { "data-slot": "header-right", className: "flex items-center gap-4", children: [
1550
+ dropdownRight && dropdownNode,
1551
+ brandRight && brandNode,
1552
+ hasLocales && /* @__PURE__ */ jsx32(HeaderLocalesArea, { locales, onSelect: onLocaleChange }),
1553
+ hasUser && /* @__PURE__ */ jsx32(HeaderUserArea, { user, onSelect: onUserSelect })
1554
+ ] })
1555
+ ] });
1556
+ }
1557
+ function HeaderDropdownArea({
1558
+ dropdown,
1559
+ onSelect
1560
+ }) {
1561
+ return /* @__PURE__ */ jsxs23(DropdownMenu, { children: [
1562
+ /* @__PURE__ */ jsxs23(
1563
+ DropdownMenuTrigger,
1564
+ {
1565
+ "data-slot": "header-dropdown",
1566
+ className: cn(menuItemClass, "outline-hidden"),
1567
+ children: [
1568
+ dropdown.label,
1569
+ /* @__PURE__ */ jsx32(ChevronDownIcon, { className: "size-3.5", "aria-hidden": "true" })
1570
+ ]
1571
+ }
1572
+ ),
1573
+ /* @__PURE__ */ jsx32(DropdownMenuContent, { children: dropdown.items.map((item) => /* @__PURE__ */ jsxs23(
1574
+ DropdownMenuItem,
1575
+ {
1576
+ disabled: item.disabled,
1577
+ onClick: () => onSelect?.(item.value),
1578
+ children: [
1579
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1580
+ item.label
1581
+ ]
1582
+ },
1583
+ item.value
1584
+ )) })
1585
+ ] });
1586
+ }
1587
+ function HeaderMenuArea({
1588
+ items,
1589
+ onSelect
1590
+ }) {
1591
+ return /* @__PURE__ */ jsx32("nav", { "data-slot": "header-menu", className: "flex items-center gap-1", children: items.map(
1592
+ (item) => item.children !== void 0 && item.children.length > 0 ? /* @__PURE__ */ jsxs23(DropdownMenu, { children: [
1593
+ /* @__PURE__ */ jsxs23(
1594
+ DropdownMenuTrigger,
1595
+ {
1596
+ "data-slot": "header-menu-item",
1597
+ "data-key": item.key,
1598
+ className: cn(menuItemClass, "outline-hidden"),
1599
+ children: [
1600
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1601
+ item.label,
1602
+ /* @__PURE__ */ jsx32(ChevronDownIcon, { className: "size-3.5", "aria-hidden": "true" })
1603
+ ]
1604
+ }
1605
+ ),
1606
+ /* @__PURE__ */ jsx32(DropdownMenuContent, { children: item.children.map((child) => /* @__PURE__ */ jsx32(HeaderMenuEntry, { item: child, onSelect }, child.key)) })
1607
+ ] }, item.key) : /* @__PURE__ */ jsxs23(
1608
+ "button",
1609
+ {
1610
+ type: "button",
1611
+ "data-slot": "header-menu-item",
1612
+ "data-key": item.key,
1613
+ className: menuItemClass,
1614
+ onClick: () => onSelect?.(item.key),
1615
+ children: [
1616
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1617
+ item.label
1618
+ ]
1619
+ },
1620
+ item.key
1621
+ )
1622
+ ) });
1623
+ }
1624
+ function HeaderMenuEntry({
1625
+ item,
1626
+ onSelect
1627
+ }) {
1628
+ if (item.children !== void 0 && item.children.length > 0) {
1629
+ return /* @__PURE__ */ jsxs23(DropdownMenuSub, { children: [
1630
+ /* @__PURE__ */ jsxs23(DropdownMenuSubTrigger, { "data-key": item.key, children: [
1631
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1632
+ item.label
1633
+ ] }),
1634
+ /* @__PURE__ */ jsx32(DropdownMenuSubContent, { children: item.children.map((child) => /* @__PURE__ */ jsx32(HeaderMenuEntry, { item: child, onSelect }, child.key)) })
1635
+ ] });
1636
+ }
1637
+ return /* @__PURE__ */ jsxs23(DropdownMenuItem, { "data-key": item.key, onClick: () => onSelect?.(item.key), children: [
1638
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1639
+ item.label
1640
+ ] });
1641
+ }
1642
+ function HeaderUserArea({
1643
+ user,
1644
+ onSelect
1645
+ }) {
1646
+ const identity = /* @__PURE__ */ jsxs23(Fragment2, { children: [
1647
+ /* @__PURE__ */ jsxs23(Avatar, { className: "size-7", children: [
1648
+ user.avatar !== void 0 && /* @__PURE__ */ jsx32(AvatarImage, { src: user.avatar, alt: user.name }),
1649
+ /* @__PURE__ */ jsx32(AvatarFallback, { children: user.name.charAt(0) })
1650
+ ] }),
1651
+ /* @__PURE__ */ jsx32("span", { className: "text-sm", children: user.name })
1652
+ ] });
1653
+ if (user.items === void 0 || user.items.length === 0) {
1654
+ return /* @__PURE__ */ jsx32("div", { "data-slot": "header-user", className: "flex items-center gap-2", children: identity });
1655
+ }
1656
+ return /* @__PURE__ */ jsxs23(DropdownMenu, { children: [
1657
+ /* @__PURE__ */ jsx32(
1658
+ DropdownMenuTrigger,
1659
+ {
1660
+ "data-slot": "header-user",
1661
+ className: "flex items-center gap-2 rounded-md px-2 py-1.5 transition-colors outline-hidden hover:bg-accent/50",
1662
+ children: identity
1663
+ }
1664
+ ),
1665
+ /* @__PURE__ */ jsx32(DropdownMenuContent, { align: "end", children: user.items.map((item) => /* @__PURE__ */ jsxs23(DropdownMenuItem, { onClick: () => onSelect?.(item.value), children: [
1666
+ item.icon ? /* @__PURE__ */ jsx32(Icon, { name: item.icon, size: "sm" }) : null,
1667
+ item.label
1668
+ ] }, item.value)) })
1669
+ ] });
1670
+ }
1671
+ function HeaderLocalesArea({
1672
+ locales,
1673
+ onSelect
1674
+ }) {
1675
+ const { locale } = useI18n4();
1676
+ const current = locales.find((option) => option.value === locale);
1677
+ return /* @__PURE__ */ jsxs23(DropdownMenu, { children: [
1678
+ /* @__PURE__ */ jsxs23(
1679
+ DropdownMenuTrigger,
1680
+ {
1681
+ "data-slot": "header-locales",
1682
+ className: cn(menuItemClass, "outline-hidden"),
1683
+ children: [
1684
+ current?.label ?? locale,
1685
+ /* @__PURE__ */ jsx32(ChevronDownIcon, { className: "size-3.5", "aria-hidden": "true" })
1686
+ ]
1687
+ }
1688
+ ),
1689
+ /* @__PURE__ */ jsx32(DropdownMenuContent, { align: "end", children: locales.map((option) => /* @__PURE__ */ jsx32(
1690
+ DropdownMenuItem,
1691
+ {
1692
+ onClick: () => onSelect?.(option.value),
1693
+ children: option.label
1694
+ },
1695
+ option.value
1696
+ )) })
1697
+ ] });
1698
+ }
1699
+
1700
+ // src/components/components/HoverCard/index.tsx
1701
+ import { useRenderer as useRenderer8 } from "@pactor-app/runtime";
1702
+ import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
1703
+ function isDslNode2(value) {
1704
+ return typeof value === "object" && value !== null && typeof value.type === "string";
1705
+ }
1706
+ function HoverCard2({ content, children, className, style }) {
1707
+ const { renderChildren } = useRenderer8();
1708
+ return /* @__PURE__ */ jsxs24(HoverCard, { children: [
1709
+ /* @__PURE__ */ jsx33(HoverCardTrigger, { render: triggerWrapper("hover-card-trigger-wrap"), children }),
1710
+ /* @__PURE__ */ jsx33(HoverCardContent, { className, style, children: isDslNode2(content) ? renderChildren([content]) : content })
1711
+ ] });
1712
+ }
1713
+
1714
+ // src/components/components/Input/index.tsx
1715
+ import { useEffect as useEffect6, useId as useId3 } from "react";
1716
+ import { jsx as jsx34, jsxs as jsxs25 } from "react/jsx-runtime";
1717
+ function Input2({
1718
+ name,
1719
+ label,
1720
+ rules,
1721
+ value,
1722
+ type = "text",
1723
+ placeholder,
1724
+ disabled,
1725
+ onChange,
1726
+ className,
1727
+ style
1728
+ }) {
1729
+ const form = useFormContext();
1730
+ const controlId = useId3();
1731
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
1732
+ useEffect6(() => {
1733
+ if (inForm && form && name) {
1734
+ form.registerField(name, rules, value);
1735
+ return () => form.unregisterField(name);
1736
+ }
1737
+ return void 0;
1738
+ });
1739
+ if (inForm && form && name) {
1740
+ const fieldValue = form.values[name];
1741
+ const error = form.errors[name];
1742
+ return /* @__PURE__ */ jsxs25(
1743
+ "div",
1744
+ {
1745
+ "data-slot": "form-item",
1746
+ className: cn(formItemClass(form.layout), className),
1747
+ style,
1748
+ children: [
1749
+ label ? /* @__PURE__ */ jsx34(
1750
+ "label",
1751
+ {
1752
+ htmlFor: controlId,
1753
+ className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
1754
+ children: label
1755
+ }
1756
+ ) : null,
1757
+ /* @__PURE__ */ jsx34(
1758
+ Input,
1759
+ {
1760
+ id: controlId,
1761
+ type,
1762
+ value: typeof fieldValue === "string" ? fieldValue : "",
1763
+ placeholder,
1764
+ disabled,
1765
+ onChange: (event) => {
1766
+ form.setValue(name, event.target.value);
1767
+ onChange?.(event.target.value);
1768
+ }
1769
+ }
1770
+ ),
1771
+ error ? /* @__PURE__ */ jsx34("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
1772
+ ]
1773
+ }
1774
+ );
1775
+ }
1776
+ return /* @__PURE__ */ jsx34(
1777
+ Input,
1778
+ {
1779
+ type,
1780
+ value: value ?? "",
1781
+ placeholder,
1782
+ disabled,
1783
+ className,
1784
+ style,
1785
+ onChange: (event) => onChange?.(event.target.value)
1786
+ }
1787
+ );
1788
+ }
1789
+
1790
+ // src/components/components/InputGroup/index.tsx
1791
+ import { jsx as jsx35 } from "react/jsx-runtime";
1792
+ function InputGroup2({ className, style, children }) {
1793
+ return /* @__PURE__ */ jsx35(InputGroup, { className, style, children });
1794
+ }
1795
+
1796
+ // src/components/components/InputOTP/index.tsx
1797
+ import { useEffect as useEffect7, useState as useState9 } from "react";
1798
+ import { jsx as jsx36, jsxs as jsxs26 } from "react/jsx-runtime";
1799
+ function InputOTP2({
1800
+ name,
1801
+ label,
1802
+ rules,
1803
+ length = 6,
1804
+ value,
1805
+ disabled,
1806
+ onChange,
1807
+ onComplete,
1808
+ className,
1809
+ style
1810
+ }) {
1811
+ const form = useFormContext();
1812
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
1813
+ useEffect7(() => {
1814
+ if (inForm && form && name) {
1815
+ form.registerField(name, rules, value);
1816
+ return () => form.unregisterField(name);
1817
+ }
1818
+ return void 0;
1819
+ });
1820
+ const [innerValue, setInnerValue] = useState9(typeof value === "string" ? value : "");
1821
+ useEffect7(() => {
1822
+ if (!inForm) setInnerValue(typeof value === "string" ? value : "");
1823
+ }, [inForm, value]);
1824
+ const current = inForm && form && name ? typeof form.values[name] === "string" ? form.values[name] : "" : innerValue;
1825
+ const handleChange = (next) => {
1826
+ if (inForm && form && name) {
1827
+ form.setValue(name, next);
1828
+ } else {
1829
+ setInnerValue(next);
1830
+ }
1831
+ onChange?.(next);
1832
+ if (next.length === length) {
1833
+ onComplete?.(next);
1834
+ }
1835
+ };
1836
+ const control = /* @__PURE__ */ jsx36(
1837
+ InputOTP,
1838
+ {
1839
+ maxLength: length,
1840
+ value: current,
1841
+ onChange: handleChange,
1842
+ disabled,
1843
+ children: /* @__PURE__ */ jsx36(InputOTPGroup, { children: Array.from({ length }, (_, index) => /* @__PURE__ */ jsx36(InputOTPSlot, { index }, index)) })
1844
+ }
1845
+ );
1846
+ if (inForm && form && name) {
1847
+ const error = form.errors[name];
1848
+ return /* @__PURE__ */ jsxs26(
1849
+ "div",
1850
+ {
1851
+ "data-slot": "form-item",
1852
+ className: cn(formItemClass(form.layout), className),
1853
+ style,
1854
+ children: [
1855
+ label ? /* @__PURE__ */ jsx36("label", { className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap", children: label }) : null,
1856
+ control,
1857
+ error ? /* @__PURE__ */ jsx36("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
1858
+ ]
1859
+ }
1860
+ );
1861
+ }
1862
+ return /* @__PURE__ */ jsx36("div", { "data-slot": "input-otp-field", className: cn("inline-block", className), style, children: control });
1863
+ }
1864
+
1865
+ // src/components/components/Item/index.tsx
1866
+ import { useRenderer as useRenderer9 } from "@pactor-app/runtime";
1867
+ import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
1868
+ function Item2({
1869
+ title,
1870
+ description,
1871
+ media,
1872
+ actions,
1873
+ className,
1874
+ style
1875
+ }) {
1876
+ const { renderChildren } = useRenderer9();
1877
+ const mediaNodes = media === void 0 ? [] : Array.isArray(media) ? media : [media];
1878
+ return /* @__PURE__ */ jsxs27(Item, { className, style, children: [
1879
+ mediaNodes.length > 0 ? /* @__PURE__ */ jsx37(ItemMedia, { children: renderChildren(mediaNodes) }) : null,
1880
+ /* @__PURE__ */ jsxs27(ItemContent, { children: [
1881
+ title ? /* @__PURE__ */ jsx37(ItemTitle, { children: title }) : null,
1882
+ description ? /* @__PURE__ */ jsx37(ItemDescription, { children: description }) : null
1883
+ ] }),
1884
+ actions && actions.length > 0 ? /* @__PURE__ */ jsx37(ItemActions, { children: renderChildren(actions) }) : null
1885
+ ] });
1886
+ }
1887
+
1888
+ // src/components/components/Kbd/index.tsx
1889
+ import { jsx as jsx38 } from "react/jsx-runtime";
1890
+ function Kbd2({ text, className, style }) {
1891
+ return /* @__PURE__ */ jsx38(Kbd, { className, style, children: text });
1892
+ }
1893
+
1894
+ // src/components/components/Label/index.tsx
1895
+ import { jsx as jsx39 } from "react/jsx-runtime";
1896
+ function Label2({ text, htmlFor, className, style }) {
1897
+ return /* @__PURE__ */ jsx39(Label, { htmlFor, className, style, children: text });
1898
+ }
1899
+
1900
+ // src/components/components/Layout/index.tsx
1901
+ import { isDslSourceRef } from "@pactor-app/core";
1902
+ import { useRenderer as useRenderer10 } from "@pactor-app/runtime";
1903
+ import { jsx as jsx40 } from "react/jsx-runtime";
1904
+ function Layout({ direction, className, style, dslChildren }) {
1905
+ const { renderChildren, context } = useRenderer10();
1906
+ const hasSider = Array.isArray(dslChildren) ? dslChildren.some(
1907
+ (child) => !isDslSourceRef(child) && resolveRootType(child, context) === "Sider"
1908
+ ) : false;
1909
+ const dir = direction ?? (hasSider ? "horizontal" : "vertical");
1910
+ return /* @__PURE__ */ jsx40(
1911
+ "div",
1912
+ {
1913
+ "data-slot": "layout",
1914
+ "data-direction": dir,
1915
+ className: cn(
1916
+ "flex min-h-0 w-full h-full flex-1",
1917
+ dir === "vertical" ? "flex-col" : "flex-row",
1918
+ className
1919
+ ),
1920
+ style,
1921
+ children: renderChildren(dslChildren)
1922
+ }
1923
+ );
1924
+ }
1925
+ function resolveRootType(node, context) {
1926
+ if (node.component !== void 0) {
1927
+ const def = context.pageComponents[node.component];
1928
+ return def !== void 0 && "type" in def ? def.type : void 0;
1929
+ }
1930
+ return node.type;
1931
+ }
1932
+
1933
+ // src/components/components/Link/index.tsx
1934
+ import { jsx as jsx41 } from "react/jsx-runtime";
1935
+ function Link({ href, text, target, className, style, children }) {
1936
+ return /* @__PURE__ */ jsx41(
1937
+ "a",
1938
+ {
1939
+ "data-slot": "link",
1940
+ href,
1941
+ target,
1942
+ rel: target === "_blank" ? "noreferrer" : void 0,
1943
+ className: cn("text-primary underline-offset-4 hover:underline", className),
1944
+ style,
1945
+ children: text ?? children
1946
+ }
1947
+ );
1948
+ }
1949
+
1950
+ // src/components/components/Sidebar/rail-tooltip.tsx
1951
+ import { jsx as jsx42, jsxs as jsxs28 } from "react/jsx-runtime";
1952
+ function RailTooltip({
1953
+ label,
1954
+ children
1955
+ }) {
1956
+ return /* @__PURE__ */ jsxs28(Tooltip, { children: [
1957
+ /* @__PURE__ */ jsx42(TooltipTrigger, { render: children }),
1958
+ /* @__PURE__ */ jsx42(TooltipContent, { side: "right", sideOffset: 8, children: label })
1959
+ ] });
1960
+ }
1961
+
1962
+ // src/components/components/Sidebar/index.tsx
1963
+ import { useI18n as useI18n5, useRenderer as useRenderer11 } from "@pactor-app/runtime";
1964
+ import { ChevronLeft, ChevronRight } from "lucide-react";
1965
+ import {
1966
+ createContext as createContext2,
1967
+ useCallback as useCallback2,
1968
+ useContext as useContext2,
1969
+ useEffect as useEffect8,
1970
+ useState as useState10
1971
+ } from "react";
1972
+ import { Fragment as Fragment3, jsx as jsx43, jsxs as jsxs29 } from "react/jsx-runtime";
1973
+ var SidebarDrawerContext = createContext2(null);
1974
+ function useSidebarDrawer() {
1975
+ return useContext2(SidebarDrawerContext);
1976
+ }
1977
+ var MOBILE_MEDIA_QUERY = "(max-width: 767px)";
1978
+ function useIsMobileViewport() {
1979
+ const [isMobile, setIsMobile] = useState10(
1980
+ () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(MOBILE_MEDIA_QUERY).matches
1981
+ );
1982
+ useEffect8(() => {
1983
+ if (typeof window.matchMedia !== "function") {
1984
+ return;
1985
+ }
1986
+ const media = window.matchMedia(MOBILE_MEDIA_QUERY);
1987
+ const onChange = (event) => {
1988
+ setIsMobile(event.matches);
1989
+ };
1990
+ setIsMobile(media.matches);
1991
+ media.addEventListener("change", onChange);
1992
+ return () => media.removeEventListener("change", onChange);
1993
+ }, []);
1994
+ return isMobile;
1995
+ }
1996
+ function useOptionalRenderer() {
1997
+ try {
1998
+ return useRenderer11();
1999
+ } catch {
2000
+ return null;
2001
+ }
2002
+ }
2003
+ function SidebarContent({ content }) {
2004
+ const renderer = useOptionalRenderer();
2005
+ if (renderer !== null && typeof content === "object" && content !== null && !("$$typeof" in content) && "type" in content) {
2006
+ return /* @__PURE__ */ jsx43(Fragment3, { children: renderer.renderChildren([content]) });
2007
+ }
2008
+ return /* @__PURE__ */ jsx43(Fragment3, { children: content });
2009
+ }
2010
+ function isBrandObject(brand) {
2011
+ return typeof brand === "object" && brand !== null && !("$$typeof" in brand) && "title" in brand;
2012
+ }
2013
+ function Sidebar({
2014
+ brand,
2015
+ items = [],
2016
+ content,
2017
+ sidebarFooter,
2018
+ collapsible,
2019
+ onCollapse,
2020
+ locationKey,
2021
+ drawer = true,
2022
+ className,
2023
+ style,
2024
+ children
2025
+ }) {
2026
+ const { t } = useI18n5();
2027
+ const isMobile = useIsMobileViewport();
2028
+ const [drawerOpen, setDrawerOpen] = useState10(false);
2029
+ const [collapsed, setCollapsed] = useState10(false);
2030
+ const collapsedEffective = collapsible === true && collapsed && !isMobile;
2031
+ const close = useCallback2(() => setDrawerOpen(false), []);
2032
+ const toggleCollapsed = () => {
2033
+ const next = !collapsed;
2034
+ setCollapsed(next);
2035
+ onCollapse?.(next);
2036
+ };
2037
+ const [trackedLocationKey, setTrackedLocationKey] = useState10(locationKey);
2038
+ if (trackedLocationKey !== locationKey) {
2039
+ setTrackedLocationKey(locationKey);
2040
+ setDrawerOpen(false);
2041
+ }
2042
+ useEffect8(() => {
2043
+ if (!drawerOpen) {
2044
+ return;
2045
+ }
2046
+ const onKeyDown = (event) => {
2047
+ if (event.key === "Escape") {
2048
+ setDrawerOpen(false);
2049
+ }
2050
+ };
2051
+ window.addEventListener("keydown", onKeyDown);
2052
+ return () => window.removeEventListener("keydown", onKeyDown);
2053
+ }, [drawerOpen]);
2054
+ const brandNode = isBrandObject(brand) ? /* @__PURE__ */ jsxs29(Fragment3, { children: [
2055
+ brand.logo ? /* @__PURE__ */ jsx43(
2056
+ "img",
2057
+ {
2058
+ "data-slot": "sidebar-brand-logo",
2059
+ src: brand.logo,
2060
+ alt: brand.title,
2061
+ className: "size-6 shrink-0"
2062
+ }
2063
+ ) : null,
2064
+ collapsedEffective ? null : /* @__PURE__ */ jsx43("span", { className: "truncate text-sm font-semibold", children: brand.title })
2065
+ ] }) : brand;
2066
+ const collapseTrigger = collapsible && !isMobile ? /* @__PURE__ */ jsx43(
2067
+ "button",
2068
+ {
2069
+ type: "button",
2070
+ "data-slot": "sidebar-collapse-trigger",
2071
+ "aria-label": collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
2072
+ "aria-expanded": !collapsedEffective,
2073
+ title: collapsedEffective ? t("pactor.layout.expandSidebar") : t("pactor.layout.collapseSidebar"),
2074
+ className: cn(
2075
+ "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"
2076
+ ),
2077
+ onClick: toggleCollapsed,
2078
+ children: collapsedEffective ? /* @__PURE__ */ jsx43(ChevronRight, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ jsx43(ChevronLeft, { "aria-hidden": true, className: "size-4" })
2079
+ }
2080
+ ) : null;
2081
+ return /* @__PURE__ */ jsx43(
2082
+ SidebarDrawerContext.Provider,
2083
+ {
2084
+ value: { close, collapsed: collapsedEffective },
2085
+ children: /* @__PURE__ */ jsxs29(
2086
+ "div",
2087
+ {
2088
+ "data-slot": "sidebar-layout",
2089
+ className: cn("flex min-h-screen w-full", className),
2090
+ style,
2091
+ children: [
2092
+ drawer && drawerOpen ? /* @__PURE__ */ jsx43(
2093
+ "div",
2094
+ {
2095
+ "data-slot": "sidebar-scrim",
2096
+ "aria-hidden": true,
2097
+ className: "fixed inset-0 z-40 bg-black/40 md:hidden",
2098
+ onClick: close
2099
+ }
2100
+ ) : null,
2101
+ /* @__PURE__ */ jsxs29(
2102
+ "aside",
2103
+ {
2104
+ "data-slot": "sidebar",
2105
+ "data-collapsed": collapsedEffective || void 0,
2106
+ "data-open": drawerOpen ? "true" : "false",
2107
+ inert: drawer && isMobile && !drawerOpen ? true : void 0,
2108
+ className: cn(
2109
+ "flex shrink-0 flex-col border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-[width,transform]",
2110
+ collapsedEffective ? "w-16" : "w-60",
2111
+ // 移动端覆盖抽屉:退出文档流,关闭时移出屏幕
2112
+ 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"
2113
+ ),
2114
+ children: [
2115
+ brand !== void 0 || collapseTrigger !== null ? /* @__PURE__ */ jsxs29(
2116
+ "div",
2117
+ {
2118
+ "data-slot": "sidebar-brand",
2119
+ className: cn(
2120
+ "flex h-14 shrink-0 items-center gap-2 border-b border-sidebar-border px-4",
2121
+ // 移动端品牌维持顶栏现状:抽屉内不重复渲染品牌行
2122
+ "max-md:hidden",
2123
+ collapsedEffective && "justify-center px-2"
2124
+ ),
2125
+ children: [
2126
+ collapsedEffective ? null : /* @__PURE__ */ jsx43("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: brandNode }),
2127
+ collapseTrigger
2128
+ ]
2129
+ }
2130
+ ) : null,
2131
+ /* @__PURE__ */ jsx43(
2132
+ "nav",
2133
+ {
2134
+ "data-slot": "sidebar-nav",
2135
+ className: "min-h-0 flex-1 overflow-auto p-2",
2136
+ children: content !== void 0 && content !== null ? /* @__PURE__ */ jsx43(SidebarContent, { content }) : items.map((item, index) => /* @__PURE__ */ jsx43(
2137
+ SidebarEntry,
2138
+ {
2139
+ item,
2140
+ depth: 0,
2141
+ collapsed: collapsedEffective
2142
+ },
2143
+ item.href ?? item.label ?? index
2144
+ ))
2145
+ }
2146
+ ),
2147
+ sidebarFooter !== void 0 && sidebarFooter !== null && !collapsedEffective ? /* @__PURE__ */ jsx43(
2148
+ "div",
2149
+ {
2150
+ "data-slot": "sidebar-footer",
2151
+ className: "shrink-0 border-t border-sidebar-border p-2",
2152
+ children: sidebarFooter
2153
+ }
2154
+ ) : null
2155
+ ]
2156
+ }
2157
+ ),
2158
+ /* @__PURE__ */ jsxs29("main", { "data-slot": "sidebar-content", className: "min-w-0 flex-1", children: [
2159
+ drawer ? /* @__PURE__ */ jsxs29(
2160
+ "div",
2161
+ {
2162
+ "data-slot": "sidebar-topbar",
2163
+ className: "flex h-14 items-center gap-2 border-b border-sidebar-border bg-sidebar px-3 md:hidden",
2164
+ children: [
2165
+ /* @__PURE__ */ jsx43(
2166
+ "button",
2167
+ {
2168
+ type: "button",
2169
+ "data-slot": "sidebar-menu-trigger",
2170
+ "aria-label": t("pactor.layout.openNavigation"),
2171
+ "aria-expanded": drawerOpen,
2172
+ className: "flex size-8 items-center justify-center rounded-md text-sidebar-foreground/60 transition-colors hover:bg-sidebar-accent hover:text-sidebar-foreground",
2173
+ onClick: () => setDrawerOpen(true),
2174
+ children: /* @__PURE__ */ jsx43(Icon, { name: "menu", size: 18 })
2175
+ }
2176
+ ),
2177
+ brandNode
2178
+ ]
2179
+ }
2180
+ ) : null,
2181
+ children
2182
+ ] })
2183
+ ]
2184
+ }
2185
+ )
2186
+ }
2187
+ );
2188
+ }
2189
+ function SidebarEntry({
2190
+ item,
2191
+ depth,
2192
+ collapsed
2193
+ }) {
2194
+ const entryClass = cn(
2195
+ "flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors",
2196
+ "text-sidebar-foreground/70 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
2197
+ collapsed && "justify-center px-0"
2198
+ );
2199
+ const indentStyle = !collapsed && depth > 0 ? { paddingLeft: 12 + depth * 16 } : void 0;
2200
+ const labelNode = collapsed ? null : item.label;
2201
+ const iconNode = item.icon ? /* @__PURE__ */ jsx43(Icon, { name: item.icon, size: "sm" }) : null;
2202
+ const entry = item.href ? /* @__PURE__ */ jsxs29(
2203
+ "a",
2204
+ {
2205
+ "data-slot": "sidebar-item",
2206
+ href: item.href,
2207
+ className: entryClass,
2208
+ style: indentStyle,
2209
+ children: [
2210
+ iconNode,
2211
+ labelNode
2212
+ ]
2213
+ }
2214
+ ) : /* @__PURE__ */ jsxs29("span", { "data-slot": "sidebar-item", className: entryClass, style: indentStyle, children: [
2215
+ iconNode,
2216
+ labelNode
2217
+ ] });
2218
+ return /* @__PURE__ */ jsxs29("div", { "data-slot": "sidebar-entry", children: [
2219
+ collapsed ? /* @__PURE__ */ jsx43(RailTooltip, { label: item.label, children: entry }) : entry,
2220
+ item.children?.map((child, index) => /* @__PURE__ */ jsx43(
2221
+ SidebarEntry,
2222
+ {
2223
+ item: child,
2224
+ depth: depth + 1,
2225
+ collapsed
2226
+ },
2227
+ child.href ?? child.label ?? index
2228
+ ))
2229
+ ] });
2230
+ }
2231
+
2232
+ // src/components/components/Menu/index.tsx
2233
+ import { jsx as jsx44, jsxs as jsxs30 } from "react/jsx-runtime";
2234
+ function Menu({
2235
+ items = [],
2236
+ mode = "inline",
2237
+ selectedKey,
2238
+ onSelect,
2239
+ className,
2240
+ style
2241
+ }) {
2242
+ const drawer = useSidebarDrawer();
2243
+ const collapsed = mode === "inline" && drawer?.collapsed === true;
2244
+ let previousGroup;
2245
+ return /* @__PURE__ */ jsx44(
2246
+ "nav",
2247
+ {
2248
+ "data-slot": "menu",
2249
+ "data-mode": mode,
2250
+ "data-collapsed": collapsed || void 0,
2251
+ className: cn(
2252
+ mode === "horizontal" ? "flex items-center gap-1" : "flex flex-col gap-0.5 p-2",
2253
+ className
2254
+ ),
2255
+ style,
2256
+ children: items.map((item) => {
2257
+ let groupLabel;
2258
+ if (!collapsed && mode === "inline" && item.group !== void 0 && item.group !== previousGroup) {
2259
+ groupLabel = item.group;
2260
+ }
2261
+ previousGroup = item.group;
2262
+ return /* @__PURE__ */ jsxs30("div", { "data-slot": "menu-group-entry", children: [
2263
+ groupLabel !== void 0 && /* @__PURE__ */ jsx44(
2264
+ "div",
2265
+ {
2266
+ "data-slot": "menu-group",
2267
+ className: "px-3 pb-1 pt-3 text-xs font-medium text-muted-foreground first:pt-1",
2268
+ children: groupLabel
2269
+ }
2270
+ ),
2271
+ /* @__PURE__ */ jsx44(
2272
+ MenuEntry,
2273
+ {
2274
+ item,
2275
+ mode,
2276
+ depth: 0,
2277
+ selectedKey,
2278
+ onSelect,
2279
+ collapsed
2280
+ }
2281
+ )
2282
+ ] }, item.key);
2283
+ })
2284
+ }
2285
+ );
2286
+ }
2287
+ function MenuEntry({
2288
+ item,
2289
+ mode,
2290
+ depth,
2291
+ selectedKey,
2292
+ onSelect,
2293
+ collapsed = false
2294
+ }) {
2295
+ const selected = item.key === selectedKey;
2296
+ const button = /* @__PURE__ */ jsxs30(
2297
+ "button",
2298
+ {
2299
+ type: "button",
2300
+ "data-slot": "menu-item",
2301
+ "aria-current": selected ? "page" : void 0,
2302
+ disabled: item.disabled,
2303
+ className: cn(
2304
+ "flex w-full items-center gap-2 rounded-md text-sm transition-colors",
2305
+ mode === "horizontal" ? "px-3 py-2" : "px-3 py-2 text-left",
2306
+ collapsed && "justify-center px-0",
2307
+ selected ? "bg-accent font-medium text-accent-foreground" : "text-muted-foreground hover:bg-accent/50 hover:text-foreground",
2308
+ item.disabled && "cursor-not-allowed opacity-50 hover:bg-transparent hover:text-muted-foreground"
2309
+ ),
2310
+ style: mode === "inline" && depth > 0 && !collapsed ? { paddingLeft: 12 + depth * 16 } : void 0,
2311
+ onClick: () => {
2312
+ if (!item.disabled) {
2313
+ onSelect?.(item.key);
2314
+ }
2315
+ },
2316
+ children: [
2317
+ item.icon ? /* @__PURE__ */ jsx44(Icon, { name: item.icon, size: "sm" }) : null,
2318
+ collapsed ? null : /* @__PURE__ */ jsx44("span", { className: "min-w-0 flex-1 truncate text-left", children: item.label }),
2319
+ item.dot && !collapsed ? /* @__PURE__ */ jsx44("span", { "data-slot": "menu-item-dot", className: "size-1.5 shrink-0 rounded-full bg-destructive" }) : null,
2320
+ item.badge !== void 0 && !collapsed ? /* @__PURE__ */ jsx44(
2321
+ "span",
2322
+ {
2323
+ "data-slot": "menu-item-badge",
2324
+ className: "shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",
2325
+ children: item.badge
2326
+ }
2327
+ ) : null
2328
+ ]
2329
+ }
2330
+ );
2331
+ return /* @__PURE__ */ jsxs30("div", { "data-slot": "menu-entry", "data-key": item.key, children: [
2332
+ collapsed ? /* @__PURE__ */ jsx44(RailTooltip, { label: item.label, children: button }) : button,
2333
+ item.children?.map((child) => /* @__PURE__ */ jsx44(
2334
+ MenuEntry,
2335
+ {
2336
+ item: child,
2337
+ mode,
2338
+ depth: depth + 1,
2339
+ selectedKey,
2340
+ onSelect,
2341
+ collapsed
2342
+ },
2343
+ child.key
2344
+ ))
2345
+ ] });
2346
+ }
2347
+
2348
+ // src/components/components/Menubar/index.tsx
2349
+ import { jsx as jsx45, jsxs as jsxs31 } from "react/jsx-runtime";
2350
+ function Menubar2({ menus = [], onSelect, className, style }) {
2351
+ return /* @__PURE__ */ jsx45(Menubar, { className, style, children: menus.map((menu) => /* @__PURE__ */ jsxs31(MenubarMenu, { children: [
2352
+ /* @__PURE__ */ jsx45(MenubarTrigger, { children: menu.label }),
2353
+ /* @__PURE__ */ jsx45(MenubarContent, { children: menu.items.map((item) => /* @__PURE__ */ jsxs31(
2354
+ MenubarItem,
2355
+ {
2356
+ disabled: item.disabled,
2357
+ onClick: () => onSelect?.(item.value),
2358
+ children: [
2359
+ item.icon ? /* @__PURE__ */ jsx45(Icon, { name: item.icon, size: "sm" }) : null,
2360
+ item.label
2361
+ ]
2362
+ },
2363
+ item.value
2364
+ )) })
2365
+ ] }, menu.label)) });
2366
+ }
2367
+
2368
+ // src/components/components/NavigationMenu/index.tsx
2369
+ import { Fragment as Fragment4, jsx as jsx46, jsxs as jsxs32 } from "react/jsx-runtime";
2370
+ function NavigationMenu2({ items = [], className, style }) {
2371
+ return /* @__PURE__ */ jsx46(NavigationMenu, { className, style, children: /* @__PURE__ */ jsx46(NavigationMenuList, { children: items.map((item, index) => /* @__PURE__ */ jsx46(NavigationMenuItem, { value: `item-${index}`, children: item.children && item.children.length > 0 ? /* @__PURE__ */ jsxs32(Fragment4, { children: [
2372
+ /* @__PURE__ */ jsxs32(
2373
+ NavigationMenuTrigger,
2374
+ {
2375
+ className: item.icon !== void 0 ? "gap-2" : void 0,
2376
+ children: [
2377
+ item.icon ? /* @__PURE__ */ jsx46(Icon, { name: item.icon, size: "sm" }) : null,
2378
+ item.label
2379
+ ]
2380
+ }
2381
+ ),
2382
+ /* @__PURE__ */ jsx46(NavigationMenuContent, { children: /* @__PURE__ */ jsx46("ul", { className: "grid w-64 gap-1", children: item.children.map((child) => /* @__PURE__ */ jsx46("li", { children: /* @__PURE__ */ jsxs32(NavigationMenuLink, { href: child.href, children: [
2383
+ /* @__PURE__ */ jsxs32(
2384
+ "span",
2385
+ {
2386
+ className: child.icon !== void 0 ? "flex items-center gap-2 font-medium" : "font-medium",
2387
+ children: [
2388
+ child.icon ? /* @__PURE__ */ jsx46(Icon, { name: child.icon, size: "sm" }) : null,
2389
+ child.label
2390
+ ]
2391
+ }
2392
+ ),
2393
+ child.description ? /* @__PURE__ */ jsx46("span", { className: "text-muted-foreground", children: child.description }) : null
2394
+ ] }) }, child.href)) }) })
2395
+ ] }) : /* @__PURE__ */ jsxs32(
2396
+ NavigationMenuLink,
2397
+ {
2398
+ href: item.href,
2399
+ className: cn(
2400
+ navigationMenuTriggerStyle(),
2401
+ item.icon !== void 0 && "gap-2"
2402
+ ),
2403
+ children: [
2404
+ item.icon ? /* @__PURE__ */ jsx46(Icon, { name: item.icon, size: "sm" }) : null,
2405
+ item.label
2406
+ ]
2407
+ }
2408
+ ) }, `${item.label}-${index}`)) }) });
2409
+ }
2410
+
2411
+ // src/components/components/Page/index.tsx
2412
+ import { jsx as jsx47, jsxs as jsxs33 } from "react/jsx-runtime";
2413
+ function Page({ title, className, style, children }) {
2414
+ return /* @__PURE__ */ jsxs33("div", { "data-slot": "page", className: cn("p-6", className), style, children: [
2415
+ title ? /* @__PURE__ */ jsx47("h2", { "data-slot": "page-title", className: "mb-5 text-xl font-semibold", children: title }) : null,
2416
+ /* @__PURE__ */ jsx47("div", { "data-slot": "page-content", className: "space-y-5", children })
2417
+ ] });
2418
+ }
2419
+
2420
+ // src/components/components/Pagination/index.tsx
2421
+ import { useState as useState11 } from "react";
2422
+ import { jsx as jsx48, jsxs as jsxs34 } from "react/jsx-runtime";
2423
+ function pageItems(current, count) {
2424
+ if (count <= 7) {
2425
+ return Array.from({ length: count }, (_, i) => i + 1);
2426
+ }
2427
+ if (current <= 4) {
2428
+ return [1, 2, 3, 4, 5, "ellipsis", count];
2429
+ }
2430
+ if (current >= count - 3) {
2431
+ return [1, "ellipsis", count - 4, count - 3, count - 2, count - 1, count];
2432
+ }
2433
+ return [1, "ellipsis", current - 1, current, current + 1, "ellipsis", count];
2434
+ }
2435
+ function Pagination2({
2436
+ total = 0,
2437
+ pageSize = 10,
2438
+ page,
2439
+ onChange,
2440
+ className,
2441
+ style
2442
+ }) {
2443
+ const [innerPage, setInnerPage] = useState11(1);
2444
+ const pageCount = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
2445
+ const current = Math.min(Math.max(1, page ?? innerPage), pageCount);
2446
+ const goTo = (next) => {
2447
+ const target = Math.min(Math.max(1, next), pageCount);
2448
+ if (target === current) {
2449
+ return;
2450
+ }
2451
+ if (page === void 0) {
2452
+ setInnerPage(target);
2453
+ }
2454
+ onChange?.(target);
2455
+ };
2456
+ return /* @__PURE__ */ jsx48(Pagination, { className, style, children: /* @__PURE__ */ jsxs34(PaginationContent, { children: [
2457
+ /* @__PURE__ */ jsx48(PaginationItem, { children: /* @__PURE__ */ jsx48(
2458
+ PaginationPrevious,
2459
+ {
2460
+ href: "#",
2461
+ disabled: current <= 1,
2462
+ onClick: (e) => {
2463
+ e.preventDefault();
2464
+ goTo(current - 1);
2465
+ }
2466
+ }
2467
+ ) }),
2468
+ pageItems(current, pageCount).map((item, index) => /* @__PURE__ */ jsx48(PaginationItem, { children: item === "ellipsis" ? /* @__PURE__ */ jsx48(PaginationEllipsis, {}) : /* @__PURE__ */ jsx48(
2469
+ PaginationLink,
2470
+ {
2471
+ href: "#",
2472
+ isActive: item === current,
2473
+ onClick: (e) => {
2474
+ e.preventDefault();
2475
+ goTo(item);
2476
+ },
2477
+ children: item
2478
+ }
2479
+ ) }, item === "ellipsis" ? `ellipsis-${index}` : item)),
2480
+ /* @__PURE__ */ jsx48(PaginationItem, { children: /* @__PURE__ */ jsx48(
2481
+ PaginationNext,
2482
+ {
2483
+ href: "#",
2484
+ disabled: current >= pageCount,
2485
+ onClick: (e) => {
2486
+ e.preventDefault();
2487
+ goTo(current + 1);
2488
+ }
2489
+ }
2490
+ ) })
2491
+ ] }) });
2492
+ }
2493
+
2494
+ // src/components/components/Popover/index.tsx
2495
+ import { useRenderer as useRenderer12 } from "@pactor-app/runtime";
2496
+ import { jsx as jsx49, jsxs as jsxs35 } from "react/jsx-runtime";
2497
+ function isDslNode3(value) {
2498
+ return typeof value === "object" && value !== null && typeof value.type === "string";
2499
+ }
2500
+ function Popover2({ content, children, className, style }) {
2501
+ const { renderChildren } = useRenderer12();
2502
+ return /* @__PURE__ */ jsxs35(Popover, { children: [
2503
+ /* @__PURE__ */ jsx49(
2504
+ PopoverTrigger,
2505
+ {
2506
+ nativeButton: false,
2507
+ render: triggerWrapper("popover-trigger-wrap"),
2508
+ children
2509
+ }
2510
+ ),
2511
+ /* @__PURE__ */ jsx49(PopoverContent, { className, style, children: isDslNode3(content) ? renderChildren([content]) : content })
2512
+ ] });
2513
+ }
2514
+
2515
+ // src/components/components/Progress/index.tsx
2516
+ import { jsx as jsx50 } from "react/jsx-runtime";
2517
+ function Progress2({ value, className, style }) {
2518
+ const resolved = typeof value === "number" && Number.isFinite(value) ? Math.min(100, Math.max(0, value)) : null;
2519
+ return /* @__PURE__ */ jsx50(Progress, { value: resolved, className, style, children: /* @__PURE__ */ jsx50(ProgressTrack, { children: /* @__PURE__ */ jsx50(ProgressIndicator, {}) }) });
2520
+ }
2521
+
2522
+ // src/components/components/RadioGroup/index.tsx
2523
+ import { useEffect as useEffect9, useId as useId4 } from "react";
2524
+
2525
+ // src/components/components/Form/form-item.tsx
2526
+ import { jsx as jsx51, jsxs as jsxs36 } from "react/jsx-runtime";
2527
+ function FieldShell({
2528
+ layout,
2529
+ label,
2530
+ htmlFor,
2531
+ error,
2532
+ className,
2533
+ style,
2534
+ children
2535
+ }) {
2536
+ return /* @__PURE__ */ jsxs36(
2537
+ "div",
2538
+ {
2539
+ "data-slot": "form-item",
2540
+ className: cn(formItemClass(layout), className),
2541
+ style,
2542
+ children: [
2543
+ label ? /* @__PURE__ */ jsx51(
2544
+ "label",
2545
+ {
2546
+ htmlFor,
2547
+ className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
2548
+ children: label
2549
+ }
2550
+ ) : null,
2551
+ children,
2552
+ error ? /* @__PURE__ */ jsx51("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
2553
+ ]
2554
+ }
2555
+ );
2556
+ }
2557
+
2558
+ // src/components/components/RadioGroup/index.tsx
2559
+ import { jsx as jsx52, jsxs as jsxs37 } from "react/jsx-runtime";
2560
+ function RadioGroup2({
2561
+ name,
2562
+ label,
2563
+ rules,
2564
+ options = [],
2565
+ value,
2566
+ disabled,
2567
+ onChange,
2568
+ className,
2569
+ style
2570
+ }) {
2571
+ const form = useFormContext();
2572
+ const controlId = useId4();
2573
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
2574
+ useEffect9(() => {
2575
+ if (inForm && form && name) {
2576
+ form.registerField(name, rules, value);
2577
+ return () => form.unregisterField(name);
2578
+ }
2579
+ return void 0;
2580
+ });
2581
+ const current = inForm && form && name ? form.values[name] : value;
2582
+ const handleChange = (next) => {
2583
+ if (inForm && form && name) {
2584
+ form.setValue(name, next);
2585
+ }
2586
+ onChange?.(next);
2587
+ };
2588
+ const groupValue = current ?? "";
2589
+ const group = /* @__PURE__ */ jsx52(
2590
+ RadioGroup,
2591
+ {
2592
+ value: groupValue,
2593
+ onValueChange: handleChange,
2594
+ disabled,
2595
+ name: inForm ? name : void 0,
2596
+ className: cn(!inForm && className),
2597
+ style: inForm ? void 0 : style,
2598
+ children: options.map((option, index) => {
2599
+ const optionId = `${controlId}-${index}`;
2600
+ return /* @__PURE__ */ jsxs37("span", { className: "inline-flex items-center gap-2", children: [
2601
+ /* @__PURE__ */ jsx52(
2602
+ RadioGroupItem,
2603
+ {
2604
+ id: optionId,
2605
+ value: option.value,
2606
+ disabled: option.disabled
2607
+ }
2608
+ ),
2609
+ /* @__PURE__ */ jsx52("label", { htmlFor: optionId, className: "text-sm leading-none font-medium", children: option.label })
2610
+ ] }, String(option.value));
2611
+ })
2612
+ }
2613
+ );
2614
+ if (inForm && form && name) {
2615
+ return /* @__PURE__ */ jsx52(
2616
+ FieldShell,
2617
+ {
2618
+ layout: form.layout,
2619
+ label,
2620
+ error: form.errors[name],
2621
+ className,
2622
+ style,
2623
+ children: group
2624
+ }
2625
+ );
2626
+ }
2627
+ return group;
2628
+ }
2629
+
2630
+ // src/components/components/Resizable/index.tsx
2631
+ import { useRenderer as useRenderer13 } from "@pactor-app/runtime";
2632
+ import { Fragment as Fragment5 } from "react";
2633
+ import { jsx as jsx53, jsxs as jsxs38 } from "react/jsx-runtime";
2634
+ function Resizable({
2635
+ panels = [],
2636
+ direction = "horizontal",
2637
+ className,
2638
+ style
2639
+ }) {
2640
+ const { renderChildren } = useRenderer13();
2641
+ return /* @__PURE__ */ jsx53(PanelGroup, { orientation: direction, className, style, children: panels.map((panel, index) => /* @__PURE__ */ jsxs38(Fragment5, { children: [
2642
+ index > 0 ? /* @__PURE__ */ jsx53(ResizableHandle, { withHandle: true }) : null,
2643
+ /* @__PURE__ */ jsx53(
2644
+ Panel,
2645
+ {
2646
+ defaultSize: typeof panel.defaultSize === "number" ? `${panel.defaultSize}%` : void 0,
2647
+ children: renderChildren(panel.children)
2648
+ }
2649
+ )
2650
+ ] }, index)) });
2651
+ }
2652
+
2653
+ // src/components/components/ScrollArea/index.tsx
2654
+ import { jsx as jsx54 } from "react/jsx-runtime";
2655
+ function ScrollArea2({
2656
+ maxHeight,
2657
+ maxWidth,
2658
+ className,
2659
+ style,
2660
+ children
2661
+ }) {
2662
+ return /* @__PURE__ */ jsx54(
2663
+ ScrollArea,
2664
+ {
2665
+ className,
2666
+ style: { maxHeight, maxWidth, ...style },
2667
+ children
2668
+ }
2669
+ );
2670
+ }
2671
+
2672
+ // src/components/components/Select/index.tsx
2673
+ import { useI18n as useI18n6 } from "@pactor-app/runtime";
2674
+ import { useEffect as useEffect10, useId as useId5 } from "react";
2675
+ import { jsx as jsx55, jsxs as jsxs39 } from "react/jsx-runtime";
2676
+ function Select2({
2677
+ name,
2678
+ label,
2679
+ rules,
2680
+ options = [],
2681
+ value,
2682
+ placeholder,
2683
+ disabled,
2684
+ allowClear,
2685
+ onChange,
2686
+ className,
2687
+ style
2688
+ }) {
2689
+ const form = useFormContext();
2690
+ const { t } = useI18n6();
2691
+ const controlId = useId5();
2692
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
2693
+ useEffect10(() => {
2694
+ if (inForm && form && name) {
2695
+ form.registerField(name, rules, value);
2696
+ return () => form.unregisterField(name);
2697
+ }
2698
+ return void 0;
2699
+ });
2700
+ const current = inForm && form && name ? form.values[name] : value;
2701
+ const selectedValue = current === void 0 || current === null || current === "" ? null : current;
2702
+ const handleChange = (next) => {
2703
+ if (inForm && form && name) {
2704
+ form.setValue(name, next ?? void 0);
2705
+ }
2706
+ onChange?.(next ?? void 0);
2707
+ };
2708
+ const inFormRoot = inForm === true;
2709
+ const select = /* @__PURE__ */ jsxs39(
2710
+ "span",
2711
+ {
2712
+ className: cn("inline-flex items-center gap-1", !inFormRoot && className),
2713
+ style: inFormRoot ? void 0 : style,
2714
+ children: [
2715
+ /* @__PURE__ */ jsxs39(
2716
+ Select,
2717
+ {
2718
+ items: options,
2719
+ value: selectedValue,
2720
+ onValueChange: handleChange,
2721
+ disabled,
2722
+ name: inForm ? name : void 0,
2723
+ children: [
2724
+ /* @__PURE__ */ jsx55(SelectTrigger, { id: controlId, children: /* @__PURE__ */ jsx55(SelectValue, { placeholder }) }),
2725
+ /* @__PURE__ */ jsx55(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx55(
2726
+ SelectItem,
2727
+ {
2728
+ value: option.value,
2729
+ disabled: option.disabled,
2730
+ children: option.label
2731
+ },
2732
+ String(option.value)
2733
+ )) })
2734
+ ]
2735
+ }
2736
+ ),
2737
+ allowClear && selectedValue !== null && !disabled ? /* @__PURE__ */ jsx55(
2738
+ "button",
2739
+ {
2740
+ type: "button",
2741
+ "aria-label": t("pactor.select.clear"),
2742
+ className: "cursor-pointer text-muted-foreground hover:text-foreground",
2743
+ onClick: () => {
2744
+ if (inForm && form && name) {
2745
+ form.setValue(name, void 0);
2746
+ }
2747
+ onChange?.(void 0);
2748
+ },
2749
+ children: "\xD7"
2750
+ }
2751
+ ) : null
2752
+ ]
2753
+ }
2754
+ );
2755
+ if (inForm && form && name) {
2756
+ const error = form.errors[name];
2757
+ return /* @__PURE__ */ jsxs39(
2758
+ "div",
2759
+ {
2760
+ "data-slot": "form-item",
2761
+ className: cn(formItemClass(form.layout), className),
2762
+ style,
2763
+ children: [
2764
+ label ? /* @__PURE__ */ jsx55(
2765
+ "label",
2766
+ {
2767
+ htmlFor: controlId,
2768
+ className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
2769
+ children: label
2770
+ }
2771
+ ) : null,
2772
+ select,
2773
+ error ? /* @__PURE__ */ jsx55("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
2774
+ ]
2775
+ }
2776
+ );
2777
+ }
2778
+ return select;
2779
+ }
2780
+
2781
+ // src/components/components/Separator/index.tsx
2782
+ import { jsx as jsx56 } from "react/jsx-runtime";
2783
+ function Separator2({ orientation = "horizontal", className, style }) {
2784
+ return /* @__PURE__ */ jsx56(Separator, { orientation, className, style });
2785
+ }
2786
+
2787
+ // src/components/components/Sheet/index.tsx
2788
+ import { jsx as jsx57, jsxs as jsxs40 } from "react/jsx-runtime";
2789
+ function Sheet2({
2790
+ title,
2791
+ open,
2792
+ side = "right",
2793
+ onClose,
2794
+ children,
2795
+ className,
2796
+ style
2797
+ }) {
2798
+ return /* @__PURE__ */ jsx57(
2799
+ Sheet,
2800
+ {
2801
+ open: open ?? false,
2802
+ onOpenChange: (next) => {
2803
+ if (!next) {
2804
+ onClose?.();
2805
+ }
2806
+ },
2807
+ children: /* @__PURE__ */ jsxs40(SheetContent, { side, className, style, children: [
2808
+ title ? /* @__PURE__ */ jsx57(SheetHeader, { children: /* @__PURE__ */ jsx57(SheetTitle, { children: title }) }) : null,
2809
+ /* @__PURE__ */ jsx57("div", { className: "flex-1 overflow-auto px-4", children })
2810
+ ] })
2811
+ }
2812
+ );
2813
+ }
2814
+
2815
+ // src/components/components/Sider/index.tsx
2816
+ import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight2 } from "lucide-react";
2817
+ import { jsx as jsx58, jsxs as jsxs41 } from "react/jsx-runtime";
2818
+ function Sider({
2819
+ width = 200,
2820
+ collapsible,
2821
+ collapsed,
2822
+ collapsedWidth = 64,
2823
+ onCollapse,
2824
+ className,
2825
+ style,
2826
+ children
2827
+ }) {
2828
+ const current = collapsed ? collapsedWidth : width;
2829
+ return /* @__PURE__ */ jsxs41(
2830
+ "aside",
2831
+ {
2832
+ "data-slot": "layout-sider",
2833
+ "data-collapsed": collapsed || void 0,
2834
+ className: cn(
2835
+ "flex min-h-0 shrink-0 flex-col border-r bg-background transition-[width]",
2836
+ className
2837
+ ),
2838
+ style: { width: current, ...style },
2839
+ children: [
2840
+ /* @__PURE__ */ jsx58("div", { className: "min-h-0 flex-1 overflow-auto", children }),
2841
+ collapsible ? /* @__PURE__ */ jsx58(
2842
+ "button",
2843
+ {
2844
+ type: "button",
2845
+ "aria-label": collapsed ? "expand sider" : "collapse sider",
2846
+ className: "flex h-10 shrink-0 items-center justify-center border-t text-muted-foreground hover:text-foreground",
2847
+ onClick: () => onCollapse?.(!collapsed),
2848
+ children: collapsed ? /* @__PURE__ */ jsx58(ChevronRight2, { "aria-hidden": true, className: "size-4" }) : /* @__PURE__ */ jsx58(ChevronLeft2, { "aria-hidden": true, className: "size-4" })
2849
+ }
2850
+ ) : null
2851
+ ]
2852
+ }
2853
+ );
2854
+ }
2855
+
2856
+ // src/components/components/Skeleton/index.tsx
2857
+ import { jsx as jsx59 } from "react/jsx-runtime";
2858
+ var shapeDefaults = {
2859
+ line: { className: "h-4 w-full", style: {} },
2860
+ circle: { className: "rounded-full", style: { width: 40, height: 40 } },
2861
+ rect: { className: "h-24 w-full", style: {} }
2862
+ };
2863
+ function toSize(value) {
2864
+ return typeof value === "number" ? `${value}px` : value;
2865
+ }
2866
+ function Skeleton2({ shape = "line", width, height, className, style }) {
2867
+ const defaults = shapeDefaults[shape];
2868
+ return /* @__PURE__ */ jsx59(
2869
+ Skeleton,
2870
+ {
2871
+ className: cn(defaults.className, className),
2872
+ style: {
2873
+ ...defaults.style,
2874
+ width: toSize(width) ?? defaults.style.width,
2875
+ height: toSize(height) ?? defaults.style.height,
2876
+ ...style
2877
+ }
2878
+ }
2879
+ );
2880
+ }
2881
+
2882
+ // src/components/components/Slider/index.tsx
2883
+ import { useEffect as useEffect11 } from "react";
2884
+ import { jsx as jsx60, jsxs as jsxs42 } from "react/jsx-runtime";
2885
+ function Slider2({
2886
+ name,
2887
+ label,
2888
+ rules,
2889
+ value,
2890
+ min = 0,
2891
+ max = 100,
2892
+ step = 1,
2893
+ disabled,
2894
+ onChange,
2895
+ className,
2896
+ style
2897
+ }) {
2898
+ const form = useFormContext();
2899
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
2900
+ useEffect11(() => {
2901
+ if (inForm && form && name) {
2902
+ form.registerField(name, rules, value);
2903
+ return () => form.unregisterField(name);
2904
+ }
2905
+ return void 0;
2906
+ });
2907
+ const current = inForm && form && name ? form.values[name] : value;
2908
+ const numberValue = typeof current === "number" ? current : min;
2909
+ const handleChange = (next) => {
2910
+ if (inForm && form && name) {
2911
+ form.setValue(name, next);
2912
+ }
2913
+ onChange?.(next);
2914
+ };
2915
+ const slider = /* @__PURE__ */ jsx60(
2916
+ Slider,
2917
+ {
2918
+ value: numberValue,
2919
+ min,
2920
+ max,
2921
+ step,
2922
+ disabled,
2923
+ name: inForm ? name : void 0,
2924
+ onValueChange: handleChange,
2925
+ className: inForm ? void 0 : className,
2926
+ style: inForm ? void 0 : style,
2927
+ children: /* @__PURE__ */ jsx60(SliderControl, { children: /* @__PURE__ */ jsxs42(SliderTrack, { children: [
2928
+ /* @__PURE__ */ jsx60(SliderIndicator, {}),
2929
+ /* @__PURE__ */ jsx60(SliderThumb, {})
2930
+ ] }) })
2931
+ }
2932
+ );
2933
+ if (inForm && form && name) {
2934
+ return /* @__PURE__ */ jsx60(
2935
+ FieldShell,
2936
+ {
2937
+ layout: form.layout,
2938
+ label,
2939
+ error: form.errors[name],
2940
+ className,
2941
+ style,
2942
+ children: slider
2943
+ }
2944
+ );
2945
+ }
2946
+ return slider;
2947
+ }
2948
+
2949
+ // src/components/components/Sonner/index.tsx
2950
+ import { useRenderer as useRenderer14 } from "@pactor-app/runtime";
2951
+ import { useEffect as useEffect12 } from "react";
2952
+ import { jsx as jsx61 } from "react/jsx-runtime";
2953
+ function Sonner({ className, style }) {
2954
+ const { context } = useRenderer14();
2955
+ useEffect12(() => {
2956
+ const { actions } = context;
2957
+ if (actions.has("toast")) {
2958
+ return;
2959
+ }
2960
+ actions.register("toast", (action) => {
2961
+ const params = action.params ?? {};
2962
+ toast(params["message"], {
2963
+ description: params["description"],
2964
+ variant: params["variant"]
2965
+ });
2966
+ return { ok: true };
2967
+ });
2968
+ }, [context]);
2969
+ return /* @__PURE__ */ jsx61("div", { "data-slot": "sonner", className, style, children: /* @__PURE__ */ jsx61(Toaster, {}) });
2970
+ }
2971
+
2972
+ // src/components/components/Spinner/index.tsx
2973
+ import { jsx as jsx62 } from "react/jsx-runtime";
2974
+ var sizeClass = {
2975
+ sm: "size-3",
2976
+ default: "size-4",
2977
+ lg: "size-6"
2978
+ };
2979
+ function Spinner2({ size = "default", className, style }) {
2980
+ return /* @__PURE__ */ jsx62(Spinner, { className: cn(sizeClass[size], className), style });
2981
+ }
2982
+
2983
+ // src/components/components/Statistic/index.tsx
2984
+ import { jsx as jsx63, jsxs as jsxs43 } from "react/jsx-runtime";
2985
+ function Statistic({ title, value, precision, suffix, className, style }) {
2986
+ const display = typeof value === "number" && precision !== void 0 ? value.toFixed(precision) : value;
2987
+ return /* @__PURE__ */ jsxs43("div", { "data-slot": "statistic", className: cn(className), style, children: [
2988
+ title ? /* @__PURE__ */ jsx63("div", { "data-slot": "statistic-title", className: "text-sm text-muted-foreground", children: title }) : null,
2989
+ /* @__PURE__ */ jsxs43("div", { "data-slot": "statistic-value", className: "text-2xl font-bold tabular-nums", children: [
2990
+ display,
2991
+ suffix ? /* @__PURE__ */ jsx63("span", { className: "ml-1 text-sm font-normal text-muted-foreground", children: suffix }) : null
2992
+ ] })
2993
+ ] });
2994
+ }
2995
+
2996
+ // src/components/components/Switch/index.tsx
2997
+ import { useEffect as useEffect13, useId as useId6 } from "react";
2998
+ import { jsx as jsx64, jsxs as jsxs44 } from "react/jsx-runtime";
2999
+ function Switch2({
3000
+ name,
3001
+ label,
3002
+ rules,
3003
+ value,
3004
+ disabled,
3005
+ onChange,
3006
+ className,
3007
+ style
3008
+ }) {
3009
+ const form = useFormContext();
3010
+ const controlId = useId6();
3011
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
3012
+ useEffect13(() => {
3013
+ if (inForm && form && name) {
3014
+ form.registerField(name, rules, value);
3015
+ return () => form.unregisterField(name);
3016
+ }
3017
+ return void 0;
3018
+ });
3019
+ const current = inForm && form && name ? form.values[name] : value;
3020
+ const checked = current === true;
3021
+ const handleChange = (next) => {
3022
+ if (inForm && form && name) {
3023
+ form.setValue(name, next);
3024
+ }
3025
+ onChange?.(next);
3026
+ };
3027
+ const control = /* @__PURE__ */ jsxs44(
3028
+ "span",
3029
+ {
3030
+ className: cn("inline-flex items-center gap-2", !inForm && className),
3031
+ style: inForm ? void 0 : style,
3032
+ children: [
3033
+ /* @__PURE__ */ jsx64(
3034
+ Switch,
3035
+ {
3036
+ id: controlId,
3037
+ checked,
3038
+ disabled,
3039
+ name: inForm ? name : void 0,
3040
+ onCheckedChange: handleChange
3041
+ }
3042
+ ),
3043
+ label ? /* @__PURE__ */ jsx64("label", { htmlFor: controlId, className: "text-sm leading-none font-medium", children: label }) : null
3044
+ ]
3045
+ }
3046
+ );
3047
+ if (inForm && form && name) {
3048
+ return /* @__PURE__ */ jsxs44(
3049
+ "div",
3050
+ {
3051
+ "data-slot": "form-item",
3052
+ className: cn("mb-4", className),
3053
+ style,
3054
+ children: [
3055
+ control,
3056
+ form.errors[name] ? /* @__PURE__ */ jsx64("div", { "data-slot": "form-error", className: "mt-1.5 text-sm text-destructive", children: form.errors[name] }) : null
3057
+ ]
3058
+ }
3059
+ );
3060
+ }
3061
+ return control;
3062
+ }
3063
+
3064
+ // src/components/components/Table/index.tsx
3065
+ import { useI18n as useI18n7, useRenderer as useRenderer15 } from "@pactor-app/runtime";
3066
+ import { useState as useState12 } from "react";
3067
+ import { jsx as jsx65, jsxs as jsxs45 } from "react/jsx-runtime";
3068
+ function renderCellValue2(value) {
3069
+ if (value === void 0 || value === null) {
3070
+ return "";
3071
+ }
3072
+ if (typeof value === "object") {
3073
+ return JSON.stringify(value);
3074
+ }
3075
+ return String(value);
3076
+ }
3077
+ function Table2({
3078
+ columns = [],
3079
+ dataSource = [],
3080
+ rowKey = "id",
3081
+ loading,
3082
+ pagination,
3083
+ onChange,
3084
+ className,
3085
+ style
3086
+ }) {
3087
+ const { renderChildren } = useRenderer15();
3088
+ const { t } = useI18n7();
3089
+ const [current, setCurrent] = useState12(1);
3090
+ const pageSize = pagination === false ? void 0 : pagination?.pageSize;
3091
+ const total = dataSource.length;
3092
+ const pageCount = pageSize !== void 0 && pageSize > 0 ? Math.max(1, Math.ceil(total / pageSize)) : 1;
3093
+ const pageRows = pageSize !== void 0 && pageSize > 0 ? dataSource.slice((current - 1) * pageSize, current * pageSize) : dataSource;
3094
+ const goToPage = (page) => {
3095
+ setCurrent(page);
3096
+ onChange?.({ current: page, pageSize, total });
3097
+ };
3098
+ return /* @__PURE__ */ jsxs45("div", { "data-slot": "dsl-table", className: cn("relative", className), style, children: [
3099
+ loading ? /* @__PURE__ */ jsx65(
3100
+ "div",
3101
+ {
3102
+ "data-slot": "table-loading",
3103
+ className: "absolute inset-0 z-10 flex items-center justify-center bg-background/60 text-sm text-muted-foreground",
3104
+ children: t("pactor.table.loading")
3105
+ }
3106
+ ) : null,
3107
+ /* @__PURE__ */ jsxs45(Table, { children: [
3108
+ /* @__PURE__ */ jsx65(TableHeader, { children: /* @__PURE__ */ jsx65(TableRow, { className: "hover:bg-transparent", children: columns.map((column, index) => /* @__PURE__ */ jsx65(
3109
+ TableHead,
3110
+ {
3111
+ style: column.width !== void 0 ? { width: column.width } : void 0,
3112
+ children: column.title
3113
+ },
3114
+ column.dataIndex ?? String(index)
3115
+ )) }) }),
3116
+ /* @__PURE__ */ jsx65(TableBody, { children: pageRows.length === 0 ? /* @__PURE__ */ jsx65(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx65(TableCell, { colSpan: Math.max(1, columns.length), children: /* @__PURE__ */ jsx65(
3117
+ "div",
3118
+ {
3119
+ "data-slot": "table-empty",
3120
+ className: "py-8 text-center text-muted-foreground",
3121
+ children: t("pactor.table.empty")
3122
+ }
3123
+ ) }) }) : pageRows.map((row, rowIndex) => {
3124
+ const key = row[rowKey];
3125
+ return /* @__PURE__ */ jsx65(
3126
+ TableRow,
3127
+ {
3128
+ children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx65(TableCell, { children: column.cell ? renderChildren([column.cell], { row, rowIndex }) : renderCellValue2(
3129
+ column.dataIndex === void 0 ? void 0 : row[column.dataIndex]
3130
+ ) }, column.dataIndex ?? String(columnIndex)))
3131
+ },
3132
+ key === void 0 || key === null ? rowIndex : String(key)
3133
+ );
3134
+ }) })
3135
+ ] }),
3136
+ pageSize !== void 0 && pageSize > 0 ? /* @__PURE__ */ jsx65("div", { "data-slot": "table-pagination", className: "mt-3 flex justify-end gap-1", children: Array.from({ length: pageCount }, (_, index) => index + 1).map(
3137
+ (page) => /* @__PURE__ */ jsx65(
3138
+ Button,
3139
+ {
3140
+ type: "button",
3141
+ size: "sm",
3142
+ variant: page === current ? "default" : "outline",
3143
+ "aria-current": page === current ? "page" : void 0,
3144
+ onClick: () => goToPage(page),
3145
+ children: page
3146
+ },
3147
+ page
3148
+ )
3149
+ ) }) : null
3150
+ ] });
3151
+ }
3152
+
3153
+ // src/components/components/Tabs/index.tsx
3154
+ import { useRenderer as useRenderer16 } from "@pactor-app/runtime";
3155
+ import { jsx as jsx66, jsxs as jsxs46 } from "react/jsx-runtime";
3156
+ function Tabs2({ items = [], activeKey, onChange, className, style }) {
3157
+ const { renderChildren } = useRenderer16();
3158
+ return /* @__PURE__ */ jsxs46(
3159
+ Tabs,
3160
+ {
3161
+ value: activeKey,
3162
+ defaultValue: activeKey === void 0 ? items[0]?.key : void 0,
3163
+ onValueChange: (key) => onChange?.(key),
3164
+ className,
3165
+ style,
3166
+ children: [
3167
+ /* @__PURE__ */ jsx66(TabsList, { children: items.map((item) => /* @__PURE__ */ jsx66(TabsTrigger, { value: item.key, children: item.label }, item.key)) }),
3168
+ items.map((item) => /* @__PURE__ */ jsx66(TabsContent, { value: item.key, children: renderChildren(item.children) }, item.key))
3169
+ ]
3170
+ }
3171
+ );
3172
+ }
3173
+
3174
+ // src/components/components/Text/index.tsx
3175
+ import { jsx as jsx67 } from "react/jsx-runtime";
3176
+ var typeClassMap = {
3177
+ default: "",
3178
+ secondary: "text-muted-foreground",
3179
+ success: "text-green-600 dark:text-green-400",
3180
+ warning: "text-amber-600 dark:text-amber-400",
3181
+ danger: "text-destructive"
3182
+ };
3183
+ function Text({
3184
+ text,
3185
+ type = "default",
3186
+ strong,
3187
+ delete: del,
3188
+ underline,
3189
+ italic,
3190
+ className,
3191
+ style,
3192
+ children
3193
+ }) {
3194
+ return /* @__PURE__ */ jsx67(
3195
+ "span",
3196
+ {
3197
+ "data-slot": "text",
3198
+ "data-type": type,
3199
+ className: cn(
3200
+ typeClassMap[type],
3201
+ strong && "font-semibold",
3202
+ del && "line-through",
3203
+ underline && "underline",
3204
+ italic && "italic",
3205
+ className
3206
+ ),
3207
+ style,
3208
+ children: text ?? children
3209
+ }
3210
+ );
3211
+ }
3212
+
3213
+ // src/components/components/Textarea/index.tsx
3214
+ import { useEffect as useEffect14, useId as useId7 } from "react";
3215
+ import { jsx as jsx68 } from "react/jsx-runtime";
3216
+ function Textarea2({
3217
+ name,
3218
+ label,
3219
+ rules,
3220
+ value,
3221
+ placeholder,
3222
+ rows,
3223
+ disabled,
3224
+ onChange,
3225
+ className,
3226
+ style
3227
+ }) {
3228
+ const form = useFormContext();
3229
+ const controlId = useId7();
3230
+ const inForm = form?.inForm === true && typeof name === "string" && name !== "";
3231
+ useEffect14(() => {
3232
+ if (inForm && form && name) {
3233
+ form.registerField(name, rules, value);
3234
+ return () => form.unregisterField(name);
3235
+ }
3236
+ return void 0;
3237
+ });
3238
+ if (inForm && form && name) {
3239
+ const fieldValue = form.values[name];
3240
+ return /* @__PURE__ */ jsx68(
3241
+ FieldShell,
3242
+ {
3243
+ layout: form.layout,
3244
+ label,
3245
+ htmlFor: controlId,
3246
+ error: form.errors[name],
3247
+ className,
3248
+ style,
3249
+ children: /* @__PURE__ */ jsx68(
3250
+ Textarea,
3251
+ {
3252
+ id: controlId,
3253
+ value: typeof fieldValue === "string" ? fieldValue : "",
3254
+ placeholder,
3255
+ rows,
3256
+ disabled,
3257
+ onChange: (event) => {
3258
+ form.setValue(name, event.target.value);
3259
+ onChange?.(event.target.value);
3260
+ }
3261
+ }
3262
+ )
3263
+ }
3264
+ );
3265
+ }
3266
+ return /* @__PURE__ */ jsx68(
3267
+ Textarea,
3268
+ {
3269
+ value: value ?? "",
3270
+ placeholder,
3271
+ rows,
3272
+ disabled,
3273
+ className,
3274
+ style,
3275
+ onChange: (event) => onChange?.(event.target.value)
3276
+ }
3277
+ );
3278
+ }
3279
+
3280
+ // src/components/components/Toggle/index.tsx
3281
+ import { jsx as jsx69 } from "react/jsx-runtime";
3282
+ function Toggle2({
3283
+ text,
3284
+ pressed,
3285
+ variant,
3286
+ size,
3287
+ disabled,
3288
+ onChange,
3289
+ className,
3290
+ style
3291
+ }) {
3292
+ return /* @__PURE__ */ jsx69(
3293
+ Toggle,
3294
+ {
3295
+ pressed,
3296
+ variant,
3297
+ size,
3298
+ disabled,
3299
+ onPressedChange: (next) => onChange?.(next),
3300
+ className,
3301
+ style,
3302
+ children: text
3303
+ }
3304
+ );
3305
+ }
3306
+
3307
+ // src/components/components/ToggleGroup/index.tsx
3308
+ import { jsx as jsx70 } from "react/jsx-runtime";
3309
+ function ToggleGroup2({
3310
+ options = [],
3311
+ value,
3312
+ multiple,
3313
+ disabled,
3314
+ onChange,
3315
+ className,
3316
+ style
3317
+ }) {
3318
+ const groupValue = value === void 0 ? void 0 : Array.isArray(value) ? value : [value];
3319
+ const handleChange = (next) => {
3320
+ if (multiple) {
3321
+ onChange?.(next);
3322
+ } else {
3323
+ const previous = groupValue ?? [];
3324
+ const added = next.find((item) => !previous.includes(item));
3325
+ onChange?.(added ?? void 0);
3326
+ }
3327
+ };
3328
+ return /* @__PURE__ */ jsx70(
3329
+ ToggleGroup,
3330
+ {
3331
+ value: groupValue,
3332
+ multiple,
3333
+ disabled,
3334
+ onValueChange: (next) => handleChange(next),
3335
+ className,
3336
+ style,
3337
+ children: options.map((option) => /* @__PURE__ */ jsx70(
3338
+ ToggleGroupItem,
3339
+ {
3340
+ value: option.value,
3341
+ disabled: option.disabled,
3342
+ children: option.label
3343
+ },
3344
+ option.value
3345
+ ))
3346
+ }
3347
+ );
3348
+ }
3349
+
3350
+ // src/components/components/Tooltip/index.tsx
3351
+ import { jsx as jsx71, jsxs as jsxs47 } from "react/jsx-runtime";
3352
+ function Tooltip3({ content, children, className, style }) {
3353
+ return /* @__PURE__ */ jsxs47(Tooltip, { children: [
3354
+ /* @__PURE__ */ jsx71(TooltipTrigger, { render: triggerWrapper("tooltip-trigger-wrap"), children }),
3355
+ /* @__PURE__ */ jsx71(TooltipContent, { className, style, children: content })
3356
+ ] });
3357
+ }
3358
+
3359
+ // src/components/components/Typography/index.tsx
3360
+ import { jsx as jsx72 } from "react/jsx-runtime";
3361
+ function Typography2({
3362
+ variant = "p",
3363
+ text,
3364
+ className,
3365
+ style
3366
+ }) {
3367
+ return /* @__PURE__ */ jsx72(Typography, { variant, className, style, children: text });
3368
+ }
3369
+
3370
+ // src/components/register.ts
3371
+ var shadcnComponents = {
3372
+ Page,
3373
+ Grid,
3374
+ Flex,
3375
+ Card: Card2,
3376
+ Button: Button2,
3377
+ Alert: Alert2,
3378
+ Statistic,
3379
+ Tabs: Tabs2,
3380
+ Table: Table2,
3381
+ Form,
3382
+ Input: Input2,
3383
+ Select: Select2,
3384
+ // Layout 需要原始 DSL 子树做方向推导(含 Sider 判定),以 withScope 注册
3385
+ Layout: { component: Layout, withScope: true },
3386
+ Header,
3387
+ Sider,
3388
+ Content,
3389
+ Footer,
3390
+ Menu,
3391
+ Link,
3392
+ Text,
3393
+ // 展示类扩展组件
3394
+ Badge: Badge2,
3395
+ Avatar: Avatar2,
3396
+ Skeleton: Skeleton2,
3397
+ Separator: Separator2,
3398
+ Kbd: Kbd2,
3399
+ Spinner: Spinner2,
3400
+ Empty: Empty2,
3401
+ AspectRatio: AspectRatio2,
3402
+ Progress: Progress2,
3403
+ // 表单类扩展组件
3404
+ Textarea: Textarea2,
3405
+ Checkbox: Checkbox2,
3406
+ RadioGroup: RadioGroup2,
3407
+ Switch: Switch2,
3408
+ Slider: Slider2,
3409
+ Label: Label2,
3410
+ Field: Field2,
3411
+ ChatInput,
3412
+ // 导航类扩展组件
3413
+ Breadcrumb: Breadcrumb2,
3414
+ Pagination: Pagination2,
3415
+ Menubar: Menubar2,
3416
+ NavigationMenu: NavigationMenu2,
3417
+ DropdownMenu: DropdownMenu2,
3418
+ ContextMenu: ContextMenu2,
3419
+ // 反馈与弹层类扩展组件
3420
+ Dialog: Dialog2,
3421
+ AlertDialog: AlertDialog2,
3422
+ Drawer: Drawer2,
3423
+ Sheet: Sheet2,
3424
+ Popover: Popover2,
3425
+ Sonner,
3426
+ Accordion: Accordion2,
3427
+ Collapsible: Collapsible2,
3428
+ Tooltip: Tooltip3,
3429
+ HoverCard: HoverCard2,
3430
+ // 复合类扩展组件(第三批)
3431
+ Calendar: Calendar2,
3432
+ InputOTP: InputOTP2,
3433
+ Combobox: Combobox2,
3434
+ Carousel: Carousel2,
3435
+ Command: Command2,
3436
+ Resizable,
3437
+ ScrollArea: ScrollArea2,
3438
+ Toggle: Toggle2,
3439
+ ToggleGroup: ToggleGroup2,
3440
+ ButtonGroup: ButtonGroup2,
3441
+ InputGroup: InputGroup2,
3442
+ Item: Item2,
3443
+ Typography: Typography2,
3444
+ // 页面级组合类扩展组件(第四批)
3445
+ Sidebar,
3446
+ DataTable,
3447
+ Chart,
3448
+ // 图标(lucide 白名单)
3449
+ Icon
3450
+ };
3451
+ function registerShadcnComponents(registry) {
3452
+ for (const [type, component] of Object.entries(shadcnComponents)) {
3453
+ registry.register(type, component);
3454
+ }
3455
+ }
3456
+ function createShadcnComponentRegistry() {
3457
+ const registry = new Registry("ComponentRegistry");
3458
+ registerShadcnComponents(registry);
3459
+ return registry;
3460
+ }
3461
+
3462
+ export {
3463
+ Accordion2 as Accordion,
3464
+ Alert2 as Alert,
3465
+ AlertDialog2 as AlertDialog,
3466
+ AspectRatio2 as AspectRatio,
3467
+ Avatar2 as Avatar,
3468
+ Badge2 as Badge,
3469
+ Breadcrumb2 as Breadcrumb,
3470
+ Button2 as Button,
3471
+ ButtonGroup2 as ButtonGroup,
3472
+ useFormContext,
3473
+ Calendar2 as Calendar,
3474
+ Card2 as Card,
3475
+ Carousel2 as Carousel,
3476
+ Checkbox2 as Checkbox,
3477
+ Collapsible2 as Collapsible,
3478
+ Combobox2 as Combobox,
3479
+ Command2 as Command,
3480
+ Chart,
3481
+ Content,
3482
+ ContextMenu2 as ContextMenu,
3483
+ DataTable,
3484
+ Dialog2 as Dialog,
3485
+ Drawer2 as Drawer,
3486
+ DropdownMenu2 as DropdownMenu,
3487
+ Empty2 as Empty,
3488
+ Field2 as Field,
3489
+ Flex,
3490
+ Footer,
3491
+ Form,
3492
+ Grid,
3493
+ Header,
3494
+ HoverCard2 as HoverCard,
3495
+ Input2 as Input,
3496
+ InputGroup2 as InputGroup,
3497
+ InputOTP2 as InputOTP,
3498
+ Item2 as Item,
3499
+ Kbd2 as Kbd,
3500
+ Label2 as Label,
3501
+ Layout,
3502
+ Link,
3503
+ RailTooltip,
3504
+ useSidebarDrawer,
3505
+ Sidebar,
3506
+ Menu,
3507
+ Menubar2 as Menubar,
3508
+ NavigationMenu2 as NavigationMenu,
3509
+ Page,
3510
+ Pagination2 as Pagination,
3511
+ Popover2 as Popover,
3512
+ Progress2 as Progress,
3513
+ RadioGroup2 as RadioGroup,
3514
+ Resizable,
3515
+ ScrollArea2 as ScrollArea,
3516
+ Select2 as Select,
3517
+ Separator2 as Separator,
3518
+ Sheet2 as Sheet,
3519
+ Sider,
3520
+ Skeleton2 as Skeleton,
3521
+ Slider2 as Slider,
3522
+ Sonner,
3523
+ Spinner2 as Spinner,
3524
+ Statistic,
3525
+ Switch2 as Switch,
3526
+ Table2 as Table,
3527
+ Tabs2 as Tabs,
3528
+ Text,
3529
+ Textarea2 as Textarea,
3530
+ Toggle2 as Toggle,
3531
+ ToggleGroup2 as ToggleGroup,
3532
+ Tooltip3 as Tooltip,
3533
+ Typography2 as Typography,
3534
+ shadcnComponents,
3535
+ registerShadcnComponents,
3536
+ createShadcnComponentRegistry
3537
+ };