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