@jameskabz/nextcraft-ui 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -0
- package/dist/chunk-6F7FN2ZF.js +671 -0
- package/dist/chunk-6F7FN2ZF.js.map +1 -0
- package/dist/chunk-7Q4Z47HT.js +657 -0
- package/dist/chunk-7Q4Z47HT.js.map +1 -0
- package/dist/chunk-7SKDTIEK.js +49 -0
- package/dist/chunk-7SKDTIEK.js.map +1 -0
- package/dist/chunk-FEFH5O5K.js +49 -0
- package/dist/chunk-FEFH5O5K.js.map +1 -0
- package/dist/chunk-M2EKVXB6.js +127 -0
- package/dist/chunk-M2EKVXB6.js.map +1 -0
- package/dist/chunk-SBLIF6UU.js +1029 -0
- package/dist/chunk-SBLIF6UU.js.map +1 -0
- package/dist/chunk-VQ6T3HIX.js +9 -0
- package/dist/chunk-VQ6T3HIX.js.map +1 -0
- package/dist/chunk-YVZL4GET.js +328 -0
- package/dist/chunk-YVZL4GET.js.map +1 -0
- package/dist/chunk-ZRV4Y374.js +582 -0
- package/dist/chunk-ZRV4Y374.js.map +1 -0
- package/dist/craft/components.cjs +1838 -0
- package/dist/craft/components.cjs.map +1 -0
- package/dist/craft/components.d.cts +369 -0
- package/dist/craft/components.d.ts +369 -0
- package/dist/craft/components.js +78 -0
- package/dist/craft/components.js.map +1 -0
- package/dist/craft/forms.cjs +1376 -0
- package/dist/craft/forms.cjs.map +1 -0
- package/dist/craft/forms.d.cts +101 -0
- package/dist/craft/forms.d.ts +101 -0
- package/dist/craft/forms.js +14 -0
- package/dist/craft/forms.js.map +1 -0
- package/dist/craft/layout.cjs +410 -0
- package/dist/craft/layout.cjs.map +1 -0
- package/dist/craft/layout.d.cts +170 -0
- package/dist/craft/layout.d.ts +170 -0
- package/dist/craft/layout.js +27 -0
- package/dist/craft/layout.js.map +1 -0
- package/dist/craft/table.cjs +662 -0
- package/dist/craft/table.cjs.map +1 -0
- package/dist/craft/table.d.cts +99 -0
- package/dist/craft/table.d.ts +99 -0
- package/dist/craft/table.js +15 -0
- package/dist/craft/table.js.map +1 -0
- package/dist/craft/theme.cjs +166 -0
- package/dist/craft/theme.cjs.map +1 -0
- package/dist/craft/theme.d.cts +10 -0
- package/dist/craft/theme.d.ts +10 -0
- package/dist/craft/theme.js +12 -0
- package/dist/craft/theme.js.map +1 -0
- package/dist/index.cjs +1000 -299
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -499
- package/dist/index.d.ts +10 -499
- package/dist/index.js +81 -2689
- package/dist/index.js.map +1 -1
- package/dist/styles.css +124 -0
- package/dist/theme-context-EVI9PfKv.d.cts +22 -0
- package/dist/theme-context-EVI9PfKv.d.ts +22 -0
- package/package.json +28 -1
package/dist/index.cjs
CHANGED
|
@@ -31,32 +31,44 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AppShell: () => AppShell,
|
|
34
|
+
AppTemplate: () => AppTemplate,
|
|
34
35
|
AuthLayout: () => AuthLayout,
|
|
35
36
|
Breadcrumbs: () => Breadcrumbs,
|
|
36
37
|
Container: () => Container,
|
|
38
|
+
CraftAlert: () => CraftAlert,
|
|
37
39
|
CraftBadge: () => CraftBadge,
|
|
38
40
|
CraftButton: () => CraftButton,
|
|
39
41
|
CraftCard: () => CraftCard,
|
|
40
42
|
CraftCheckbox: () => CraftCheckbox,
|
|
43
|
+
CraftCommandPalette: () => CraftCommandPalette,
|
|
41
44
|
CraftConfirmDialog: () => CraftConfirmDialog,
|
|
42
45
|
CraftCreateEditDrawer: () => CraftCreateEditDrawer,
|
|
43
46
|
CraftCurrencyInput: () => CraftCurrencyInput,
|
|
44
47
|
CraftDataTable: () => CraftDataTable,
|
|
45
48
|
CraftDatePicker: () => CraftDatePicker,
|
|
46
49
|
CraftDrawer: () => CraftDrawer,
|
|
50
|
+
CraftDropdownMenu: () => CraftDropdownMenu,
|
|
47
51
|
CraftEmptyState: () => CraftEmptyState,
|
|
52
|
+
CraftErrorState: () => CraftErrorState,
|
|
48
53
|
CraftFilterBar: () => CraftFilterBar,
|
|
49
54
|
CraftForm: () => CraftForm,
|
|
50
55
|
CraftFormBuilder: () => CraftFormBuilder,
|
|
51
56
|
CraftFormField: () => CraftFormField,
|
|
57
|
+
CraftIcon: () => CraftIcon,
|
|
58
|
+
CraftIconProvider: () => CraftIconProvider,
|
|
52
59
|
CraftInput: () => CraftInput,
|
|
60
|
+
CraftLink: () => CraftLink,
|
|
61
|
+
CraftLoadingState: () => CraftLoadingState,
|
|
53
62
|
CraftModal: () => CraftModal,
|
|
54
63
|
CraftNumberInput: () => CraftNumberInput,
|
|
55
64
|
CraftPagination: () => CraftPagination,
|
|
65
|
+
CraftPopover: () => CraftPopover,
|
|
56
66
|
CraftSelect: () => CraftSelect,
|
|
57
67
|
CraftSkeleton: () => CraftSkeleton,
|
|
68
|
+
CraftStatCard: () => CraftStatCard,
|
|
58
69
|
CraftSubmitButton: () => CraftSubmitButton,
|
|
59
70
|
CraftSwitch: () => CraftSwitch,
|
|
71
|
+
CraftTableToolbar: () => CraftTableToolbar,
|
|
60
72
|
CraftTabs: () => CraftTabs,
|
|
61
73
|
CraftTextarea: () => CraftTextarea,
|
|
62
74
|
CraftToastHost: () => CraftToastHost,
|
|
@@ -68,6 +80,7 @@ __export(index_exports, {
|
|
|
68
80
|
ThemeProvider: () => ThemeProvider,
|
|
69
81
|
ThemeSwitcher: () => ThemeSwitcher,
|
|
70
82
|
TopNav: () => TopNav,
|
|
83
|
+
layoutConfigSchema: () => layoutConfigSchema,
|
|
71
84
|
useCraftToast: () => useCraftToast,
|
|
72
85
|
useTheme: () => useTheme
|
|
73
86
|
});
|
|
@@ -412,20 +425,149 @@ function CraftBadge({
|
|
|
412
425
|
);
|
|
413
426
|
}
|
|
414
427
|
|
|
415
|
-
// src/components/craft-
|
|
428
|
+
// src/components/craft-alert.tsx
|
|
416
429
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
417
|
-
|
|
418
|
-
|
|
430
|
+
var variantClasses3 = {
|
|
431
|
+
info: "border-[rgb(var(--nc-accent-1)/0.45)] bg-[rgb(var(--nc-accent-1)/0.12)]",
|
|
432
|
+
success: "border-[rgb(var(--nc-accent-2)/0.45)] bg-[rgb(var(--nc-accent-2)/0.12)]",
|
|
433
|
+
warning: "border-[rgb(var(--nc-accent-3)/0.45)] bg-[rgb(var(--nc-accent-3)/0.12)]",
|
|
434
|
+
error: "border-[rgb(var(--nc-accent-3)/0.65)] bg-[rgb(var(--nc-accent-3)/0.18)]"
|
|
435
|
+
};
|
|
436
|
+
function CraftAlert({
|
|
437
|
+
title,
|
|
438
|
+
description,
|
|
439
|
+
variant = "info",
|
|
440
|
+
icon,
|
|
441
|
+
actions,
|
|
442
|
+
tone,
|
|
443
|
+
className,
|
|
444
|
+
...props
|
|
445
|
+
}) {
|
|
446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
419
447
|
"div",
|
|
420
448
|
{
|
|
421
449
|
className: cn(
|
|
422
|
-
"rounded-
|
|
423
|
-
|
|
450
|
+
"rounded-2xl border p-4 text-[rgb(var(--nc-fg))] backdrop-blur-xl",
|
|
451
|
+
variantClasses3[variant],
|
|
452
|
+
className
|
|
453
|
+
),
|
|
454
|
+
"data-nc-theme": tone,
|
|
455
|
+
...props,
|
|
456
|
+
children: [
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-start gap-3", children: [
|
|
458
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-1 text-[rgb(var(--nc-fg))]", children: icon }),
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "space-y-1", children: [
|
|
460
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-sm font-semibold", children: title }),
|
|
461
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
462
|
+
] })
|
|
463
|
+
] }),
|
|
464
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "mt-3 flex flex-wrap gap-2", children: actions })
|
|
465
|
+
]
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// src/components/craft-error-state.tsx
|
|
471
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
472
|
+
function CraftErrorState({
|
|
473
|
+
title = "Something went wrong",
|
|
474
|
+
description = "Try again or check your connection.",
|
|
475
|
+
actionLabel = "Retry",
|
|
476
|
+
onAction,
|
|
477
|
+
action,
|
|
478
|
+
tone,
|
|
479
|
+
className,
|
|
480
|
+
...props
|
|
481
|
+
}) {
|
|
482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
483
|
+
"div",
|
|
484
|
+
{
|
|
485
|
+
className: cn(
|
|
486
|
+
"rounded-3xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.12)] p-6 text-[rgb(var(--nc-fg))] shadow-[0_12px_30px_rgba(0,0,0,0.25)] backdrop-blur-xl",
|
|
487
|
+
className
|
|
488
|
+
),
|
|
489
|
+
"data-nc-theme": tone,
|
|
490
|
+
...props,
|
|
491
|
+
children: [
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "space-y-2", children: [
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: "text-lg font-semibold", children: title }),
|
|
494
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-4", children: action != null ? action : onAction && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CraftButton, { size: "sm", onClick: onAction, children: actionLabel }) })
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// src/components/craft-loading-state.tsx
|
|
503
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
504
|
+
var sizeClasses2 = {
|
|
505
|
+
sm: "h-4 w-4 border-2",
|
|
506
|
+
md: "h-6 w-6 border-2",
|
|
507
|
+
lg: "h-8 w-8 border-[3px]"
|
|
508
|
+
};
|
|
509
|
+
function CraftLoadingState({
|
|
510
|
+
label = "Loading...",
|
|
511
|
+
size = "md",
|
|
512
|
+
tone,
|
|
513
|
+
className,
|
|
514
|
+
...props
|
|
515
|
+
}) {
|
|
516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
className: cn("flex items-center gap-3 text-[rgb(var(--nc-fg))]", className),
|
|
520
|
+
"data-nc-theme": tone,
|
|
521
|
+
...props,
|
|
522
|
+
children: [
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
524
|
+
"span",
|
|
525
|
+
{
|
|
526
|
+
className: cn(
|
|
527
|
+
"inline-block animate-spin rounded-full border-[rgb(var(--nc-accent-1)/0.25)] border-t-[rgb(var(--nc-accent-1))]",
|
|
528
|
+
sizeClasses2[size]
|
|
529
|
+
),
|
|
530
|
+
"aria-hidden": "true"
|
|
531
|
+
}
|
|
532
|
+
),
|
|
533
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: label })
|
|
534
|
+
]
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/components/craft-card.tsx
|
|
540
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
541
|
+
var intensityClasses2 = {
|
|
542
|
+
subtle: "backdrop-blur-md bg-opacity-50",
|
|
543
|
+
medium: "backdrop-blur-xl bg-opacity-70",
|
|
544
|
+
strong: "backdrop-blur-2xl bg-opacity-90"
|
|
545
|
+
};
|
|
546
|
+
function CraftCard({
|
|
547
|
+
className,
|
|
548
|
+
tone,
|
|
549
|
+
elevated = true,
|
|
550
|
+
intensity = "medium",
|
|
551
|
+
bordered = true,
|
|
552
|
+
children,
|
|
553
|
+
...props
|
|
554
|
+
}) {
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
556
|
+
"div",
|
|
557
|
+
{
|
|
558
|
+
className: cn(
|
|
559
|
+
"relative overflow-hidden rounded-3xl p-6 text-[rgb(var(--nc-fg))]",
|
|
560
|
+
intensityClasses2[intensity],
|
|
561
|
+
"bg-linear-to-br from-[rgb(var(--nc-accent-1)/0.15)] via-[rgb(var(--nc-accent-2)/0.10)] to-[rgb(var(--nc-accent-3)/0.15)]",
|
|
562
|
+
bordered ? "border-2 border-[rgb(var(--nc-accent-1)/0.3)]" : "border-0",
|
|
563
|
+
elevated ? "shadow-[0_8px_32px_rgba(0,0,0,0.3)] hover:shadow-[0_8px_40px_rgba(0,0,0,0.4)]" : "shadow-none",
|
|
564
|
+
"before:absolute before:inset-0 before:bg-linear-to-br before:from-white/10 before:to-transparent before:opacity-0 hover:before:opacity-100 before:transition-opacity before:duration-300",
|
|
424
565
|
"transition-all duration-300",
|
|
425
566
|
className
|
|
426
567
|
),
|
|
427
568
|
"data-nc-theme": tone,
|
|
428
|
-
...props
|
|
569
|
+
...props,
|
|
570
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "relative z-10", children })
|
|
429
571
|
}
|
|
430
572
|
);
|
|
431
573
|
}
|
|
@@ -433,7 +575,7 @@ function CraftCard({ className, tone, elevated = true, ...props }) {
|
|
|
433
575
|
// src/components/craft-modal.tsx
|
|
434
576
|
var React6 = __toESM(require("react"), 1);
|
|
435
577
|
var import_react_dom = require("react-dom");
|
|
436
|
-
var
|
|
578
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
437
579
|
var FOCUSABLE_SELECTORS = [
|
|
438
580
|
"a[href]",
|
|
439
581
|
"button:not([disabled])",
|
|
@@ -507,15 +649,15 @@ function CraftModal({
|
|
|
507
649
|
return () => document.removeEventListener("keydown", handleKey);
|
|
508
650
|
}, [isOpen, setOpen]);
|
|
509
651
|
const ref = useFocusTrap(isOpen);
|
|
510
|
-
const content = isOpen ? /* @__PURE__ */ (0,
|
|
511
|
-
/* @__PURE__ */ (0,
|
|
652
|
+
const content = isOpen ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "fixed inset-0 z-50 flex items-center justify-center px-4 py-8", children: [
|
|
653
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
512
654
|
"div",
|
|
513
655
|
{
|
|
514
656
|
className: "absolute inset-0 backdrop-blur-sm",
|
|
515
657
|
onClick: () => setOpen(false)
|
|
516
658
|
}
|
|
517
659
|
),
|
|
518
|
-
/* @__PURE__ */ (0,
|
|
660
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
519
661
|
"div",
|
|
520
662
|
{
|
|
521
663
|
ref,
|
|
@@ -527,29 +669,29 @@ function CraftModal({
|
|
|
527
669
|
),
|
|
528
670
|
"data-nc-theme": tone,
|
|
529
671
|
children: [
|
|
530
|
-
/* @__PURE__ */ (0,
|
|
531
|
-
/* @__PURE__ */ (0,
|
|
532
|
-
title && /* @__PURE__ */ (0,
|
|
533
|
-
description && /* @__PURE__ */ (0,
|
|
672
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", children: [
|
|
674
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-2xl font-semibold", children: title }),
|
|
675
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
534
676
|
] }),
|
|
535
|
-
/* @__PURE__ */ (0,
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
536
678
|
"button",
|
|
537
679
|
{
|
|
538
680
|
className: "rounded-full border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] p-2 text-[rgb(var(--nc-fg-soft))] transition hover:text-[rgb(var(--nc-fg))]",
|
|
539
681
|
onClick: () => setOpen(false),
|
|
540
682
|
"aria-label": "Close",
|
|
541
|
-
children: /* @__PURE__ */ (0,
|
|
683
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) })
|
|
542
684
|
}
|
|
543
685
|
)
|
|
544
686
|
] }),
|
|
545
|
-
/* @__PURE__ */ (0,
|
|
546
|
-
footer && /* @__PURE__ */ (0,
|
|
687
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mt-5 space-y-4", children }),
|
|
688
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mt-6", children: footer })
|
|
547
689
|
]
|
|
548
690
|
}
|
|
549
691
|
)
|
|
550
692
|
] }) : null;
|
|
551
|
-
return /* @__PURE__ */ (0,
|
|
552
|
-
trigger && /* @__PURE__ */ (0,
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
694
|
+
trigger && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
553
695
|
"span",
|
|
554
696
|
{
|
|
555
697
|
onClick: () => setOpen(true),
|
|
@@ -569,7 +711,7 @@ function CraftModal({
|
|
|
569
711
|
// src/components/craft-drawer.tsx
|
|
570
712
|
var React7 = __toESM(require("react"), 1);
|
|
571
713
|
var import_react_dom2 = require("react-dom");
|
|
572
|
-
var
|
|
714
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
573
715
|
function CraftDrawer({
|
|
574
716
|
open,
|
|
575
717
|
defaultOpen = false,
|
|
@@ -600,15 +742,15 @@ function CraftDrawer({
|
|
|
600
742
|
document.addEventListener("keydown", handleKey);
|
|
601
743
|
return () => document.removeEventListener("keydown", handleKey);
|
|
602
744
|
}, [isOpen, setOpen]);
|
|
603
|
-
const content = isOpen ? /* @__PURE__ */ (0,
|
|
604
|
-
/* @__PURE__ */ (0,
|
|
745
|
+
const content = isOpen ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "fixed inset-0 z-50 overflow-hidden", children: [
|
|
746
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
605
747
|
"div",
|
|
606
748
|
{
|
|
607
749
|
className: "absolute inset-0 backdrop-blur-sm",
|
|
608
750
|
onClick: () => setOpen(false)
|
|
609
751
|
}
|
|
610
752
|
),
|
|
611
|
-
/* @__PURE__ */ (0,
|
|
753
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
612
754
|
"div",
|
|
613
755
|
{
|
|
614
756
|
className: cn(
|
|
@@ -618,26 +760,26 @@ function CraftDrawer({
|
|
|
618
760
|
),
|
|
619
761
|
"data-nc-theme": tone,
|
|
620
762
|
children: [
|
|
621
|
-
/* @__PURE__ */ (0,
|
|
622
|
-
title && /* @__PURE__ */ (0,
|
|
623
|
-
/* @__PURE__ */ (0,
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between border-b border-[rgb(var(--nc-border)/0.3)] p-6", children: [
|
|
764
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "text-xl font-semibold", children: title }),
|
|
765
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
624
766
|
"button",
|
|
625
767
|
{
|
|
626
768
|
className: "rounded-full border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] p-2 text-[rgb(var(--nc-fg-soft))] transition hover:text-[rgb(var(--nc-fg))]",
|
|
627
769
|
onClick: () => setOpen(false),
|
|
628
770
|
"aria-label": "Close",
|
|
629
|
-
children: /* @__PURE__ */ (0,
|
|
771
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" }) })
|
|
630
772
|
}
|
|
631
773
|
)
|
|
632
774
|
] }),
|
|
633
|
-
/* @__PURE__ */ (0,
|
|
634
|
-
footer && /* @__PURE__ */ (0,
|
|
775
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "p-6 space-y-4 overflow-y-auto h-[calc(100%-5.5rem)]", children }),
|
|
776
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "border-t border-[rgb(var(--nc-border)/0.3)] p-6", children: footer })
|
|
635
777
|
]
|
|
636
778
|
}
|
|
637
779
|
)
|
|
638
780
|
] }) : null;
|
|
639
|
-
return /* @__PURE__ */ (0,
|
|
640
|
-
trigger && /* @__PURE__ */ (0,
|
|
781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
782
|
+
trigger && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
641
783
|
"span",
|
|
642
784
|
{
|
|
643
785
|
onClick: () => setOpen(true),
|
|
@@ -656,7 +798,7 @@ function CraftDrawer({
|
|
|
656
798
|
|
|
657
799
|
// src/components/craft-tabs.tsx
|
|
658
800
|
var React8 = __toESM(require("react"), 1);
|
|
659
|
-
var
|
|
801
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
660
802
|
function CraftTabs({
|
|
661
803
|
value,
|
|
662
804
|
defaultValue,
|
|
@@ -694,14 +836,14 @@ function CraftTabs({
|
|
|
694
836
|
setValue(next.value);
|
|
695
837
|
}
|
|
696
838
|
};
|
|
697
|
-
return /* @__PURE__ */ (0,
|
|
698
|
-
/* @__PURE__ */ (0,
|
|
839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("space-y-4", className), "data-nc-theme": tone, children: [
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
699
841
|
"div",
|
|
700
842
|
{
|
|
701
843
|
className: "inline-flex flex-wrap items-center gap-2 rounded-full border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.08)] p-2",
|
|
702
844
|
role: "tablist",
|
|
703
845
|
onKeyDown,
|
|
704
|
-
children: tabs.map((tab) => /* @__PURE__ */ (0,
|
|
846
|
+
children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
705
847
|
"button",
|
|
706
848
|
{
|
|
707
849
|
role: "tab",
|
|
@@ -717,16 +859,16 @@ function CraftTabs({
|
|
|
717
859
|
))
|
|
718
860
|
}
|
|
719
861
|
),
|
|
720
|
-
/* @__PURE__ */ (0,
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "rounded-2xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.08)] p-4 text-[rgb(var(--nc-fg))]", children: panels[activeValue] })
|
|
721
863
|
] });
|
|
722
864
|
}
|
|
723
865
|
|
|
724
866
|
// src/components/craft-tooltip.tsx
|
|
725
867
|
var React9 = __toESM(require("react"), 1);
|
|
726
|
-
var
|
|
868
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
727
869
|
function CraftTooltip({ content, tone, children, side = "top" }) {
|
|
728
870
|
const [open, setOpen] = React9.useState(false);
|
|
729
|
-
return /* @__PURE__ */ (0,
|
|
871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
730
872
|
"span",
|
|
731
873
|
{
|
|
732
874
|
className: "relative inline-flex",
|
|
@@ -736,7 +878,7 @@ function CraftTooltip({ content, tone, children, side = "top" }) {
|
|
|
736
878
|
onBlur: () => setOpen(false),
|
|
737
879
|
children: [
|
|
738
880
|
children,
|
|
739
|
-
/* @__PURE__ */ (0,
|
|
881
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
740
882
|
"span",
|
|
741
883
|
{
|
|
742
884
|
className: cn(
|
|
@@ -760,8 +902,8 @@ function CraftTooltip({ content, tone, children, side = "top" }) {
|
|
|
760
902
|
|
|
761
903
|
// src/components/craft-toast.tsx
|
|
762
904
|
var React10 = __toESM(require("react"), 1);
|
|
763
|
-
var
|
|
764
|
-
var
|
|
905
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
906
|
+
var variantClasses4 = {
|
|
765
907
|
info: "border-[color:rgb(var(--nc-accent-1)/0.4)]",
|
|
766
908
|
success: "border-emerald-400/40",
|
|
767
909
|
warning: "border-amber-400/40",
|
|
@@ -780,26 +922,26 @@ function useCraftToast() {
|
|
|
780
922
|
return { toasts, push, remove };
|
|
781
923
|
}
|
|
782
924
|
function CraftToastHost({ toasts, onDismiss, tone }) {
|
|
783
|
-
return /* @__PURE__ */ (0,
|
|
925
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
784
926
|
"div",
|
|
785
927
|
{
|
|
786
928
|
className: "fixed right-6 top-6 z-50 flex w-full max-w-sm flex-col gap-3",
|
|
787
929
|
"data-nc-theme": tone,
|
|
788
930
|
children: toasts.map((toast) => {
|
|
789
931
|
var _a;
|
|
790
|
-
return /* @__PURE__ */ (0,
|
|
932
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
791
933
|
"div",
|
|
792
934
|
{
|
|
793
935
|
className: cn(
|
|
794
936
|
"rounded-2xl border bg-[rgb(var(--nc-surface)/0.12)] p-4 text-[rgb(var(--nc-fg))] shadow-[0_15px_35px_rgba(0,0,0,0.35)] backdrop-blur-xl",
|
|
795
|
-
|
|
937
|
+
variantClasses4[(_a = toast.variant) != null ? _a : "info"]
|
|
796
938
|
),
|
|
797
|
-
children: /* @__PURE__ */ (0,
|
|
798
|
-
/* @__PURE__ */ (0,
|
|
799
|
-
/* @__PURE__ */ (0,
|
|
800
|
-
toast.description && /* @__PURE__ */ (0,
|
|
939
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
|
|
940
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
941
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-sm font-semibold", children: toast.title }),
|
|
942
|
+
toast.description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-xs text-[rgb(var(--nc-fg-muted))]", children: toast.description })
|
|
801
943
|
] }),
|
|
802
|
-
/* @__PURE__ */ (0,
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
803
945
|
"button",
|
|
804
946
|
{
|
|
805
947
|
className: "text-[rgb(var(--nc-fg-soft))] hover:text-[rgb(var(--nc-fg))]",
|
|
@@ -817,9 +959,9 @@ function CraftToastHost({ toasts, onDismiss, tone }) {
|
|
|
817
959
|
}
|
|
818
960
|
|
|
819
961
|
// src/components/craft-skeleton.tsx
|
|
820
|
-
var
|
|
962
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
821
963
|
function CraftSkeleton({ className, tone, ...props }) {
|
|
822
|
-
return /* @__PURE__ */ (0,
|
|
964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
823
965
|
"div",
|
|
824
966
|
{
|
|
825
967
|
className: cn(
|
|
@@ -835,7 +977,7 @@ function CraftSkeleton({ className, tone, ...props }) {
|
|
|
835
977
|
}
|
|
836
978
|
|
|
837
979
|
// src/components/craft-empty-state.tsx
|
|
838
|
-
var
|
|
980
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
839
981
|
function CraftEmptyState({
|
|
840
982
|
className,
|
|
841
983
|
tone,
|
|
@@ -845,7 +987,7 @@ function CraftEmptyState({
|
|
|
845
987
|
action,
|
|
846
988
|
...props
|
|
847
989
|
}) {
|
|
848
|
-
return /* @__PURE__ */ (0,
|
|
990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
849
991
|
"div",
|
|
850
992
|
{
|
|
851
993
|
className: cn(
|
|
@@ -856,18 +998,357 @@ function CraftEmptyState({
|
|
|
856
998
|
"data-nc-theme": tone,
|
|
857
999
|
...props,
|
|
858
1000
|
children: [
|
|
859
|
-
icon && /* @__PURE__ */ (0,
|
|
860
|
-
/* @__PURE__ */ (0,
|
|
861
|
-
description && /* @__PURE__ */ (0,
|
|
862
|
-
action && /* @__PURE__ */ (0,
|
|
1001
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-[rgb(var(--nc-accent-1)/0.2)] text-[rgb(var(--nc-accent-1))]", children: icon }),
|
|
1002
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h3", { className: "text-xl font-semibold", children: title }),
|
|
1003
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "mt-2 text-sm text-[rgb(var(--nc-fg-muted))]", children: description }),
|
|
1004
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mt-6 flex justify-center", children: action })
|
|
863
1005
|
]
|
|
864
1006
|
}
|
|
865
1007
|
);
|
|
866
1008
|
}
|
|
867
1009
|
|
|
868
|
-
// src/components/craft-
|
|
1010
|
+
// src/components/craft-popover.tsx
|
|
869
1011
|
var React11 = __toESM(require("react"), 1);
|
|
870
|
-
var
|
|
1012
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1013
|
+
var alignClasses = {
|
|
1014
|
+
start: "left-0",
|
|
1015
|
+
center: "left-1/2 -translate-x-1/2",
|
|
1016
|
+
end: "right-0"
|
|
1017
|
+
};
|
|
1018
|
+
function CraftPopover({
|
|
1019
|
+
open,
|
|
1020
|
+
defaultOpen = false,
|
|
1021
|
+
onOpenChange,
|
|
1022
|
+
trigger,
|
|
1023
|
+
content,
|
|
1024
|
+
align = "start",
|
|
1025
|
+
sideOffset = 10,
|
|
1026
|
+
tone,
|
|
1027
|
+
className,
|
|
1028
|
+
contentClassName
|
|
1029
|
+
}) {
|
|
1030
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React11.useState(defaultOpen);
|
|
1031
|
+
const isControlled = typeof open === "boolean";
|
|
1032
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1033
|
+
const rootRef = React11.useRef(null);
|
|
1034
|
+
const setOpen = React11.useCallback(
|
|
1035
|
+
(next) => {
|
|
1036
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
1037
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1038
|
+
},
|
|
1039
|
+
[isControlled, onOpenChange]
|
|
1040
|
+
);
|
|
1041
|
+
React11.useEffect(() => {
|
|
1042
|
+
if (!isOpen) return;
|
|
1043
|
+
const handleClick = (event) => {
|
|
1044
|
+
if (!rootRef.current) return;
|
|
1045
|
+
if (!rootRef.current.contains(event.target)) setOpen(false);
|
|
1046
|
+
};
|
|
1047
|
+
const handleKey = (event) => {
|
|
1048
|
+
if (event.key === "Escape") setOpen(false);
|
|
1049
|
+
};
|
|
1050
|
+
document.addEventListener("mousedown", handleClick);
|
|
1051
|
+
document.addEventListener("keydown", handleKey);
|
|
1052
|
+
return () => {
|
|
1053
|
+
document.removeEventListener("mousedown", handleClick);
|
|
1054
|
+
document.removeEventListener("keydown", handleKey);
|
|
1055
|
+
};
|
|
1056
|
+
}, [isOpen, setOpen]);
|
|
1057
|
+
const triggerNode = React11.isValidElement(trigger) ? React11.cloneElement(trigger, {
|
|
1058
|
+
onClick: (event) => {
|
|
1059
|
+
const handler = trigger.props.onClick;
|
|
1060
|
+
handler == null ? void 0 : handler(event);
|
|
1061
|
+
if (!event.defaultPrevented) setOpen(!isOpen);
|
|
1062
|
+
},
|
|
1063
|
+
"aria-expanded": isOpen,
|
|
1064
|
+
"aria-haspopup": "dialog"
|
|
1065
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1066
|
+
"button",
|
|
1067
|
+
{
|
|
1068
|
+
type: "button",
|
|
1069
|
+
onClick: () => setOpen(!isOpen),
|
|
1070
|
+
className: "inline-flex",
|
|
1071
|
+
"aria-expanded": isOpen,
|
|
1072
|
+
"aria-haspopup": "dialog",
|
|
1073
|
+
children: trigger
|
|
1074
|
+
}
|
|
1075
|
+
);
|
|
1076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: cn("relative inline-flex", className), ref: rootRef, children: [
|
|
1077
|
+
triggerNode,
|
|
1078
|
+
isOpen && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1079
|
+
"div",
|
|
1080
|
+
{
|
|
1081
|
+
className: cn(
|
|
1082
|
+
"absolute z-40 w-max min-w-48 rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.08)] p-3 text-[rgb(var(--nc-fg))] shadow-[0_18px_40px_rgba(0,0,0,0.35)] backdrop-blur-2xl",
|
|
1083
|
+
alignClasses[align],
|
|
1084
|
+
contentClassName
|
|
1085
|
+
),
|
|
1086
|
+
style: { marginTop: sideOffset },
|
|
1087
|
+
role: "dialog",
|
|
1088
|
+
"data-nc-theme": tone,
|
|
1089
|
+
children: content
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
] });
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// src/components/craft-dropdown-menu.tsx
|
|
1096
|
+
var React12 = __toESM(require("react"), 1);
|
|
1097
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1098
|
+
function CraftDropdownMenu({
|
|
1099
|
+
trigger,
|
|
1100
|
+
items = [],
|
|
1101
|
+
content,
|
|
1102
|
+
open,
|
|
1103
|
+
defaultOpen = false,
|
|
1104
|
+
onOpenChange,
|
|
1105
|
+
align = "end",
|
|
1106
|
+
tone,
|
|
1107
|
+
className,
|
|
1108
|
+
menuClassName
|
|
1109
|
+
}) {
|
|
1110
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React12.useState(defaultOpen);
|
|
1111
|
+
const isControlled = typeof open === "boolean";
|
|
1112
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1113
|
+
const setOpen = React12.useCallback(
|
|
1114
|
+
(next) => {
|
|
1115
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
1116
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1117
|
+
},
|
|
1118
|
+
[isControlled, onOpenChange]
|
|
1119
|
+
);
|
|
1120
|
+
const menuContent = content != null ? content : items.length ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: cn("space-y-1", menuClassName), role: "menu", children: items.map((item, index) => {
|
|
1121
|
+
var _a;
|
|
1122
|
+
const key = (_a = item.id) != null ? _a : `${index}-${String(item.label)}`;
|
|
1123
|
+
const itemClasses = cn(
|
|
1124
|
+
"flex w-full items-start gap-3 rounded-xl px-3 py-2 text-left text-sm transition",
|
|
1125
|
+
item.disabled ? "cursor-not-allowed text-[rgb(var(--nc-fg-soft))] opacity-60" : "text-[rgb(var(--nc-fg))] hover:bg-[rgb(var(--nc-surface)/0.12)]"
|
|
1126
|
+
);
|
|
1127
|
+
const contentNode = /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
1128
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "mt-0.5", children: item.icon }),
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "flex-1", children: [
|
|
1130
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "block font-medium", children: item.label }),
|
|
1131
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "block text-xs text-[rgb(var(--nc-fg-muted))]", children: item.description })
|
|
1132
|
+
] })
|
|
1133
|
+
] });
|
|
1134
|
+
if (item.href) {
|
|
1135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1136
|
+
"a",
|
|
1137
|
+
{
|
|
1138
|
+
href: item.href,
|
|
1139
|
+
className: itemClasses,
|
|
1140
|
+
role: "menuitem",
|
|
1141
|
+
onClick: () => {
|
|
1142
|
+
var _a2;
|
|
1143
|
+
if (item.disabled) return;
|
|
1144
|
+
(_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
|
|
1145
|
+
setOpen(false);
|
|
1146
|
+
},
|
|
1147
|
+
children: contentNode
|
|
1148
|
+
},
|
|
1149
|
+
key
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1153
|
+
"button",
|
|
1154
|
+
{
|
|
1155
|
+
type: "button",
|
|
1156
|
+
className: itemClasses,
|
|
1157
|
+
role: "menuitem",
|
|
1158
|
+
onClick: () => {
|
|
1159
|
+
var _a2;
|
|
1160
|
+
if (item.disabled) return;
|
|
1161
|
+
(_a2 = item.onSelect) == null ? void 0 : _a2.call(item);
|
|
1162
|
+
setOpen(false);
|
|
1163
|
+
},
|
|
1164
|
+
children: contentNode
|
|
1165
|
+
},
|
|
1166
|
+
key
|
|
1167
|
+
);
|
|
1168
|
+
}) }) : null;
|
|
1169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1170
|
+
CraftPopover,
|
|
1171
|
+
{
|
|
1172
|
+
trigger,
|
|
1173
|
+
content: menuContent,
|
|
1174
|
+
open: isOpen,
|
|
1175
|
+
onOpenChange: setOpen,
|
|
1176
|
+
align,
|
|
1177
|
+
tone,
|
|
1178
|
+
className
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
// src/components/craft-command-palette.tsx
|
|
1184
|
+
var React13 = __toESM(require("react"), 1);
|
|
1185
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1186
|
+
function CraftCommandPalette({
|
|
1187
|
+
items,
|
|
1188
|
+
open,
|
|
1189
|
+
defaultOpen = false,
|
|
1190
|
+
onOpenChange,
|
|
1191
|
+
trigger,
|
|
1192
|
+
title = "Command Palette",
|
|
1193
|
+
placeholder = "Search commands...",
|
|
1194
|
+
emptyText = "No results found.",
|
|
1195
|
+
tone,
|
|
1196
|
+
className
|
|
1197
|
+
}) {
|
|
1198
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React13.useState(defaultOpen);
|
|
1199
|
+
const isControlled = typeof open === "boolean";
|
|
1200
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1201
|
+
const [query, setQuery] = React13.useState("");
|
|
1202
|
+
const setOpen = React13.useCallback(
|
|
1203
|
+
(next) => {
|
|
1204
|
+
if (!isControlled) setUncontrolledOpen(next);
|
|
1205
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1206
|
+
},
|
|
1207
|
+
[isControlled, onOpenChange]
|
|
1208
|
+
);
|
|
1209
|
+
const filtered = React13.useMemo(() => {
|
|
1210
|
+
const q = query.trim().toLowerCase();
|
|
1211
|
+
if (!q) return items;
|
|
1212
|
+
return items.filter((item) => {
|
|
1213
|
+
var _a, _b;
|
|
1214
|
+
const haystack = [
|
|
1215
|
+
item.label,
|
|
1216
|
+
(_a = item.description) != null ? _a : "",
|
|
1217
|
+
...(_b = item.keywords) != null ? _b : []
|
|
1218
|
+
].join(" ").toLowerCase();
|
|
1219
|
+
return haystack.includes(q);
|
|
1220
|
+
});
|
|
1221
|
+
}, [items, query]);
|
|
1222
|
+
React13.useEffect(() => {
|
|
1223
|
+
if (!isOpen) setQuery("");
|
|
1224
|
+
}, [isOpen]);
|
|
1225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1226
|
+
CraftModal,
|
|
1227
|
+
{
|
|
1228
|
+
open: isOpen,
|
|
1229
|
+
onOpenChange: setOpen,
|
|
1230
|
+
trigger,
|
|
1231
|
+
title,
|
|
1232
|
+
tone,
|
|
1233
|
+
className: cn("max-w-xl", className),
|
|
1234
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "space-y-4", children: [
|
|
1235
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1236
|
+
CraftInput,
|
|
1237
|
+
{
|
|
1238
|
+
type: "search",
|
|
1239
|
+
placeholder,
|
|
1240
|
+
value: query,
|
|
1241
|
+
onChange: (event) => setQuery(event.target.value)
|
|
1242
|
+
}
|
|
1243
|
+
),
|
|
1244
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "space-y-2", children: [
|
|
1245
|
+
filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.12)] p-4 text-sm text-[rgb(var(--nc-fg-muted))]", children: emptyText }),
|
|
1246
|
+
filtered.map((item) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1247
|
+
"button",
|
|
1248
|
+
{
|
|
1249
|
+
type: "button",
|
|
1250
|
+
disabled: item.disabled,
|
|
1251
|
+
onClick: () => {
|
|
1252
|
+
var _a;
|
|
1253
|
+
if (item.disabled) return;
|
|
1254
|
+
(_a = item.onSelect) == null ? void 0 : _a.call(item);
|
|
1255
|
+
setOpen(false);
|
|
1256
|
+
},
|
|
1257
|
+
className: cn(
|
|
1258
|
+
"flex w-full items-start gap-3 rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.08)] px-4 py-3 text-left transition",
|
|
1259
|
+
item.disabled ? "cursor-not-allowed opacity-60" : "hover:bg-[rgb(var(--nc-surface)/0.16)]"
|
|
1260
|
+
),
|
|
1261
|
+
children: [
|
|
1262
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "mt-1", children: item.icon }),
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { children: [
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "block text-sm font-semibold", children: item.label }),
|
|
1265
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "block text-xs text-[rgb(var(--nc-fg-muted))]", children: item.description })
|
|
1266
|
+
] })
|
|
1267
|
+
]
|
|
1268
|
+
},
|
|
1269
|
+
item.id
|
|
1270
|
+
))
|
|
1271
|
+
] })
|
|
1272
|
+
] })
|
|
1273
|
+
}
|
|
1274
|
+
);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// src/components/craft-link.tsx
|
|
1278
|
+
var import_link = __toESM(require("next/link"), 1);
|
|
1279
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1280
|
+
var variantClasses5 = {
|
|
1281
|
+
default: "text-[rgb(var(--nc-accent-1))] hover:text-[rgb(var(--nc-accent-1))]",
|
|
1282
|
+
muted: "text-[rgb(var(--nc-fg-muted))] hover:text-[rgb(var(--nc-fg))]",
|
|
1283
|
+
button: "inline-flex items-center rounded-xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.12)] px-4 py-2 text-sm font-semibold text-[rgb(var(--nc-fg))] transition hover:bg-[rgb(var(--nc-surface)/0.2)]",
|
|
1284
|
+
ghost: "inline-flex items-center rounded-xl px-4 py-2 text-sm font-semibold text-[rgb(var(--nc-fg))] transition hover:bg-[rgb(var(--nc-surface)/0.18)]"
|
|
1285
|
+
};
|
|
1286
|
+
function CraftLink({
|
|
1287
|
+
variant = "default",
|
|
1288
|
+
underline = false,
|
|
1289
|
+
tone,
|
|
1290
|
+
className,
|
|
1291
|
+
children,
|
|
1292
|
+
...props
|
|
1293
|
+
}) {
|
|
1294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1295
|
+
import_link.default,
|
|
1296
|
+
{
|
|
1297
|
+
className: cn(
|
|
1298
|
+
"transition-colors",
|
|
1299
|
+
variantClasses5[variant],
|
|
1300
|
+
underline && "underline underline-offset-4",
|
|
1301
|
+
className
|
|
1302
|
+
),
|
|
1303
|
+
"data-nc-theme": tone,
|
|
1304
|
+
...props,
|
|
1305
|
+
children
|
|
1306
|
+
}
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
// src/components/craft-stat-card.tsx
|
|
1311
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1312
|
+
var trendClasses = {
|
|
1313
|
+
up: "text-emerald-300",
|
|
1314
|
+
down: "text-rose-300",
|
|
1315
|
+
neutral: "text-[rgb(var(--nc-fg-muted))]"
|
|
1316
|
+
};
|
|
1317
|
+
function CraftStatCard({
|
|
1318
|
+
label,
|
|
1319
|
+
value,
|
|
1320
|
+
delta,
|
|
1321
|
+
trend = "neutral",
|
|
1322
|
+
icon,
|
|
1323
|
+
footer,
|
|
1324
|
+
tone,
|
|
1325
|
+
className,
|
|
1326
|
+
...props
|
|
1327
|
+
}) {
|
|
1328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1329
|
+
CraftCard,
|
|
1330
|
+
{
|
|
1331
|
+
className: cn("space-y-3", className),
|
|
1332
|
+
tone,
|
|
1333
|
+
...props,
|
|
1334
|
+
children: [
|
|
1335
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1336
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: label }),
|
|
1337
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "text-[rgb(var(--nc-fg-soft))]", children: icon })
|
|
1338
|
+
] }),
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "text-3xl font-semibold", children: value }),
|
|
1340
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex items-center justify-between text-xs", children: [
|
|
1341
|
+
delta && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: trendClasses[trend], children: delta }),
|
|
1342
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "text-[rgb(var(--nc-fg-muted))]", children: footer })
|
|
1343
|
+
] })
|
|
1344
|
+
]
|
|
1345
|
+
}
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// src/components/craft-date-picker.tsx
|
|
1350
|
+
var React14 = __toESM(require("react"), 1);
|
|
1351
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
871
1352
|
var WEEK_DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
872
1353
|
function formatDate(date) {
|
|
873
1354
|
const year = date.getFullYear();
|
|
@@ -901,18 +1382,18 @@ function CraftDatePicker({
|
|
|
901
1382
|
placeholder = "Select date",
|
|
902
1383
|
className
|
|
903
1384
|
}) {
|
|
904
|
-
const [open, setOpen] =
|
|
905
|
-
const [uncontrolledValue, setUncontrolledValue] =
|
|
1385
|
+
const [open, setOpen] = React14.useState(false);
|
|
1386
|
+
const [uncontrolledValue, setUncontrolledValue] = React14.useState(defaultValue != null ? defaultValue : "");
|
|
906
1387
|
const isControlled = value !== void 0;
|
|
907
1388
|
const selectedValue = isControlled ? value != null ? value : "" : uncontrolledValue;
|
|
908
1389
|
const selectedDate = parseDate(selectedValue);
|
|
909
1390
|
const initialMonth = selectedDate != null ? selectedDate : /* @__PURE__ */ new Date();
|
|
910
|
-
const [viewDate, setViewDate] =
|
|
911
|
-
|
|
1391
|
+
const [viewDate, setViewDate] = React14.useState(initialMonth);
|
|
1392
|
+
React14.useEffect(() => {
|
|
912
1393
|
if (selectedDate) setViewDate(selectedDate);
|
|
913
1394
|
}, [selectedDate]);
|
|
914
|
-
const wrapperRef =
|
|
915
|
-
|
|
1395
|
+
const wrapperRef = React14.useRef(null);
|
|
1396
|
+
React14.useEffect(() => {
|
|
916
1397
|
if (!open) return;
|
|
917
1398
|
const handleClick = (event) => {
|
|
918
1399
|
var _a;
|
|
@@ -930,7 +1411,7 @@ function CraftDatePicker({
|
|
|
930
1411
|
document.removeEventListener("keydown", handleKey);
|
|
931
1412
|
};
|
|
932
1413
|
}, [open]);
|
|
933
|
-
const setValue =
|
|
1414
|
+
const setValue = React14.useCallback(
|
|
934
1415
|
(next) => {
|
|
935
1416
|
if (!isControlled) setUncontrolledValue(next);
|
|
936
1417
|
onChange == null ? void 0 : onChange(next);
|
|
@@ -973,8 +1454,8 @@ function CraftDatePicker({
|
|
|
973
1454
|
}
|
|
974
1455
|
}
|
|
975
1456
|
};
|
|
976
|
-
return /* @__PURE__ */ (0,
|
|
977
|
-
/* @__PURE__ */ (0,
|
|
1457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "relative w-full", "data-nc-theme": tone, ref: wrapperRef, children: [
|
|
1458
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
978
1459
|
"button",
|
|
979
1460
|
{
|
|
980
1461
|
type: "button",
|
|
@@ -988,12 +1469,12 @@ function CraftDatePicker({
|
|
|
988
1469
|
className
|
|
989
1470
|
),
|
|
990
1471
|
children: [
|
|
991
|
-
/* @__PURE__ */ (0,
|
|
992
|
-
/* @__PURE__ */ (0,
|
|
1472
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: selectedValue ? "text-[rgb(var(--nc-fg))]" : "text-[rgb(var(--nc-fg-soft))]", children: selectedValue || placeholder }),
|
|
1473
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("svg", { className: "h-4 w-4 text-[rgb(var(--nc-fg-soft))]", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M6 2a1 1 0 011 1v1h6V3a1 1 0 112 0v1h1a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6a2 2 0 012-2h1V3a1 1 0 011-1zm10 6H4v8h12V8z" }) })
|
|
993
1474
|
]
|
|
994
1475
|
}
|
|
995
1476
|
),
|
|
996
|
-
open && /* @__PURE__ */ (0,
|
|
1477
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
997
1478
|
"div",
|
|
998
1479
|
{
|
|
999
1480
|
className: cn(
|
|
@@ -1002,8 +1483,8 @@ function CraftDatePicker({
|
|
|
1002
1483
|
onKeyDown: handleKeyDown,
|
|
1003
1484
|
tabIndex: -1,
|
|
1004
1485
|
children: [
|
|
1005
|
-
/* @__PURE__ */ (0,
|
|
1006
|
-
/* @__PURE__ */ (0,
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1007
1488
|
"button",
|
|
1008
1489
|
{
|
|
1009
1490
|
type: "button",
|
|
@@ -1014,8 +1495,8 @@ function CraftDatePicker({
|
|
|
1014
1495
|
children: "Prev"
|
|
1015
1496
|
}
|
|
1016
1497
|
),
|
|
1017
|
-
/* @__PURE__ */ (0,
|
|
1018
|
-
/* @__PURE__ */ (0,
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-sm font-semibold", children: viewDate.toLocaleString(void 0, { month: "long", year: "numeric" }) }),
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1019
1500
|
"button",
|
|
1020
1501
|
{
|
|
1021
1502
|
type: "button",
|
|
@@ -1027,12 +1508,12 @@ function CraftDatePicker({
|
|
|
1027
1508
|
}
|
|
1028
1509
|
)
|
|
1029
1510
|
] }),
|
|
1030
|
-
/* @__PURE__ */ (0,
|
|
1031
|
-
/* @__PURE__ */ (0,
|
|
1032
|
-
if (!date) return /* @__PURE__ */ (0,
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mt-4 grid grid-cols-7 gap-2 text-xs text-[rgb(var(--nc-fg-muted))]", children: WEEK_DAYS.map((day) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "text-center", children: day }, day)) }),
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "mt-2 grid grid-cols-7 gap-2", children: cells.map((date, index) => {
|
|
1513
|
+
if (!date) return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", {}, `empty-${index}`);
|
|
1033
1514
|
const disabled = isOutsideRange(date, min, max);
|
|
1034
1515
|
const selected = selectedDate && isSameDay(date, selectedDate);
|
|
1035
|
-
return /* @__PURE__ */ (0,
|
|
1516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1036
1517
|
"button",
|
|
1037
1518
|
{
|
|
1038
1519
|
type: "button",
|
|
@@ -1054,11 +1535,51 @@ function CraftDatePicker({
|
|
|
1054
1535
|
] });
|
|
1055
1536
|
}
|
|
1056
1537
|
|
|
1538
|
+
// src/components/craft-icon.tsx
|
|
1539
|
+
var React15 = __toESM(require("react"), 1);
|
|
1540
|
+
var import_dynamic = require("lucide-react/dynamic");
|
|
1541
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1542
|
+
var CraftIconContext = React15.createContext(null);
|
|
1543
|
+
function CraftIconProvider({ icons, children }) {
|
|
1544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CraftIconContext.Provider, { value: icons, children });
|
|
1545
|
+
}
|
|
1546
|
+
function CraftIcon({
|
|
1547
|
+
name,
|
|
1548
|
+
className,
|
|
1549
|
+
"aria-label": ariaLabel,
|
|
1550
|
+
icons,
|
|
1551
|
+
useLucide = true
|
|
1552
|
+
}) {
|
|
1553
|
+
const contextRegistry = React15.useContext(CraftIconContext);
|
|
1554
|
+
const registry = icons != null ? icons : contextRegistry;
|
|
1555
|
+
const icon = registry == null ? void 0 : registry[name];
|
|
1556
|
+
if (!icon) {
|
|
1557
|
+
if (!useLucide) return null;
|
|
1558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1559
|
+
import_dynamic.DynamicIcon,
|
|
1560
|
+
{
|
|
1561
|
+
name,
|
|
1562
|
+
className,
|
|
1563
|
+
"aria-hidden": ariaLabel ? void 0 : true,
|
|
1564
|
+
"aria-label": ariaLabel
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
if (React15.isValidElement(icon)) {
|
|
1569
|
+
return React15.cloneElement(icon, {
|
|
1570
|
+
className: cn(icon.props.className, className),
|
|
1571
|
+
"aria-hidden": ariaLabel ? void 0 : true,
|
|
1572
|
+
"aria-label": ariaLabel
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className, "aria-label": ariaLabel, children: icon });
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1057
1578
|
// src/components/craft-number-input.tsx
|
|
1058
|
-
var
|
|
1059
|
-
var
|
|
1060
|
-
var CraftNumberInput =
|
|
1061
|
-
return /* @__PURE__ */ (0,
|
|
1579
|
+
var React16 = __toESM(require("react"), 1);
|
|
1580
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1581
|
+
var CraftNumberInput = React16.forwardRef(({ className, tone, ...props }, ref) => {
|
|
1582
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "relative w-full", "data-nc-theme": tone, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1062
1583
|
"input",
|
|
1063
1584
|
{
|
|
1064
1585
|
ref,
|
|
@@ -1081,12 +1602,12 @@ var CraftNumberInput = React12.forwardRef(({ className, tone, ...props }, ref) =
|
|
|
1081
1602
|
CraftNumberInput.displayName = "CraftNumberInput";
|
|
1082
1603
|
|
|
1083
1604
|
// src/components/craft-currency-input.tsx
|
|
1084
|
-
var
|
|
1085
|
-
var
|
|
1086
|
-
var CraftCurrencyInput =
|
|
1087
|
-
return /* @__PURE__ */ (0,
|
|
1088
|
-
/* @__PURE__ */ (0,
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1605
|
+
var React17 = __toESM(require("react"), 1);
|
|
1606
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1607
|
+
var CraftCurrencyInput = React17.forwardRef(({ className, tone, currencySymbol = "$", ...props }, ref) => {
|
|
1608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "relative w-full", "data-nc-theme": tone, children: [
|
|
1609
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-[rgb(var(--nc-fg-soft))]", children: currencySymbol }),
|
|
1610
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1090
1611
|
"input",
|
|
1091
1612
|
{
|
|
1092
1613
|
ref,
|
|
@@ -1112,12 +1633,12 @@ var CraftCurrencyInput = React13.forwardRef(({ className, tone, currencySymbol =
|
|
|
1112
1633
|
CraftCurrencyInput.displayName = "CraftCurrencyInput";
|
|
1113
1634
|
|
|
1114
1635
|
// src/components/craft-form.tsx
|
|
1115
|
-
var
|
|
1636
|
+
var React18 = __toESM(require("react"), 1);
|
|
1116
1637
|
var import_react_hook_form2 = require("react-hook-form");
|
|
1117
1638
|
|
|
1118
1639
|
// src/components/craft-submit-button.tsx
|
|
1119
1640
|
var import_react_hook_form = require("react-hook-form");
|
|
1120
|
-
var
|
|
1641
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1121
1642
|
function CraftSubmitButton({
|
|
1122
1643
|
className,
|
|
1123
1644
|
tone,
|
|
@@ -1133,7 +1654,7 @@ function CraftSubmitButton({
|
|
|
1133
1654
|
const isSubmitting = (_b = loading != null ? loading : (_a = form == null ? void 0 : form.formState) == null ? void 0 : _a.isSubmitting) != null ? _b : false;
|
|
1134
1655
|
const isValid = (_d = (_c = form == null ? void 0 : form.formState) == null ? void 0 : _c.isValid) != null ? _d : true;
|
|
1135
1656
|
const isDisabled = disabled || isSubmitting || disableWhenInvalid && !isValid;
|
|
1136
|
-
return /* @__PURE__ */ (0,
|
|
1657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
1137
1658
|
"button",
|
|
1138
1659
|
{
|
|
1139
1660
|
type: "submit",
|
|
@@ -1151,15 +1672,15 @@ function CraftSubmitButton({
|
|
|
1151
1672
|
disabled: isDisabled,
|
|
1152
1673
|
...props,
|
|
1153
1674
|
children: [
|
|
1154
|
-
isSubmitting && /* @__PURE__ */ (0,
|
|
1155
|
-
/* @__PURE__ */ (0,
|
|
1675
|
+
isSubmitting && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "inline-flex h-4 w-4 animate-spin rounded-full border-2 border-white/60 border-t-white" }),
|
|
1676
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: isSubmitting ? loadingLabel : children })
|
|
1156
1677
|
]
|
|
1157
1678
|
}
|
|
1158
1679
|
);
|
|
1159
1680
|
}
|
|
1160
1681
|
|
|
1161
1682
|
// src/components/craft-form.tsx
|
|
1162
|
-
var
|
|
1683
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1163
1684
|
function CraftForm({
|
|
1164
1685
|
form,
|
|
1165
1686
|
onSubmit,
|
|
@@ -1179,24 +1700,24 @@ function CraftForm({
|
|
|
1179
1700
|
closeOnSubmit = true,
|
|
1180
1701
|
formClassName
|
|
1181
1702
|
}) {
|
|
1182
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
1703
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React18.useState(defaultOpen);
|
|
1183
1704
|
const isControlled = typeof open === "boolean";
|
|
1184
1705
|
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1185
|
-
const setOpen =
|
|
1706
|
+
const setOpen = React18.useCallback(
|
|
1186
1707
|
(next) => {
|
|
1187
1708
|
if (!isControlled) setUncontrolledOpen(next);
|
|
1188
1709
|
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1189
1710
|
},
|
|
1190
1711
|
[isControlled, onOpenChange]
|
|
1191
1712
|
);
|
|
1192
|
-
const formId =
|
|
1713
|
+
const formId = React18.useId();
|
|
1193
1714
|
const handleSubmit = form.handleSubmit(async (values) => {
|
|
1194
1715
|
await onSubmit(values);
|
|
1195
1716
|
if (closeOnSubmit) setOpen(false);
|
|
1196
1717
|
});
|
|
1197
|
-
const footerContent = footer != null ? footer : /* @__PURE__ */ (0,
|
|
1198
|
-
/* @__PURE__ */ (0,
|
|
1199
|
-
/* @__PURE__ */ (0,
|
|
1718
|
+
const footerContent = footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: [
|
|
1719
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(CraftButton, { type: "button", variant: "ghost", onClick: () => setOpen(false), children: cancelLabel }),
|
|
1720
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1200
1721
|
CraftSubmitButton,
|
|
1201
1722
|
{
|
|
1202
1723
|
form: formId,
|
|
@@ -1205,7 +1726,7 @@ function CraftForm({
|
|
|
1205
1726
|
}
|
|
1206
1727
|
)
|
|
1207
1728
|
] });
|
|
1208
|
-
return /* @__PURE__ */ (0,
|
|
1729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react_hook_form2.FormProvider, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1209
1730
|
CraftModal,
|
|
1210
1731
|
{
|
|
1211
1732
|
open: isOpen,
|
|
@@ -1216,7 +1737,7 @@ function CraftForm({
|
|
|
1216
1737
|
tone,
|
|
1217
1738
|
className,
|
|
1218
1739
|
footer: footerContent,
|
|
1219
|
-
children: /* @__PURE__ */ (0,
|
|
1740
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1220
1741
|
"form",
|
|
1221
1742
|
{
|
|
1222
1743
|
id: formId,
|
|
@@ -1230,12 +1751,12 @@ function CraftForm({
|
|
|
1230
1751
|
}
|
|
1231
1752
|
|
|
1232
1753
|
// src/components/craft-form-builder.tsx
|
|
1233
|
-
var
|
|
1754
|
+
var React19 = __toESM(require("react"), 1);
|
|
1234
1755
|
var import_react_hook_form4 = require("react-hook-form");
|
|
1235
1756
|
|
|
1236
1757
|
// src/components/craft-form-field.tsx
|
|
1237
1758
|
var import_react_hook_form3 = require("react-hook-form");
|
|
1238
|
-
var
|
|
1759
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1239
1760
|
function getFieldError(errors, name) {
|
|
1240
1761
|
if (!errors || typeof errors !== "object") return void 0;
|
|
1241
1762
|
const segments = name.split(".");
|
|
@@ -1267,9 +1788,9 @@ function CraftFormField({
|
|
|
1267
1788
|
const error = getFieldError(formState.errors, name);
|
|
1268
1789
|
const errorMessage = typeof (error == null ? void 0 : error.message) === "string" ? error.message : void 0;
|
|
1269
1790
|
if (type === "hidden") {
|
|
1270
|
-
return /* @__PURE__ */ (0,
|
|
1791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("input", { type: "hidden", ...register(name, rules) });
|
|
1271
1792
|
}
|
|
1272
|
-
const labelNode = label ? /* @__PURE__ */ (0,
|
|
1793
|
+
const labelNode = label ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1273
1794
|
"label",
|
|
1274
1795
|
{
|
|
1275
1796
|
htmlFor: name,
|
|
@@ -1280,7 +1801,7 @@ function CraftFormField({
|
|
|
1280
1801
|
children: label
|
|
1281
1802
|
}
|
|
1282
1803
|
) : null;
|
|
1283
|
-
const descriptionNode = description ? /* @__PURE__ */ (0,
|
|
1804
|
+
const descriptionNode = description ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1284
1805
|
"p",
|
|
1285
1806
|
{
|
|
1286
1807
|
className: cn(
|
|
@@ -1290,10 +1811,10 @@ function CraftFormField({
|
|
|
1290
1811
|
children: description
|
|
1291
1812
|
}
|
|
1292
1813
|
) : null;
|
|
1293
|
-
const errorNode = errorMessage ? /* @__PURE__ */ (0,
|
|
1814
|
+
const errorNode = errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "text-xs text-[rgb(var(--nc-accent-3))]", children: errorMessage }) : null;
|
|
1294
1815
|
const renderInput = () => {
|
|
1295
1816
|
if (type === "textarea") {
|
|
1296
|
-
return /* @__PURE__ */ (0,
|
|
1817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1297
1818
|
CraftTextarea,
|
|
1298
1819
|
{
|
|
1299
1820
|
id: name,
|
|
@@ -1307,7 +1828,7 @@ function CraftFormField({
|
|
|
1307
1828
|
);
|
|
1308
1829
|
}
|
|
1309
1830
|
if (type === "select" || type === "multiselect") {
|
|
1310
|
-
return /* @__PURE__ */ (0,
|
|
1831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1311
1832
|
CraftSelect,
|
|
1312
1833
|
{
|
|
1313
1834
|
id: name,
|
|
@@ -1318,8 +1839,8 @@ function CraftFormField({
|
|
|
1318
1839
|
...fieldProps,
|
|
1319
1840
|
...register(name, rules),
|
|
1320
1841
|
children: [
|
|
1321
|
-
placeholder && /* @__PURE__ */ (0,
|
|
1322
|
-
options.map((option) => /* @__PURE__ */ (0,
|
|
1842
|
+
placeholder && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("option", { value: "", disabled: true, children: placeholder }),
|
|
1843
|
+
options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1323
1844
|
"option",
|
|
1324
1845
|
{
|
|
1325
1846
|
value: option.value,
|
|
@@ -1333,7 +1854,7 @@ function CraftFormField({
|
|
|
1333
1854
|
);
|
|
1334
1855
|
}
|
|
1335
1856
|
if (type === "checkbox") {
|
|
1336
|
-
return /* @__PURE__ */ (0,
|
|
1857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1337
1858
|
CraftCheckbox,
|
|
1338
1859
|
{
|
|
1339
1860
|
tone,
|
|
@@ -1346,7 +1867,7 @@ function CraftFormField({
|
|
|
1346
1867
|
);
|
|
1347
1868
|
}
|
|
1348
1869
|
if (type === "switch") {
|
|
1349
|
-
return /* @__PURE__ */ (0,
|
|
1870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1350
1871
|
CraftSwitch,
|
|
1351
1872
|
{
|
|
1352
1873
|
tone,
|
|
@@ -1358,7 +1879,7 @@ function CraftFormField({
|
|
|
1358
1879
|
);
|
|
1359
1880
|
}
|
|
1360
1881
|
if (type === "date") {
|
|
1361
|
-
return /* @__PURE__ */ (0,
|
|
1882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1362
1883
|
import_react_hook_form3.Controller,
|
|
1363
1884
|
{
|
|
1364
1885
|
control,
|
|
@@ -1366,7 +1887,7 @@ function CraftFormField({
|
|
|
1366
1887
|
rules,
|
|
1367
1888
|
render: ({ field }) => {
|
|
1368
1889
|
var _a;
|
|
1369
|
-
return /* @__PURE__ */ (0,
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1370
1891
|
CraftDatePicker,
|
|
1371
1892
|
{
|
|
1372
1893
|
value: (_a = field.value) != null ? _a : "",
|
|
@@ -1381,7 +1902,7 @@ function CraftFormField({
|
|
|
1381
1902
|
);
|
|
1382
1903
|
}
|
|
1383
1904
|
if (type === "number") {
|
|
1384
|
-
return /* @__PURE__ */ (0,
|
|
1905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1385
1906
|
CraftNumberInput,
|
|
1386
1907
|
{
|
|
1387
1908
|
id: name,
|
|
@@ -1395,7 +1916,7 @@ function CraftFormField({
|
|
|
1395
1916
|
);
|
|
1396
1917
|
}
|
|
1397
1918
|
if (type === "currency") {
|
|
1398
|
-
return /* @__PURE__ */ (0,
|
|
1919
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1399
1920
|
CraftCurrencyInput,
|
|
1400
1921
|
{
|
|
1401
1922
|
id: name,
|
|
@@ -1409,7 +1930,7 @@ function CraftFormField({
|
|
|
1409
1930
|
);
|
|
1410
1931
|
}
|
|
1411
1932
|
if (type === "radio") {
|
|
1412
|
-
return /* @__PURE__ */ (0,
|
|
1933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "grid gap-3", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
1413
1934
|
"label",
|
|
1414
1935
|
{
|
|
1415
1936
|
className: cn(
|
|
@@ -1420,7 +1941,7 @@ function CraftFormField({
|
|
|
1420
1941
|
),
|
|
1421
1942
|
"data-nc-theme": tone,
|
|
1422
1943
|
children: [
|
|
1423
|
-
/* @__PURE__ */ (0,
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1424
1945
|
"input",
|
|
1425
1946
|
{
|
|
1426
1947
|
type: "radio",
|
|
@@ -1431,14 +1952,14 @@ function CraftFormField({
|
|
|
1431
1952
|
...register(name, rules)
|
|
1432
1953
|
}
|
|
1433
1954
|
),
|
|
1434
|
-
/* @__PURE__ */ (0,
|
|
1955
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: option.label })
|
|
1435
1956
|
]
|
|
1436
1957
|
},
|
|
1437
1958
|
option.value
|
|
1438
1959
|
)) });
|
|
1439
1960
|
}
|
|
1440
1961
|
if (type === "range" || type === "slider") {
|
|
1441
|
-
return /* @__PURE__ */ (0,
|
|
1962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1442
1963
|
"input",
|
|
1443
1964
|
{
|
|
1444
1965
|
id: name,
|
|
@@ -1454,7 +1975,7 @@ function CraftFormField({
|
|
|
1454
1975
|
);
|
|
1455
1976
|
}
|
|
1456
1977
|
if (type === "file" || type === "multifile") {
|
|
1457
|
-
return /* @__PURE__ */ (0,
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1458
1979
|
"input",
|
|
1459
1980
|
{
|
|
1460
1981
|
id: name,
|
|
@@ -1472,7 +1993,7 @@ function CraftFormField({
|
|
|
1472
1993
|
);
|
|
1473
1994
|
}
|
|
1474
1995
|
const inputType = type === "search" || type === "password" || type === "email" || type === "tel" || type === "url" || type === "time" || type === "datetime-local" || type === "month" || type === "week" || type === "color" ? type : "text";
|
|
1475
|
-
return /* @__PURE__ */ (0,
|
|
1996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
1476
1997
|
CraftInput,
|
|
1477
1998
|
{
|
|
1478
1999
|
id: name,
|
|
@@ -1489,7 +2010,7 @@ function CraftFormField({
|
|
|
1489
2010
|
const showLabel = type !== "checkbox" && type !== "switch";
|
|
1490
2011
|
const showDescriptionAbove = type !== "checkbox" && type !== "switch";
|
|
1491
2012
|
const showDescriptionBelow = type === "switch";
|
|
1492
|
-
return /* @__PURE__ */ (0,
|
|
2013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("space-y-2", className), "data-nc-theme": tone, children: [
|
|
1493
2014
|
showLabel ? labelNode : null,
|
|
1494
2015
|
showDescriptionAbove ? descriptionNode : null,
|
|
1495
2016
|
renderInput(),
|
|
@@ -1499,7 +2020,7 @@ function CraftFormField({
|
|
|
1499
2020
|
}
|
|
1500
2021
|
|
|
1501
2022
|
// src/components/craft-form-builder.tsx
|
|
1502
|
-
var
|
|
2023
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1503
2024
|
function defaultValueForField(field) {
|
|
1504
2025
|
var _a, _b, _c, _d;
|
|
1505
2026
|
if (field.defaultValue !== void 0) return field.defaultValue;
|
|
@@ -1657,17 +2178,17 @@ function CraftFormBuilder({
|
|
|
1657
2178
|
onCancel,
|
|
1658
2179
|
customValidation
|
|
1659
2180
|
}) {
|
|
1660
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
2181
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React19.useState(defaultOpen);
|
|
1661
2182
|
const isControlled = typeof open === "boolean";
|
|
1662
2183
|
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1663
|
-
const setOpen =
|
|
2184
|
+
const setOpen = React19.useCallback(
|
|
1664
2185
|
(next) => {
|
|
1665
2186
|
if (!isControlled) setUncontrolledOpen(next);
|
|
1666
2187
|
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1667
2188
|
},
|
|
1668
2189
|
[isControlled, onOpenChange]
|
|
1669
2190
|
);
|
|
1670
|
-
const defaultValues =
|
|
2191
|
+
const defaultValues = React19.useMemo(
|
|
1671
2192
|
() => buildDefaultValues(fields, initialData),
|
|
1672
2193
|
[fields, initialData]
|
|
1673
2194
|
);
|
|
@@ -1675,8 +2196,8 @@ function CraftFormBuilder({
|
|
|
1675
2196
|
mode: "onChange",
|
|
1676
2197
|
defaultValues
|
|
1677
2198
|
});
|
|
1678
|
-
const formId =
|
|
1679
|
-
|
|
2199
|
+
const formId = React19.useId();
|
|
2200
|
+
React19.useEffect(() => {
|
|
1680
2201
|
form.reset(defaultValues);
|
|
1681
2202
|
}, [defaultValues, form]);
|
|
1682
2203
|
const handleSubmit = form.handleSubmit(async (values) => {
|
|
@@ -1705,7 +2226,7 @@ function CraftFormBuilder({
|
|
|
1705
2226
|
onCancel == null ? void 0 : onCancel();
|
|
1706
2227
|
if (closeOnCancel) setOpen(false);
|
|
1707
2228
|
};
|
|
1708
|
-
return /* @__PURE__ */ (0,
|
|
2229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_hook_form4.FormProvider, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1709
2230
|
CraftModal,
|
|
1710
2231
|
{
|
|
1711
2232
|
open: isOpen,
|
|
@@ -1715,8 +2236,8 @@ function CraftFormBuilder({
|
|
|
1715
2236
|
description,
|
|
1716
2237
|
tone,
|
|
1717
2238
|
className,
|
|
1718
|
-
footer: /* @__PURE__ */ (0,
|
|
1719
|
-
showReset && /* @__PURE__ */ (0,
|
|
2239
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: [
|
|
2240
|
+
showReset && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1720
2241
|
CraftButton,
|
|
1721
2242
|
{
|
|
1722
2243
|
type: "button",
|
|
@@ -1726,7 +2247,7 @@ function CraftFormBuilder({
|
|
|
1726
2247
|
children: resetLabel
|
|
1727
2248
|
}
|
|
1728
2249
|
),
|
|
1729
|
-
showCancel && /* @__PURE__ */ (0,
|
|
2250
|
+
showCancel && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1730
2251
|
CraftButton,
|
|
1731
2252
|
{
|
|
1732
2253
|
type: "button",
|
|
@@ -1736,7 +2257,7 @@ function CraftFormBuilder({
|
|
|
1736
2257
|
children: cancelLabel
|
|
1737
2258
|
}
|
|
1738
2259
|
),
|
|
1739
|
-
/* @__PURE__ */ (0,
|
|
2260
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1740
2261
|
CraftSubmitButton,
|
|
1741
2262
|
{
|
|
1742
2263
|
loading,
|
|
@@ -1746,15 +2267,15 @@ function CraftFormBuilder({
|
|
|
1746
2267
|
}
|
|
1747
2268
|
)
|
|
1748
2269
|
] }),
|
|
1749
|
-
children: /* @__PURE__ */ (0,
|
|
2270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1750
2271
|
"form",
|
|
1751
2272
|
{
|
|
1752
2273
|
id: formId,
|
|
1753
2274
|
onSubmit: handleSubmit,
|
|
1754
2275
|
className: cn("space-y-5", formClassName),
|
|
1755
|
-
children: fields.map((field) => /* @__PURE__ */ (0,
|
|
1756
|
-
field.helpText && /* @__PURE__ */ (0,
|
|
1757
|
-
/* @__PURE__ */ (0,
|
|
2276
|
+
children: fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "space-y-2", children: [
|
|
2277
|
+
field.helpText && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-xs text-[rgb(var(--nc-fg-muted))]", children: field.helpText }),
|
|
2278
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1758
2279
|
CraftFormField,
|
|
1759
2280
|
{
|
|
1760
2281
|
name: field.name,
|
|
@@ -1785,8 +2306,8 @@ function CraftFormBuilder({
|
|
|
1785
2306
|
}
|
|
1786
2307
|
|
|
1787
2308
|
// src/components/craft-confirm-dialog.tsx
|
|
1788
|
-
var
|
|
1789
|
-
var
|
|
2309
|
+
var React20 = __toESM(require("react"), 1);
|
|
2310
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1790
2311
|
function CraftConfirmDialog({
|
|
1791
2312
|
open,
|
|
1792
2313
|
defaultOpen = false,
|
|
@@ -1801,17 +2322,17 @@ function CraftConfirmDialog({
|
|
|
1801
2322
|
className,
|
|
1802
2323
|
confirmVariant = "solid"
|
|
1803
2324
|
}) {
|
|
1804
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
2325
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React20.useState(defaultOpen);
|
|
1805
2326
|
const isControlled = typeof open === "boolean";
|
|
1806
2327
|
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1807
|
-
const setOpen =
|
|
2328
|
+
const setOpen = React20.useCallback(
|
|
1808
2329
|
(next) => {
|
|
1809
2330
|
if (!isControlled) setUncontrolledOpen(next);
|
|
1810
2331
|
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1811
2332
|
},
|
|
1812
2333
|
[isControlled, onOpenChange]
|
|
1813
2334
|
);
|
|
1814
|
-
const [isLoading, setIsLoading] =
|
|
2335
|
+
const [isLoading, setIsLoading] = React20.useState(false);
|
|
1815
2336
|
const handleConfirm = async () => {
|
|
1816
2337
|
if (!onConfirm) {
|
|
1817
2338
|
setOpen(false);
|
|
@@ -1822,7 +2343,7 @@ function CraftConfirmDialog({
|
|
|
1822
2343
|
setIsLoading(false);
|
|
1823
2344
|
setOpen(false);
|
|
1824
2345
|
};
|
|
1825
|
-
return /* @__PURE__ */ (0,
|
|
2346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1826
2347
|
CraftModal,
|
|
1827
2348
|
{
|
|
1828
2349
|
open: isOpen,
|
|
@@ -1832,8 +2353,8 @@ function CraftConfirmDialog({
|
|
|
1832
2353
|
description,
|
|
1833
2354
|
tone,
|
|
1834
2355
|
className: cn("max-w-md", className),
|
|
1835
|
-
footer: /* @__PURE__ */ (0,
|
|
1836
|
-
/* @__PURE__ */ (0,
|
|
2356
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: [
|
|
2357
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1837
2358
|
CraftButton,
|
|
1838
2359
|
{
|
|
1839
2360
|
type: "button",
|
|
@@ -1842,7 +2363,7 @@ function CraftConfirmDialog({
|
|
|
1842
2363
|
children: cancelLabel
|
|
1843
2364
|
}
|
|
1844
2365
|
),
|
|
1845
|
-
/* @__PURE__ */ (0,
|
|
2366
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1846
2367
|
CraftButton,
|
|
1847
2368
|
{
|
|
1848
2369
|
type: "button",
|
|
@@ -1853,15 +2374,15 @@ function CraftConfirmDialog({
|
|
|
1853
2374
|
}
|
|
1854
2375
|
)
|
|
1855
2376
|
] }),
|
|
1856
|
-
children: /* @__PURE__ */ (0,
|
|
2377
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
1857
2378
|
}
|
|
1858
2379
|
);
|
|
1859
2380
|
}
|
|
1860
2381
|
|
|
1861
2382
|
// src/components/craft-create-edit-drawer.tsx
|
|
1862
|
-
var
|
|
2383
|
+
var React21 = __toESM(require("react"), 1);
|
|
1863
2384
|
var import_react_hook_form5 = require("react-hook-form");
|
|
1864
|
-
var
|
|
2385
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1865
2386
|
function CraftCreateEditDrawer({
|
|
1866
2387
|
mode = "create",
|
|
1867
2388
|
form,
|
|
@@ -1882,26 +2403,26 @@ function CraftCreateEditDrawer({
|
|
|
1882
2403
|
closeOnSubmit = true,
|
|
1883
2404
|
side = "right"
|
|
1884
2405
|
}) {
|
|
1885
|
-
const [uncontrolledOpen, setUncontrolledOpen] =
|
|
2406
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React21.useState(defaultOpen);
|
|
1886
2407
|
const isControlled = typeof open === "boolean";
|
|
1887
2408
|
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
1888
|
-
const setOpen =
|
|
2409
|
+
const setOpen = React21.useCallback(
|
|
1889
2410
|
(next) => {
|
|
1890
2411
|
if (!isControlled) setUncontrolledOpen(next);
|
|
1891
2412
|
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
1892
2413
|
},
|
|
1893
2414
|
[isControlled, onOpenChange]
|
|
1894
2415
|
);
|
|
1895
|
-
const formId =
|
|
2416
|
+
const formId = React21.useId();
|
|
1896
2417
|
const handleSubmit = form.handleSubmit(async (values) => {
|
|
1897
2418
|
await onSubmit(values);
|
|
1898
2419
|
if (closeOnSubmit) setOpen(false);
|
|
1899
2420
|
});
|
|
1900
2421
|
const resolvedTitle = title != null ? title : mode === "create" ? "Create item" : "Edit item";
|
|
1901
2422
|
const resolvedSubmitLabel = submitLabel != null ? submitLabel : mode === "create" ? "Create" : "Save changes";
|
|
1902
|
-
const footerContent = footer != null ? footer : /* @__PURE__ */ (0,
|
|
1903
|
-
/* @__PURE__ */ (0,
|
|
1904
|
-
/* @__PURE__ */ (0,
|
|
2423
|
+
const footerContent = footer != null ? footer : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex flex-wrap items-center justify-end gap-3", children: [
|
|
2424
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(CraftButton, { type: "button", variant: "ghost", onClick: () => setOpen(false), children: cancelLabel }),
|
|
2425
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
1905
2426
|
CraftSubmitButton,
|
|
1906
2427
|
{
|
|
1907
2428
|
form: formId,
|
|
@@ -1910,7 +2431,7 @@ function CraftCreateEditDrawer({
|
|
|
1910
2431
|
}
|
|
1911
2432
|
)
|
|
1912
2433
|
] });
|
|
1913
|
-
return /* @__PURE__ */ (0,
|
|
2434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_hook_form5.FormProvider, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
1914
2435
|
CraftDrawer,
|
|
1915
2436
|
{
|
|
1916
2437
|
open: isOpen,
|
|
@@ -1921,8 +2442,8 @@ function CraftCreateEditDrawer({
|
|
|
1921
2442
|
side,
|
|
1922
2443
|
className: cn("flex flex-col", className),
|
|
1923
2444
|
footer: footerContent,
|
|
1924
|
-
children: /* @__PURE__ */ (0,
|
|
1925
|
-
description && /* @__PURE__ */ (0,
|
|
2445
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("form", { id: formId, onSubmit: handleSubmit, className: "space-y-5", children: [
|
|
2446
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description }),
|
|
1926
2447
|
children
|
|
1927
2448
|
] })
|
|
1928
2449
|
}
|
|
@@ -1930,7 +2451,7 @@ function CraftCreateEditDrawer({
|
|
|
1930
2451
|
}
|
|
1931
2452
|
|
|
1932
2453
|
// src/components/craft-filter-bar.tsx
|
|
1933
|
-
var
|
|
2454
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1934
2455
|
function CraftFilterBar({
|
|
1935
2456
|
title,
|
|
1936
2457
|
description,
|
|
@@ -1942,7 +2463,7 @@ function CraftFilterBar({
|
|
|
1942
2463
|
tone,
|
|
1943
2464
|
className
|
|
1944
2465
|
}) {
|
|
1945
|
-
return /* @__PURE__ */ (0,
|
|
2466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
1946
2467
|
"div",
|
|
1947
2468
|
{
|
|
1948
2469
|
className: cn(
|
|
@@ -1951,15 +2472,15 @@ function CraftFilterBar({
|
|
|
1951
2472
|
),
|
|
1952
2473
|
"data-nc-theme": tone,
|
|
1953
2474
|
children: [
|
|
1954
|
-
/* @__PURE__ */ (0,
|
|
1955
|
-
/* @__PURE__ */ (0,
|
|
1956
|
-
title && /* @__PURE__ */ (0,
|
|
1957
|
-
description && /* @__PURE__ */ (0,
|
|
2475
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
2476
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { children: [
|
|
2477
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-lg font-semibold", children: title }),
|
|
2478
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
1958
2479
|
] }),
|
|
1959
|
-
actions && /* @__PURE__ */ (0,
|
|
2480
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex items-center gap-3", children: actions })
|
|
1960
2481
|
] }),
|
|
1961
|
-
/* @__PURE__ */ (0,
|
|
1962
|
-
/* @__PURE__ */ (0,
|
|
2482
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mt-4 grid gap-4 md:grid-cols-[minmax(0,1fr)_auto]", children: [
|
|
2483
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
1963
2484
|
CraftInput,
|
|
1964
2485
|
{
|
|
1965
2486
|
type: "search",
|
|
@@ -1969,7 +2490,58 @@ function CraftFilterBar({
|
|
|
1969
2490
|
tone
|
|
1970
2491
|
}
|
|
1971
2492
|
),
|
|
1972
|
-
filters && /* @__PURE__ */ (0,
|
|
2493
|
+
filters && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex flex-wrap items-center gap-3", children: filters })
|
|
2494
|
+
] })
|
|
2495
|
+
]
|
|
2496
|
+
}
|
|
2497
|
+
);
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
// src/components/craft-table-toolbar.tsx
|
|
2501
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
2502
|
+
function CraftTableToolbar({
|
|
2503
|
+
title,
|
|
2504
|
+
description,
|
|
2505
|
+
searchValue,
|
|
2506
|
+
onSearchChange,
|
|
2507
|
+
searchPlaceholder = "Search table...",
|
|
2508
|
+
actions,
|
|
2509
|
+
filters,
|
|
2510
|
+
bulkActions,
|
|
2511
|
+
tone,
|
|
2512
|
+
className
|
|
2513
|
+
}) {
|
|
2514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
2515
|
+
"div",
|
|
2516
|
+
{
|
|
2517
|
+
className: cn(
|
|
2518
|
+
"rounded-3xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] p-4 text-[rgb(var(--nc-fg))] shadow-[0_12px_36px_rgba(0,0,0,0.2)] backdrop-blur-2xl",
|
|
2519
|
+
className
|
|
2520
|
+
),
|
|
2521
|
+
"data-nc-theme": tone,
|
|
2522
|
+
children: [
|
|
2523
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
|
|
2524
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
|
|
2525
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h3", { className: "text-lg font-semibold", children: title }),
|
|
2526
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
2527
|
+
] }),
|
|
2528
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex items-center gap-3", children: actions })
|
|
2529
|
+
] }),
|
|
2530
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "mt-4 grid gap-4 lg:grid-cols-[minmax(0,1fr)_auto]", children: [
|
|
2531
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
2532
|
+
CraftInput,
|
|
2533
|
+
{
|
|
2534
|
+
type: "search",
|
|
2535
|
+
placeholder: searchPlaceholder,
|
|
2536
|
+
value: searchValue != null ? searchValue : "",
|
|
2537
|
+
onChange: (event) => onSearchChange == null ? void 0 : onSearchChange(event.target.value),
|
|
2538
|
+
tone
|
|
2539
|
+
}
|
|
2540
|
+
),
|
|
2541
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
2542
|
+
filters,
|
|
2543
|
+
bulkActions
|
|
2544
|
+
] })
|
|
1973
2545
|
] })
|
|
1974
2546
|
]
|
|
1975
2547
|
}
|
|
@@ -1977,10 +2549,10 @@ function CraftFilterBar({
|
|
|
1977
2549
|
}
|
|
1978
2550
|
|
|
1979
2551
|
// src/components/craft-data-table.tsx
|
|
1980
|
-
var
|
|
2552
|
+
var React22 = __toESM(require("react"), 1);
|
|
1981
2553
|
|
|
1982
2554
|
// src/components/craft-pagination.tsx
|
|
1983
|
-
var
|
|
2555
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1984
2556
|
function getPageNumbers(pageIndex, pageCount, maxButtons = 5) {
|
|
1985
2557
|
if (pageCount <= maxButtons) {
|
|
1986
2558
|
return Array.from({ length: pageCount }, (_, i) => i);
|
|
@@ -2010,7 +2582,7 @@ function CraftPagination({
|
|
|
2010
2582
|
className
|
|
2011
2583
|
}) {
|
|
2012
2584
|
const pages = getPageNumbers(pageIndex, pageCount);
|
|
2013
|
-
return /* @__PURE__ */ (0,
|
|
2585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
2014
2586
|
"div",
|
|
2015
2587
|
{
|
|
2016
2588
|
className: cn(
|
|
@@ -2019,8 +2591,8 @@ function CraftPagination({
|
|
|
2019
2591
|
),
|
|
2020
2592
|
"data-nc-theme": tone,
|
|
2021
2593
|
children: [
|
|
2022
|
-
/* @__PURE__ */ (0,
|
|
2023
|
-
/* @__PURE__ */ (0,
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2595
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2024
2596
|
"button",
|
|
2025
2597
|
{
|
|
2026
2598
|
type: "button",
|
|
@@ -2035,7 +2607,7 @@ function CraftPagination({
|
|
|
2035
2607
|
}
|
|
2036
2608
|
),
|
|
2037
2609
|
pages.map(
|
|
2038
|
-
(page, index) => page === "ellipsis" ? /* @__PURE__ */ (0,
|
|
2610
|
+
(page, index) => page === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "px-2 text-[rgb(var(--nc-fg-muted))]", children: "..." }, `ellipsis-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2039
2611
|
"button",
|
|
2040
2612
|
{
|
|
2041
2613
|
type: "button",
|
|
@@ -2049,7 +2621,7 @@ function CraftPagination({
|
|
|
2049
2621
|
page
|
|
2050
2622
|
)
|
|
2051
2623
|
),
|
|
2052
|
-
/* @__PURE__ */ (0,
|
|
2624
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2053
2625
|
"button",
|
|
2054
2626
|
{
|
|
2055
2627
|
type: "button",
|
|
@@ -2064,15 +2636,15 @@ function CraftPagination({
|
|
|
2064
2636
|
}
|
|
2065
2637
|
)
|
|
2066
2638
|
] }),
|
|
2067
|
-
onPageSizeChange && /* @__PURE__ */ (0,
|
|
2068
|
-
/* @__PURE__ */ (0,
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
2639
|
+
onPageSizeChange && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-2 text-xs text-[rgb(var(--nc-fg-muted))]", children: [
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Rows" }),
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
2070
2642
|
"select",
|
|
2071
2643
|
{
|
|
2072
2644
|
className: "rounded-xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] px-2 py-1 text-xs text-[rgb(var(--nc-fg))]",
|
|
2073
2645
|
value: pageSize,
|
|
2074
2646
|
onChange: (event) => onPageSizeChange(Number(event.target.value)),
|
|
2075
|
-
children: pageSizeOptions.map((size) => /* @__PURE__ */ (0,
|
|
2647
|
+
children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("option", { value: size, children: size }, size))
|
|
2076
2648
|
}
|
|
2077
2649
|
)
|
|
2078
2650
|
] })
|
|
@@ -2082,7 +2654,7 @@ function CraftPagination({
|
|
|
2082
2654
|
}
|
|
2083
2655
|
|
|
2084
2656
|
// src/components/craft-data-table.tsx
|
|
2085
|
-
var
|
|
2657
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2086
2658
|
function getColumnValue(column, row) {
|
|
2087
2659
|
if (typeof column.accessor === "function") return column.accessor(row);
|
|
2088
2660
|
const record = row;
|
|
@@ -2130,18 +2702,18 @@ function CraftDataTable({
|
|
|
2130
2702
|
onPageChange,
|
|
2131
2703
|
onPageSizeChange
|
|
2132
2704
|
}) {
|
|
2133
|
-
const [internalSort, setInternalSort] =
|
|
2134
|
-
const [internalFilters, setInternalFilters] =
|
|
2135
|
-
const [internalGlobalFilter, setInternalGlobalFilter] =
|
|
2136
|
-
const [internalVisibility, setInternalVisibility] =
|
|
2705
|
+
const [internalSort, setInternalSort] = React22.useState(null);
|
|
2706
|
+
const [internalFilters, setInternalFilters] = React22.useState({});
|
|
2707
|
+
const [internalGlobalFilter, setInternalGlobalFilter] = React22.useState("");
|
|
2708
|
+
const [internalVisibility, setInternalVisibility] = React22.useState(
|
|
2137
2709
|
() => columns.reduce((acc, column) => {
|
|
2138
2710
|
acc[column.id] = !column.hidden;
|
|
2139
2711
|
return acc;
|
|
2140
2712
|
}, {})
|
|
2141
2713
|
);
|
|
2142
|
-
const [internalSelection, setInternalSelection] =
|
|
2143
|
-
const [internalPageIndex, setInternalPageIndex] =
|
|
2144
|
-
const [showColumns, setShowColumns] =
|
|
2714
|
+
const [internalSelection, setInternalSelection] = React22.useState({});
|
|
2715
|
+
const [internalPageIndex, setInternalPageIndex] = React22.useState(0);
|
|
2716
|
+
const [showColumns, setShowColumns] = React22.useState(false);
|
|
2145
2717
|
const resolvedSort = sortBy != null ? sortBy : internalSort;
|
|
2146
2718
|
const resolvedFilters = filters != null ? filters : internalFilters;
|
|
2147
2719
|
const resolvedGlobalFilter = globalFilter != null ? globalFilter : internalGlobalFilter;
|
|
@@ -2164,7 +2736,7 @@ function CraftDataTable({
|
|
|
2164
2736
|
if (selectedRowIds === void 0) setInternalSelection(next);
|
|
2165
2737
|
onRowSelectionChange == null ? void 0 : onRowSelectionChange(next);
|
|
2166
2738
|
};
|
|
2167
|
-
const setPageIndex =
|
|
2739
|
+
const setPageIndex = React22.useCallback(
|
|
2168
2740
|
(next) => {
|
|
2169
2741
|
if (pageIndex === void 0) setInternalPageIndex(next);
|
|
2170
2742
|
onPageChange == null ? void 0 : onPageChange(next);
|
|
@@ -2174,7 +2746,7 @@ function CraftDataTable({
|
|
|
2174
2746
|
const visibleColumns = columns.filter(
|
|
2175
2747
|
(column) => resolvedVisibility[column.id] !== false
|
|
2176
2748
|
);
|
|
2177
|
-
const filteredData =
|
|
2749
|
+
const filteredData = React22.useMemo(() => {
|
|
2178
2750
|
if (manualFiltering) return data;
|
|
2179
2751
|
const globalValue = resolvedGlobalFilter.trim();
|
|
2180
2752
|
return data.filter((row) => {
|
|
@@ -2194,7 +2766,7 @@ function CraftDataTable({
|
|
|
2194
2766
|
});
|
|
2195
2767
|
});
|
|
2196
2768
|
}, [columns, data, manualFiltering, resolvedFilters, resolvedGlobalFilter]);
|
|
2197
|
-
const sortedData =
|
|
2769
|
+
const sortedData = React22.useMemo(() => {
|
|
2198
2770
|
if (manualSorting || !resolvedSort) return filteredData;
|
|
2199
2771
|
const column = columns.find((col) => col.id === resolvedSort.id);
|
|
2200
2772
|
if (!column) return filteredData;
|
|
@@ -2209,17 +2781,17 @@ function CraftDataTable({
|
|
|
2209
2781
|
return resolvedSort.desc ? sorted.reverse() : sorted;
|
|
2210
2782
|
}, [columns, filteredData, manualSorting, resolvedSort]);
|
|
2211
2783
|
const resolvedPageCount = manualPagination ? Math.max(pageCount != null ? pageCount : 1, 1) : Math.max(Math.ceil(sortedData.length / pageSize), 1);
|
|
2212
|
-
|
|
2784
|
+
React22.useEffect(() => {
|
|
2213
2785
|
if (resolvedPageIndex > resolvedPageCount - 1) {
|
|
2214
2786
|
setPageIndex(Math.max(resolvedPageCount - 1, 0));
|
|
2215
2787
|
}
|
|
2216
2788
|
}, [resolvedPageCount, resolvedPageIndex, setPageIndex]);
|
|
2217
|
-
const pagedData =
|
|
2789
|
+
const pagedData = React22.useMemo(() => {
|
|
2218
2790
|
if (!enablePagination || manualPagination) return sortedData;
|
|
2219
2791
|
const start = resolvedPageIndex * pageSize;
|
|
2220
2792
|
return sortedData.slice(start, start + pageSize);
|
|
2221
2793
|
}, [enablePagination, manualPagination, pageSize, resolvedPageIndex, sortedData]);
|
|
2222
|
-
const rowIdFor =
|
|
2794
|
+
const rowIdFor = React22.useCallback(
|
|
2223
2795
|
(row, index) => {
|
|
2224
2796
|
var _a;
|
|
2225
2797
|
return (_a = getRowId == null ? void 0 : getRowId(row, index)) != null ? _a : String(index);
|
|
@@ -2232,8 +2804,8 @@ function CraftDataTable({
|
|
|
2232
2804
|
);
|
|
2233
2805
|
const allSelected = pageRowIds.length > 0 && pageRowIds.every((id) => resolvedSelection[id]);
|
|
2234
2806
|
const someSelected = pageRowIds.some((id) => resolvedSelection[id]);
|
|
2235
|
-
const headerCheckboxRef =
|
|
2236
|
-
|
|
2807
|
+
const headerCheckboxRef = React22.useRef(null);
|
|
2808
|
+
React22.useEffect(() => {
|
|
2237
2809
|
if (headerCheckboxRef.current) {
|
|
2238
2810
|
headerCheckboxRef.current.indeterminate = someSelected && !allSelected;
|
|
2239
2811
|
}
|
|
@@ -2251,17 +2823,17 @@ function CraftDataTable({
|
|
|
2251
2823
|
}
|
|
2252
2824
|
setSort(null);
|
|
2253
2825
|
};
|
|
2254
|
-
const emptyContent = emptyState != null ? emptyState : /* @__PURE__ */ (0,
|
|
2826
|
+
const emptyContent = emptyState != null ? emptyState : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "text-center text-sm text-[rgb(var(--nc-fg-muted))]", children: "No results found." });
|
|
2255
2827
|
const resolvedShowGlobalFilter = showGlobalFilter != null ? showGlobalFilter : enableFiltering && !toolbar;
|
|
2256
2828
|
const setGlobalFilter = (next) => {
|
|
2257
2829
|
if (globalFilter === void 0) setInternalGlobalFilter(next);
|
|
2258
2830
|
onGlobalFilterChange == null ? void 0 : onGlobalFilterChange(next);
|
|
2259
2831
|
};
|
|
2260
|
-
return /* @__PURE__ */ (0,
|
|
2832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: cn("space-y-4", className), "data-nc-theme": tone, children: [
|
|
2261
2833
|
toolbar,
|
|
2262
|
-
resolvedShowGlobalFilter && /* @__PURE__ */ (0,
|
|
2263
|
-
/* @__PURE__ */ (0,
|
|
2264
|
-
/* @__PURE__ */ (0,
|
|
2834
|
+
resolvedShowGlobalFilter && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center justify-between gap-3 rounded-2xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] px-3 py-2 text-sm text-[rgb(var(--nc-fg))]", children: [
|
|
2835
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-xs text-[rgb(var(--nc-fg-muted))]", children: "Global filter" }),
|
|
2836
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2265
2837
|
"input",
|
|
2266
2838
|
{
|
|
2267
2839
|
type: "search",
|
|
@@ -2272,8 +2844,8 @@ function CraftDataTable({
|
|
|
2272
2844
|
}
|
|
2273
2845
|
)
|
|
2274
2846
|
] }),
|
|
2275
|
-
enableColumnVisibility && /* @__PURE__ */ (0,
|
|
2276
|
-
/* @__PURE__ */ (0,
|
|
2847
|
+
enableColumnVisibility && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "relative flex justify-end", children: [
|
|
2848
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2277
2849
|
"button",
|
|
2278
2850
|
{
|
|
2279
2851
|
type: "button",
|
|
@@ -2282,12 +2854,12 @@ function CraftDataTable({
|
|
|
2282
2854
|
children: "Columns"
|
|
2283
2855
|
}
|
|
2284
2856
|
),
|
|
2285
|
-
showColumns && /* @__PURE__ */ (0,
|
|
2857
|
+
showColumns && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "absolute right-0 top-10 z-20 w-48 rounded-2xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.2)] p-3 shadow-[0_12px_30px_rgba(0,0,0,0.35)] backdrop-blur-2xl", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "grid gap-2", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2286
2858
|
"label",
|
|
2287
2859
|
{
|
|
2288
2860
|
className: "flex items-center gap-2 text-xs text-[rgb(var(--nc-fg))]",
|
|
2289
2861
|
children: [
|
|
2290
|
-
/* @__PURE__ */ (0,
|
|
2862
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2291
2863
|
"input",
|
|
2292
2864
|
{
|
|
2293
2865
|
type: "checkbox",
|
|
@@ -2305,9 +2877,9 @@ function CraftDataTable({
|
|
|
2305
2877
|
column.id
|
|
2306
2878
|
)) }) })
|
|
2307
2879
|
] }),
|
|
2308
|
-
/* @__PURE__ */ (0,
|
|
2309
|
-
/* @__PURE__ */ (0,
|
|
2310
|
-
enableRowSelection && /* @__PURE__ */ (0,
|
|
2880
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "overflow-hidden rounded-3xl border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.08)] shadow-[0_18px_50px_rgba(0,0,0,0.35)] backdrop-blur-2xl", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("table", { className: "w-full border-collapse text-left text-sm", children: [
|
|
2881
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("thead", { className: "bg-[rgb(var(--nc-surface)/0.12)] text-[rgb(var(--nc-fg-muted))]", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("tr", { children: [
|
|
2882
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("th", { className: "w-12 px-4 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2311
2883
|
"input",
|
|
2312
2884
|
{
|
|
2313
2885
|
ref: headerCheckboxRef,
|
|
@@ -2325,7 +2897,7 @@ function CraftDataTable({
|
|
|
2325
2897
|
) }),
|
|
2326
2898
|
visibleColumns.map((column) => {
|
|
2327
2899
|
var _a;
|
|
2328
|
-
return /* @__PURE__ */ (0,
|
|
2900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2329
2901
|
"th",
|
|
2330
2902
|
{
|
|
2331
2903
|
className: cn(
|
|
@@ -2334,7 +2906,7 @@ function CraftDataTable({
|
|
|
2334
2906
|
),
|
|
2335
2907
|
style: { width: column.width },
|
|
2336
2908
|
children: [
|
|
2337
|
-
/* @__PURE__ */ (0,
|
|
2909
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2338
2910
|
"button",
|
|
2339
2911
|
{
|
|
2340
2912
|
type: "button",
|
|
@@ -2344,12 +2916,12 @@ function CraftDataTable({
|
|
|
2344
2916
|
),
|
|
2345
2917
|
onClick: () => toggleSort(column),
|
|
2346
2918
|
children: [
|
|
2347
|
-
/* @__PURE__ */ (0,
|
|
2348
|
-
(resolvedSort == null ? void 0 : resolvedSort.id) === column.id && /* @__PURE__ */ (0,
|
|
2919
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { children: column.header }),
|
|
2920
|
+
(resolvedSort == null ? void 0 : resolvedSort.id) === column.id && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-[rgb(var(--nc-accent-1))]", children: resolvedSort.desc ? "\u2193" : "\u2191" })
|
|
2349
2921
|
]
|
|
2350
2922
|
}
|
|
2351
2923
|
),
|
|
2352
|
-
enableFiltering && column.filterable !== false && /* @__PURE__ */ (0,
|
|
2924
|
+
enableFiltering && column.filterable !== false && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2353
2925
|
"input",
|
|
2354
2926
|
{
|
|
2355
2927
|
type: "text",
|
|
@@ -2368,19 +2940,19 @@ function CraftDataTable({
|
|
|
2368
2940
|
);
|
|
2369
2941
|
})
|
|
2370
2942
|
] }) }),
|
|
2371
|
-
/* @__PURE__ */ (0,
|
|
2372
|
-
loading && /* @__PURE__ */ (0,
|
|
2943
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("tbody", { className: "text-[rgb(var(--nc-fg))]", children: [
|
|
2944
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2373
2945
|
"td",
|
|
2374
2946
|
{
|
|
2375
2947
|
colSpan: visibleColumns.length + (enableRowSelection ? 1 : 0),
|
|
2376
2948
|
className: "px-4 py-10 text-center text-sm text-[rgb(var(--nc-fg-muted))]",
|
|
2377
|
-
children: /* @__PURE__ */ (0,
|
|
2378
|
-
/* @__PURE__ */ (0,
|
|
2949
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "inline-flex items-center gap-2", children: [
|
|
2950
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "h-4 w-4 animate-spin rounded-full border-2 border-[rgb(var(--nc-fg-muted))] border-t-transparent" }),
|
|
2379
2951
|
"Loading data..."
|
|
2380
2952
|
] })
|
|
2381
2953
|
}
|
|
2382
2954
|
) }),
|
|
2383
|
-
!loading && pagedData.length === 0 && /* @__PURE__ */ (0,
|
|
2955
|
+
!loading && pagedData.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2384
2956
|
"td",
|
|
2385
2957
|
{
|
|
2386
2958
|
colSpan: visibleColumns.length + (enableRowSelection ? 1 : 0),
|
|
@@ -2391,7 +2963,7 @@ function CraftDataTable({
|
|
|
2391
2963
|
!loading && pagedData.map((row, rowIndex) => {
|
|
2392
2964
|
const rowId = rowIdFor(row, pageStartIndex + rowIndex);
|
|
2393
2965
|
const isSelected = resolvedSelection[rowId];
|
|
2394
|
-
return /* @__PURE__ */ (0,
|
|
2966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2395
2967
|
"tr",
|
|
2396
2968
|
{
|
|
2397
2969
|
className: cn(
|
|
@@ -2399,7 +2971,7 @@ function CraftDataTable({
|
|
|
2399
2971
|
isSelected && "bg-[rgb(var(--nc-accent-1)/0.08)]"
|
|
2400
2972
|
),
|
|
2401
2973
|
children: [
|
|
2402
|
-
enableRowSelection && /* @__PURE__ */ (0,
|
|
2974
|
+
enableRowSelection && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("td", { className: "px-4 py-4", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2403
2975
|
"input",
|
|
2404
2976
|
{
|
|
2405
2977
|
type: "checkbox",
|
|
@@ -2413,7 +2985,7 @@ function CraftDataTable({
|
|
|
2413
2985
|
) }),
|
|
2414
2986
|
visibleColumns.map((column) => {
|
|
2415
2987
|
var _a;
|
|
2416
|
-
return /* @__PURE__ */ (0,
|
|
2988
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2417
2989
|
"td",
|
|
2418
2990
|
{
|
|
2419
2991
|
className: cn(
|
|
@@ -2434,7 +3006,7 @@ function CraftDataTable({
|
|
|
2434
3006
|
})
|
|
2435
3007
|
] })
|
|
2436
3008
|
] }) }),
|
|
2437
|
-
enablePagination && /* @__PURE__ */ (0,
|
|
3009
|
+
enablePagination && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2438
3010
|
CraftPagination,
|
|
2439
3011
|
{
|
|
2440
3012
|
pageIndex: resolvedPageIndex,
|
|
@@ -2449,9 +3021,9 @@ function CraftDataTable({
|
|
|
2449
3021
|
}
|
|
2450
3022
|
|
|
2451
3023
|
// src/components/layout/app-shell.tsx
|
|
2452
|
-
var
|
|
3024
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2453
3025
|
function AppShell({ className, sidebar, topNav, children, ...props }) {
|
|
2454
|
-
return /* @__PURE__ */ (0,
|
|
3026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
2455
3027
|
"div",
|
|
2456
3028
|
{
|
|
2457
3029
|
className: cn(
|
|
@@ -2460,20 +3032,35 @@ function AppShell({ className, sidebar, topNav, children, ...props }) {
|
|
|
2460
3032
|
),
|
|
2461
3033
|
...props,
|
|
2462
3034
|
children: [
|
|
2463
|
-
sidebar && /* @__PURE__ */ (0,
|
|
2464
|
-
/* @__PURE__ */ (0,
|
|
2465
|
-
topNav && /* @__PURE__ */ (0,
|
|
2466
|
-
/* @__PURE__ */ (0,
|
|
3035
|
+
sidebar && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "h-full lg:sticky lg:top-6 lg:self-start lg:max-h-[calc(100vh-3rem)] lg:overflow-y-auto", children: sidebar }),
|
|
3036
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
3037
|
+
topNav && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "lg:sticky lg:top-6 lg:z-20", children: topNav }),
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("main", { className: "flex-1", children })
|
|
2467
3039
|
] })
|
|
2468
3040
|
]
|
|
2469
3041
|
}
|
|
2470
3042
|
);
|
|
2471
3043
|
}
|
|
2472
3044
|
|
|
3045
|
+
// src/components/layout/app-template.tsx
|
|
3046
|
+
var React23 = __toESM(require("react"), 1);
|
|
3047
|
+
|
|
3048
|
+
// src/components/layout/breadcrumbs.tsx
|
|
3049
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3050
|
+
function Breadcrumbs({ className, items, ...props }) {
|
|
3051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("nav", { className: cn("flex items-center text-sm text-[rgb(var(--nc-fg-muted))]", className), ...props, children: items.map((item, index) => {
|
|
3052
|
+
const content = item.href ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("a", { href: item.href, className: "transition hover:text-[rgb(var(--nc-fg))]", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-[rgb(var(--nc-fg))]", children: item.label });
|
|
3053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("span", { className: "flex items-center", children: [
|
|
3054
|
+
content,
|
|
3055
|
+
index < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "mx-2 text-[rgb(var(--nc-fg-soft))]", children: "/" })
|
|
3056
|
+
] }, `${item.label}-${index}`);
|
|
3057
|
+
}) });
|
|
3058
|
+
}
|
|
3059
|
+
|
|
2473
3060
|
// src/components/layout/sidebar.tsx
|
|
2474
|
-
var
|
|
3061
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2475
3062
|
function Sidebar({ className, title, items, footer, ...props }) {
|
|
2476
|
-
return /* @__PURE__ */ (0,
|
|
3063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
2477
3064
|
"aside",
|
|
2478
3065
|
{
|
|
2479
3066
|
className: cn(
|
|
@@ -2482,10 +3069,10 @@ function Sidebar({ className, title, items, footer, ...props }) {
|
|
|
2482
3069
|
),
|
|
2483
3070
|
...props,
|
|
2484
3071
|
children: [
|
|
2485
|
-
title && /* @__PURE__ */ (0,
|
|
2486
|
-
/* @__PURE__ */ (0,
|
|
3072
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "text-lg font-semibold", children: title }),
|
|
3073
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("nav", { className: "flex flex-col gap-2", children: items.map((item, index) => {
|
|
2487
3074
|
var _a;
|
|
2488
|
-
return /* @__PURE__ */ (0,
|
|
3075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
|
|
2489
3076
|
"a",
|
|
2490
3077
|
{
|
|
2491
3078
|
href: (_a = item.href) != null ? _a : "#",
|
|
@@ -2495,22 +3082,22 @@ function Sidebar({ className, title, items, footer, ...props }) {
|
|
|
2495
3082
|
),
|
|
2496
3083
|
children: [
|
|
2497
3084
|
item.icon,
|
|
2498
|
-
/* @__PURE__ */ (0,
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: item.label })
|
|
2499
3086
|
]
|
|
2500
3087
|
},
|
|
2501
3088
|
`${item.label}-${index}`
|
|
2502
3089
|
);
|
|
2503
3090
|
}) }),
|
|
2504
|
-
footer && /* @__PURE__ */ (0,
|
|
3091
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "mt-auto pt-4", children: footer })
|
|
2505
3092
|
]
|
|
2506
3093
|
}
|
|
2507
3094
|
);
|
|
2508
3095
|
}
|
|
2509
3096
|
|
|
2510
3097
|
// src/components/layout/top-nav.tsx
|
|
2511
|
-
var
|
|
3098
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2512
3099
|
function TopNav({ className, title, actions, breadcrumb, ...props }) {
|
|
2513
|
-
return /* @__PURE__ */ (0,
|
|
3100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
2514
3101
|
"header",
|
|
2515
3102
|
{
|
|
2516
3103
|
className: cn(
|
|
@@ -2519,18 +3106,131 @@ function TopNav({ className, title, actions, breadcrumb, ...props }) {
|
|
|
2519
3106
|
),
|
|
2520
3107
|
...props,
|
|
2521
3108
|
children: [
|
|
2522
|
-
/* @__PURE__ */ (0,
|
|
3109
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "space-y-1", children: [
|
|
2523
3110
|
breadcrumb,
|
|
2524
|
-
title && /* @__PURE__ */ (0,
|
|
3111
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "text-xl font-semibold", children: title })
|
|
2525
3112
|
] }),
|
|
2526
|
-
actions && /* @__PURE__ */ (0,
|
|
3113
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "flex flex-wrap gap-3", children: actions })
|
|
2527
3114
|
]
|
|
2528
3115
|
}
|
|
2529
3116
|
);
|
|
2530
3117
|
}
|
|
2531
3118
|
|
|
3119
|
+
// src/components/layout/app-template.tsx
|
|
3120
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3121
|
+
function AppTemplate({
|
|
3122
|
+
config,
|
|
3123
|
+
headerActions,
|
|
3124
|
+
headerBreadcrumb,
|
|
3125
|
+
sidebarFooter,
|
|
3126
|
+
resolveIcon,
|
|
3127
|
+
icons,
|
|
3128
|
+
activePath,
|
|
3129
|
+
getActivePath,
|
|
3130
|
+
lucideFallback = true,
|
|
3131
|
+
children
|
|
3132
|
+
}) {
|
|
3133
|
+
const sidebarConfig = config.sidebar;
|
|
3134
|
+
const headerConfig = config.header;
|
|
3135
|
+
const resolvedActivePath = activePath != null ? activePath : getActivePath == null ? void 0 : getActivePath();
|
|
3136
|
+
const buildIcon = React23.useCallback(
|
|
3137
|
+
(name) => {
|
|
3138
|
+
if (!name) return void 0;
|
|
3139
|
+
if (resolveIcon) return resolveIcon(name);
|
|
3140
|
+
if (icons == null ? void 0 : icons[name]) return icons[name];
|
|
3141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CraftIcon, { name, useLucide: lucideFallback });
|
|
3142
|
+
},
|
|
3143
|
+
[icons, lucideFallback, resolveIcon]
|
|
3144
|
+
);
|
|
3145
|
+
const sidebarItems = sidebarConfig ? sidebarConfig.items.map((item) => {
|
|
3146
|
+
var _a;
|
|
3147
|
+
return {
|
|
3148
|
+
label: item.label,
|
|
3149
|
+
href: item.href,
|
|
3150
|
+
active: (_a = item.active) != null ? _a : resolvedActivePath && item.href ? item.href === resolvedActivePath : false,
|
|
3151
|
+
icon: buildIcon(item.icon)
|
|
3152
|
+
};
|
|
3153
|
+
}) : null;
|
|
3154
|
+
const breadcrumbNode = headerBreadcrumb != null ? headerBreadcrumb : (headerConfig == null ? void 0 : headerConfig.breadcrumb) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Breadcrumbs, { items: headerConfig.breadcrumb }) : null;
|
|
3155
|
+
const sidebarFooterNode = sidebarFooter != null ? sidebarFooter : (sidebarConfig == null ? void 0 : sidebarConfig.footerText) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-xs text-[rgb(var(--nc-fg-muted))]", children: sidebarConfig.footerText }) : null;
|
|
3156
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3157
|
+
AppShell,
|
|
3158
|
+
{
|
|
3159
|
+
sidebar: sidebarConfig && sidebarItems ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3160
|
+
Sidebar,
|
|
3161
|
+
{
|
|
3162
|
+
title: sidebarConfig.title,
|
|
3163
|
+
items: sidebarItems,
|
|
3164
|
+
footer: sidebarFooterNode
|
|
3165
|
+
}
|
|
3166
|
+
) : void 0,
|
|
3167
|
+
topNav: headerConfig ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3168
|
+
TopNav,
|
|
3169
|
+
{
|
|
3170
|
+
title: headerConfig.title,
|
|
3171
|
+
breadcrumb: breadcrumbNode,
|
|
3172
|
+
actions: headerActions
|
|
3173
|
+
}
|
|
3174
|
+
) : void 0,
|
|
3175
|
+
children
|
|
3176
|
+
}
|
|
3177
|
+
);
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
// src/components/layout/layout-config.ts
|
|
3181
|
+
var layoutConfigSchema = {
|
|
3182
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
3183
|
+
title: "Nextcraft UI Layout Config",
|
|
3184
|
+
type: "object",
|
|
3185
|
+
additionalProperties: false,
|
|
3186
|
+
properties: {
|
|
3187
|
+
sidebar: {
|
|
3188
|
+
type: "object",
|
|
3189
|
+
additionalProperties: false,
|
|
3190
|
+
properties: {
|
|
3191
|
+
title: { type: "string" },
|
|
3192
|
+
footerText: { type: "string" },
|
|
3193
|
+
items: {
|
|
3194
|
+
type: "array",
|
|
3195
|
+
items: {
|
|
3196
|
+
type: "object",
|
|
3197
|
+
additionalProperties: false,
|
|
3198
|
+
properties: {
|
|
3199
|
+
label: { type: "string" },
|
|
3200
|
+
href: { type: "string" },
|
|
3201
|
+
icon: { type: "string" },
|
|
3202
|
+
active: { type: "boolean" }
|
|
3203
|
+
},
|
|
3204
|
+
required: ["label"]
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
},
|
|
3208
|
+
required: ["items"]
|
|
3209
|
+
},
|
|
3210
|
+
header: {
|
|
3211
|
+
type: "object",
|
|
3212
|
+
additionalProperties: false,
|
|
3213
|
+
properties: {
|
|
3214
|
+
title: { type: "string" },
|
|
3215
|
+
breadcrumb: {
|
|
3216
|
+
type: "array",
|
|
3217
|
+
items: {
|
|
3218
|
+
type: "object",
|
|
3219
|
+
additionalProperties: false,
|
|
3220
|
+
properties: {
|
|
3221
|
+
label: { type: "string" },
|
|
3222
|
+
href: { type: "string" }
|
|
3223
|
+
},
|
|
3224
|
+
required: ["label"]
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
};
|
|
3231
|
+
|
|
2532
3232
|
// src/components/layout/page-header.tsx
|
|
2533
|
-
var
|
|
3233
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2534
3234
|
function PageHeader({
|
|
2535
3235
|
className,
|
|
2536
3236
|
title,
|
|
@@ -2538,36 +3238,24 @@ function PageHeader({
|
|
|
2538
3238
|
actions,
|
|
2539
3239
|
...props
|
|
2540
3240
|
}) {
|
|
2541
|
-
return /* @__PURE__ */ (0,
|
|
3241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
2542
3242
|
"div",
|
|
2543
3243
|
{
|
|
2544
3244
|
className: cn("flex flex-wrap items-start justify-between gap-6", className),
|
|
2545
3245
|
...props,
|
|
2546
3246
|
children: [
|
|
2547
|
-
/* @__PURE__ */ (0,
|
|
2548
|
-
/* @__PURE__ */ (0,
|
|
2549
|
-
description && /* @__PURE__ */ (0,
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "space-y-2", children: [
|
|
3248
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h1", { className: "text-3xl font-bold text-[rgb(var(--nc-fg))]", children: title }),
|
|
3249
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
2550
3250
|
] }),
|
|
2551
|
-
actions && /* @__PURE__ */ (0,
|
|
3251
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex flex-wrap gap-3", children: actions })
|
|
2552
3252
|
]
|
|
2553
3253
|
}
|
|
2554
3254
|
);
|
|
2555
3255
|
}
|
|
2556
3256
|
|
|
2557
|
-
// src/components/layout/breadcrumbs.tsx
|
|
2558
|
-
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2559
|
-
function Breadcrumbs({ className, items, ...props }) {
|
|
2560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("nav", { className: cn("flex items-center text-sm text-[rgb(var(--nc-fg-muted))]", className), ...props, children: items.map((item, index) => {
|
|
2561
|
-
const content = item.href ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("a", { href: item.href, className: "transition hover:text-[rgb(var(--nc-fg))]", children: item.label }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "text-[rgb(var(--nc-fg))]", children: item.label });
|
|
2562
|
-
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("span", { className: "flex items-center", children: [
|
|
2563
|
-
content,
|
|
2564
|
-
index < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { className: "mx-2 text-[rgb(var(--nc-fg-soft))]", children: "/" })
|
|
2565
|
-
] }, `${item.label}-${index}`);
|
|
2566
|
-
}) });
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
3257
|
// src/components/layout/auth-layout.tsx
|
|
2570
|
-
var
|
|
3258
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2571
3259
|
function AuthLayout({
|
|
2572
3260
|
className,
|
|
2573
3261
|
title,
|
|
@@ -2577,7 +3265,7 @@ function AuthLayout({
|
|
|
2577
3265
|
children,
|
|
2578
3266
|
...props
|
|
2579
3267
|
}) {
|
|
2580
|
-
return /* @__PURE__ */ (0,
|
|
3268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
2581
3269
|
"div",
|
|
2582
3270
|
{
|
|
2583
3271
|
className: cn(
|
|
@@ -2587,17 +3275,17 @@ function AuthLayout({
|
|
|
2587
3275
|
),
|
|
2588
3276
|
...props,
|
|
2589
3277
|
children: [
|
|
2590
|
-
/* @__PURE__ */ (0,
|
|
2591
|
-
(title || description) && /* @__PURE__ */ (0,
|
|
2592
|
-
title && /* @__PURE__ */ (0,
|
|
2593
|
-
description && /* @__PURE__ */ (0,
|
|
3278
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex flex-col justify-center px-6 py-16 sm:px-12", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "mx-auto w-full max-w-md space-y-6", children: [
|
|
3279
|
+
(title || description) && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "space-y-2", children: [
|
|
3280
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "text-3xl font-bold text-[rgb(var(--nc-fg))]", children: title }),
|
|
3281
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
2594
3282
|
] }),
|
|
2595
3283
|
children,
|
|
2596
|
-
footer && /* @__PURE__ */ (0,
|
|
3284
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: footer })
|
|
2597
3285
|
] }) }),
|
|
2598
|
-
/* @__PURE__ */ (0,
|
|
2599
|
-
/* @__PURE__ */ (0,
|
|
2600
|
-
/* @__PURE__ */ (0,
|
|
3286
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "hidden items-center justify-center border-l border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.08)] p-12 text-[rgb(var(--nc-fg))] lg:flex", children: graphic != null ? graphic : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "max-w-sm space-y-4 text-center", children: [
|
|
3287
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", { className: "text-2xl font-semibold", children: "Crafted experiences" }),
|
|
3288
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: "Build authentication flows that feel premium and cohesive." })
|
|
2601
3289
|
] }) })
|
|
2602
3290
|
]
|
|
2603
3291
|
}
|
|
@@ -2605,25 +3293,25 @@ function AuthLayout({
|
|
|
2605
3293
|
}
|
|
2606
3294
|
|
|
2607
3295
|
// src/components/layout/container.tsx
|
|
2608
|
-
var
|
|
2609
|
-
var
|
|
3296
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3297
|
+
var sizeClasses3 = {
|
|
2610
3298
|
sm: "max-w-3xl",
|
|
2611
3299
|
md: "max-w-5xl",
|
|
2612
3300
|
lg: "max-w-6xl",
|
|
2613
3301
|
xl: "max-w-7xl"
|
|
2614
3302
|
};
|
|
2615
3303
|
function Container({ className, size = "lg", ...props }) {
|
|
2616
|
-
return /* @__PURE__ */ (0,
|
|
3304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
2617
3305
|
"div",
|
|
2618
3306
|
{
|
|
2619
|
-
className: cn("mx-auto w-full px-4 sm:px-6 lg:px-8",
|
|
3307
|
+
className: cn("mx-auto w-full px-4 sm:px-6 lg:px-8", sizeClasses3[size], className),
|
|
2620
3308
|
...props
|
|
2621
3309
|
}
|
|
2622
3310
|
);
|
|
2623
3311
|
}
|
|
2624
3312
|
|
|
2625
3313
|
// src/components/layout/grid.tsx
|
|
2626
|
-
var
|
|
3314
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
2627
3315
|
var colClasses = {
|
|
2628
3316
|
1: "grid-cols-1",
|
|
2629
3317
|
2: "grid-cols-1 md:grid-cols-2",
|
|
@@ -2639,12 +3327,12 @@ var gapClasses = {
|
|
|
2639
3327
|
xl: "gap-10"
|
|
2640
3328
|
};
|
|
2641
3329
|
function Grid({ className, columns = 3, gap = "md", ...props }) {
|
|
2642
|
-
return /* @__PURE__ */ (0,
|
|
3330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: cn("grid", colClasses[columns], gapClasses[gap], className), ...props });
|
|
2643
3331
|
}
|
|
2644
3332
|
|
|
2645
3333
|
// src/theme/theme-context.tsx
|
|
2646
|
-
var
|
|
2647
|
-
var
|
|
3334
|
+
var React24 = __toESM(require("react"), 1);
|
|
3335
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
2648
3336
|
var THEME_NAMES = [
|
|
2649
3337
|
"aurora",
|
|
2650
3338
|
"ember",
|
|
@@ -2652,7 +3340,7 @@ var THEME_NAMES = [
|
|
|
2652
3340
|
"midnight",
|
|
2653
3341
|
"cosmic"
|
|
2654
3342
|
];
|
|
2655
|
-
var ThemeContext =
|
|
3343
|
+
var ThemeContext = React24.createContext(null);
|
|
2656
3344
|
var DEFAULT_THEME_KEY = "nextcraft-theme";
|
|
2657
3345
|
var DEFAULT_MODE_KEY = "nextcraft-mode";
|
|
2658
3346
|
function ThemeProvider({
|
|
@@ -2662,9 +3350,9 @@ function ThemeProvider({
|
|
|
2662
3350
|
storageKeyTheme = DEFAULT_THEME_KEY,
|
|
2663
3351
|
storageKeyMode = DEFAULT_MODE_KEY
|
|
2664
3352
|
}) {
|
|
2665
|
-
const [theme, setTheme] =
|
|
2666
|
-
const [mode, setMode] =
|
|
2667
|
-
|
|
3353
|
+
const [theme, setTheme] = React24.useState(defaultTheme);
|
|
3354
|
+
const [mode, setMode] = React24.useState(defaultMode);
|
|
3355
|
+
React24.useEffect(() => {
|
|
2668
3356
|
if (typeof window === "undefined") return;
|
|
2669
3357
|
try {
|
|
2670
3358
|
const storedTheme = window.localStorage.getItem(storageKeyTheme);
|
|
@@ -2674,7 +3362,7 @@ function ThemeProvider({
|
|
|
2674
3362
|
} catch {
|
|
2675
3363
|
}
|
|
2676
3364
|
}, [storageKeyTheme, storageKeyMode]);
|
|
2677
|
-
|
|
3365
|
+
React24.useEffect(() => {
|
|
2678
3366
|
if (typeof window === "undefined") return;
|
|
2679
3367
|
try {
|
|
2680
3368
|
window.localStorage.setItem(storageKeyTheme, theme);
|
|
@@ -2682,7 +3370,7 @@ function ThemeProvider({
|
|
|
2682
3370
|
} catch {
|
|
2683
3371
|
}
|
|
2684
3372
|
}, [theme, mode, storageKeyTheme, storageKeyMode]);
|
|
2685
|
-
|
|
3373
|
+
React24.useEffect(() => {
|
|
2686
3374
|
if (typeof document === "undefined") return;
|
|
2687
3375
|
const root = document.documentElement;
|
|
2688
3376
|
root.dataset.ncTheme = theme;
|
|
@@ -2702,14 +3390,14 @@ function ThemeProvider({
|
|
|
2702
3390
|
mediaQuery.addListener(applySystem);
|
|
2703
3391
|
return () => mediaQuery.removeListener(applySystem);
|
|
2704
3392
|
}, [theme, mode]);
|
|
2705
|
-
const value =
|
|
3393
|
+
const value = React24.useMemo(
|
|
2706
3394
|
() => ({ theme, mode, setTheme, setMode }),
|
|
2707
3395
|
[theme, mode]
|
|
2708
3396
|
);
|
|
2709
|
-
return /* @__PURE__ */ (0,
|
|
3397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ThemeContext.Provider, { value, children });
|
|
2710
3398
|
}
|
|
2711
3399
|
function useTheme() {
|
|
2712
|
-
const context =
|
|
3400
|
+
const context = React24.useContext(ThemeContext);
|
|
2713
3401
|
if (!context) {
|
|
2714
3402
|
throw new Error("useTheme must be used within ThemeProvider");
|
|
2715
3403
|
}
|
|
@@ -2717,11 +3405,11 @@ function useTheme() {
|
|
|
2717
3405
|
}
|
|
2718
3406
|
|
|
2719
3407
|
// src/components/theme-switcher.tsx
|
|
2720
|
-
var
|
|
3408
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
2721
3409
|
var MODE_OPTIONS = ["system", "light", "dark"];
|
|
2722
3410
|
function ThemeSwitcher({ className, showLabels = true, ...props }) {
|
|
2723
3411
|
const { theme, mode, setTheme, setMode } = useTheme();
|
|
2724
|
-
return /* @__PURE__ */ (0,
|
|
3412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
|
|
2725
3413
|
"div",
|
|
2726
3414
|
{
|
|
2727
3415
|
className: cn(
|
|
@@ -2730,27 +3418,27 @@ function ThemeSwitcher({ className, showLabels = true, ...props }) {
|
|
|
2730
3418
|
),
|
|
2731
3419
|
...props,
|
|
2732
3420
|
children: [
|
|
2733
|
-
/* @__PURE__ */ (0,
|
|
2734
|
-
showLabels && /* @__PURE__ */ (0,
|
|
2735
|
-
/* @__PURE__ */ (0,
|
|
3421
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
3422
|
+
showLabels && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "text-[rgb(var(--nc-fg-muted))]", children: "Theme" }),
|
|
3423
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2736
3424
|
"select",
|
|
2737
3425
|
{
|
|
2738
3426
|
className: "rounded-lg border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] px-3 py-1 text-[rgb(var(--nc-fg))] outline-none focus:ring-2 focus:ring-[rgb(var(--nc-accent-1)/0.5)]",
|
|
2739
3427
|
value: theme,
|
|
2740
3428
|
onChange: (event) => setTheme(event.target.value),
|
|
2741
|
-
children: THEME_NAMES.map((name) => /* @__PURE__ */ (0,
|
|
3429
|
+
children: THEME_NAMES.map((name) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value: name, className: "text-slate-900", children: name }, name))
|
|
2742
3430
|
}
|
|
2743
3431
|
)
|
|
2744
3432
|
] }),
|
|
2745
|
-
/* @__PURE__ */ (0,
|
|
2746
|
-
showLabels && /* @__PURE__ */ (0,
|
|
2747
|
-
/* @__PURE__ */ (0,
|
|
3433
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
3434
|
+
showLabels && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "text-[rgb(var(--nc-fg-muted))]", children: "Mode" }),
|
|
3435
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
2748
3436
|
"select",
|
|
2749
3437
|
{
|
|
2750
3438
|
className: "rounded-lg border border-[rgb(var(--nc-border)/0.3)] bg-[rgb(var(--nc-surface)/0.12)] px-3 py-1 text-[rgb(var(--nc-fg))] outline-none focus:ring-2 focus:ring-[rgb(var(--nc-accent-1)/0.5)]",
|
|
2751
3439
|
value: mode,
|
|
2752
3440
|
onChange: (event) => setMode(event.target.value),
|
|
2753
|
-
children: MODE_OPTIONS.map((value) => /* @__PURE__ */ (0,
|
|
3441
|
+
children: MODE_OPTIONS.map((value) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("option", { value, className: "text-slate-900", children: value }, value))
|
|
2754
3442
|
}
|
|
2755
3443
|
)
|
|
2756
3444
|
] })
|
|
@@ -2761,32 +3449,44 @@ function ThemeSwitcher({ className, showLabels = true, ...props }) {
|
|
|
2761
3449
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2762
3450
|
0 && (module.exports = {
|
|
2763
3451
|
AppShell,
|
|
3452
|
+
AppTemplate,
|
|
2764
3453
|
AuthLayout,
|
|
2765
3454
|
Breadcrumbs,
|
|
2766
3455
|
Container,
|
|
3456
|
+
CraftAlert,
|
|
2767
3457
|
CraftBadge,
|
|
2768
3458
|
CraftButton,
|
|
2769
3459
|
CraftCard,
|
|
2770
3460
|
CraftCheckbox,
|
|
3461
|
+
CraftCommandPalette,
|
|
2771
3462
|
CraftConfirmDialog,
|
|
2772
3463
|
CraftCreateEditDrawer,
|
|
2773
3464
|
CraftCurrencyInput,
|
|
2774
3465
|
CraftDataTable,
|
|
2775
3466
|
CraftDatePicker,
|
|
2776
3467
|
CraftDrawer,
|
|
3468
|
+
CraftDropdownMenu,
|
|
2777
3469
|
CraftEmptyState,
|
|
3470
|
+
CraftErrorState,
|
|
2778
3471
|
CraftFilterBar,
|
|
2779
3472
|
CraftForm,
|
|
2780
3473
|
CraftFormBuilder,
|
|
2781
3474
|
CraftFormField,
|
|
3475
|
+
CraftIcon,
|
|
3476
|
+
CraftIconProvider,
|
|
2782
3477
|
CraftInput,
|
|
3478
|
+
CraftLink,
|
|
3479
|
+
CraftLoadingState,
|
|
2783
3480
|
CraftModal,
|
|
2784
3481
|
CraftNumberInput,
|
|
2785
3482
|
CraftPagination,
|
|
3483
|
+
CraftPopover,
|
|
2786
3484
|
CraftSelect,
|
|
2787
3485
|
CraftSkeleton,
|
|
3486
|
+
CraftStatCard,
|
|
2788
3487
|
CraftSubmitButton,
|
|
2789
3488
|
CraftSwitch,
|
|
3489
|
+
CraftTableToolbar,
|
|
2790
3490
|
CraftTabs,
|
|
2791
3491
|
CraftTextarea,
|
|
2792
3492
|
CraftToastHost,
|
|
@@ -2798,6 +3498,7 @@ function ThemeSwitcher({ className, showLabels = true, ...props }) {
|
|
|
2798
3498
|
ThemeProvider,
|
|
2799
3499
|
ThemeSwitcher,
|
|
2800
3500
|
TopNav,
|
|
3501
|
+
layoutConfigSchema,
|
|
2801
3502
|
useCraftToast,
|
|
2802
3503
|
useTheme
|
|
2803
3504
|
});
|