cortena-ui 1.3.0 → 1.4.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 +74 -3
- package/dist/a2ui/catalogue-doc.d.ts +44 -0
- package/dist/a2ui/catalogue-doc.js +169 -0
- package/dist/a2ui/catalogue-doc.js.map +1 -0
- package/dist/a2ui/catalogue.d.ts +44 -0
- package/dist/a2ui/catalogue.js +942 -0
- package/dist/a2ui/catalogue.js.map +1 -0
- package/dist/a2ui/index.d.ts +7 -0
- package/dist/a2ui/message.d.ts +232 -0
- package/dist/a2ui/message.js +365 -0
- package/dist/a2ui/message.js.map +1 -0
- package/dist/a2ui/renderer.d.ts +46 -0
- package/dist/a2ui/renderer.js +252 -0
- package/dist/a2ui/renderer.js.map +1 -0
- package/dist/a2ui/views.d.ts +80 -0
- package/dist/a2ui/views.js +596 -0
- package/dist/a2ui/views.js.map +1 -0
- package/dist/a2ui.d.ts +8 -0
- package/dist/a2ui.js +7 -0
- package/dist/chart.d.ts +9 -0
- package/dist/chart.js +9 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +63 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +15 -0
- package/dist/components/alert.js +64 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.d.ts +18 -0
- package/dist/components/avatar.js +40 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +47 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +71 -0
- package/dist/components/breadcrumb.js +123 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-link.d.ts +28 -0
- package/dist/components/button-link.js +24 -0
- package/dist/components/button-link.js.map +1 -0
- package/dist/components/button.d.ts +24 -0
- package/dist/components/button.js +65 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +28 -0
- package/dist/components/calendar.js +123 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +32 -0
- package/dist/components/card.js +57 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart/chart.d.ts +71 -0
- package/dist/components/chart/chart.js +167 -0
- package/dist/components/chart/chart.js.map +1 -0
- package/dist/components/chart/container.d.ts +88 -0
- package/dist/components/chart/container.js +189 -0
- package/dist/components/chart/container.js.map +1 -0
- package/dist/components/chart/data.js +128 -0
- package/dist/components/chart/data.js.map +1 -0
- package/dist/components/chart/index.d.ts +9 -0
- package/dist/components/chart/index.js +10 -0
- package/dist/components/chart/nivo-charts.js +225 -0
- package/dist/components/chart/nivo-charts.js.map +1 -0
- package/dist/components/chart/nivo-lazy.js +50 -0
- package/dist/components/chart/nivo-lazy.js.map +1 -0
- package/dist/components/chart/nivo-theme.d.ts +156 -0
- package/dist/components/chart/nivo-theme.js +161 -0
- package/dist/components/chart/nivo-theme.js.map +1 -0
- package/dist/components/chart/recharts-charts.js +276 -0
- package/dist/components/chart/recharts-charts.js.map +1 -0
- package/dist/components/chart/recharts-lazy.js +58 -0
- package/dist/components/chart/recharts-lazy.js.map +1 -0
- package/dist/components/chart/recharts-parts.d.ts +10 -0
- package/dist/components/chart/recharts-parts.js +25 -0
- package/dist/components/chart/recharts-parts.js.map +1 -0
- package/dist/components/chart/tokens.d.ts +62 -0
- package/dist/components/chart/tokens.js +192 -0
- package/dist/components/chart/tokens.js.map +1 -0
- package/dist/components/chart/types.d.ts +114 -0
- package/dist/components/chart/types.js +27 -0
- package/dist/components/chart/types.js.map +1 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js +24 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +17 -0
- package/dist/components/chip.js +47 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/combobox.d.ts +76 -0
- package/dist/components/combobox.js +201 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +50 -0
- package/dist/components/command.js +117 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/data-table/data-table.d.ts +65 -0
- package/dist/components/data-table/data-table.js +588 -0
- package/dist/components/data-table/data-table.js.map +1 -0
- package/dist/components/data-table/export.d.ts +23 -0
- package/dist/components/data-table/export.js +95 -0
- package/dist/components/data-table/export.js.map +1 -0
- package/dist/components/data-table/features.d.ts +66 -0
- package/dist/components/data-table/features.js +103 -0
- package/dist/components/data-table/features.js.map +1 -0
- package/dist/components/data-table/index.d.ts +8 -0
- package/dist/components/data-table/parts.d.ts +79 -0
- package/dist/components/data-table/parts.js +400 -0
- package/dist/components/data-table/parts.js.map +1 -0
- package/dist/components/data-table/system-columns.js +84 -0
- package/dist/components/data-table/system-columns.js.map +1 -0
- package/dist/components/data-table/types.d.ts +172 -0
- package/dist/components/data-table/use-data-table.d.ts +19 -0
- package/dist/components/data-table/use-data-table.js +171 -0
- package/dist/components/data-table/use-data-table.js.map +1 -0
- package/dist/components/data-table/use-server-source.js +200 -0
- package/dist/components/data-table/use-server-source.js.map +1 -0
- package/dist/components/date-field.d.ts +54 -0
- package/dist/components/date-field.js +235 -0
- package/dist/components/date-field.js.map +1 -0
- package/dist/components/date-picker.d.ts +42 -0
- package/dist/components/date-picker.js +125 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +36 -0
- package/dist/components/dialog.js +97 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +54 -0
- package/dist/components/dropdown-menu.js +191 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/dropzone.d.ts +48 -0
- package/dist/components/dropzone.js +185 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.d.ts +22 -0
- package/dist/components/empty-state.js +46 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/error-banner.d.ts +17 -0
- package/dist/components/error-banner.js +52 -0
- package/dist/components/error-banner.js.map +1 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.js +133 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/components/form.js +103 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +26 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/kbd.d.ts +11 -0
- package/dist/components/kbd.js +20 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +14 -0
- package/dist/components/label.js +28 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-skeleton.d.ts +22 -0
- package/dist/components/loading-skeleton.js +123 -0
- package/dist/components/loading-skeleton.js.map +1 -0
- package/dist/components/markdown.d.ts +44 -0
- package/dist/components/markdown.js +231 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page-header.d.ts +26 -0
- package/dist/components/page-header.js +53 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/popover.d.ts +29 -0
- package/dist/components/popover.js +74 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +22 -0
- package/dist/components/progress.js +49 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +20 -0
- package/dist/components/radio-group.js +29 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/scroll-area.d.ts +25 -0
- package/dist/components/scroll-area.js +39 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/section-card.d.ts +29 -0
- package/dist/components/section-card.js +55 -0
- package/dist/components/section-card.js.map +1 -0
- package/dist/components/segmented.d.ts +27 -0
- package/dist/components/segmented.js +32 -0
- package/dist/components/segmented.js.map +1 -0
- package/dist/components/select.d.ts +62 -0
- package/dist/components/select.js +97 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +19 -0
- package/dist/components/separator.js +23 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +35 -0
- package/dist/components/sheet.js +131 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.d.ts +12 -0
- package/dist/components/skeleton.js +22 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/sortable-list.d.ts +67 -0
- package/dist/components/sortable-list.js +206 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/spinner.d.ts +29 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/status-dot.d.ts +26 -0
- package/dist/components/status-dot.js +47 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/switch.d.ts +21 -0
- package/dist/components/switch.js +21 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +24 -0
- package/dist/components/tabs.js +60 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +19 -0
- package/dist/components/textarea.js +47 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +47 -0
- package/dist/components/toast.js +106 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toolbar.d.ts +19 -0
- package/dist/components/toolbar.js +45 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/components/tooltip.d.ts +28 -0
- package/dist/components/tooltip.js +59 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/core.d.ts +44 -0
- package/dist/core.js +44 -0
- package/dist/data-table.d.ts +9 -0
- package/dist/data-table.js +7 -0
- package/dist/form.d.ts +7 -0
- package/dist/form.js +7 -0
- package/dist/hooks/use-cortena-theme.d.ts +98 -0
- package/dist/hooks/use-cortena-theme.js +145 -0
- package/dist/hooks/use-cortena-theme.js.map +1 -0
- package/dist/index.d.ts +75 -2678
- package/dist/index.js +66 -8598
- package/dist/lib/cn.d.ts +10 -0
- package/dist/lib/cn.js +15 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/render.d.ts +23 -0
- package/dist/lib/render.js +20 -0
- package/dist/lib/render.js.map +1 -0
- package/dist/lib/shakeable.js +39 -0
- package/dist/lib/shakeable.js.map +1 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +3 -0
- package/dist/sortable-list.d.ts +3 -0
- package/dist/sortable-list.js +3 -0
- package/package.json +37 -14
- package/src/a2ui/catalogue.ts +140 -103
- package/src/a2ui/views.tsx +5 -2
- package/src/components/alert.tsx +1 -1
- package/src/components/badge.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/chart/chart.tsx +72 -25
- package/src/components/chart/container.tsx +24 -39
- package/src/components/chart/index.tsx +4 -2
- package/src/components/chart/nivo-charts.tsx +41 -13
- package/src/components/chart/nivo-lazy.tsx +52 -0
- package/src/components/chart/recharts-charts.tsx +98 -3
- package/src/components/chart/recharts-lazy.tsx +72 -0
- package/src/components/chart/recharts-parts.tsx +34 -0
- package/src/components/chart/tokens.ts +1 -1
- package/src/components/chart/types.ts +14 -0
- package/src/components/chip.tsx +1 -1
- package/src/components/combobox.tsx +2 -2
- package/src/components/data-table/export.ts +18 -2
- package/src/components/data-table/features.ts +77 -45
- package/src/components/data-table/parts.tsx +15 -0
- package/src/components/data-table/use-data-table.ts +7 -2
- package/src/components/data-table/use-server-source.ts +17 -4
- package/src/components/date-field.tsx +1 -1
- package/src/components/error-banner.tsx +1 -1
- package/src/components/field.tsx +2 -2
- package/src/components/form.tsx +2 -2
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/markdown.tsx +5 -4
- package/src/components/sheet.tsx +2 -2
- package/src/components/sortable-list.tsx +2 -2
- package/src/components/textarea.tsx +1 -1
- package/src/components/toast.tsx +1 -1
- package/src/entries/a2ui.ts +11 -0
- package/src/entries/chart.ts +10 -0
- package/src/entries/core.ts +91 -0
- package/src/entries/data-table.ts +9 -0
- package/src/entries/form.ts +24 -0
- package/src/entries/markdown.ts +9 -0
- package/src/entries/sortable-list.ts +13 -0
- package/src/index.ts +32 -98
- package/src/lib/shakeable.ts +33 -0
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { AlertTriangle, RefreshCw, X } from "lucide-react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/error-banner.tsx
|
|
7
|
+
const actionClass = /* @__PURE__ */ cn("inline-flex items-center justify-center rounded-[var(--ds-radius-sm)] p-1", "text-[color:var(--ds-destructive)] hover:bg-[var(--ds-destructive)]/10", "outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ds-destructive)]/40", "transition-colors duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]");
|
|
8
|
+
/**
|
|
9
|
+
* ErrorBanner — the one error surface every screen uses: a warning icon, the
|
|
10
|
+
* message, and optional Retry / Dismiss actions. Renders nothing for an empty
|
|
11
|
+
* message so callers can pass their error state straight through.
|
|
12
|
+
*/
|
|
13
|
+
function ErrorBanner({ message, onDismiss, onRetry, className, ...props }) {
|
|
14
|
+
if (!message) return null;
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
"data-slot": "error-banner",
|
|
17
|
+
role: "alert",
|
|
18
|
+
className: cn("flex items-start gap-3 rounded-[var(--ds-radius-md)] border px-4 py-3", "border-[var(--ds-destructive)]/30 bg-[var(--ds-destructive-soft)]", "text-[length:var(--ds-text-body-sm)] leading-[var(--ds-text-body-sm--line-height)]", "text-[color:var(--ds-destructive)]", className),
|
|
19
|
+
...props,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx(AlertTriangle, {
|
|
22
|
+
"aria-hidden": true,
|
|
23
|
+
className: "mt-0.5 size-4 shrink-0"
|
|
24
|
+
}),
|
|
25
|
+
/* @__PURE__ */ jsx("p", {
|
|
26
|
+
"data-slot": "error-banner-message",
|
|
27
|
+
className: "flex-1",
|
|
28
|
+
children: message
|
|
29
|
+
}),
|
|
30
|
+
onRetry || onDismiss ? /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "flex shrink-0 items-center gap-1",
|
|
32
|
+
children: [onRetry ? /* @__PURE__ */ jsx("button", {
|
|
33
|
+
type: "button",
|
|
34
|
+
onClick: onRetry,
|
|
35
|
+
"aria-label": "Retry",
|
|
36
|
+
className: actionClass,
|
|
37
|
+
children: /* @__PURE__ */ jsx(RefreshCw, { className: "size-3.5" })
|
|
38
|
+
}) : null, onDismiss ? /* @__PURE__ */ jsx("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: onDismiss,
|
|
41
|
+
"aria-label": "Dismiss",
|
|
42
|
+
className: actionClass,
|
|
43
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
44
|
+
}) : null]
|
|
45
|
+
}) : null
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ErrorBanner };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=error-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-banner.js","names":[],"sources":["../../src/components/error-banner.tsx"],"sourcesContent":["\"use client\";\n\nimport { AlertTriangle, RefreshCw, X } from \"lucide-react\";\nimport type * as React from \"react\";\nimport { cn } from \"@/lib/cn\";\n\nexport interface ErrorBannerProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n message: string;\n onDismiss?: () => void;\n onRetry?: () => void;\n}\n\nconst actionClass = /* @__PURE__ */ cn(\n \"inline-flex items-center justify-center rounded-[var(--ds-radius-sm)] p-1\",\n \"text-[color:var(--ds-destructive)] hover:bg-[var(--ds-destructive)]/10\",\n \"outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ds-destructive)]/40\",\n \"transition-colors duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]\",\n);\n\n/**\n * ErrorBanner — the one error surface every screen uses: a warning icon, the\n * message, and optional Retry / Dismiss actions. Renders nothing for an empty\n * message so callers can pass their error state straight through.\n */\nfunction ErrorBanner({ message, onDismiss, onRetry, className, ...props }: ErrorBannerProps) {\n if (!message) {\n return null;\n }\n\n return (\n <div\n data-slot=\"error-banner\"\n role=\"alert\"\n className={cn(\n \"flex items-start gap-3 rounded-[var(--ds-radius-md)] border px-4 py-3\",\n \"border-[var(--ds-destructive)]/30 bg-[var(--ds-destructive-soft)]\",\n \"text-[length:var(--ds-text-body-sm)] leading-[var(--ds-text-body-sm--line-height)]\",\n \"text-[color:var(--ds-destructive)]\",\n className,\n )}\n {...props}\n >\n <AlertTriangle aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n <p data-slot=\"error-banner-message\" className=\"flex-1\">\n {message}\n </p>\n {onRetry || onDismiss ? (\n <div className=\"flex shrink-0 items-center gap-1\">\n {onRetry ? (\n <button type=\"button\" onClick={onRetry} aria-label=\"Retry\" className={actionClass}>\n <RefreshCw className=\"size-3.5\" />\n </button>\n ) : null}\n {onDismiss ? (\n <button type=\"button\" onClick={onDismiss} aria-label=\"Dismiss\" className={actionClass}>\n <X className=\"size-3.5\" />\n </button>\n ) : null}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport { ErrorBanner };\n"],"mappings":";;;;;;AAYA,MAAM,cAA8B,mBAClC,6EACA,0EACA,uFACA,gFACF;;;;;;AAOA,SAAS,YAAY,EAAE,SAAS,WAAW,SAAS,WAAW,GAAG,SAA2B;CAC3F,IAAI,CAAC,SACH,OAAO;CAGT,OACE,qBAAC,OAAD;EACE,aAAU;EACV,MAAK;EACL,WAAW,GACT,yEACA,qEACA,sFACA,sCACA,SACF;EACA,GAAI;EAVN,UAAA;GAYE,oBAAC,eAAD;IAAe,eAAA;IAAY,WAAU;GAA0B,CAAA;GAC/D,oBAAC,KAAD;IAAG,aAAU;IAAuB,WAAU;IAC3C,UAAA;GACA,CAAA;GACF,WAAW,YACV,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,UACC,oBAAC,UAAD;KAAQ,MAAK;KAAS,SAAS;KAAS,cAAW;KAAQ,WAAW;KACpE,UAAA,oBAAC,WAAD,EAAW,WAAU,WAAY,CAAA;IAC3B,CAAA,IACN,MACH,YACC,oBAAC,UAAD;KAAQ,MAAK;KAAS,SAAS;KAAW,cAAW;KAAU,WAAW;KACxE,UAAA,oBAAC,GAAD,EAAG,WAAU,WAAY,CAAA;IACnB,CAAA,IACN,IACD;GACH,CAAA,IAAA;EACD;;AAET"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Field } from "@base-ui/react/field";
|
|
5
|
+
import { Fieldset } from "@base-ui/react/fieldset";
|
|
6
|
+
//#region src/components/field.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Field.
|
|
9
|
+
*
|
|
10
|
+
* The shadcn Field shape over Base UI's Field and Fieldset. `Field` is
|
|
11
|
+
* `Field.Root`: it owns the label/control/description/error association, so a
|
|
12
|
+
* `FieldLabel` focuses its `FieldControl` (or any Base UI control such as
|
|
13
|
+
* Checkbox, Select, Switch) without an explicit `htmlFor`, and every message
|
|
14
|
+
* ends up in the control's `aria-describedby`.
|
|
15
|
+
*
|
|
16
|
+
* Validity: Base UI puts `data-invalid` on every part once the control fails
|
|
17
|
+
* native constraints or a `validate` callback, and adds `aria-invalid` to the
|
|
18
|
+
* control. Pass `invalid` on `Field` when an external library owns the state
|
|
19
|
+
* (the Form component does this from react-hook-form).
|
|
20
|
+
*
|
|
21
|
+
* `FieldError` follows the field's validity: static children show once the
|
|
22
|
+
* control is invalid or the Field is marked `invalid`; `match="valueMissing"`
|
|
23
|
+
* narrows that to one constraint. Given `errors` (a react-hook-form error
|
|
24
|
+
* list) it renders whenever the list has a message.
|
|
25
|
+
*/
|
|
26
|
+
declare const fieldVariants: (props?: ({
|
|
27
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
28
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
29
|
+
export interface FieldProps extends React.ComponentProps<typeof Field.Root>, VariantProps<typeof fieldVariants> {}
|
|
30
|
+
declare function Field$1({ className, orientation, invalid, ...props }: FieldProps): React.JSX.Element;
|
|
31
|
+
/** Stacks a label and description beside a control in a horizontal Field. */
|
|
32
|
+
declare function FieldContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
33
|
+
export interface FieldLabelProps extends React.ComponentProps<typeof Field.Label> {}
|
|
34
|
+
declare function FieldLabel({ className, ...props }: FieldLabelProps): React.JSX.Element;
|
|
35
|
+
export interface FieldControlProps extends React.ComponentProps<typeof Field.Control> {}
|
|
36
|
+
/**
|
|
37
|
+
* The field's `<input>`, styled like Input. Swap the element with `render`
|
|
38
|
+
* (`render={<Textarea />}`); the input styling still applies unless the
|
|
39
|
+
* rendered element's own className wins in tailwind-merge.
|
|
40
|
+
*/
|
|
41
|
+
declare function FieldControl({ className, ...props }: FieldControlProps): React.JSX.Element;
|
|
42
|
+
export interface FieldDescriptionProps extends React.ComponentProps<typeof Field.Description> {}
|
|
43
|
+
declare function FieldDescription({ className, ...props }: FieldDescriptionProps): React.JSX.Element;
|
|
44
|
+
/** The shape react-hook-form gives for a field error; only `message` is read. */
|
|
45
|
+
export interface FieldErrorItem {
|
|
46
|
+
message?: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface FieldErrorProps extends React.ComponentProps<typeof Field.Error> {
|
|
49
|
+
/**
|
|
50
|
+
* Errors from an external validator. Duplicate messages collapse; one message
|
|
51
|
+
* renders as text, several as a list.
|
|
52
|
+
*/
|
|
53
|
+
errors?: ReadonlyArray<FieldErrorItem | undefined> | undefined;
|
|
54
|
+
}
|
|
55
|
+
declare function FieldError({ className, children, errors, match, ...props }: FieldErrorProps): React.JSX.Element | null;
|
|
56
|
+
export interface FieldsetProps extends React.ComponentProps<typeof Fieldset.Root> {}
|
|
57
|
+
declare function Fieldset$1({ className, ...props }: FieldsetProps): React.JSX.Element;
|
|
58
|
+
export interface FieldsetLegendProps extends React.ComponentProps<typeof Fieldset.Legend> {}
|
|
59
|
+
declare function FieldsetLegend({ className, ...props }: FieldsetLegendProps): React.JSX.Element;
|
|
60
|
+
/** A vertical stack of Fields with the spacing a form uses between rows. */
|
|
61
|
+
declare function FieldGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { Field$1 as Field, FieldContent, FieldControl, FieldDescription, FieldError, FieldGroup, FieldLabel, Fieldset$1 as Fieldset, FieldsetLegend, fieldVariants };
|
|
64
|
+
//# sourceMappingURL=field.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { inputClassName } from "./input.js";
|
|
5
|
+
import { labelVariants } from "./label.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Field } from "@base-ui/react/field";
|
|
10
|
+
import { Fieldset } from "@base-ui/react/fieldset";
|
|
11
|
+
//#region src/components/field.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Field.
|
|
14
|
+
*
|
|
15
|
+
* The shadcn Field shape over Base UI's Field and Fieldset. `Field` is
|
|
16
|
+
* `Field.Root`: it owns the label/control/description/error association, so a
|
|
17
|
+
* `FieldLabel` focuses its `FieldControl` (or any Base UI control such as
|
|
18
|
+
* Checkbox, Select, Switch) without an explicit `htmlFor`, and every message
|
|
19
|
+
* ends up in the control's `aria-describedby`.
|
|
20
|
+
*
|
|
21
|
+
* Validity: Base UI puts `data-invalid` on every part once the control fails
|
|
22
|
+
* native constraints or a `validate` callback, and adds `aria-invalid` to the
|
|
23
|
+
* control. Pass `invalid` on `Field` when an external library owns the state
|
|
24
|
+
* (the Form component does this from react-hook-form).
|
|
25
|
+
*
|
|
26
|
+
* `FieldError` follows the field's validity: static children show once the
|
|
27
|
+
* control is invalid or the Field is marked `invalid`; `match="valueMissing"`
|
|
28
|
+
* narrows that to one constraint. Given `errors` (a react-hook-form error
|
|
29
|
+
* list) it renders whenever the list has a message.
|
|
30
|
+
*/
|
|
31
|
+
const fieldVariants = /* @__PURE__ */ cva("group/field flex w-full gap-2", {
|
|
32
|
+
variants: { orientation: {
|
|
33
|
+
vertical: "flex-col [&>*]:w-full [&>.sr-only]:w-auto",
|
|
34
|
+
horizontal: ["flex-row items-center [&>[data-slot=field-label]]:flex-auto", "has-[>[data-slot=field-content]]:items-start"]
|
|
35
|
+
} },
|
|
36
|
+
defaultVariants: { orientation: "vertical" }
|
|
37
|
+
});
|
|
38
|
+
const FieldInvalidContext = /* @__PURE__ */ React.createContext(false);
|
|
39
|
+
function Field$1({ className, orientation = "vertical", invalid, ...props }) {
|
|
40
|
+
return /* @__PURE__ */ jsx(FieldInvalidContext.Provider, {
|
|
41
|
+
value: invalid === true,
|
|
42
|
+
children: /* @__PURE__ */ jsx(Field.Root, {
|
|
43
|
+
"data-slot": "field",
|
|
44
|
+
"data-orientation": orientation,
|
|
45
|
+
invalid,
|
|
46
|
+
className: cn(fieldVariants({ orientation }), className),
|
|
47
|
+
...props
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Stacks a label and description beside a control in a horizontal Field. */
|
|
52
|
+
function FieldContent({ className, ...props }) {
|
|
53
|
+
return /* @__PURE__ */ jsx("div", {
|
|
54
|
+
"data-slot": "field-content",
|
|
55
|
+
className: cn("group/field-content flex flex-1 flex-col gap-1 leading-snug", className),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function FieldLabel({ className, ...props }) {
|
|
60
|
+
return /* @__PURE__ */ jsx(Field.Label, {
|
|
61
|
+
"data-slot": "field-label",
|
|
62
|
+
className: cn(labelVariants(), "w-fit", "data-[disabled]:pointer-events-none data-[disabled]:opacity-70", "data-[invalid]:text-[color:var(--ds-destructive)]", className),
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The field's `<input>`, styled like Input. Swap the element with `render`
|
|
68
|
+
* (`render={<Textarea />}`); the input styling still applies unless the
|
|
69
|
+
* rendered element's own className wins in tailwind-merge.
|
|
70
|
+
*/
|
|
71
|
+
function FieldControl({ className, ...props }) {
|
|
72
|
+
return /* @__PURE__ */ jsx(Field.Control, {
|
|
73
|
+
"data-slot": "field-control",
|
|
74
|
+
className: cn(inputClassName, "data-[invalid]:border-[var(--ds-destructive)] data-[invalid]:ring-[3px] data-[invalid]:ring-[var(--ds-destructive)]/20", className),
|
|
75
|
+
...props
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function FieldDescription({ className, ...props }) {
|
|
79
|
+
return /* @__PURE__ */ jsx(Field.Description, {
|
|
80
|
+
"data-slot": "field-description",
|
|
81
|
+
className: cn("text-[length:var(--ds-text-caption)] leading-[var(--ds-text-caption--line-height)] font-normal text-[color:var(--ds-muted-foreground)]", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-[color:var(--ds-primary)]", className),
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function FieldError({ className, children, errors, match, ...props }) {
|
|
86
|
+
const fieldInvalid = React.useContext(FieldInvalidContext);
|
|
87
|
+
const content = React.useMemo(() => {
|
|
88
|
+
if (children) return children;
|
|
89
|
+
if (!errors?.length) return null;
|
|
90
|
+
const unique = [...new Map(errors.map((e) => [e?.message, e])).values()].filter((e) => Boolean(e?.message));
|
|
91
|
+
if (unique.length === 0) return null;
|
|
92
|
+
if (unique.length === 1) return unique[0]?.message;
|
|
93
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
94
|
+
className: "ml-4 flex list-disc flex-col gap-1",
|
|
95
|
+
children: unique.map((e) => /* @__PURE__ */ jsx("li", { children: e.message }, e.message))
|
|
96
|
+
});
|
|
97
|
+
}, [children, errors]);
|
|
98
|
+
if (errors !== void 0 && content === null) return null;
|
|
99
|
+
return /* @__PURE__ */ jsx(Field.Error, {
|
|
100
|
+
role: "alert",
|
|
101
|
+
"data-slot": "field-error",
|
|
102
|
+
match: match ?? (errors !== void 0 || fieldInvalid ? true : void 0),
|
|
103
|
+
className: cn("text-[length:var(--ds-text-caption)] leading-[var(--ds-text-caption--line-height)] font-normal text-[color:var(--ds-destructive)]", className),
|
|
104
|
+
...props,
|
|
105
|
+
children: content
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function Fieldset$1({ className, ...props }) {
|
|
109
|
+
return /* @__PURE__ */ jsx(Fieldset.Root, {
|
|
110
|
+
"data-slot": "fieldset",
|
|
111
|
+
className: cn("flex flex-col gap-4", "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className),
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function FieldsetLegend({ className, ...props }) {
|
|
116
|
+
return /* @__PURE__ */ jsx(Fieldset.Legend, {
|
|
117
|
+
"data-slot": "fieldset-legend",
|
|
118
|
+
className: cn("text-[length:var(--ds-text-body-sm)] font-medium leading-none text-[color:var(--ds-foreground)]", "data-[disabled]:opacity-70", className),
|
|
119
|
+
...props
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/** A vertical stack of Fields with the spacing a form uses between rows. */
|
|
123
|
+
function FieldGroup({ className, ...props }) {
|
|
124
|
+
return /* @__PURE__ */ jsx("div", {
|
|
125
|
+
"data-slot": "field-group",
|
|
126
|
+
className: cn("group/field-group flex w-full flex-col gap-6 [&>[data-slot=field-group]]:gap-4", className),
|
|
127
|
+
...props
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
export { Field$1 as Field, FieldContent, FieldControl, FieldDescription, FieldError, FieldGroup, FieldLabel, Fieldset$1 as Fieldset, FieldsetLegend, fieldVariants };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","names":["Field","FieldPrimitive","Fieldset","FieldsetPrimitive"],"sources":["../../src/components/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as FieldPrimitive } from \"@base-ui/react/field\";\nimport { Fieldset as FieldsetPrimitive } from \"@base-ui/react/fieldset\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport * as React from \"react\";\nimport { inputClassName } from \"@/components/input\";\nimport { labelVariants } from \"@/components/label\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Field.\n *\n * The shadcn Field shape over Base UI's Field and Fieldset. `Field` is\n * `Field.Root`: it owns the label/control/description/error association, so a\n * `FieldLabel` focuses its `FieldControl` (or any Base UI control such as\n * Checkbox, Select, Switch) without an explicit `htmlFor`, and every message\n * ends up in the control's `aria-describedby`.\n *\n * Validity: Base UI puts `data-invalid` on every part once the control fails\n * native constraints or a `validate` callback, and adds `aria-invalid` to the\n * control. Pass `invalid` on `Field` when an external library owns the state\n * (the Form component does this from react-hook-form).\n *\n * `FieldError` follows the field's validity: static children show once the\n * control is invalid or the Field is marked `invalid`; `match=\"valueMissing\"`\n * narrows that to one constraint. Given `errors` (a react-hook-form error\n * list) it renders whenever the list has a message.\n */\nconst fieldVariants = /* @__PURE__ */ cva(\"group/field flex w-full gap-2\", {\n variants: {\n orientation: {\n vertical: \"flex-col [&>*]:w-full [&>.sr-only]:w-auto\",\n horizontal: [\n \"flex-row items-center [&>[data-slot=field-label]]:flex-auto\",\n \"has-[>[data-slot=field-content]]:items-start\",\n ],\n },\n },\n defaultVariants: { orientation: \"vertical\" },\n});\n\nexport interface FieldProps\n extends React.ComponentProps<typeof FieldPrimitive.Root>,\n VariantProps<typeof fieldVariants> {}\n\n// Base UI's Field.Error reads the control's computed validity only; the\n// external `invalid` prop reaches the data attributes but not the error's\n// visibility. Carry it so FieldError can show its static message.\nconst FieldInvalidContext = /* @__PURE__ */ React.createContext(false);\n\nfunction Field({ className, orientation = \"vertical\", invalid, ...props }: FieldProps) {\n return (\n <FieldInvalidContext.Provider value={invalid === true}>\n <FieldPrimitive.Root\n data-slot=\"field\"\n data-orientation={orientation}\n invalid={invalid}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n </FieldInvalidContext.Provider>\n );\n}\n\n/** Stacks a label and description beside a control in a horizontal Field. */\nfunction FieldContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn(\"group/field-content flex flex-1 flex-col gap-1 leading-snug\", className)}\n {...props}\n />\n );\n}\n\nexport interface FieldLabelProps extends React.ComponentProps<typeof FieldPrimitive.Label> {}\n\nfunction FieldLabel({ className, ...props }: FieldLabelProps) {\n return (\n <FieldPrimitive.Label\n data-slot=\"field-label\"\n className={cn(\n labelVariants(),\n \"w-fit\",\n \"data-[disabled]:pointer-events-none data-[disabled]:opacity-70\",\n \"data-[invalid]:text-[color:var(--ds-destructive)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface FieldControlProps extends React.ComponentProps<typeof FieldPrimitive.Control> {}\n\n/**\n * The field's `<input>`, styled like Input. Swap the element with `render`\n * (`render={<Textarea />}`); the input styling still applies unless the\n * rendered element's own className wins in tailwind-merge.\n */\nfunction FieldControl({ className, ...props }: FieldControlProps) {\n return (\n <FieldPrimitive.Control\n data-slot=\"field-control\"\n className={cn(\n inputClassName,\n \"data-[invalid]:border-[var(--ds-destructive)] data-[invalid]:ring-[3px] data-[invalid]:ring-[var(--ds-destructive)]/20\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface FieldDescriptionProps\n extends React.ComponentProps<typeof FieldPrimitive.Description> {}\n\nfunction FieldDescription({ className, ...props }: FieldDescriptionProps) {\n return (\n <FieldPrimitive.Description\n data-slot=\"field-description\"\n className={cn(\n \"text-[length:var(--ds-text-caption)] leading-[var(--ds-text-caption--line-height)] font-normal text-[color:var(--ds-muted-foreground)]\",\n \"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-[color:var(--ds-primary)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** The shape react-hook-form gives for a field error; only `message` is read. */\nexport interface FieldErrorItem {\n message?: string | undefined;\n}\n\nexport interface FieldErrorProps extends React.ComponentProps<typeof FieldPrimitive.Error> {\n /**\n * Errors from an external validator. Duplicate messages collapse; one message\n * renders as text, several as a list.\n */\n errors?: ReadonlyArray<FieldErrorItem | undefined> | undefined;\n}\n\nfunction FieldError({ className, children, errors, match, ...props }: FieldErrorProps) {\n const fieldInvalid = React.useContext(FieldInvalidContext);\n const content = React.useMemo(() => {\n if (children) {\n return children;\n }\n if (!errors?.length) {\n return null;\n }\n const unique = [...new Map(errors.map((e) => [e?.message, e])).values()].filter(\n (e): e is FieldErrorItem => Boolean(e?.message),\n );\n if (unique.length === 0) {\n return null;\n }\n if (unique.length === 1) {\n return unique[0]?.message;\n }\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {unique.map((e) => (\n <li key={e.message}>{e.message}</li>\n ))}\n </ul>\n );\n }, [children, errors]);\n\n if (errors !== undefined && content === null) {\n return null;\n }\n\n return (\n <FieldPrimitive.Error\n role=\"alert\"\n data-slot=\"field-error\"\n match={match ?? (errors !== undefined || fieldInvalid ? true : undefined)}\n className={cn(\n \"text-[length:var(--ds-text-caption)] leading-[var(--ds-text-caption--line-height)] font-normal text-[color:var(--ds-destructive)]\",\n className,\n )}\n {...props}\n >\n {content}\n </FieldPrimitive.Error>\n );\n}\n\nexport interface FieldsetProps extends React.ComponentProps<typeof FieldsetPrimitive.Root> {}\n\nfunction Fieldset({ className, ...props }: FieldsetProps) {\n return (\n <FieldsetPrimitive.Root\n data-slot=\"fieldset\"\n className={cn(\n \"flex flex-col gap-4\",\n \"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface FieldsetLegendProps extends React.ComponentProps<typeof FieldsetPrimitive.Legend> {}\n\nfunction FieldsetLegend({ className, ...props }: FieldsetLegendProps) {\n return (\n <FieldsetPrimitive.Legend\n data-slot=\"fieldset-legend\"\n className={cn(\n \"text-[length:var(--ds-text-body-sm)] font-medium leading-none text-[color:var(--ds-foreground)]\",\n \"data-[disabled]:opacity-70\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** A vertical stack of Fields with the spacing a form uses between rows. */\nfunction FieldGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n \"group/field-group flex w-full flex-col gap-6 [&>[data-slot=field-group]]:gap-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n Field,\n FieldContent,\n FieldLabel,\n FieldControl,\n FieldDescription,\n FieldError,\n Fieldset,\n FieldsetLegend,\n FieldGroup,\n fieldVariants,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,gBAAgC,oBAAI,iCAAiC;CACzE,UAAU,EACR,aAAa;EACX,UAAU;EACV,YAAY,CACV,+DACA,8CACF;CACF,EACF;CACA,iBAAiB,EAAE,aAAa,WAAW;AAC7C,CAAC;AASD,MAAM,sBAAsC,sBAAM,cAAc,KAAK;AAErE,SAASA,QAAM,EAAE,WAAW,cAAc,YAAY,SAAS,GAAG,SAAqB;CACrF,OACE,oBAAC,oBAAoB,UAArB;EAA8B,OAAO,YAAY;EAC/C,UAAA,oBAACC,MAAe,MAAhB;GACE,aAAU;GACV,oBAAkB;GACT;GACT,WAAW,GAAG,cAAc,EAAE,YAAY,CAAC,GAAG,SAAS;GACvD,GAAI;EACL,CAAA;CAC2B,CAAA;AAElC;;AAGA,SAAS,aAAa,EAAE,WAAW,GAAG,SAAsC;CAC1E,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GAAG,+DAA+D,SAAS;EACtF,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,WAAW,EAAE,WAAW,GAAG,SAA0B;CAC5D,OACE,oBAACA,MAAe,OAAhB;EACE,aAAU;EACV,WAAW,GACT,cAAc,GACd,SACA,kEACA,qDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;;;;;;AASA,SAAS,aAAa,EAAE,WAAW,GAAG,SAA4B;CAChE,OACE,oBAACA,MAAe,SAAhB;EACE,aAAU;EACV,WAAW,GACT,gBACA,0HACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAKA,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAgC;CACxE,OACE,oBAACA,MAAe,aAAhB;EACE,aAAU;EACV,WAAW,GACT,0IACA,uFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAeA,SAAS,WAAW,EAAE,WAAW,UAAU,QAAQ,OAAO,GAAG,SAA0B;CACrF,MAAM,eAAe,MAAM,WAAW,mBAAmB;CACzD,MAAM,UAAU,MAAM,cAAc;EAClC,IAAI,UACF,OAAO;EAET,IAAI,CAAC,QAAQ,QACX,OAAO;EAET,MAAM,SAAS,CAAC,GAAG,IAAI,IAAI,OAAO,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QACtE,MAA2B,QAAQ,GAAG,OAAO,CAChD;EACA,IAAI,OAAO,WAAW,GACpB,OAAO;EAET,IAAI,OAAO,WAAW,GACpB,OAAO,OAAO,EAAE,EAAE;EAEpB,OACE,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,OAAO,KAAK,MACX,oBAAC,MAAD,EAAA,UAAqB,EAAE,QAAY,GAA1B,EAAE,OAAwB,CACpC;EACC,CAAA;CAER,GAAG,CAAC,UAAU,MAAM,CAAC;CAErB,IAAI,WAAW,KAAA,KAAa,YAAY,MACtC,OAAO;CAGT,OACE,oBAACA,MAAe,OAAhB;EACE,MAAK;EACL,aAAU;EACV,OAAO,UAAU,WAAW,KAAA,KAAa,eAAe,OAAO,KAAA;EAC/D,WAAW,GACT,qIACA,SACF;EACA,GAAI;EAEH,UAAA;CACmB,CAAA;AAE1B;AAIA,SAASC,WAAS,EAAE,WAAW,GAAG,SAAwB;CACxD,OACE,oBAACC,SAAkB,MAAnB;EACE,aAAU;EACV,WAAW,GACT,uBACA,gFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,eAAe,EAAE,WAAW,GAAG,SAA8B;CACpE,OACE,oBAACA,SAAkB,QAAnB;EACE,aAAU;EACV,WAAW,GACT,mGACA,8BACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;;AAGA,SAAS,WAAW,EAAE,WAAW,GAAG,SAAsC;CACxE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,kFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { FieldDescriptionProps, FieldErrorProps, FieldLabelProps, FieldProps } from "./field.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ControllerProps, FieldError, FieldPath, FieldValues, SubmitHandler, UseFormReturn, useForm } from "react-hook-form";
|
|
5
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
|
+
//#region src/components/form.d.ts
|
|
7
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>({ children, watch, getValues, getErrors, getFieldState, setError, clearErrors, setValue, setValues, trigger, formState, resetField, reset, resetDefaultValues, handleSubmit, unregister, control, register, setFocus, subscribe }: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
8
|
+
declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>(props: ControllerProps<TFieldValues, TName, TTransformedValues>): React.JSX.Element;
|
|
9
|
+
export interface UseFormFieldReturn {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
formItemId: string;
|
|
13
|
+
formDescriptionId: string;
|
|
14
|
+
formMessageId: string;
|
|
15
|
+
invalid: boolean;
|
|
16
|
+
isDirty: boolean;
|
|
17
|
+
isTouched: boolean;
|
|
18
|
+
isValidating: boolean;
|
|
19
|
+
error?: FieldError | undefined;
|
|
20
|
+
}
|
|
21
|
+
declare function useFormField(): UseFormFieldReturn;
|
|
22
|
+
export interface FormItemProps extends Omit<FieldProps, "invalid" | "name"> {}
|
|
23
|
+
declare function FormItem({ className, ...props }: FormItemProps): React.JSX.Element;
|
|
24
|
+
export interface FormLabelProps extends FieldLabelProps {}
|
|
25
|
+
declare function FormLabel({ className, ...props }: FormLabelProps): React.JSX.Element;
|
|
26
|
+
export interface FormControlProps extends React.HTMLAttributes<HTMLElement> {
|
|
27
|
+
/** The single control element; it receives `id`, `aria-describedby` and `aria-invalid`. */
|
|
28
|
+
children: React.ReactElement;
|
|
29
|
+
}
|
|
30
|
+
declare function FormControl({ children, ...props }: FormControlProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
31
|
+
export interface FormDescriptionProps extends FieldDescriptionProps {}
|
|
32
|
+
declare function FormDescription({ className, ...props }: FormDescriptionProps): React.JSX.Element;
|
|
33
|
+
export interface FormMessageProps extends Omit<FieldErrorProps, "errors" | "match"> {}
|
|
34
|
+
declare function FormMessage({ className, children, ...props }: FormMessageProps): React.JSX.Element | null;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, type SubmitHandler, type UseFormReturn, useForm, useFormField, zodResolver };
|
|
37
|
+
//# sourceMappingURL=form.d.ts.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { Field, FieldDescription, FieldError as FieldError$1, FieldLabel } from "./field.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { Controller, FormProvider, useForm, useFormContext, useFormState } from "react-hook-form";
|
|
8
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
9
|
+
//#region src/components/form.tsx
|
|
10
|
+
const Form = FormProvider;
|
|
11
|
+
const FormFieldContext = /* @__PURE__ */ React.createContext(null);
|
|
12
|
+
function FormField(props) {
|
|
13
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
14
|
+
value: { name: props.name },
|
|
15
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const FormItemContext = /* @__PURE__ */ React.createContext(null);
|
|
19
|
+
function useFormFieldState() {
|
|
20
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
21
|
+
if (!fieldContext) throw new Error("useFormField must be used within <FormField>");
|
|
22
|
+
const { getFieldState } = useFormContext();
|
|
23
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
24
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
25
|
+
return {
|
|
26
|
+
name: fieldContext.name,
|
|
27
|
+
...fieldState
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function useFormField() {
|
|
31
|
+
const fieldState = useFormFieldState();
|
|
32
|
+
const itemContext = React.useContext(FormItemContext);
|
|
33
|
+
if (!itemContext) throw new Error("useFormField must be used within <FormItem>");
|
|
34
|
+
const { id } = itemContext;
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
formItemId: `${id}-form-item`,
|
|
38
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
39
|
+
formMessageId: `${id}-form-item-message`,
|
|
40
|
+
...fieldState
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function FormItem({ className, ...props }) {
|
|
44
|
+
const id = React.useId();
|
|
45
|
+
const { name, error } = useFormFieldState();
|
|
46
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
47
|
+
value: { id },
|
|
48
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
49
|
+
"data-slot": "form-item",
|
|
50
|
+
name,
|
|
51
|
+
invalid: Boolean(error),
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function FormLabel({ className, ...props }) {
|
|
58
|
+
const { formItemId } = useFormField();
|
|
59
|
+
return /* @__PURE__ */ jsx(FieldLabel, {
|
|
60
|
+
"data-slot": "form-label",
|
|
61
|
+
htmlFor: formItemId,
|
|
62
|
+
className,
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function FormControl({ children, ...props }) {
|
|
67
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
68
|
+
return useRender({
|
|
69
|
+
render: children,
|
|
70
|
+
props: {
|
|
71
|
+
id: formItemId,
|
|
72
|
+
"aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId,
|
|
73
|
+
"aria-invalid": error ? true : void 0,
|
|
74
|
+
...props
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function FormDescription({ className, ...props }) {
|
|
79
|
+
const { formDescriptionId } = useFormField();
|
|
80
|
+
return /* @__PURE__ */ jsx(FieldDescription, {
|
|
81
|
+
"data-slot": "form-description",
|
|
82
|
+
id: formDescriptionId,
|
|
83
|
+
className,
|
|
84
|
+
...props
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function FormMessage({ className, children, ...props }) {
|
|
88
|
+
const { error, formMessageId } = useFormField();
|
|
89
|
+
const body = error ? String(error.message ?? "") : children;
|
|
90
|
+
if (!body) return null;
|
|
91
|
+
return /* @__PURE__ */ jsx(FieldError$1, {
|
|
92
|
+
"data-slot": "form-message",
|
|
93
|
+
id: formMessageId,
|
|
94
|
+
match: true,
|
|
95
|
+
className,
|
|
96
|
+
...props,
|
|
97
|
+
children: body
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useForm, useFormField, zodResolver };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","names":["FieldError"],"sources":["../../src/components/form.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRender } from \"@base-ui/react/use-render\";\nimport * as React from \"react\";\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldError as RHFFieldError,\n type FieldPath,\n type FieldValues,\n} from \"react-hook-form\";\nimport {\n Field,\n FieldDescription,\n FieldError,\n FieldLabel,\n type FieldDescriptionProps,\n type FieldErrorProps,\n type FieldLabelProps,\n type FieldProps,\n} from \"@/components/field\";\n\n/**\n * Form.\n *\n * The shadcn react-hook-form recipe, with the parts built on Field so a form\n * written this way and one written with Field directly look the same:\n *\n * ```tsx\n * const form = useForm({ resolver: zodResolver(schema), defaultValues: { email: \"\" } });\n * <Form {...form}>\n * <form onSubmit={form.handleSubmit(onSubmit)}>\n * <FormField control={form.control} name=\"email\" render={({ field }) => (\n * <FormItem>\n * <FormLabel>Email</FormLabel>\n * <FormControl><Input {...field} /></FormControl>\n * <FormDescription>Where we send receipts.</FormDescription>\n * <FormMessage />\n * </FormItem>\n * )} />\n * </form>\n * </Form>\n * ```\n *\n * `FormItem` is a Field marked `invalid` from the react-hook-form error, so\n * `data-invalid` lands on the label and any Base UI control. `FormControl`\n * has no element of its own: it merges `id`, `aria-describedby` and\n * `aria-invalid` onto its single child, so a plain Input, Textarea or a Base\n * UI Checkbox/Select/Switch all work. `FormLabel` targets that `id`.\n *\n * `useForm` and `zodResolver` are re-exported so a consumer imports one package.\n */\nexport { useForm } from \"react-hook-form\";\nexport type { SubmitHandler, UseFormReturn } from \"react-hook-form\";\nexport { zodResolver } from \"@hookform/resolvers/zod\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = /* @__PURE__ */ React.createContext<FormFieldContextValue | null>(null);\n\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n TTransformedValues = TFieldValues,\n>(props: ControllerProps<TFieldValues, TName, TTransformedValues>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n}\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = /* @__PURE__ */ React.createContext<FormItemContextValue | null>(null);\n\nfunction useFormFieldState() {\n const fieldContext = React.useContext(FormFieldContext);\n if (!fieldContext) {\n throw new Error(\"useFormField must be used within <FormField>\");\n }\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n return { name: fieldContext.name, ...fieldState };\n}\n\nexport interface UseFormFieldReturn {\n id: string;\n name: string;\n formItemId: string;\n formDescriptionId: string;\n formMessageId: string;\n invalid: boolean;\n isDirty: boolean;\n isTouched: boolean;\n isValidating: boolean;\n error?: RHFFieldError | undefined;\n}\n\nfunction useFormField(): UseFormFieldReturn {\n const fieldState = useFormFieldState();\n const itemContext = React.useContext(FormItemContext);\n if (!itemContext) {\n throw new Error(\"useFormField must be used within <FormItem>\");\n }\n const { id } = itemContext;\n return {\n id,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n}\n\nexport interface FormItemProps extends Omit<FieldProps, \"invalid\" | \"name\"> {}\n\nfunction FormItem({ className, ...props }: FormItemProps) {\n const id = React.useId();\n const { name, error } = useFormFieldState();\n return (\n <FormItemContext.Provider value={{ id }}>\n <Field\n data-slot=\"form-item\"\n name={name}\n invalid={Boolean(error)}\n className={className}\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\nexport interface FormLabelProps extends FieldLabelProps {}\n\nfunction FormLabel({ className, ...props }: FormLabelProps) {\n const { formItemId } = useFormField();\n return (\n <FieldLabel data-slot=\"form-label\" htmlFor={formItemId} className={className} {...props} />\n );\n}\n\nexport interface FormControlProps extends React.HTMLAttributes<HTMLElement> {\n /** The single control element; it receives `id`, `aria-describedby` and `aria-invalid`. */\n children: React.ReactElement;\n}\n\nfunction FormControl({ children, ...props }: FormControlProps) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n return useRender({\n render: children,\n props: {\n id: formItemId,\n \"aria-describedby\": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId,\n \"aria-invalid\": error ? true : undefined,\n ...props,\n },\n });\n}\n\nexport interface FormDescriptionProps extends FieldDescriptionProps {}\n\nfunction FormDescription({ className, ...props }: FormDescriptionProps) {\n const { formDescriptionId } = useFormField();\n return (\n <FieldDescription\n data-slot=\"form-description\"\n id={formDescriptionId}\n className={className}\n {...props}\n />\n );\n}\n\nexport interface FormMessageProps extends Omit<FieldErrorProps, \"errors\" | \"match\"> {}\n\nfunction FormMessage({ className, children, ...props }: FormMessageProps) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error.message ?? \"\") : children;\n if (!body) {\n return null;\n }\n return (\n <FieldError data-slot=\"form-message\" id={formMessageId} match className={className} {...props}>\n {body}\n </FieldError>\n );\n}\n\nexport {\n Form,\n FormField,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n useFormField,\n};\n"],"mappings":";;;;;;;;;AA2DA,MAAM,OAAO;AASb,MAAM,mBAAmC,sBAAM,cAA4C,IAAI;AAE/F,SAAS,UAIP,OAAiE;CACjE,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,EAAE,MAAM,MAAM,KAAK;EACnD,UAAA,oBAAC,YAAD,EAAY,GAAI,MAAQ,CAAA;CACC,CAAA;AAE/B;AAMA,MAAM,kBAAkC,sBAAM,cAA2C,IAAI;AAE7F,SAAS,oBAAoB;CAC3B,MAAM,eAAe,MAAM,WAAW,gBAAgB;CACtD,IAAI,CAAC,cACH,MAAM,IAAI,MAAM,8CAA8C;CAEhE,MAAM,EAAE,kBAAkB,eAAe;CACzC,MAAM,YAAY,aAAa,EAAE,MAAM,aAAa,KAAK,CAAC;CAC1D,MAAM,aAAa,cAAc,aAAa,MAAM,SAAS;CAC7D,OAAO;EAAE,MAAM,aAAa;EAAM,GAAG;CAAW;AAClD;AAeA,SAAS,eAAmC;CAC1C,MAAM,aAAa,kBAAkB;CACrC,MAAM,cAAc,MAAM,WAAW,eAAe;CACpD,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,6CAA6C;CAE/D,MAAM,EAAE,OAAO;CACf,OAAO;EACL;EACA,YAAY,GAAG,GAAG;EAClB,mBAAmB,GAAG,GAAG;EACzB,eAAe,GAAG,GAAG;EACrB,GAAG;CACL;AACF;AAIA,SAAS,SAAS,EAAE,WAAW,GAAG,SAAwB;CACxD,MAAM,KAAK,MAAM,MAAM;CACvB,MAAM,EAAE,MAAM,UAAU,kBAAkB;CAC1C,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO,EAAE,GAAG;EACpC,UAAA,oBAAC,OAAD;GACE,aAAU;GACJ;GACN,SAAS,QAAQ,KAAK;GACX;GACX,GAAI;EACL,CAAA;CACuB,CAAA;AAE9B;AAIA,SAAS,UAAU,EAAE,WAAW,GAAG,SAAyB;CAC1D,MAAM,EAAE,eAAe,aAAa;CACpC,OACE,oBAAC,YAAD;EAAY,aAAU;EAAa,SAAS;EAAuB;EAAW,GAAI;CAAQ,CAAA;AAE9F;AAOA,SAAS,YAAY,EAAE,UAAU,GAAG,SAA2B;CAC7D,MAAM,EAAE,OAAO,YAAY,mBAAmB,kBAAkB,aAAa;CAC7E,OAAO,UAAU;EACf,QAAQ;EACR,OAAO;GACL,IAAI;GACJ,oBAAoB,QAAQ,GAAG,kBAAkB,GAAG,kBAAkB;GACtE,gBAAgB,QAAQ,OAAO,KAAA;GAC/B,GAAG;EACL;CACF,CAAC;AACH;AAIA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAA+B;CACtE,MAAM,EAAE,sBAAsB,aAAa;CAC3C,OACE,oBAAC,kBAAD;EACE,aAAU;EACV,IAAI;EACO;EACX,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,YAAY,EAAE,WAAW,UAAU,GAAG,SAA2B;CACxE,MAAM,EAAE,OAAO,kBAAkB,aAAa;CAC9C,MAAM,OAAO,QAAQ,OAAO,MAAM,WAAW,EAAE,IAAI;CACnD,IAAI,CAAC,MACH,OAAO;CAET,OACE,oBAACA,cAAD;EAAY,aAAU;EAAe,IAAI;EAAe,OAAA;EAAiB;EAAW,GAAI;EACrF,UAAA;CACS,CAAA;AAEhB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/components/input.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Input.
|
|
6
|
+
*
|
|
7
|
+
* A plain `<input>`; Base UI has no primitive for it and none is needed. The
|
|
8
|
+
* look is cortenaweb's: sunken surface, subtle border that strengthens on hover
|
|
9
|
+
* and takes the ring colour on focus. `aria-invalid` swaps the border and ring
|
|
10
|
+
* for the destructive pair so a Field can mark errors without extra classes.
|
|
11
|
+
*/
|
|
12
|
+
declare const inputClassName: string;
|
|
13
|
+
export interface InputProps extends React.ComponentProps<"input"> {}
|
|
14
|
+
declare function Input({ className, type, ...props }: InputProps): React.JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { Input, inputClassName };
|
|
17
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/input.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Input.
|
|
8
|
+
*
|
|
9
|
+
* A plain `<input>`; Base UI has no primitive for it and none is needed. The
|
|
10
|
+
* look is cortenaweb's: sunken surface, subtle border that strengthens on hover
|
|
11
|
+
* and takes the ring colour on focus. `aria-invalid` swaps the border and ring
|
|
12
|
+
* for the destructive pair so a Field can mark errors without extra classes.
|
|
13
|
+
*/
|
|
14
|
+
const inputClassName = /* @__PURE__ */ cn("flex h-10 w-full min-w-0 rounded-[var(--ds-radius-md)] border border-[var(--ds-border)] bg-[var(--ds-muted)] px-3 py-2", "text-[length:var(--ds-text-caption-lg)] leading-[var(--ds-text-caption-lg--line-height)] text-[color:var(--ds-foreground)]", "placeholder:text-[color:var(--ds-text-tertiary)]", "transition-[border-color,box-shadow] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]", "hover:border-[var(--ds-border-strong)]", "outline-none focus-visible:border-[var(--ds-ring)] focus-visible:ring-[3px] focus-visible:ring-[var(--ds-ring)]/40", "file:border-0 file:bg-transparent file:text-[length:var(--ds-text-body-sm)] file:font-medium file:text-[color:var(--ds-foreground)]", "disabled:cursor-not-allowed disabled:opacity-50", "aria-invalid:border-[var(--ds-destructive)] aria-invalid:ring-[3px] aria-invalid:ring-[var(--ds-destructive)]/20");
|
|
15
|
+
function Input({ className, type, ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx("input", {
|
|
17
|
+
type,
|
|
18
|
+
"data-slot": "input",
|
|
19
|
+
className: cn(inputClassName, className),
|
|
20
|
+
...props
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Input, inputClassName };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../src/components/input.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Input.\n *\n * A plain `<input>`; Base UI has no primitive for it and none is needed. The\n * look is cortenaweb's: sunken surface, subtle border that strengthens on hover\n * and takes the ring colour on focus. `aria-invalid` swaps the border and ring\n * for the destructive pair so a Field can mark errors without extra classes.\n */\nconst inputClassName = /* @__PURE__ */ cn(\n \"flex h-10 w-full min-w-0 rounded-[var(--ds-radius-md)] border border-[var(--ds-border)] bg-[var(--ds-muted)] px-3 py-2\",\n \"text-[length:var(--ds-text-caption-lg)] leading-[var(--ds-text-caption-lg--line-height)] text-[color:var(--ds-foreground)]\",\n \"placeholder:text-[color:var(--ds-text-tertiary)]\",\n \"transition-[border-color,box-shadow] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]\",\n \"hover:border-[var(--ds-border-strong)]\",\n \"outline-none focus-visible:border-[var(--ds-ring)] focus-visible:ring-[3px] focus-visible:ring-[var(--ds-ring)]/40\",\n \"file:border-0 file:bg-transparent file:text-[length:var(--ds-text-body-sm)] file:font-medium file:text-[color:var(--ds-foreground)]\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"aria-invalid:border-[var(--ds-destructive)] aria-invalid:ring-[3px] aria-invalid:ring-[var(--ds-destructive)]/20\",\n);\n\nexport interface InputProps extends React.ComponentProps<\"input\"> {}\n\nfunction Input({ className, type, ...props }: InputProps) {\n return <input type={type} data-slot=\"input\" className={cn(inputClassName, className)} {...props} />;\n}\n\nexport { Input, inputClassName };\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAM,iBAAiC,mBACrC,0HACA,8HACA,oDACA,qGACA,0CACA,sHACA,uIACA,mDACA,kHACF;AAIA,SAAS,MAAM,EAAE,WAAW,MAAM,GAAG,SAAqB;CACxD,OAAO,oBAAC,SAAD;EAAa;EAAM,aAAU;EAAQ,WAAW,GAAG,gBAAgB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACpG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/components/kbd.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Kbd — an inline keyboard-key cap. Mono caption-sm text on the sunken
|
|
6
|
+
* surface, with a heavier bottom border for the key-cap read.
|
|
7
|
+
*/
|
|
8
|
+
declare function Kbd({ className, ...props }: React.ComponentProps<"kbd">): React.JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { Kbd };
|
|
11
|
+
//# sourceMappingURL=kbd.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/kbd.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Kbd — an inline keyboard-key cap. Mono caption-sm text on the sunken
|
|
8
|
+
* surface, with a heavier bottom border for the key-cap read.
|
|
9
|
+
*/
|
|
10
|
+
function Kbd({ className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
12
|
+
"data-slot": "kbd",
|
|
13
|
+
className: cn("inline-flex items-center px-1.5 py-0.5", "font-[family-name:var(--ds-font-mono)] text-[length:var(--ds-text-caption-sm)] leading-none", "bg-[var(--ds-muted)] text-[color:var(--ds-muted-foreground)]", "border border-b-2 border-[var(--ds-border)] rounded-[var(--ds-radius-sm)]", className),
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Kbd };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=kbd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kbd.js","names":[],"sources":["../../src/components/kbd.tsx"],"sourcesContent":["\"use client\";\n\nimport type * as React from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Kbd — an inline keyboard-key cap. Mono caption-sm text on the sunken\n * surface, with a heavier bottom border for the key-cap read.\n */\nfunction Kbd({ className, ...props }: React.ComponentProps<\"kbd\">) {\n return (\n <kbd\n data-slot=\"kbd\"\n className={cn(\n \"inline-flex items-center px-1.5 py-0.5\",\n \"font-[family-name:var(--ds-font-mono)] text-[length:var(--ds-text-caption-sm)] leading-none\",\n \"bg-[var(--ds-muted)] text-[color:var(--ds-muted-foreground)]\",\n \"border border-b-2 border-[var(--ds-border)] rounded-[var(--ds-radius-sm)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport { Kbd };\n"],"mappings":";;;;;;;;;AASA,SAAS,IAAI,EAAE,WAAW,GAAG,SAAsC;CACjE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,0CACA,+FACA,gEACA,6EACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
//#region src/components/label.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Label — a plain `<label>`. Base UI's Label lives inside Field, so this is
|
|
7
|
+
* the standalone form caption for anything that is not a Field.
|
|
8
|
+
*/
|
|
9
|
+
declare const labelVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
10
|
+
export interface LabelProps extends React.ComponentProps<"label">, VariantProps<typeof labelVariants> {}
|
|
11
|
+
declare function Label({ className, ...props }: LabelProps): React.JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Label, labelVariants };
|
|
14
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
//#region src/components/label.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Label — a plain `<label>`. Base UI's Label lives inside Field, so this is
|
|
9
|
+
* the standalone form caption for anything that is not a Field.
|
|
10
|
+
*/
|
|
11
|
+
const labelVariants = /* @__PURE__ */ cva([
|
|
12
|
+
"inline-flex items-center gap-2 select-none",
|
|
13
|
+
"text-[length:var(--ds-text-body-sm)] font-medium leading-none",
|
|
14
|
+
"text-[color:var(--ds-foreground)]",
|
|
15
|
+
"peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
16
|
+
"group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-70"
|
|
17
|
+
]);
|
|
18
|
+
function Label({ className, ...props }) {
|
|
19
|
+
return /* @__PURE__ */ jsx("label", {
|
|
20
|
+
"data-slot": "label",
|
|
21
|
+
className: cn(labelVariants(), className),
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Label, labelVariants };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../src/components/label.tsx"],"sourcesContent":["\"use client\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { cn } from \"@/lib/cn\";\n\n/**\n * Label — a plain `<label>`. Base UI's Label lives inside Field, so this is\n * the standalone form caption for anything that is not a Field.\n */\nconst labelVariants = /* @__PURE__ */ cva([\n \"inline-flex items-center gap-2 select-none\",\n \"text-[length:var(--ds-text-body-sm)] font-medium leading-none\",\n \"text-[color:var(--ds-foreground)]\",\n \"peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n \"group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-70\",\n]);\n\nexport interface LabelProps\n extends React.ComponentProps<\"label\">, VariantProps<typeof labelVariants> {}\n\nfunction Label({ className, ...props }: LabelProps) {\n return <label data-slot=\"label\" className={cn(labelVariants(), className)} {...props} />;\n}\n\nexport { Label, labelVariants };\n"],"mappings":";;;;;;;;;;AAUA,MAAM,gBAAgC,oBAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAKD,SAAS,MAAM,EAAE,WAAW,GAAG,SAAqB;CAClD,OAAO,oBAAC,SAAD;EAAO,aAAU;EAAQ,WAAW,GAAG,cAAc,GAAG,SAAS;EAAG,GAAI;CAAQ,CAAA;AACzF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/components/loading-skeleton.d.ts
|
|
4
|
+
export type LoadingSkeletonPreset = "list" | "table" | "card" | "form";
|
|
5
|
+
export interface LoadingSkeletonProps extends React.ComponentProps<"div"> {
|
|
6
|
+
/** Which shape of content is loading. */
|
|
7
|
+
preset?: LoadingSkeletonPreset;
|
|
8
|
+
/** Rows (list, table, form) or cards. Each preset has a sensible default. */
|
|
9
|
+
rows?: number;
|
|
10
|
+
/** Columns for `table` and `card`. */
|
|
11
|
+
columns?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* LoadingSkeleton — page-level placeholders assembled from Skeleton, one per
|
|
15
|
+
* shape of content: a list of rows with an avatar, a table with a header row,
|
|
16
|
+
* a grid of cards, or a stacked form. Announces itself as busy so assistive
|
|
17
|
+
* technology knows the region is loading; the blocks themselves are hidden.
|
|
18
|
+
*/
|
|
19
|
+
declare function LoadingSkeleton({ className, preset, rows, columns, ...props }: LoadingSkeletonProps): React.JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { LoadingSkeleton };
|
|
22
|
+
//# sourceMappingURL=loading-skeleton.d.ts.map
|