@codefast/ui 0.3.11-canary.1 → 0.3.11
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/CHANGELOG.md +36 -0
- package/README.md +34 -14
- package/dist/components/accordion.d.ts +29 -10
- package/dist/components/accordion.js +38 -37
- package/dist/components/alert-dialog.d.ts +60 -24
- package/dist/components/alert-dialog.js +69 -72
- package/dist/components/alert.d.ts +27 -15
- package/dist/components/alert.js +29 -31
- package/dist/components/aspect-ratio.d.ts +8 -4
- package/dist/components/aspect-ratio.js +7 -5
- package/dist/components/avatar.d.ts +17 -6
- package/dist/components/avatar.js +19 -17
- package/dist/components/badge.d.ts +21 -14
- package/dist/components/badge.js +19 -22
- package/dist/components/breadcrumb.d.ts +35 -12
- package/dist/components/breadcrumb.js +48 -54
- package/dist/components/button-group.d.ts +29 -14
- package/dist/components/button-group.js +27 -32
- package/dist/components/button.d.ts +35 -25
- package/dist/components/button.js +50 -48
- package/dist/components/calendar.d.ts +24 -9
- package/dist/components/calendar.js +92 -98
- package/dist/components/card.d.ts +34 -10
- package/dist/components/card.js +39 -37
- package/dist/components/carousel.d.ts +55 -24
- package/dist/components/carousel.js +113 -130
- package/dist/components/chart.d.ts +72 -36
- package/dist/components/chart.js +154 -166
- package/dist/components/checkbox-cards.d.ts +15 -8
- package/dist/components/checkbox-cards.js +22 -25
- package/dist/components/checkbox-group.d.ts +16 -8
- package/dist/components/checkbox-group.js +19 -19
- package/dist/components/checkbox.d.ts +9 -4
- package/dist/components/checkbox.js +14 -14
- package/dist/components/collapsible.d.ts +14 -6
- package/dist/components/collapsible.js +18 -16
- package/dist/components/command.d.ts +55 -23
- package/dist/components/command.js +70 -85
- package/dist/components/context-menu.d.ts +72 -22
- package/dist/components/context-menu.js +88 -109
- package/dist/components/dialog.d.ts +53 -22
- package/dist/components/dialog.js +71 -85
- package/dist/components/drawer.d.ts +60 -28
- package/dist/components/drawer.js +59 -67
- package/dist/components/dropdown-menu.d.ts +73 -22
- package/dist/components/dropdown-menu.js +95 -112
- package/dist/components/empty.d.ts +37 -15
- package/dist/components/empty.js +43 -45
- package/dist/components/field.d.ts +63 -25
- package/dist/components/field.js +88 -104
- package/dist/components/form.d.ts +37 -15
- package/dist/components/form.js +65 -70
- package/dist/components/hover-card.d.ts +21 -7
- package/dist/components/hover-card.js +24 -24
- package/dist/components/input-group.d.ts +53 -28
- package/dist/components/input-group.js +63 -77
- package/dist/components/input-number.d.ts +28 -7
- package/dist/components/input-number.js +55 -59
- package/dist/components/input-otp.d.ts +24 -10
- package/dist/components/input-otp.js +33 -37
- package/dist/components/input-password.d.ts +12 -5
- package/dist/components/input-password.js +31 -32
- package/dist/components/input-search.d.ts +18 -8
- package/dist/components/input-search.js +43 -41
- package/dist/components/input.d.ts +10 -4
- package/dist/components/input.js +9 -7
- package/dist/components/item.d.ts +69 -32
- package/dist/components/item.js +89 -92
- package/dist/components/kbd.d.ts +13 -5
- package/dist/components/kbd.js +13 -11
- package/dist/components/label.d.ts +9 -4
- package/dist/components/label.js +9 -7
- package/dist/components/menubar.d.ts +80 -23
- package/dist/components/menubar.js +97 -118
- package/dist/components/native-select.d.ts +16 -6
- package/dist/components/native-select.js +25 -26
- package/dist/components/navigation-menu.d.ts +36 -12
- package/dist/components/navigation-menu.js +60 -75
- package/dist/components/pagination.d.ts +35 -14
- package/dist/components/pagination.js +54 -69
- package/dist/components/popover.d.ts +24 -8
- package/dist/components/popover.js +28 -28
- package/dist/components/progress-circle.d.ts +106 -88
- package/dist/components/progress-circle.js +106 -138
- package/dist/components/progress.d.ts +10 -4
- package/dist/components/progress.js +14 -14
- package/dist/components/radio-cards.d.ts +10 -4
- package/dist/components/radio-cards.js +22 -23
- package/dist/components/radio-group.d.ts +13 -5
- package/dist/components/radio-group.js +18 -16
- package/dist/components/radio.d.ts +12 -5
- package/dist/components/radio.js +10 -8
- package/dist/components/resizable.d.ts +18 -7
- package/dist/components/resizable.js +22 -22
- package/dist/components/scroll-area.d.ts +33 -20
- package/dist/components/scroll-area.js +84 -88
- package/dist/components/select.d.ts +50 -16
- package/dist/components/select.js +77 -96
- package/dist/components/separator.d.ts +29 -19
- package/dist/components/separator.js +36 -34
- package/dist/components/sheet.d.ts +62 -29
- package/dist/components/sheet.js +79 -100
- package/dist/components/sidebar.d.ts +160 -66
- package/dist/components/sidebar.js +294 -336
- package/dist/components/skeleton.d.ts +9 -4
- package/dist/components/skeleton.js +8 -6
- package/dist/components/slider.d.ts +13 -4
- package/dist/components/slider.js +34 -40
- package/dist/components/sonner.d.ts +10 -7
- package/dist/components/sonner.js +16 -14
- package/dist/components/spinner.d.ts +12 -5
- package/dist/components/spinner.js +33 -35
- package/dist/components/switch.d.ts +9 -4
- package/dist/components/switch.js +13 -11
- package/dist/components/table.d.ts +37 -11
- package/dist/components/table.js +47 -45
- package/dist/components/tabs.d.ts +21 -7
- package/dist/components/tabs.js +24 -22
- package/dist/components/textarea.d.ts +9 -4
- package/dist/components/textarea.js +8 -6
- package/dist/components/toggle-group.d.ts +24 -9
- package/dist/components/toggle-group.js +41 -42
- package/dist/components/toggle.d.ts +25 -17
- package/dist/components/toggle.js +30 -28
- package/dist/components/tooltip.d.ts +24 -8
- package/dist/components/tooltip.js +29 -32
- package/dist/hooks/use-animated-value.d.ts +4 -1
- package/dist/hooks/use-animated-value.js +57 -36
- package/dist/hooks/use-copy-to-clipboard.d.ts +11 -5
- package/dist/hooks/use-copy-to-clipboard.js +39 -20
- package/dist/hooks/use-is-mobile.d.ts +4 -1
- package/dist/hooks/use-is-mobile.js +21 -1
- package/dist/hooks/use-media-query.d.ts +4 -1
- package/dist/hooks/use-media-query.js +45 -18
- package/dist/hooks/use-mutation-observer.d.ts +6 -2
- package/dist/hooks/use-mutation-observer.js +34 -16
- package/dist/hooks/use-pagination.d.ts +22 -14
- package/dist/hooks/use-pagination.js +100 -49
- package/dist/index.d.ts +69 -130
- package/dist/index.js +11 -11
- package/dist/primitives/checkbox-group.d.ts +105 -83
- package/dist/primitives/checkbox-group.js +111 -84
- package/dist/primitives/input-number.d.ts +51 -40
- package/dist/primitives/input-number.js +483 -350
- package/dist/primitives/input.d.ts +48 -42
- package/dist/primitives/input.js +65 -43
- package/dist/primitives/progress-circle.d.ts +79 -48
- package/dist/primitives/progress-circle.js +154 -105
- package/package.json +6 -7
package/dist/components/empty.js
CHANGED
|
@@ -1,61 +1,59 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cn, tv } from "@codefast/tailwind-variants";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/empty.tsx
|
|
3
4
|
const emptyMediaVariants = tv({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
default: "bg-transparent",
|
|
11
|
-
icon: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
5
|
+
base: "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
6
|
+
defaultVariants: { variant: "default" },
|
|
7
|
+
variants: { variant: {
|
|
8
|
+
default: "bg-transparent",
|
|
9
|
+
icon: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg:not([class*='size-'])]:size-6"
|
|
10
|
+
} }
|
|
14
11
|
});
|
|
15
12
|
function Empty({ className, ...props }) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: cn("flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-xl border-dashed p-6 text-center text-balance md:p-12", className),
|
|
15
|
+
"data-slot": "empty",
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
21
18
|
}
|
|
22
19
|
function EmptyHeader({ className, ...props }) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
return /* @__PURE__ */ jsx("div", {
|
|
21
|
+
className: cn("flex max-w-sm flex-col items-center gap-2 text-center", className),
|
|
22
|
+
"data-slot": "empty-header",
|
|
23
|
+
...props
|
|
24
|
+
});
|
|
28
25
|
}
|
|
29
26
|
function EmptyMedia({ className, variant = "default", ...props }) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
return /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: emptyMediaVariants({
|
|
29
|
+
className,
|
|
30
|
+
variant
|
|
31
|
+
}),
|
|
32
|
+
"data-slot": "empty-icon",
|
|
33
|
+
"data-variant": variant,
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
39
36
|
}
|
|
40
37
|
function EmptyTitle({ className, ...props }) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: cn("text-lg font-medium tracking-tight", className),
|
|
40
|
+
"data-slot": "empty-title",
|
|
41
|
+
...props
|
|
42
|
+
});
|
|
46
43
|
}
|
|
47
44
|
function EmptyDescription({ className, ...props }) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
return /* @__PURE__ */ jsx("p", {
|
|
46
|
+
className: cn("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
47
|
+
"data-slot": "empty-description",
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
53
50
|
}
|
|
54
51
|
function EmptyContent({ className, ...props }) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
className: cn("flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance", className),
|
|
54
|
+
"data-slot": "empty-content",
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
60
57
|
}
|
|
58
|
+
//#endregion
|
|
61
59
|
export { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, emptyMediaVariants };
|
|
@@ -1,41 +1,79 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { Label } from "./label.js";
|
|
2
|
+
import * as _$_codefast_tailwind_variants0 from "@codefast/tailwind-variants";
|
|
3
|
+
import { VariantProps } from "@codefast/tailwind-variants";
|
|
4
|
+
import { ComponentProps, JSX } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/field.d.ts
|
|
7
|
+
declare const fieldVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
8
|
+
orientation: {
|
|
9
|
+
horizontal: string;
|
|
10
|
+
responsive: string;
|
|
11
|
+
vertical: string;
|
|
12
|
+
};
|
|
10
13
|
}, Record<string, never>>;
|
|
11
14
|
type FieldSetProps = ComponentProps<"fieldset">;
|
|
12
|
-
declare function FieldSet({
|
|
15
|
+
declare function FieldSet({
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: FieldSetProps): JSX.Element;
|
|
13
19
|
type FieldLegendProps = ComponentProps<"legend"> & {
|
|
14
|
-
|
|
20
|
+
variant?: "label" | "legend";
|
|
15
21
|
};
|
|
16
|
-
declare function FieldLegend({
|
|
22
|
+
declare function FieldLegend({
|
|
23
|
+
className,
|
|
24
|
+
variant,
|
|
25
|
+
...props
|
|
26
|
+
}: FieldLegendProps): JSX.Element;
|
|
17
27
|
type FieldGroupProps = ComponentProps<"div">;
|
|
18
|
-
declare function FieldGroup({
|
|
28
|
+
declare function FieldGroup({
|
|
29
|
+
className,
|
|
30
|
+
...props
|
|
31
|
+
}: FieldGroupProps): JSX.Element;
|
|
19
32
|
type FieldProps = ComponentProps<"div"> & VariantProps<typeof fieldVariants>;
|
|
20
|
-
declare function Field({
|
|
33
|
+
declare function Field({
|
|
34
|
+
className,
|
|
35
|
+
orientation,
|
|
36
|
+
...props
|
|
37
|
+
}: FieldProps): JSX.Element;
|
|
21
38
|
type FieldContentProps = ComponentProps<"div">;
|
|
22
|
-
declare function FieldContent({
|
|
39
|
+
declare function FieldContent({
|
|
40
|
+
className,
|
|
41
|
+
...props
|
|
42
|
+
}: FieldContentProps): JSX.Element;
|
|
23
43
|
type FieldLabelProps = ComponentProps<typeof Label>;
|
|
24
|
-
declare function FieldLabel({
|
|
44
|
+
declare function FieldLabel({
|
|
45
|
+
className,
|
|
46
|
+
...props
|
|
47
|
+
}: FieldLabelProps): JSX.Element;
|
|
25
48
|
type FieldTitleProps = ComponentProps<"div">;
|
|
26
|
-
declare function FieldTitle({
|
|
49
|
+
declare function FieldTitle({
|
|
50
|
+
className,
|
|
51
|
+
...props
|
|
52
|
+
}: FieldTitleProps): JSX.Element;
|
|
27
53
|
type FieldDescriptionProps = ComponentProps<"p">;
|
|
28
|
-
declare function FieldDescription({
|
|
54
|
+
declare function FieldDescription({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}: FieldDescriptionProps): JSX.Element;
|
|
29
58
|
type FieldSeparatorProps = ComponentProps<"div"> & {
|
|
30
|
-
|
|
59
|
+
children?: ComponentProps<"span">["children"];
|
|
31
60
|
};
|
|
32
|
-
declare function FieldSeparator({
|
|
61
|
+
declare function FieldSeparator({
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: FieldSeparatorProps): JSX.Element;
|
|
33
66
|
interface FieldErrorMessage {
|
|
34
|
-
|
|
67
|
+
message?: string;
|
|
35
68
|
}
|
|
36
69
|
interface FieldErrorProps extends ComponentProps<"div"> {
|
|
37
|
-
|
|
70
|
+
errors?: (FieldErrorMessage | undefined)[];
|
|
38
71
|
}
|
|
39
|
-
declare function FieldError({
|
|
40
|
-
|
|
41
|
-
|
|
72
|
+
declare function FieldError({
|
|
73
|
+
children,
|
|
74
|
+
className,
|
|
75
|
+
errors,
|
|
76
|
+
...props
|
|
77
|
+
}: FieldErrorProps): JSX.Element | null;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { Field, FieldContent, type FieldContentProps, FieldDescription, type FieldDescriptionProps, FieldError, type FieldErrorProps, FieldGroup, type FieldGroupProps, FieldLabel, type FieldLabelProps, FieldLegend, type FieldLegendProps, type FieldProps, FieldSeparator, type FieldSeparatorProps, FieldSet, type FieldSetProps, FieldTitle, type FieldTitleProps, fieldVariants };
|
package/dist/components/field.js
CHANGED
|
@@ -1,130 +1,114 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { Separator } from "./separator.js";
|
|
3
|
+
import { Label } from "./label.js";
|
|
3
4
|
import { cn, tv } from "@codefast/tailwind-variants";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
6
|
import { useMemo } from "react";
|
|
5
|
-
|
|
6
|
-
import { Separator } from "./separator.js";
|
|
7
|
+
//#region src/components/field.tsx
|
|
7
8
|
const fieldVariants = tv({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
responsive: cn("flex-col [&>*]:w-full [&>.sr-only]:w-auto", "@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto", "@md/field-group:[&>[data-slot=field-label]]:flex-auto", "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"),
|
|
16
|
-
vertical: "flex-col [&>*]:w-full [&>.sr-only]:w-auto"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
base: "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
10
|
+
defaultVariants: { orientation: "vertical" },
|
|
11
|
+
variants: { orientation: {
|
|
12
|
+
horizontal: cn("flex-row items-center", "[&>[data-slot=field-label]]:flex-auto", "has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"),
|
|
13
|
+
responsive: cn("flex-col [&>*]:w-full [&>.sr-only]:w-auto", "@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto", "@md/field-group:[&>[data-slot=field-label]]:flex-auto", "@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"),
|
|
14
|
+
vertical: "flex-col [&>*]:w-full [&>.sr-only]:w-auto"
|
|
15
|
+
} }
|
|
19
16
|
});
|
|
20
17
|
function FieldSet({ className, ...props }) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
return /* @__PURE__ */ jsx("fieldset", {
|
|
19
|
+
className: cn("flex flex-col gap-6", "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className),
|
|
20
|
+
"data-slot": "field-set",
|
|
21
|
+
...props
|
|
22
|
+
});
|
|
26
23
|
}
|
|
27
24
|
function FieldLegend({ className, variant = "legend", ...props }) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
return /* @__PURE__ */ jsx("legend", {
|
|
26
|
+
className: cn("mb-3 text-base font-medium", "data-[variant=label]:text-sm", className),
|
|
27
|
+
"data-slot": "field-legend",
|
|
28
|
+
"data-variant": variant,
|
|
29
|
+
...props
|
|
30
|
+
});
|
|
34
31
|
}
|
|
35
32
|
function FieldGroup({ className, ...props }) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
return /* @__PURE__ */ jsx("div", {
|
|
34
|
+
className: cn("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4", className),
|
|
35
|
+
"data-slot": "field-group",
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
41
38
|
}
|
|
42
39
|
function Field({ className, orientation = "vertical", ...props }) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
return /* @__PURE__ */ jsx("div", {
|
|
41
|
+
className: fieldVariants({
|
|
42
|
+
className,
|
|
43
|
+
orientation
|
|
44
|
+
}),
|
|
45
|
+
"data-orientation": orientation,
|
|
46
|
+
"data-slot": "field",
|
|
47
|
+
role: "group",
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
53
50
|
}
|
|
54
51
|
function FieldContent({ className, ...props }) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
className: cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className),
|
|
54
|
+
"data-slot": "field-content",
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
60
57
|
}
|
|
61
58
|
function FieldLabel({ className, ...props }) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
60
|
+
className: cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50", "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4", "has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10", className),
|
|
61
|
+
"data-slot": "field-label",
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
67
64
|
}
|
|
68
65
|
function FieldTitle({ className, ...props }) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
return /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: cn("flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50", className),
|
|
68
|
+
"data-slot": "field-label",
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
74
71
|
}
|
|
75
72
|
function FieldDescription({ className, ...props }) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
return /* @__PURE__ */ jsx("p", {
|
|
74
|
+
className: cn("text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance", "last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5", "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
75
|
+
"data-slot": "field-description",
|
|
76
|
+
...props
|
|
77
|
+
});
|
|
81
78
|
}
|
|
82
79
|
function FieldSeparator({ children, className, ...props }) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"data-slot": "field-separator-content",
|
|
96
|
-
children: children
|
|
97
|
-
}) : null
|
|
98
|
-
]
|
|
99
|
-
});
|
|
80
|
+
const hasContent = Boolean(children);
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
className: cn("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2", className),
|
|
83
|
+
"data-content": hasContent,
|
|
84
|
+
"data-slot": "field-separator",
|
|
85
|
+
...props,
|
|
86
|
+
children: [/* @__PURE__ */ jsx(Separator, { className: "absolute inset-0 top-1/2" }), hasContent ? /* @__PURE__ */ jsx("span", {
|
|
87
|
+
className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
|
|
88
|
+
"data-slot": "field-separator-content",
|
|
89
|
+
children
|
|
90
|
+
}) : null]
|
|
91
|
+
});
|
|
100
92
|
}
|
|
101
93
|
function FieldError({ children, className, errors, ...props }) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const content = children ?? fallbackContent;
|
|
121
|
-
if (null == content || false === content) return null;
|
|
122
|
-
return /*#__PURE__*/ jsx("div", {
|
|
123
|
-
className: cn("text-sm font-normal text-destructive", className),
|
|
124
|
-
"data-slot": "field-error",
|
|
125
|
-
role: "alert",
|
|
126
|
-
...props,
|
|
127
|
-
children: content
|
|
128
|
-
});
|
|
94
|
+
const fallbackContent = useMemo(() => {
|
|
95
|
+
if (!errors?.length) return null;
|
|
96
|
+
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
|
|
97
|
+
if (uniqueErrors.length === 1) return uniqueErrors[0]?.message ?? null;
|
|
98
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
99
|
+
className: "ml-4 flex list-disc flex-col gap-1",
|
|
100
|
+
children: uniqueErrors.map((error) => error?.message ? /* @__PURE__ */ jsx("li", { children: error.message }, error.message) : null)
|
|
101
|
+
});
|
|
102
|
+
}, [errors]);
|
|
103
|
+
const content = children ?? fallbackContent;
|
|
104
|
+
if (content === null || content === void 0 || content === false) return null;
|
|
105
|
+
return /* @__PURE__ */ jsx("div", {
|
|
106
|
+
className: cn("text-sm font-normal text-destructive", className),
|
|
107
|
+
"data-slot": "field-error",
|
|
108
|
+
role: "alert",
|
|
109
|
+
...props,
|
|
110
|
+
children: content
|
|
111
|
+
});
|
|
129
112
|
}
|
|
113
|
+
//#endregion
|
|
130
114
|
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, fieldVariants };
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
import type { Scope } from "@radix-ui/react-context";
|
|
2
|
-
import type * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
-
import type { ComponentProps, JSX, ReactNode } from "react";
|
|
4
|
-
import type { ControllerProps, FieldPath, FieldValues } from "react-hook-form";
|
|
5
1
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
-
import {
|
|
2
|
+
import { ComponentProps, JSX, ReactNode } from "react";
|
|
3
|
+
import * as _$_radix_ui_react_context0 from "@radix-ui/react-context";
|
|
4
|
+
import { Scope } from "@radix-ui/react-context";
|
|
5
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
6
|
+
import * as _$react_hook_form0 from "react-hook-form";
|
|
7
|
+
import { ControllerProps, FieldPath, FieldValues, FormProvider } from "react-hook-form";
|
|
8
|
+
|
|
9
|
+
//#region src/components/form.d.ts
|
|
7
10
|
type FormProps = ComponentProps<typeof FormProvider>;
|
|
8
|
-
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props:
|
|
11
|
+
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: _$react_hook_form0.FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
9
12
|
type ScopedProps<P> = P & {
|
|
10
|
-
|
|
13
|
+
__scopeFormField?: Scope;
|
|
11
14
|
};
|
|
12
|
-
declare const createFormFieldScope:
|
|
15
|
+
declare const createFormFieldScope: _$_radix_ui_react_context0.CreateScope;
|
|
13
16
|
type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = ControllerProps<TFieldValues, TName>;
|
|
14
17
|
declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(formFieldProps: ScopedProps<FormFieldProps<TFieldValues, TName>>): JSX.Element;
|
|
15
18
|
type FormItemProps = ComponentProps<"div">;
|
|
16
|
-
declare function FormItem({
|
|
19
|
+
declare function FormItem({
|
|
20
|
+
__scopeFormField,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: ScopedProps<FormItemProps>): JSX.Element;
|
|
17
24
|
type FormLabelProps = ComponentProps<typeof LabelPrimitive.Root>;
|
|
18
|
-
declare function FormLabel({
|
|
25
|
+
declare function FormLabel({
|
|
26
|
+
__scopeFormField,
|
|
27
|
+
...props
|
|
28
|
+
}: ScopedProps<FormLabelProps>): JSX.Element;
|
|
19
29
|
type FormControlProps = ComponentProps<typeof Slot>;
|
|
20
|
-
declare function FormControl({
|
|
30
|
+
declare function FormControl({
|
|
31
|
+
__scopeFormField,
|
|
32
|
+
...props
|
|
33
|
+
}: ScopedProps<FormControlProps>): JSX.Element;
|
|
21
34
|
type FormDescriptionProps = ComponentProps<"p">;
|
|
22
|
-
declare function FormDescription({
|
|
35
|
+
declare function FormDescription({
|
|
36
|
+
__scopeFormField,
|
|
37
|
+
className,
|
|
38
|
+
...props
|
|
39
|
+
}: ScopedProps<FormDescriptionProps>): JSX.Element;
|
|
23
40
|
type FormMessageProps = ComponentProps<"p">;
|
|
24
|
-
declare function FormMessage({
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
declare function FormMessage({
|
|
42
|
+
__scopeFormField,
|
|
43
|
+
children,
|
|
44
|
+
className,
|
|
45
|
+
...props
|
|
46
|
+
}: ScopedProps<FormMessageProps>): ReactNode;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { Form, FormControl, type FormControlProps, FormDescription, type FormDescriptionProps, FormField, type FormFieldProps, FormItem, type FormItemProps, FormLabel, type FormLabelProps, FormMessage, type FormMessageProps, type FormProps, createFormFieldScope };
|