@jameskabz/nextcraft-ui 0.6.6 → 0.6.8
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/dist/components/craft-alert.cjs +69 -0
- package/dist/components/craft-alert.cjs.map +1 -0
- package/dist/components/craft-alert.d.cts +16 -0
- package/dist/components/craft-alert.d.ts +16 -0
- package/dist/components/craft-alert.js +45 -0
- package/dist/components/craft-alert.js.map +1 -0
- package/dist/components/craft-badge.cjs +54 -0
- package/dist/components/craft-badge.cjs.map +1 -0
- package/dist/components/craft-badge.d.cts +12 -0
- package/dist/components/craft-badge.d.ts +12 -0
- package/dist/components/craft-badge.js +30 -0
- package/dist/components/craft-badge.js.map +1 -0
- package/dist/components/craft-button.cjs +66 -0
- package/dist/components/craft-button.cjs.map +1 -0
- package/dist/components/craft-button.d.cts +15 -0
- package/dist/components/craft-button.d.ts +15 -0
- package/dist/components/craft-button.js +42 -0
- package/dist/components/craft-button.js.map +1 -0
- package/dist/components/craft-card.cjs +63 -0
- package/dist/components/craft-card.cjs.map +1 -0
- package/dist/components/craft-card.d.cts +13 -0
- package/dist/components/craft-card.d.ts +13 -0
- package/dist/components/craft-card.js +39 -0
- package/dist/components/craft-card.js.map +1 -0
- package/dist/components/craft-checkbox.cjs +103 -0
- package/dist/components/craft-checkbox.cjs.map +1 -0
- package/dist/components/craft-checkbox.d.cts +16 -0
- package/dist/components/craft-checkbox.d.ts +16 -0
- package/dist/components/craft-checkbox.js +69 -0
- package/dist/components/craft-checkbox.js.map +1 -0
- package/dist/components/craft-command-palette.cjs +134 -0
- package/dist/components/craft-command-palette.cjs.map +1 -0
- package/dist/components/craft-command-palette.d.cts +28 -0
- package/dist/components/craft-command-palette.d.ts +28 -0
- package/dist/components/craft-command-palette.js +100 -0
- package/dist/components/craft-command-palette.js.map +1 -0
- package/dist/components/craft-confirm-dialog.cjs +114 -0
- package/dist/components/craft-confirm-dialog.cjs.map +1 -0
- package/dist/components/craft-confirm-dialog.d.cts +21 -0
- package/dist/components/craft-confirm-dialog.d.ts +21 -0
- package/dist/components/craft-confirm-dialog.js +80 -0
- package/dist/components/craft-confirm-dialog.js.map +1 -0
- package/dist/components/craft-create-edit-drawer.cjs +112 -0
- package/dist/components/craft-create-edit-drawer.cjs.map +1 -0
- package/dist/components/craft-create-edit-drawer.d.cts +28 -0
- package/dist/components/craft-create-edit-drawer.d.ts +28 -0
- package/dist/components/craft-create-edit-drawer.js +78 -0
- package/dist/components/craft-create-edit-drawer.js.map +1 -0
- package/dist/components/craft-currency-input.cjs +68 -0
- package/dist/components/craft-currency-input.cjs.map +1 -0
- package/dist/components/craft-currency-input.d.cts +14 -0
- package/dist/components/craft-currency-input.d.ts +14 -0
- package/dist/components/craft-currency-input.js +34 -0
- package/dist/components/craft-currency-input.js.map +1 -0
- package/dist/components/craft-data-table.cjs +407 -0
- package/dist/components/craft-data-table.cjs.map +1 -0
- package/dist/components/craft-data-table.d.cts +58 -0
- package/dist/components/craft-data-table.d.ts +58 -0
- package/dist/components/craft-data-table.js +373 -0
- package/dist/components/craft-data-table.js.map +1 -0
- package/dist/components/craft-date-picker.cjs +226 -0
- package/dist/components/craft-date-picker.cjs.map +1 -0
- package/dist/components/craft-date-picker.d.cts +17 -0
- package/dist/components/craft-date-picker.d.ts +17 -0
- package/dist/components/craft-date-picker.js +192 -0
- package/dist/components/craft-date-picker.js.map +1 -0
- package/dist/components/craft-drawer.cjs +126 -0
- package/dist/components/craft-drawer.cjs.map +1 -0
- package/dist/components/craft-drawer.d.cts +19 -0
- package/dist/components/craft-drawer.d.ts +19 -0
- package/dist/components/craft-drawer.js +92 -0
- package/dist/components/craft-drawer.js.map +1 -0
- package/dist/components/craft-dropdown-menu.cjs +127 -0
- package/dist/components/craft-dropdown-menu.cjs.map +1 -0
- package/dist/components/craft-dropdown-menu.d.cts +28 -0
- package/dist/components/craft-dropdown-menu.d.ts +28 -0
- package/dist/components/craft-dropdown-menu.js +93 -0
- package/dist/components/craft-dropdown-menu.js.map +1 -0
- package/dist/components/craft-empty-state.cjs +58 -0
- package/dist/components/craft-empty-state.cjs.map +1 -0
- package/dist/components/craft-empty-state.d.cts +14 -0
- package/dist/components/craft-empty-state.d.ts +14 -0
- package/dist/components/craft-empty-state.js +34 -0
- package/dist/components/craft-empty-state.js.map +1 -0
- package/dist/components/craft-error-state.cjs +60 -0
- package/dist/components/craft-error-state.cjs.map +1 -0
- package/dist/components/craft-error-state.d.cts +15 -0
- package/dist/components/craft-error-state.d.ts +15 -0
- package/dist/components/craft-error-state.js +36 -0
- package/dist/components/craft-error-state.js.map +1 -0
- package/dist/components/craft-filter-bar.cjs +76 -0
- package/dist/components/craft-filter-bar.cjs.map +1 -0
- package/dist/components/craft-filter-bar.d.cts +18 -0
- package/dist/components/craft-filter-bar.d.ts +18 -0
- package/dist/components/craft-filter-bar.js +52 -0
- package/dist/components/craft-filter-bar.js.map +1 -0
- package/dist/components/craft-form-builder.cjs +330 -0
- package/dist/components/craft-form-builder.cjs.map +1 -0
- package/dist/components/craft-form-builder.d.cts +57 -0
- package/dist/components/craft-form-builder.d.ts +57 -0
- package/dist/components/craft-form-builder.js +301 -0
- package/dist/components/craft-form-builder.js.map +1 -0
- package/dist/components/craft-form-field.cjs +301 -0
- package/dist/components/craft-form-field.cjs.map +1 -0
- package/dist/components/craft-form-field.d.cts +30 -0
- package/dist/components/craft-form-field.d.ts +30 -0
- package/dist/components/craft-form-field.js +280 -0
- package/dist/components/craft-form-field.js.map +1 -0
- package/dist/components/craft-form.cjs +114 -0
- package/dist/components/craft-form.cjs.map +1 -0
- package/dist/components/craft-form.d.cts +27 -0
- package/dist/components/craft-form.d.ts +27 -0
- package/dist/components/craft-form.js +80 -0
- package/dist/components/craft-form.js.map +1 -0
- package/dist/components/craft-icon.cjs +102 -0
- package/dist/components/craft-icon.cjs.map +1 -0
- package/dist/components/craft-icon.d.cts +19 -0
- package/dist/components/craft-icon.d.ts +19 -0
- package/dist/components/craft-icon.js +67 -0
- package/dist/components/craft-icon.js.map +1 -0
- package/dist/components/craft-input.cjs +78 -0
- package/dist/components/craft-input.cjs.map +1 -0
- package/dist/components/craft-input.d.cts +19 -0
- package/dist/components/craft-input.d.ts +19 -0
- package/dist/components/craft-input.js +44 -0
- package/dist/components/craft-input.js.map +1 -0
- package/dist/components/craft-link.cjs +70 -0
- package/dist/components/craft-link.cjs.map +1 -0
- package/dist/components/craft-link.d.cts +14 -0
- package/dist/components/craft-link.d.ts +14 -0
- package/dist/components/craft-link.js +36 -0
- package/dist/components/craft-link.js.map +1 -0
- package/dist/components/craft-loading-state.cjs +64 -0
- package/dist/components/craft-loading-state.cjs.map +1 -0
- package/dist/components/craft-loading-state.d.cts +13 -0
- package/dist/components/craft-loading-state.d.ts +13 -0
- package/dist/components/craft-loading-state.js +40 -0
- package/dist/components/craft-loading-state.js.map +1 -0
- package/dist/components/craft-modal.cjs +174 -0
- package/dist/components/craft-modal.cjs.map +1 -0
- package/dist/components/craft-modal.d.cts +19 -0
- package/dist/components/craft-modal.d.ts +19 -0
- package/dist/components/craft-modal.js +140 -0
- package/dist/components/craft-modal.js.map +1 -0
- package/dist/components/craft-number-input.cjs +63 -0
- package/dist/components/craft-number-input.cjs.map +1 -0
- package/dist/components/craft-number-input.d.cts +12 -0
- package/dist/components/craft-number-input.d.ts +12 -0
- package/dist/components/craft-number-input.js +29 -0
- package/dist/components/craft-number-input.js.map +1 -0
- package/dist/components/craft-pagination.cjs +130 -0
- package/dist/components/craft-pagination.cjs.map +1 -0
- package/dist/components/craft-pagination.d.cts +19 -0
- package/dist/components/craft-pagination.d.ts +19 -0
- package/dist/components/craft-pagination.js +106 -0
- package/dist/components/craft-pagination.js.map +1 -0
- package/dist/components/craft-popover.cjs +123 -0
- package/dist/components/craft-popover.cjs.map +1 -0
- package/dist/components/craft-popover.d.cts +20 -0
- package/dist/components/craft-popover.d.ts +20 -0
- package/dist/components/craft-popover.js +89 -0
- package/dist/components/craft-popover.js.map +1 -0
- package/dist/components/craft-select.cjs +84 -0
- package/dist/components/craft-select.cjs.map +1 -0
- package/dist/components/craft-select.d.cts +12 -0
- package/dist/components/craft-select.d.ts +12 -0
- package/dist/components/craft-select.js +50 -0
- package/dist/components/craft-select.js.map +1 -0
- package/dist/components/craft-skeleton.cjs +45 -0
- package/dist/components/craft-skeleton.cjs.map +1 -0
- package/dist/components/craft-skeleton.d.cts +10 -0
- package/dist/components/craft-skeleton.d.ts +10 -0
- package/dist/components/craft-skeleton.js +21 -0
- package/dist/components/craft-skeleton.js.map +1 -0
- package/dist/components/craft-stat-card.cjs +67 -0
- package/dist/components/craft-stat-card.cjs.map +1 -0
- package/dist/components/craft-stat-card.d.cts +17 -0
- package/dist/components/craft-stat-card.d.ts +17 -0
- package/dist/components/craft-stat-card.js +43 -0
- package/dist/components/craft-stat-card.js.map +1 -0
- package/dist/components/craft-submit-button.cjs +71 -0
- package/dist/components/craft-submit-button.cjs.map +1 -0
- package/dist/components/craft-submit-button.d.cts +13 -0
- package/dist/components/craft-submit-button.d.ts +13 -0
- package/dist/components/craft-submit-button.js +47 -0
- package/dist/components/craft-submit-button.js.map +1 -0
- package/dist/components/craft-switch.cjs +82 -0
- package/dist/components/craft-switch.cjs.map +1 -0
- package/dist/components/craft-switch.d.cts +14 -0
- package/dist/components/craft-switch.d.ts +14 -0
- package/dist/components/craft-switch.js +48 -0
- package/dist/components/craft-switch.js.map +1 -0
- package/dist/components/craft-table-toolbar.cjs +79 -0
- package/dist/components/craft-table-toolbar.cjs.map +1 -0
- package/dist/components/craft-table-toolbar.d.cts +19 -0
- package/dist/components/craft-table-toolbar.d.ts +19 -0
- package/dist/components/craft-table-toolbar.js +55 -0
- package/dist/components/craft-table-toolbar.js.map +1 -0
- package/dist/components/craft-tabs.cjs +105 -0
- package/dist/components/craft-tabs.cjs.map +1 -0
- package/dist/components/craft-tabs.d.cts +19 -0
- package/dist/components/craft-tabs.d.ts +19 -0
- package/dist/components/craft-tabs.js +71 -0
- package/dist/components/craft-tabs.js.map +1 -0
- package/dist/components/craft-textarea.cjs +69 -0
- package/dist/components/craft-textarea.cjs.map +1 -0
- package/dist/components/craft-textarea.d.cts +12 -0
- package/dist/components/craft-textarea.d.ts +12 -0
- package/dist/components/craft-textarea.js +35 -0
- package/dist/components/craft-textarea.js.map +1 -0
- package/dist/components/craft-toast.cjs +98 -0
- package/dist/components/craft-toast.cjs.map +1 -0
- package/dist/components/craft-toast.d.cts +24 -0
- package/dist/components/craft-toast.d.ts +24 -0
- package/dist/components/craft-toast.js +63 -0
- package/dist/components/craft-toast.js.map +1 -0
- package/dist/components/craft-tooltip.cjs +75 -0
- package/dist/components/craft-tooltip.cjs.map +1 -0
- package/dist/components/craft-tooltip.d.cts +13 -0
- package/dist/components/craft-tooltip.d.ts +13 -0
- package/dist/components/craft-tooltip.js +41 -0
- package/dist/components/craft-tooltip.js.map +1 -0
- package/dist/components/glass-card.cjs +64 -0
- package/dist/components/glass-card.cjs.map +1 -0
- package/dist/components/glass-card.d.cts +12 -0
- package/dist/components/glass-card.d.ts +12 -0
- package/dist/components/glass-card.js +40 -0
- package/dist/components/glass-card.js.map +1 -0
- package/dist/components/layout/app-shell.cjs +49 -0
- package/dist/components/layout/app-shell.cjs.map +1 -0
- package/dist/components/layout/app-shell.d.cts +10 -0
- package/dist/components/layout/app-shell.d.ts +10 -0
- package/dist/components/layout/app-shell.js +25 -0
- package/dist/components/layout/app-shell.js.map +1 -0
- package/dist/components/layout/app-template.cjs +104 -0
- package/dist/components/layout/app-template.cjs.map +1 -0
- package/dist/components/layout/app-template.d.cts +19 -0
- package/dist/components/layout/app-template.d.ts +19 -0
- package/dist/components/layout/app-template.js +70 -0
- package/dist/components/layout/app-template.js.map +1 -0
- package/dist/components/layout/auth-layout.cjs +65 -0
- package/dist/components/layout/auth-layout.cjs.map +1 -0
- package/dist/components/layout/auth-layout.d.cts +12 -0
- package/dist/components/layout/auth-layout.d.ts +12 -0
- package/dist/components/layout/auth-layout.js +41 -0
- package/dist/components/layout/auth-layout.js.map +1 -0
- package/dist/components/layout/breadcrumbs.cjs +39 -0
- package/dist/components/layout/breadcrumbs.cjs.map +1 -0
- package/dist/components/layout/breadcrumbs.d.cts +13 -0
- package/dist/components/layout/breadcrumbs.d.ts +13 -0
- package/dist/components/layout/breadcrumbs.js +15 -0
- package/dist/components/layout/breadcrumbs.js.map +1 -0
- package/dist/components/layout/container.cjs +45 -0
- package/dist/components/layout/container.cjs.map +1 -0
- package/dist/components/layout/container.d.cts +9 -0
- package/dist/components/layout/container.d.ts +9 -0
- package/dist/components/layout/container.js +21 -0
- package/dist/components/layout/container.js.map +1 -0
- package/dist/components/layout/grid.cjs +47 -0
- package/dist/components/layout/grid.cjs.map +1 -0
- package/dist/components/layout/grid.d.cts +10 -0
- package/dist/components/layout/grid.d.ts +10 -0
- package/dist/components/layout/grid.js +23 -0
- package/dist/components/layout/grid.js.map +1 -0
- package/dist/components/layout/layout-config.cjs +78 -0
- package/dist/components/layout/layout-config.cjs.map +1 -0
- package/dist/components/layout/layout-config.d.cts +92 -0
- package/dist/components/layout/layout-config.d.ts +92 -0
- package/dist/components/layout/layout-config.js +54 -0
- package/dist/components/layout/layout-config.js.map +1 -0
- package/dist/components/layout/page-header.cjs +52 -0
- package/dist/components/layout/page-header.cjs.map +1 -0
- package/dist/components/layout/page-header.d.cts +11 -0
- package/dist/components/layout/page-header.d.ts +11 -0
- package/dist/components/layout/page-header.js +28 -0
- package/dist/components/layout/page-header.js.map +1 -0
- package/dist/components/layout/sidebar.cjs +64 -0
- package/dist/components/layout/sidebar.cjs.map +1 -0
- package/dist/components/layout/sidebar.d.cts +17 -0
- package/dist/components/layout/sidebar.d.ts +17 -0
- package/dist/components/layout/sidebar.js +40 -0
- package/dist/components/layout/sidebar.js.map +1 -0
- package/dist/components/layout/top-nav.cjs +49 -0
- package/dist/components/layout/top-nav.cjs.map +1 -0
- package/dist/components/layout/top-nav.d.cts +11 -0
- package/dist/components/layout/top-nav.d.ts +11 -0
- package/dist/components/layout/top-nav.js +25 -0
- package/dist/components/layout/top-nav.js.map +1 -0
- package/dist/components/theme-switcher.cjs +72 -0
- package/dist/components/theme-switcher.cjs.map +1 -0
- package/dist/components/theme-switcher.d.cts +9 -0
- package/dist/components/theme-switcher.d.ts +9 -0
- package/dist/components/theme-switcher.js +48 -0
- package/dist/components/theme-switcher.js.map +1 -0
- package/dist/index.cjs +103 -3448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -746
- package/dist/index.d.ts +54 -746
- package/dist/index.js +50 -3388
- package/dist/index.js.map +1 -1
- package/dist/theme/theme-context.cjs +115 -0
- package/dist/theme/theme-context.cjs.map +1 -0
- package/dist/theme/theme-context.d.cts +23 -0
- package/dist/theme/theme-context.d.ts +23 -0
- package/dist/theme/theme-context.js +79 -0
- package/dist/theme/theme-context.js.map +1 -0
- package/dist/utils/cn.cjs +31 -0
- package/dist/utils/cn.cjs.map +1 -0
- package/dist/utils/cn.d.cts +3 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +7 -0
- package/dist/utils/cn.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ThemeName } from '../theme/theme-context.js';
|
|
4
|
+
|
|
5
|
+
type CraftLoadingSize = "sm" | "md" | "lg";
|
|
6
|
+
type CraftLoadingStateProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
7
|
+
label?: React.ReactNode;
|
|
8
|
+
size?: CraftLoadingSize;
|
|
9
|
+
tone?: ThemeName;
|
|
10
|
+
};
|
|
11
|
+
declare function CraftLoadingState({ label, size, tone, className, ...props }: CraftLoadingStateProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { CraftLoadingState, type CraftLoadingStateProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
const sizeClasses = {
|
|
4
|
+
sm: "h-4 w-4 border-2",
|
|
5
|
+
md: "h-6 w-6 border-2",
|
|
6
|
+
lg: "h-8 w-8 border-[3px]"
|
|
7
|
+
};
|
|
8
|
+
function CraftLoadingState({
|
|
9
|
+
label = "Loading...",
|
|
10
|
+
size = "md",
|
|
11
|
+
tone,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
className: cn("flex items-center gap-3 text-[rgb(var(--nc-fg))]", className),
|
|
19
|
+
"data-nc-theme": tone,
|
|
20
|
+
...props,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
"span",
|
|
24
|
+
{
|
|
25
|
+
className: cn(
|
|
26
|
+
"inline-block animate-spin rounded-full border-[rgb(var(--nc-accent-1)/0.25)] border-t-[rgb(var(--nc-accent-1))]",
|
|
27
|
+
sizeClasses[size]
|
|
28
|
+
),
|
|
29
|
+
"aria-hidden": "true"
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
label && /* @__PURE__ */ jsx("span", { className: "text-sm text-[rgb(var(--nc-fg-muted))]", children: label })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
CraftLoadingState
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=craft-loading-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-loading-state.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\ntype CraftLoadingSize = \"sm\" | \"md\" | \"lg\";\n\nexport type CraftLoadingStateProps = React.HTMLAttributes<HTMLDivElement> & {\n label?: React.ReactNode;\n size?: CraftLoadingSize;\n tone?: ThemeName;\n};\n\nconst sizeClasses: Record<CraftLoadingSize, string> = {\n sm: \"h-4 w-4 border-2\",\n md: \"h-6 w-6 border-2\",\n lg: \"h-8 w-8 border-[3px]\",\n};\n\nexport function CraftLoadingState({\n label = \"Loading...\",\n size = \"md\",\n tone,\n className,\n ...props\n}: CraftLoadingStateProps) {\n return (\n <div\n className={cn(\"flex items-center gap-3 text-[rgb(var(--nc-fg))]\", className)}\n data-nc-theme={tone}\n {...props}\n >\n <span\n className={cn(\n \"inline-block animate-spin rounded-full border-[rgb(var(--nc-accent-1)/0.25)] border-t-[rgb(var(--nc-accent-1))]\",\n sizeClasses[size]\n )}\n aria-hidden=\"true\"\n />\n {label && <span className=\"text-sm text-[rgb(var(--nc-fg-muted))]\">{label}</span>}\n </div>\n );\n}\n"],"mappings":"AA2BI,SAKE,KALF;AAzBJ,SAAS,UAAU;AAWnB,MAAM,cAAgD;AAAA,EACpD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEO,SAAS,kBAAkB;AAAA,EAChC,QAAQ;AAAA,EACR,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA2B;AACzB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,oDAAoD,SAAS;AAAA,MAC3E,iBAAe;AAAA,MACd,GAAG;AAAA,MAEJ;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA,YAAY,IAAI;AAAA,YAClB;AAAA,YACA,eAAY;AAAA;AAAA,QACd;AAAA,QACC,SAAS,oBAAC,UAAK,WAAU,0CAA0C,iBAAM;AAAA;AAAA;AAAA,EAC5E;AAEJ;","names":[]}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var craft_modal_exports = {};
|
|
31
|
+
__export(craft_modal_exports, {
|
|
32
|
+
CraftModal: () => CraftModal
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(craft_modal_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var React = __toESM(require("react"), 1);
|
|
37
|
+
var import_react_dom = require("react-dom");
|
|
38
|
+
var import_cn = require("../utils/cn");
|
|
39
|
+
const FOCUSABLE_SELECTORS = [
|
|
40
|
+
"a[href]",
|
|
41
|
+
"button:not([disabled])",
|
|
42
|
+
"textarea:not([disabled])",
|
|
43
|
+
"input:not([disabled])",
|
|
44
|
+
"select:not([disabled])",
|
|
45
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
46
|
+
].join(",");
|
|
47
|
+
function useFocusTrap(active) {
|
|
48
|
+
const ref = React.useRef(null);
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (!active || !ref.current) return;
|
|
51
|
+
const root = ref.current;
|
|
52
|
+
const getFocusable = () => Array.from(root.querySelectorAll(FOCUSABLE_SELECTORS));
|
|
53
|
+
const focusables = getFocusable();
|
|
54
|
+
if (focusables.length) {
|
|
55
|
+
focusables[0].focus();
|
|
56
|
+
} else {
|
|
57
|
+
root.focus();
|
|
58
|
+
}
|
|
59
|
+
const handleKeyDown = (event) => {
|
|
60
|
+
if (event.key !== "Tab") return;
|
|
61
|
+
const items = getFocusable();
|
|
62
|
+
if (!items.length) return;
|
|
63
|
+
const first = items[0];
|
|
64
|
+
const last = items[items.length - 1];
|
|
65
|
+
const activeEl = document.activeElement;
|
|
66
|
+
if (event.shiftKey && activeEl === first) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
last.focus();
|
|
69
|
+
} else if (!event.shiftKey && activeEl === last) {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
first.focus();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
root.addEventListener("keydown", handleKeyDown);
|
|
75
|
+
return () => root.removeEventListener("keydown", handleKeyDown);
|
|
76
|
+
}, [active]);
|
|
77
|
+
return ref;
|
|
78
|
+
}
|
|
79
|
+
function CraftModal({
|
|
80
|
+
open,
|
|
81
|
+
defaultOpen = false,
|
|
82
|
+
onOpenChange,
|
|
83
|
+
tone,
|
|
84
|
+
title,
|
|
85
|
+
description,
|
|
86
|
+
children,
|
|
87
|
+
trigger,
|
|
88
|
+
footer,
|
|
89
|
+
className
|
|
90
|
+
}) {
|
|
91
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
92
|
+
const isControlled = typeof open === "boolean";
|
|
93
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
94
|
+
const setOpen = React.useCallback(
|
|
95
|
+
(next) => {
|
|
96
|
+
if (!isControlled) {
|
|
97
|
+
setUncontrolledOpen(next);
|
|
98
|
+
}
|
|
99
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
100
|
+
},
|
|
101
|
+
[isControlled, onOpenChange]
|
|
102
|
+
);
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
if (!isOpen) return;
|
|
105
|
+
const handleKey = (event) => {
|
|
106
|
+
if (event.key === "Escape") setOpen(false);
|
|
107
|
+
};
|
|
108
|
+
document.addEventListener("keydown", handleKey);
|
|
109
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
110
|
+
}, [isOpen, setOpen]);
|
|
111
|
+
const ref = useFocusTrap(isOpen);
|
|
112
|
+
const content = isOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "fixed inset-0 z-50 flex items-center justify-center px-4 py-8", children: [
|
|
113
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
className: "absolute inset-0 backdrop-blur-sm",
|
|
117
|
+
onClick: () => setOpen(false)
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
ref,
|
|
124
|
+
tabIndex: -1,
|
|
125
|
+
className: (0, import_cn.cn)(
|
|
126
|
+
"relative z-10 w-full max-w-7xl rounded-3xl border border-[rgb(var(--nc-border)/0.45)] p-6 text-[rgb(var(--nc-fg))] shadow-[0_20px_60px_rgba(0,0,0,0.45)] backdrop-blur-2xl",
|
|
127
|
+
"max-h-[calc(100vh-1rem)] overflow-y-auto",
|
|
128
|
+
className
|
|
129
|
+
),
|
|
130
|
+
"data-nc-theme": tone,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
|
|
134
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-2xl font-semibold", children: title }),
|
|
135
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
138
|
+
"button",
|
|
139
|
+
{
|
|
140
|
+
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))]",
|
|
141
|
+
onClick: () => setOpen(false),
|
|
142
|
+
"aria-label": "Close",
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.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" }) })
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-5 space-y-4", children }),
|
|
148
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-6", children: footer })
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] }) : null;
|
|
153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
154
|
+
trigger && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
"span",
|
|
156
|
+
{
|
|
157
|
+
onClick: () => setOpen(true),
|
|
158
|
+
onKeyDown: (event) => {
|
|
159
|
+
if (event.key === "Enter" || event.key === " ") setOpen(true);
|
|
160
|
+
},
|
|
161
|
+
role: "button",
|
|
162
|
+
tabIndex: 0,
|
|
163
|
+
className: "inline-flex",
|
|
164
|
+
children: trigger
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
typeof document !== "undefined" && content ? (0, import_react_dom.createPortal)(content, document.body) : content
|
|
168
|
+
] });
|
|
169
|
+
}
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
CraftModal
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=craft-modal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nconst FOCUSABLE_SELECTORS = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"textarea:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"[tabindex]:not([tabindex='-1'])\",\n].join(\",\");\n\nfunction useFocusTrap(active: boolean) {\n const ref = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n if (!active || !ref.current) return;\n const root = ref.current;\n const getFocusable = () =>\n Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS));\n\n const focusables = getFocusable();\n if (focusables.length) {\n focusables[0].focus();\n } else {\n root.focus();\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") return;\n const items = getFocusable();\n if (!items.length) return;\n const first = items[0];\n const last = items[items.length - 1];\n const activeEl = document.activeElement as HTMLElement | null;\n\n if (event.shiftKey && activeEl === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && activeEl === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n root.addEventListener(\"keydown\", handleKeyDown);\n return () => root.removeEventListener(\"keydown\", handleKeyDown);\n }, [active]);\n\n return ref;\n}\n\nexport type CraftModalProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n tone?: ThemeName;\n title?: React.ReactNode;\n description?: React.ReactNode;\n children?: React.ReactNode;\n trigger?: React.ReactNode;\n footer?: React.ReactNode;\n className?: string;\n};\n\nexport function CraftModal({\n open,\n defaultOpen = false,\n onOpenChange,\n tone,\n title,\n description,\n children,\n trigger,\n footer,\n className,\n}: CraftModalProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);\n const isControlled = typeof open === \"boolean\";\n const isOpen = isControlled ? open : uncontrolledOpen;\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange]\n );\n\n React.useEffect(() => {\n if (!isOpen) return;\n const handleKey = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"keydown\", handleKey);\n return () => document.removeEventListener(\"keydown\", handleKey);\n }, [isOpen, setOpen]);\n\n const ref = useFocusTrap(isOpen);\n\n const content = isOpen ? (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center px-4 py-8\">\n <div\n className=\"absolute inset-0 backdrop-blur-sm\"\n onClick={() => setOpen(false)}\n />\n <div\n ref={ref}\n tabIndex={-1}\n className={cn(\n \"relative z-10 w-full max-w-7xl rounded-3xl border border-[rgb(var(--nc-border)/0.45)] p-6 text-[rgb(var(--nc-fg))] shadow-[0_20px_60px_rgba(0,0,0,0.45)] backdrop-blur-2xl\",\n \"max-h-[calc(100vh-1rem)] overflow-y-auto\",\n className\n )}\n data-nc-theme={tone}\n >\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"space-y-1\">\n {title && <h3 className=\"text-2xl font-semibold\">{title}</h3>}\n {description && <p className=\"text-[rgb(var(--nc-fg-muted))]\">{description}</p>}\n </div>\n <button\n 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))]\"\n onClick={() => setOpen(false)}\n aria-label=\"Close\"\n >\n <svg viewBox=\"0 0 20 20\" className=\"h-4 w-4\" fill=\"currentColor\">\n <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\" />\n </svg>\n </button>\n </div>\n <div className=\"mt-5 space-y-4\">{children}</div>\n {footer && <div className=\"mt-6\">{footer}</div>}\n </div>\n </div>\n ) : null;\n\n return (\n <>\n {trigger && (\n <span\n onClick={() => setOpen(true)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" || event.key === \" \") setOpen(true);\n }}\n role=\"button\"\n tabIndex={0}\n className=\"inline-flex\"\n >\n {trigger}\n </span>\n )}\n {typeof document !== \"undefined\" && content\n ? createPortal(content, document.body)\n : content}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6GM;AA3GN,YAAuB;AACvB,uBAA6B;AAE7B,gBAAmB;AAGnB,MAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAEV,SAAS,aAAa,QAAiB;AACrC,QAAM,MAAM,MAAM,OAA8B,IAAI;AAEpD,QAAM,UAAU,MAAM;AACpB,Q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;AACpB,cAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IAAK,SAAQ,IAAI;AAAA,QAC9D;AAAA,QACA,MAAK;AAAA,QACL,UAAU;AAAA,QACV,WAAU;AAAA,QAET;AAAA;AAAA,IACH;AAAA,IAED,OAAO,aAAa,eAAe,cAChC,+BAAa,SAAS,SAAS,IAAI,IACnC;AAAA,KACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ThemeName } from '../theme/theme-context.cjs';
|
|
4
|
+
|
|
5
|
+
type CraftModalProps = {
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
tone?: ThemeName;
|
|
10
|
+
title?: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
trigger?: React.ReactNode;
|
|
14
|
+
footer?: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function CraftModal({ open, defaultOpen, onOpenChange, tone, title, description, children, trigger, footer, className, }: CraftModalProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { CraftModal, type CraftModalProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ThemeName } from '../theme/theme-context.js';
|
|
4
|
+
|
|
5
|
+
type CraftModalProps = {
|
|
6
|
+
open?: boolean;
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
tone?: ThemeName;
|
|
10
|
+
title?: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
trigger?: React.ReactNode;
|
|
14
|
+
footer?: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
declare function CraftModal({ open, defaultOpen, onOpenChange, tone, title, description, children, trigger, footer, className, }: CraftModalProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { CraftModal, type CraftModalProps };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
const FOCUSABLE_SELECTORS = [
|
|
7
|
+
"a[href]",
|
|
8
|
+
"button:not([disabled])",
|
|
9
|
+
"textarea:not([disabled])",
|
|
10
|
+
"input:not([disabled])",
|
|
11
|
+
"select:not([disabled])",
|
|
12
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
13
|
+
].join(",");
|
|
14
|
+
function useFocusTrap(active) {
|
|
15
|
+
const ref = React.useRef(null);
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (!active || !ref.current) return;
|
|
18
|
+
const root = ref.current;
|
|
19
|
+
const getFocusable = () => Array.from(root.querySelectorAll(FOCUSABLE_SELECTORS));
|
|
20
|
+
const focusables = getFocusable();
|
|
21
|
+
if (focusables.length) {
|
|
22
|
+
focusables[0].focus();
|
|
23
|
+
} else {
|
|
24
|
+
root.focus();
|
|
25
|
+
}
|
|
26
|
+
const handleKeyDown = (event) => {
|
|
27
|
+
if (event.key !== "Tab") return;
|
|
28
|
+
const items = getFocusable();
|
|
29
|
+
if (!items.length) return;
|
|
30
|
+
const first = items[0];
|
|
31
|
+
const last = items[items.length - 1];
|
|
32
|
+
const activeEl = document.activeElement;
|
|
33
|
+
if (event.shiftKey && activeEl === first) {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
last.focus();
|
|
36
|
+
} else if (!event.shiftKey && activeEl === last) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
first.focus();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
root.addEventListener("keydown", handleKeyDown);
|
|
42
|
+
return () => root.removeEventListener("keydown", handleKeyDown);
|
|
43
|
+
}, [active]);
|
|
44
|
+
return ref;
|
|
45
|
+
}
|
|
46
|
+
function CraftModal({
|
|
47
|
+
open,
|
|
48
|
+
defaultOpen = false,
|
|
49
|
+
onOpenChange,
|
|
50
|
+
tone,
|
|
51
|
+
title,
|
|
52
|
+
description,
|
|
53
|
+
children,
|
|
54
|
+
trigger,
|
|
55
|
+
footer,
|
|
56
|
+
className
|
|
57
|
+
}) {
|
|
58
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
|
|
59
|
+
const isControlled = typeof open === "boolean";
|
|
60
|
+
const isOpen = isControlled ? open : uncontrolledOpen;
|
|
61
|
+
const setOpen = React.useCallback(
|
|
62
|
+
(next) => {
|
|
63
|
+
if (!isControlled) {
|
|
64
|
+
setUncontrolledOpen(next);
|
|
65
|
+
}
|
|
66
|
+
onOpenChange == null ? void 0 : onOpenChange(next);
|
|
67
|
+
},
|
|
68
|
+
[isControlled, onOpenChange]
|
|
69
|
+
);
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
if (!isOpen) return;
|
|
72
|
+
const handleKey = (event) => {
|
|
73
|
+
if (event.key === "Escape") setOpen(false);
|
|
74
|
+
};
|
|
75
|
+
document.addEventListener("keydown", handleKey);
|
|
76
|
+
return () => document.removeEventListener("keydown", handleKey);
|
|
77
|
+
}, [isOpen, setOpen]);
|
|
78
|
+
const ref = useFocusTrap(isOpen);
|
|
79
|
+
const content = isOpen ? /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center px-4 py-8", children: [
|
|
80
|
+
/* @__PURE__ */ jsx(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: "absolute inset-0 backdrop-blur-sm",
|
|
84
|
+
onClick: () => setOpen(false)
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsxs(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
ref,
|
|
91
|
+
tabIndex: -1,
|
|
92
|
+
className: cn(
|
|
93
|
+
"relative z-10 w-full max-w-7xl rounded-3xl border border-[rgb(var(--nc-border)/0.45)] p-6 text-[rgb(var(--nc-fg))] shadow-[0_20px_60px_rgba(0,0,0,0.45)] backdrop-blur-2xl",
|
|
94
|
+
"max-h-[calc(100vh-1rem)] overflow-y-auto",
|
|
95
|
+
className
|
|
96
|
+
),
|
|
97
|
+
"data-nc-theme": tone,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
101
|
+
title && /* @__PURE__ */ jsx("h3", { className: "text-2xl font-semibold", children: title }),
|
|
102
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-[rgb(var(--nc-fg-muted))]", children: description })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
"button",
|
|
106
|
+
{
|
|
107
|
+
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))]",
|
|
108
|
+
onClick: () => setOpen(false),
|
|
109
|
+
"aria-label": "Close",
|
|
110
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 20 20", className: "h-4 w-4", fill: "currentColor", children: /* @__PURE__ */ 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" }) })
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] }),
|
|
114
|
+
/* @__PURE__ */ jsx("div", { className: "mt-5 space-y-4", children }),
|
|
115
|
+
footer && /* @__PURE__ */ jsx("div", { className: "mt-6", children: footer })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] }) : null;
|
|
120
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
121
|
+
trigger && /* @__PURE__ */ jsx(
|
|
122
|
+
"span",
|
|
123
|
+
{
|
|
124
|
+
onClick: () => setOpen(true),
|
|
125
|
+
onKeyDown: (event) => {
|
|
126
|
+
if (event.key === "Enter" || event.key === " ") setOpen(true);
|
|
127
|
+
},
|
|
128
|
+
role: "button",
|
|
129
|
+
tabIndex: 0,
|
|
130
|
+
className: "inline-flex",
|
|
131
|
+
children: trigger
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
typeof document !== "undefined" && content ? createPortal(content, document.body) : content
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
CraftModal
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=craft-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nconst FOCUSABLE_SELECTORS = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"textarea:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"[tabindex]:not([tabindex='-1'])\",\n].join(\",\");\n\nfunction useFocusTrap(active: boolean) {\n const ref = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n if (!active || !ref.current) return;\n const root = ref.current;\n const getFocusable = () =>\n Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS));\n\n const focusables = getFocusable();\n if (focusables.length) {\n focusables[0].focus();\n } else {\n root.focus();\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Tab\") return;\n const items = getFocusable();\n if (!items.length) return;\n const first = items[0];\n const last = items[items.length - 1];\n const activeEl = document.activeElement as HTMLElement | null;\n\n if (event.shiftKey && activeEl === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && activeEl === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n root.addEventListener(\"keydown\", handleKeyDown);\n return () => root.removeEventListener(\"keydown\", handleKeyDown);\n }, [active]);\n\n return ref;\n}\n\nexport type CraftModalProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n tone?: ThemeName;\n title?: React.ReactNode;\n description?: React.ReactNode;\n children?: React.ReactNode;\n trigger?: React.ReactNode;\n footer?: React.ReactNode;\n className?: string;\n};\n\nexport function CraftModal({\n open,\n defaultOpen = false,\n onOpenChange,\n tone,\n title,\n description,\n children,\n trigger,\n footer,\n className,\n}: CraftModalProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);\n const isControlled = typeof open === \"boolean\";\n const isOpen = isControlled ? open : uncontrolledOpen;\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (!isControlled) {\n setUncontrolledOpen(next);\n }\n onOpenChange?.(next);\n },\n [isControlled, onOpenChange]\n );\n\n React.useEffect(() => {\n if (!isOpen) return;\n const handleKey = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"keydown\", handleKey);\n return () => document.removeEventListener(\"keydown\", handleKey);\n }, [isOpen, setOpen]);\n\n const ref = useFocusTrap(isOpen);\n\n const content = isOpen ? (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center px-4 py-8\">\n <div\n className=\"absolute inset-0 backdrop-blur-sm\"\n onClick={() => setOpen(false)}\n />\n <div\n ref={ref}\n tabIndex={-1}\n className={cn(\n \"relative z-10 w-full max-w-7xl rounded-3xl border border-[rgb(var(--nc-border)/0.45)] p-6 text-[rgb(var(--nc-fg))] shadow-[0_20px_60px_rgba(0,0,0,0.45)] backdrop-blur-2xl\",\n \"max-h-[calc(100vh-1rem)] overflow-y-auto\",\n className\n )}\n data-nc-theme={tone}\n >\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"space-y-1\">\n {title && <h3 className=\"text-2xl font-semibold\">{title}</h3>}\n {description && <p className=\"text-[rgb(var(--nc-fg-muted))]\">{description}</p>}\n </div>\n <button\n 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))]\"\n onClick={() => setOpen(false)}\n aria-label=\"Close\"\n >\n <svg viewBox=\"0 0 20 20\" className=\"h-4 w-4\" fill=\"currentColor\">\n <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\" />\n </svg>\n </button>\n </div>\n <div className=\"mt-5 space-y-4\">{children}</div>\n {footer && <div className=\"mt-6\">{footer}</div>}\n </div>\n </div>\n ) : null;\n\n return (\n <>\n {trigger && (\n <span\n onClick={() => setOpen(true)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" || event.key === \" \") setOpen(true);\n }}\n role=\"button\"\n tabIndex={0}\n className=\"inline-flex\"\n >\n {trigger}\n </span>\n )}\n {typeof document !== \"undefined\" && content\n ? createPortal(content, document.body)\n : content}\n </>\n );\n}\n"],"mappings":";AA6GM,SAoCF,UApCE,KAeI,YAfJ;AA3GN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAE7B,SAAS,UAAU;AAGnB,MAAM,sBAAsB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,EAAE,KAAK,GAAG;AAEV,S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ACC;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,MAAM,QAAQ,IAAI;AAAA,QAC3B,WAAW,CAAC,UAAU;AACpB,cAAI,MAAM,QAAQ,WAAW,MAAM,QAAQ,IAAK,SAAQ,IAAI;AAAA,QAC9D;AAAA,QACA,MAAK;AAAA,QACL,UAAU;AAAA,QACV,WAAU;AAAA,QAET;AAAA;AAAA,IACH;AAAA,IAED,OAAO,aAAa,eAAe,UAChC,aAAa,SAAS,SAAS,IAAI,IACnC;AAAA,KACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var craft_number_input_exports = {};
|
|
30
|
+
__export(craft_number_input_exports, {
|
|
31
|
+
CraftNumberInput: () => CraftNumberInput
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(craft_number_input_exports);
|
|
34
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
var React = __toESM(require("react"), 1);
|
|
36
|
+
var import_cn = require("../utils/cn");
|
|
37
|
+
const CraftNumberInput = React.forwardRef(({ className, tone, ...props }, ref) => {
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative w-full", "data-nc-theme": tone, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
"input",
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
type: "number",
|
|
43
|
+
className: (0, import_cn.cn)(
|
|
44
|
+
"w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl",
|
|
45
|
+
"shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)]",
|
|
46
|
+
"focus:outline-none focus:ring-4",
|
|
47
|
+
"transition-all duration-300",
|
|
48
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
49
|
+
"border-[rgb(var(--nc-border)/0.35)]",
|
|
50
|
+
"focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)]",
|
|
51
|
+
"px-5 py-3 text-base",
|
|
52
|
+
className
|
|
53
|
+
),
|
|
54
|
+
...props
|
|
55
|
+
}
|
|
56
|
+
) });
|
|
57
|
+
});
|
|
58
|
+
CraftNumberInput.displayName = "CraftNumberInput";
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
CraftNumberInput
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=craft-number-input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-number-input.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftNumberInputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n tone?: ThemeName;\n};\n\nexport const CraftNumberInput = React.forwardRef<\n HTMLInputElement,\n CraftNumberInputProps\n>(({ className, tone, ...props }, ref) => {\n return (\n <div className=\"relative w-full\" data-nc-theme={tone}>\n <input\n ref={ref}\n type=\"number\"\n className={cn(\n \"w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl\",\n \"shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)]\",\n \"focus:outline-none focus:ring-4\",\n \"transition-all duration-300\",\n \"disabled:opacity-50 disabled:cursor-not-allowed\",\n \"border-[rgb(var(--nc-border)/0.35)]\",\n \"focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)]\",\n \"px-5 py-3 text-base\",\n className\n )}\n {...props}\n />\n </div>\n );\n});\n\nCraftNumberInput.displayName = \"CraftNumberInput\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeM;AAfN,YAAuB;AAEvB,gBAAmB;AAOZ,MAAM,mBAAmB,MAAM,WAGpC,CAAC,EAAE,WAAW,MAAM,GAAG,MAAM,GAAG,QAAQ;AACxC,SACE,4CAAC,SAAI,WAAU,mBAAkB,iBAAe,MAC9C;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,eAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN,GACF;AAEJ,CAAC;AAED,iBAAiB,cAAc;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ThemeName } from '../theme/theme-context.cjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type CraftNumberInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
6
|
+
tone?: ThemeName;
|
|
7
|
+
};
|
|
8
|
+
declare const CraftNumberInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
9
|
+
tone?: ThemeName;
|
|
10
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
11
|
+
|
|
12
|
+
export { CraftNumberInput, type CraftNumberInputProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ThemeName } from '../theme/theme-context.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
type CraftNumberInputProps = React.InputHTMLAttributes<HTMLInputElement> & {
|
|
6
|
+
tone?: ThemeName;
|
|
7
|
+
};
|
|
8
|
+
declare const CraftNumberInput: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
|
|
9
|
+
tone?: ThemeName;
|
|
10
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
11
|
+
|
|
12
|
+
export { CraftNumberInput, type CraftNumberInputProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
const CraftNumberInput = React.forwardRef(({ className, tone, ...props }, ref) => {
|
|
5
|
+
return /* @__PURE__ */ jsx("div", { className: "relative w-full", "data-nc-theme": tone, children: /* @__PURE__ */ jsx(
|
|
6
|
+
"input",
|
|
7
|
+
{
|
|
8
|
+
ref,
|
|
9
|
+
type: "number",
|
|
10
|
+
className: cn(
|
|
11
|
+
"w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl",
|
|
12
|
+
"shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)]",
|
|
13
|
+
"focus:outline-none focus:ring-4",
|
|
14
|
+
"transition-all duration-300",
|
|
15
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
16
|
+
"border-[rgb(var(--nc-border)/0.35)]",
|
|
17
|
+
"focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)]",
|
|
18
|
+
"px-5 py-3 text-base",
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
...props
|
|
22
|
+
}
|
|
23
|
+
) });
|
|
24
|
+
});
|
|
25
|
+
CraftNumberInput.displayName = "CraftNumberInput";
|
|
26
|
+
export {
|
|
27
|
+
CraftNumberInput
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=craft-number-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/craft-number-input.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\n\nexport type CraftNumberInputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n tone?: ThemeName;\n};\n\nexport const CraftNumberInput = React.forwardRef<\n HTMLInputElement,\n CraftNumberInputProps\n>(({ className, tone, ...props }, ref) => {\n return (\n <div className=\"relative w-full\" data-nc-theme={tone}>\n <input\n ref={ref}\n type=\"number\"\n className={cn(\n \"w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl\",\n \"shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)]\",\n \"focus:outline-none focus:ring-4\",\n \"transition-all duration-300\",\n \"disabled:opacity-50 disabled:cursor-not-allowed\",\n \"border-[rgb(var(--nc-border)/0.35)]\",\n \"focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)]\",\n \"px-5 py-3 text-base\",\n className\n )}\n {...props}\n />\n </div>\n );\n});\n\nCraftNumberInput.displayName = \"CraftNumberInput\";\n"],"mappings":"AAeM;AAfN,YAAY,WAAW;AAEvB,SAAS,UAAU;AAOZ,MAAM,mBAAmB,MAAM,WAGpC,CAAC,EAAE,WAAW,MAAM,GAAG,MAAM,GAAG,QAAQ;AACxC,SACE,oBAAC,SAAI,WAAU,mBAAkB,iBAAe,MAC9C;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN,GACF;AAEJ,CAAC;AAED,iBAAiB,cAAc;","names":[]}
|