@codefast/ui 0.3.10 → 0.3.11-canary.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/CHANGELOG.md +19 -0
- package/README.md +277 -167
- package/dist/components/accordion.cjs +5 -5
- package/dist/components/accordion.d.ts +4 -4
- package/dist/components/accordion.js +5 -5
- package/dist/components/alert-dialog.cjs +9 -9
- package/dist/components/alert-dialog.d.ts +11 -11
- package/dist/components/alert-dialog.js +9 -9
- package/dist/components/alert.cjs +5 -5
- package/dist/components/alert.d.ts +5 -5
- package/dist/components/alert.js +5 -5
- package/dist/components/aspect-ratio.d.ts +2 -2
- package/dist/components/avatar.cjs +3 -3
- package/dist/components/avatar.d.ts +2 -2
- package/dist/components/avatar.js +3 -3
- package/dist/components/badge.cjs +7 -7
- package/dist/components/badge.d.ts +3 -3
- package/dist/components/badge.js +7 -7
- package/dist/components/breadcrumb.cjs +6 -8
- package/dist/components/breadcrumb.d.ts +8 -8
- package/dist/components/breadcrumb.js +6 -8
- package/dist/components/button-group.cjs +8 -8
- package/dist/components/button-group.d.ts +5 -5
- package/dist/components/button-group.js +8 -8
- package/dist/components/button.cjs +17 -17
- package/dist/components/button.d.ts +6 -6
- package/dist/components/button.js +17 -17
- package/dist/components/calendar.cjs +35 -35
- package/dist/components/calendar.d.ts +5 -5
- package/dist/components/calendar.js +35 -35
- package/dist/components/card.cjs +7 -7
- package/dist/components/card.d.ts +8 -8
- package/dist/components/card.js +7 -7
- package/dist/components/carousel.cjs +20 -20
- package/dist/components/carousel.d.ts +10 -10
- package/dist/components/carousel.js +20 -20
- package/dist/components/chart.cjs +42 -42
- package/dist/components/chart.d.ts +12 -11
- package/dist/components/chart.js +42 -42
- package/dist/components/checkbox-cards.cjs +2 -2
- package/dist/components/checkbox-cards.d.ts +2 -2
- package/dist/components/checkbox-cards.js +2 -2
- package/dist/components/checkbox-group.cjs +2 -2
- package/dist/components/checkbox-group.d.ts +2 -2
- package/dist/components/checkbox-group.js +2 -2
- package/dist/components/checkbox.cjs +1 -1
- package/dist/components/checkbox.d.ts +2 -2
- package/dist/components/checkbox.js +1 -1
- package/dist/components/collapsible.d.ts +2 -2
- package/dist/components/command.cjs +10 -10
- package/dist/components/command.d.ts +4 -4
- package/dist/components/command.js +10 -10
- package/dist/components/context-menu.cjs +10 -10
- package/dist/components/context-menu.d.ts +4 -4
- package/dist/components/context-menu.js +10 -10
- package/dist/components/dialog.cjs +12 -12
- package/dist/components/dialog.d.ts +10 -10
- package/dist/components/dialog.js +12 -12
- package/dist/components/drawer.cjs +9 -9
- package/dist/components/drawer.d.ts +9 -9
- package/dist/components/drawer.js +9 -9
- package/dist/components/dropdown-menu.cjs +10 -10
- package/dist/components/dropdown-menu.d.ts +4 -4
- package/dist/components/dropdown-menu.js +10 -10
- package/dist/components/empty.cjs +10 -10
- package/dist/components/empty.d.ts +9 -9
- package/dist/components/empty.js +10 -10
- package/dist/components/field.cjs +17 -17
- package/dist/components/field.d.ts +14 -14
- package/dist/components/field.js +17 -17
- package/dist/components/form.cjs +8 -8
- package/dist/components/form.d.ts +10 -10
- package/dist/components/form.js +8 -8
- package/dist/components/hover-card.cjs +3 -3
- package/dist/components/hover-card.d.ts +2 -2
- package/dist/components/hover-card.js +3 -3
- package/dist/components/input-group.cjs +20 -20
- package/dist/components/input-group.d.ts +15 -15
- package/dist/components/input-group.js +20 -20
- package/dist/components/input-number.cjs +7 -7
- package/dist/components/input-number.d.ts +2 -2
- package/dist/components/input-number.js +7 -7
- package/dist/components/input-otp.cjs +4 -4
- package/dist/components/input-otp.d.ts +6 -6
- package/dist/components/input-otp.js +4 -4
- package/dist/components/input-password.cjs +6 -6
- package/dist/components/input-password.d.ts +3 -3
- package/dist/components/input-password.js +6 -6
- package/dist/components/input-search.cjs +4 -4
- package/dist/components/input-search.d.ts +3 -3
- package/dist/components/input-search.js +4 -4
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +1 -1
- package/dist/components/item.cjs +23 -23
- package/dist/components/item.d.ts +12 -12
- package/dist/components/item.js +23 -23
- package/dist/components/kbd.cjs +2 -2
- package/dist/components/kbd.d.ts +3 -3
- package/dist/components/kbd.js +2 -2
- package/dist/components/label.cjs +1 -1
- package/dist/components/label.d.ts +2 -2
- package/dist/components/label.js +1 -1
- package/dist/components/menubar.cjs +13 -13
- package/dist/components/menubar.d.ts +4 -4
- package/dist/components/menubar.js +13 -13
- package/dist/components/native-select.cjs +2 -2
- package/dist/components/native-select.d.ts +4 -4
- package/dist/components/native-select.js +2 -2
- package/dist/components/navigation-menu.cjs +10 -10
- package/dist/components/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu.js +10 -10
- package/dist/components/pagination.cjs +6 -6
- package/dist/components/pagination.d.ts +10 -10
- package/dist/components/pagination.js +6 -6
- package/dist/components/popover.cjs +3 -3
- package/dist/components/popover.d.ts +3 -3
- package/dist/components/popover.js +3 -3
- package/dist/components/progress-circle.cjs +22 -22
- package/dist/components/progress-circle.d.ts +5 -5
- package/dist/components/progress-circle.js +22 -22
- package/dist/components/progress.cjs +2 -2
- package/dist/components/progress.d.ts +2 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-cards.cjs +3 -3
- package/dist/components/radio-cards.d.ts +2 -2
- package/dist/components/radio-cards.js +3 -3
- package/dist/components/radio-group.cjs +3 -3
- package/dist/components/radio-group.d.ts +2 -2
- package/dist/components/radio-group.js +3 -3
- package/dist/components/radio.cjs +1 -1
- package/dist/components/radio.d.ts +2 -2
- package/dist/components/radio.js +1 -1
- package/dist/components/resizable.cjs +3 -3
- package/dist/components/resizable.d.ts +2 -2
- package/dist/components/resizable.js +3 -3
- package/dist/components/scroll-area.cjs +31 -31
- package/dist/components/scroll-area.d.ts +5 -5
- package/dist/components/scroll-area.js +31 -31
- package/dist/components/select.cjs +9 -9
- package/dist/components/select.d.ts +5 -5
- package/dist/components/select.js +9 -9
- package/dist/components/separator.cjs +9 -9
- package/dist/components/separator.d.ts +5 -5
- package/dist/components/separator.js +9 -9
- package/dist/components/sheet.cjs +17 -17
- package/dist/components/sheet.d.ts +9 -9
- package/dist/components/sheet.js +17 -17
- package/dist/components/sidebar.cjs +65 -65
- package/dist/components/sidebar.d.ts +31 -31
- package/dist/components/sidebar.js +65 -65
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.d.ts +2 -2
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.cjs +4 -4
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +4 -4
- package/dist/components/sonner.cjs +4 -4
- package/dist/components/sonner.d.ts +3 -3
- package/dist/components/sonner.js +4 -4
- package/dist/components/spinner.cjs +5 -5
- package/dist/components/spinner.d.ts +2 -2
- package/dist/components/spinner.js +5 -5
- package/dist/components/switch.cjs +2 -2
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.cjs +8 -8
- package/dist/components/table.d.ts +9 -9
- package/dist/components/table.js +8 -8
- package/dist/components/tabs.cjs +4 -4
- package/dist/components/tabs.d.ts +2 -2
- package/dist/components/tabs.js +4 -4
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.d.ts +2 -2
- package/dist/components/textarea.js +1 -1
- package/dist/components/toggle-group.cjs +5 -5
- package/dist/components/toggle-group.d.ts +4 -4
- package/dist/components/toggle-group.js +5 -5
- package/dist/components/toggle.cjs +8 -8
- package/dist/components/toggle.d.ts +3 -3
- package/dist/components/toggle.js +8 -8
- package/dist/components/tooltip.cjs +2 -2
- package/dist/components/tooltip.d.ts +3 -3
- package/dist/components/tooltip.js +2 -2
- package/dist/css/preset.css +4 -4
- package/dist/css/style.css +3 -3
- package/dist/hooks/use-copy-to-clipboard.cjs +1 -1
- package/dist/hooks/use-copy-to-clipboard.d.ts +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-media-query.cjs +3 -3
- package/dist/hooks/use-media-query.js +3 -3
- package/dist/hooks/use-mutation-observer.d.ts +1 -1
- package/dist/hooks/use-pagination.cjs +1 -1
- package/dist/hooks/use-pagination.js +1 -1
- package/dist/index.d.ts +130 -130
- package/dist/primitives/checkbox-group.cjs +3 -3
- package/dist/primitives/checkbox-group.d.ts +11 -11
- package/dist/primitives/checkbox-group.js +3 -3
- package/dist/primitives/input-number.cjs +46 -46
- package/dist/primitives/input-number.d.ts +8 -8
- package/dist/primitives/input-number.js +46 -46
- package/dist/primitives/input.cjs +7 -7
- package/dist/primitives/input.d.ts +4 -4
- package/dist/primitives/input.js +7 -7
- package/dist/primitives/progress-circle.cjs +8 -8
- package/dist/primitives/progress-circle.d.ts +7 -7
- package/dist/primitives/progress-circle.js +8 -8
- package/package.json +38 -42
package/dist/components/field.js
CHANGED
|
@@ -5,28 +5,28 @@ import { useMemo } from "react";
|
|
|
5
5
|
import { Label } from "./label.js";
|
|
6
6
|
import { Separator } from "./separator.js";
|
|
7
7
|
const fieldVariants = tv({
|
|
8
|
-
base:
|
|
8
|
+
base: "group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
9
9
|
defaultVariants: {
|
|
10
|
-
orientation:
|
|
10
|
+
orientation: "vertical"
|
|
11
11
|
},
|
|
12
12
|
variants: {
|
|
13
13
|
orientation: {
|
|
14
|
-
horizontal: cn(
|
|
15
|
-
responsive: cn(
|
|
16
|
-
vertical:
|
|
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
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
function FieldSet({ className, ...props }) {
|
|
21
21
|
return /*#__PURE__*/ jsx("fieldset", {
|
|
22
|
-
className: cn(
|
|
22
|
+
className: cn("flex flex-col gap-6", "has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3", className),
|
|
23
23
|
"data-slot": "field-set",
|
|
24
24
|
...props
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
function FieldLegend({ className, variant =
|
|
27
|
+
function FieldLegend({ className, variant = "legend", ...props }) {
|
|
28
28
|
return /*#__PURE__*/ jsx("legend", {
|
|
29
|
-
className: cn(
|
|
29
|
+
className: cn("mb-3 text-base font-medium", "data-[variant=label]:text-sm", className),
|
|
30
30
|
"data-slot": "field-legend",
|
|
31
31
|
"data-variant": variant,
|
|
32
32
|
...props
|
|
@@ -34,12 +34,12 @@ function FieldLegend({ className, variant = 'legend', ...props }) {
|
|
|
34
34
|
}
|
|
35
35
|
function FieldGroup({ className, ...props }) {
|
|
36
36
|
return /*#__PURE__*/ jsx("div", {
|
|
37
|
-
className: cn(
|
|
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
38
|
"data-slot": "field-group",
|
|
39
39
|
...props
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function Field({ className, orientation =
|
|
42
|
+
function Field({ className, orientation = "vertical", ...props }) {
|
|
43
43
|
return /*#__PURE__*/ jsx("div", {
|
|
44
44
|
className: fieldVariants({
|
|
45
45
|
className,
|
|
@@ -53,28 +53,28 @@ function Field({ className, orientation = 'vertical', ...props }) {
|
|
|
53
53
|
}
|
|
54
54
|
function FieldContent({ className, ...props }) {
|
|
55
55
|
return /*#__PURE__*/ jsx("div", {
|
|
56
|
-
className: cn(
|
|
56
|
+
className: cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className),
|
|
57
57
|
"data-slot": "field-content",
|
|
58
58
|
...props
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
function FieldLabel({ className, ...props }) {
|
|
62
62
|
return /*#__PURE__*/ jsx(Label, {
|
|
63
|
-
className: cn(
|
|
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
64
|
"data-slot": "field-label",
|
|
65
65
|
...props
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
function FieldTitle({ className, ...props }) {
|
|
69
69
|
return /*#__PURE__*/ jsx("div", {
|
|
70
|
-
className: cn(
|
|
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
71
|
"data-slot": "field-label",
|
|
72
72
|
...props
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
function FieldDescription({ className, ...props }) {
|
|
76
76
|
return /*#__PURE__*/ jsx("p", {
|
|
77
|
-
className: cn(
|
|
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
78
|
"data-slot": "field-description",
|
|
79
79
|
...props
|
|
80
80
|
});
|
|
@@ -82,7 +82,7 @@ function FieldDescription({ className, ...props }) {
|
|
|
82
82
|
function FieldSeparator({ children, className, ...props }) {
|
|
83
83
|
const hasContent = Boolean(children);
|
|
84
84
|
return /*#__PURE__*/ jsxs("div", {
|
|
85
|
-
className: cn(
|
|
85
|
+
className: cn("relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2", className),
|
|
86
86
|
"data-content": hasContent,
|
|
87
87
|
"data-slot": "field-separator",
|
|
88
88
|
...props,
|
|
@@ -91,7 +91,7 @@ function FieldSeparator({ children, className, ...props }) {
|
|
|
91
91
|
className: "absolute inset-0 top-1/2"
|
|
92
92
|
}),
|
|
93
93
|
hasContent ? /*#__PURE__*/ jsx("span", {
|
|
94
|
-
className: "
|
|
94
|
+
className: "relative mx-auto block w-fit bg-background px-2 text-muted-foreground",
|
|
95
95
|
"data-slot": "field-separator-content",
|
|
96
96
|
children: children
|
|
97
97
|
}) : null
|
|
@@ -120,7 +120,7 @@ function FieldError({ children, className, errors, ...props }) {
|
|
|
120
120
|
const content = children ?? fallbackContent;
|
|
121
121
|
if (null == content || false === content) return null;
|
|
122
122
|
return /*#__PURE__*/ jsx("div", {
|
|
123
|
-
className: cn(
|
|
123
|
+
className: cn("text-sm font-normal text-destructive", className),
|
|
124
124
|
"data-slot": "field-error",
|
|
125
125
|
role: "alert",
|
|
126
126
|
...props,
|
package/dist/components/form.cjs
CHANGED
|
@@ -42,7 +42,7 @@ const external_react_namespaceObject = require("react");
|
|
|
42
42
|
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
43
43
|
const external_label_cjs_namespaceObject = require("./label.cjs");
|
|
44
44
|
const Form = external_react_hook_form_namespaceObject.FormProvider;
|
|
45
|
-
const FORM_FIELD_NAME =
|
|
45
|
+
const FORM_FIELD_NAME = "FormField";
|
|
46
46
|
const [createFormFieldContext, createFormFieldScope] = (0, react_context_namespaceObject.createContextScope)(FORM_FIELD_NAME);
|
|
47
47
|
const [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext(FORM_FIELD_NAME);
|
|
48
48
|
function useFormItem(consumerName, scope) {
|
|
@@ -72,7 +72,7 @@ function FormField(formFieldProps) {
|
|
|
72
72
|
})
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
const FORM_ITEM_NAME =
|
|
75
|
+
const FORM_ITEM_NAME = "FormItem";
|
|
76
76
|
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext(FORM_ITEM_NAME);
|
|
77
77
|
function FormItem({ __scopeFormField, className, ...props }) {
|
|
78
78
|
const id = (0, external_react_namespaceObject.useId)();
|
|
@@ -80,13 +80,13 @@ function FormItem({ __scopeFormField, className, ...props }) {
|
|
|
80
80
|
id: id,
|
|
81
81
|
scope: __scopeFormField,
|
|
82
82
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
83
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
83
|
+
className: (0, tailwind_variants_namespaceObject.cn)("grid gap-2", className),
|
|
84
84
|
"data-slot": "form-item",
|
|
85
85
|
...props
|
|
86
86
|
})
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
const FORM_LABEL_NAME =
|
|
89
|
+
const FORM_LABEL_NAME = "FormLabel";
|
|
90
90
|
function FormLabel({ __scopeFormField, ...props }) {
|
|
91
91
|
const { error, formItemId } = useFormItem(FORM_LABEL_NAME, __scopeFormField);
|
|
92
92
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_label_cjs_namespaceObject.Label, {
|
|
@@ -96,7 +96,7 @@ function FormLabel({ __scopeFormField, ...props }) {
|
|
|
96
96
|
...props
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
const FORM_CONTROL_NAME =
|
|
99
|
+
const FORM_CONTROL_NAME = "FormControl";
|
|
100
100
|
function FormControl({ __scopeFormField, ...props }) {
|
|
101
101
|
const { error, formDescriptionId, formItemId, formMessageId } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);
|
|
102
102
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_slot_namespaceObject.Slot, {
|
|
@@ -110,19 +110,19 @@ function FormControl({ __scopeFormField, ...props }) {
|
|
|
110
110
|
function FormDescription({ __scopeFormField, className, ...props }) {
|
|
111
111
|
const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
112
112
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
113
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
113
|
+
className: (0, tailwind_variants_namespaceObject.cn)("text-xs text-muted-foreground", className),
|
|
114
114
|
"data-slot": "form-description",
|
|
115
115
|
id: formDescriptionId,
|
|
116
116
|
...props
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
const FORM_MESSAGE_NAME =
|
|
119
|
+
const FORM_MESSAGE_NAME = "FormMessage";
|
|
120
120
|
function FormMessage({ __scopeFormField, children, className, ...props }) {
|
|
121
121
|
const { error, formMessageId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
122
122
|
const body = error?.message ?? children;
|
|
123
123
|
if (!body) return null;
|
|
124
124
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
125
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
125
|
+
className: (0, tailwind_variants_namespaceObject.cn)("text-xs", error?.message ? "font-medium text-destructive" : "text-muted-foreground", className),
|
|
126
126
|
"data-slot": "form-message",
|
|
127
127
|
id: formMessageId,
|
|
128
128
|
...props,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Scope } from
|
|
2
|
-
import type * as LabelPrimitive from
|
|
3
|
-
import type { ComponentProps, JSX, ReactNode } from
|
|
4
|
-
import type { ControllerProps, FieldPath, FieldValues } from
|
|
5
|
-
import { Slot } from
|
|
6
|
-
import { FormProvider } from
|
|
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
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
+
import { FormProvider } from "react-hook-form";
|
|
7
7
|
type FormProps = ComponentProps<typeof FormProvider>;
|
|
8
8
|
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import("react-hook-form").FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
9
9
|
type ScopedProps<P> = P & {
|
|
@@ -12,15 +12,15 @@ type ScopedProps<P> = P & {
|
|
|
12
12
|
declare const createFormFieldScope: import("@radix-ui/react-context").CreateScope;
|
|
13
13
|
type FormFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = ControllerProps<TFieldValues, TName>;
|
|
14
14
|
declare function FormField<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(formFieldProps: ScopedProps<FormFieldProps<TFieldValues, TName>>): JSX.Element;
|
|
15
|
-
type FormItemProps = ComponentProps<
|
|
15
|
+
type FormItemProps = ComponentProps<"div">;
|
|
16
16
|
declare function FormItem({ __scopeFormField, className, ...props }: ScopedProps<FormItemProps>): JSX.Element;
|
|
17
17
|
type FormLabelProps = ComponentProps<typeof LabelPrimitive.Root>;
|
|
18
18
|
declare function FormLabel({ __scopeFormField, ...props }: ScopedProps<FormLabelProps>): JSX.Element;
|
|
19
19
|
type FormControlProps = ComponentProps<typeof Slot>;
|
|
20
20
|
declare function FormControl({ __scopeFormField, ...props }: ScopedProps<FormControlProps>): JSX.Element;
|
|
21
|
-
type FormDescriptionProps = ComponentProps<
|
|
21
|
+
type FormDescriptionProps = ComponentProps<"p">;
|
|
22
22
|
declare function FormDescription({ __scopeFormField, className, ...props }: ScopedProps<FormDescriptionProps>): JSX.Element;
|
|
23
|
-
type FormMessageProps = ComponentProps<
|
|
23
|
+
type FormMessageProps = ComponentProps<"p">;
|
|
24
24
|
declare function FormMessage({ __scopeFormField, children, className, ...props }: ScopedProps<FormMessageProps>): ReactNode;
|
|
25
25
|
export type { FormControlProps, FormDescriptionProps, FormFieldProps, FormItemProps, FormLabelProps, FormMessageProps, FormProps, };
|
|
26
|
-
export { createFormFieldScope, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage };
|
|
26
|
+
export { createFormFieldScope, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, };
|
package/dist/components/form.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useId } from "react";
|
|
|
7
7
|
import { Controller, FormProvider, useFormContext, useFormState } from "react-hook-form";
|
|
8
8
|
import { Label } from "./label.js";
|
|
9
9
|
const Form = FormProvider;
|
|
10
|
-
const FORM_FIELD_NAME =
|
|
10
|
+
const FORM_FIELD_NAME = "FormField";
|
|
11
11
|
const [createFormFieldContext, createFormFieldScope] = createContextScope(FORM_FIELD_NAME);
|
|
12
12
|
const [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext(FORM_FIELD_NAME);
|
|
13
13
|
function useFormItem(consumerName, scope) {
|
|
@@ -37,7 +37,7 @@ function FormField(formFieldProps) {
|
|
|
37
37
|
})
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const FORM_ITEM_NAME =
|
|
40
|
+
const FORM_ITEM_NAME = "FormItem";
|
|
41
41
|
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext(FORM_ITEM_NAME);
|
|
42
42
|
function FormItem({ __scopeFormField, className, ...props }) {
|
|
43
43
|
const id = useId();
|
|
@@ -45,13 +45,13 @@ function FormItem({ __scopeFormField, className, ...props }) {
|
|
|
45
45
|
id: id,
|
|
46
46
|
scope: __scopeFormField,
|
|
47
47
|
children: /*#__PURE__*/ jsx("div", {
|
|
48
|
-
className: cn(
|
|
48
|
+
className: cn("grid gap-2", className),
|
|
49
49
|
"data-slot": "form-item",
|
|
50
50
|
...props
|
|
51
51
|
})
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
const FORM_LABEL_NAME =
|
|
54
|
+
const FORM_LABEL_NAME = "FormLabel";
|
|
55
55
|
function FormLabel({ __scopeFormField, ...props }) {
|
|
56
56
|
const { error, formItemId } = useFormItem(FORM_LABEL_NAME, __scopeFormField);
|
|
57
57
|
return /*#__PURE__*/ jsx(Label, {
|
|
@@ -61,7 +61,7 @@ function FormLabel({ __scopeFormField, ...props }) {
|
|
|
61
61
|
...props
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
const FORM_CONTROL_NAME =
|
|
64
|
+
const FORM_CONTROL_NAME = "FormControl";
|
|
65
65
|
function FormControl({ __scopeFormField, ...props }) {
|
|
66
66
|
const { error, formDescriptionId, formItemId, formMessageId } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);
|
|
67
67
|
return /*#__PURE__*/ jsx(Slot, {
|
|
@@ -75,19 +75,19 @@ function FormControl({ __scopeFormField, ...props }) {
|
|
|
75
75
|
function FormDescription({ __scopeFormField, className, ...props }) {
|
|
76
76
|
const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
77
77
|
return /*#__PURE__*/ jsx("p", {
|
|
78
|
-
className: cn(
|
|
78
|
+
className: cn("text-xs text-muted-foreground", className),
|
|
79
79
|
"data-slot": "form-description",
|
|
80
80
|
id: formDescriptionId,
|
|
81
81
|
...props
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
const FORM_MESSAGE_NAME =
|
|
84
|
+
const FORM_MESSAGE_NAME = "FormMessage";
|
|
85
85
|
function FormMessage({ __scopeFormField, children, className, ...props }) {
|
|
86
86
|
const { error, formMessageId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
87
87
|
const body = error?.message ?? children;
|
|
88
88
|
if (!body) return null;
|
|
89
89
|
return /*#__PURE__*/ jsx("p", {
|
|
90
|
-
className: cn(
|
|
90
|
+
className: cn("text-xs", error?.message ? "font-medium text-destructive" : "text-muted-foreground", className),
|
|
91
91
|
"data-slot": "form-message",
|
|
92
92
|
id: formMessageId,
|
|
93
93
|
...props,
|
|
@@ -45,11 +45,11 @@ function HoverCardTrigger({ ...props }) {
|
|
|
45
45
|
...props
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
function HoverCardContent({ align =
|
|
48
|
+
function HoverCardContent({ align = "center", className, sideOffset = 4, ...props }) {
|
|
49
49
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Portal, {
|
|
50
50
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Content, {
|
|
51
51
|
align: align,
|
|
52
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
52
|
+
className: (0, tailwind_variants_namespaceObject.cn)("z-50 min-w-32 origin-(--radix-hover-card-content-transform-origin) rounded-lg border bg-popover p-4 text-popover-foreground shadow-lg ease-ui data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:data-[side=bottom]:slide-out-to-top-2 data-[state=closed]:data-[side=left]:slide-out-to-right-2 data-[state=closed]:data-[side=right]:slide-out-to-left-2 data-[state=closed]:data-[side=top]:slide-out-to-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:data-[side=bottom]:slide-in-from-top-2 data-[state=open]:data-[side=left]:slide-in-from-right-2 data-[state=open]:data-[side=right]:slide-in-from-left-2 data-[state=open]:data-[side=top]:slide-in-from-bottom-2", className),
|
|
53
53
|
"data-slot": "hover-card-content",
|
|
54
54
|
sideOffset: sideOffset,
|
|
55
55
|
...props
|
|
@@ -58,7 +58,7 @@ function HoverCardContent({ align = 'center', className, sideOffset = 4, ...prop
|
|
|
58
58
|
}
|
|
59
59
|
function HoverCardArrow({ className, ...props }) {
|
|
60
60
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_hover_card_namespaceObject.Arrow, {
|
|
61
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
61
|
+
className: (0, tailwind_variants_namespaceObject.cn)("fill-popover", className),
|
|
62
62
|
"data-slot": "hover-card-arrow",
|
|
63
63
|
...props
|
|
64
64
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentProps, JSX } from
|
|
2
|
-
import * as HoverCardPrimitive from
|
|
1
|
+
import type { ComponentProps, JSX } from "react";
|
|
2
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
3
3
|
type HoverCardProps = ComponentProps<typeof HoverCardPrimitive.Root>;
|
|
4
4
|
declare function HoverCard({ ...props }: HoverCardProps): JSX.Element;
|
|
5
5
|
type HoverCardTriggerProps = ComponentProps<typeof HoverCardPrimitive.Trigger>;
|
|
@@ -14,11 +14,11 @@ function HoverCardTrigger({ ...props }) {
|
|
|
14
14
|
...props
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
function HoverCardContent({ align =
|
|
17
|
+
function HoverCardContent({ align = "center", className, sideOffset = 4, ...props }) {
|
|
18
18
|
return /*#__PURE__*/ jsx(Portal, {
|
|
19
19
|
children: /*#__PURE__*/ jsx(Content, {
|
|
20
20
|
align: align,
|
|
21
|
-
className: cn(
|
|
21
|
+
className: cn("z-50 min-w-32 origin-(--radix-hover-card-content-transform-origin) rounded-lg border bg-popover p-4 text-popover-foreground shadow-lg ease-ui data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:data-[side=bottom]:slide-out-to-top-2 data-[state=closed]:data-[side=left]:slide-out-to-right-2 data-[state=closed]:data-[side=right]:slide-out-to-left-2 data-[state=closed]:data-[side=top]:slide-out-to-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:data-[side=bottom]:slide-in-from-top-2 data-[state=open]:data-[side=left]:slide-in-from-right-2 data-[state=open]:data-[side=right]:slide-in-from-left-2 data-[state=open]:data-[side=top]:slide-in-from-bottom-2", className),
|
|
22
22
|
"data-slot": "hover-card-content",
|
|
23
23
|
sideOffset: sideOffset,
|
|
24
24
|
...props
|
|
@@ -27,7 +27,7 @@ function HoverCardContent({ align = 'center', className, sideOffset = 4, ...prop
|
|
|
27
27
|
}
|
|
28
28
|
function HoverCardArrow({ className, ...props }) {
|
|
29
29
|
return /*#__PURE__*/ jsx(Arrow, {
|
|
30
|
-
className: cn(
|
|
30
|
+
className: cn("fill-popover", className),
|
|
31
31
|
"data-slot": "hover-card-arrow",
|
|
32
32
|
...props
|
|
33
33
|
});
|
|
@@ -41,33 +41,33 @@ const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
|
41
41
|
const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
42
42
|
const external_textarea_cjs_namespaceObject = require("./textarea.cjs");
|
|
43
43
|
const inputGroupVariants = (0, tailwind_variants_namespaceObject.tv)({
|
|
44
|
-
base: (0, tailwind_variants_namespaceObject.cn)(
|
|
44
|
+
base: (0, tailwind_variants_namespaceObject.cn)("group/input-group relative flex w-full items-center rounded-lg border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-2", "has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40")
|
|
45
45
|
});
|
|
46
46
|
const inputGroupAddonVariants = (0, tailwind_variants_namespaceObject.tv)({
|
|
47
|
-
base: (0, tailwind_variants_namespaceObject.cn)("
|
|
47
|
+
base: (0, tailwind_variants_namespaceObject.cn)("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4"),
|
|
48
48
|
defaultVariants: {
|
|
49
|
-
align:
|
|
49
|
+
align: "inline-start"
|
|
50
50
|
},
|
|
51
51
|
variants: {
|
|
52
52
|
align: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
"block-end": "order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3",
|
|
54
|
+
"block-start": "order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3",
|
|
55
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
56
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
const inputGroupButtonVariants = (0, tailwind_variants_namespaceObject.tv)({
|
|
61
|
-
base: "
|
|
61
|
+
base: "flex items-center gap-2 text-sm shadow-none [&>svg:not([class*='size-'])]:size-4",
|
|
62
62
|
defaultVariants: {
|
|
63
|
-
size:
|
|
63
|
+
size: "xs"
|
|
64
64
|
},
|
|
65
65
|
variants: {
|
|
66
66
|
size: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
sm:
|
|
70
|
-
xs:
|
|
67
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
|
68
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
69
|
+
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
70
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg]:size-3.5"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -81,7 +81,7 @@ function InputGroup({ className, ...props }) {
|
|
|
81
81
|
...props
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function InputGroupAddon({ align =
|
|
84
|
+
function InputGroupAddon({ align = "inline-start", className, ...props }) {
|
|
85
85
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
86
86
|
className: (0, tailwind_variants_namespaceObject.cn)(inputGroupAddonVariants({
|
|
87
87
|
align
|
|
@@ -90,15 +90,15 @@ function InputGroupAddon({ align = 'inline-start', className, ...props }) {
|
|
|
90
90
|
"data-slot": "input-group-addon",
|
|
91
91
|
role: "group",
|
|
92
92
|
onPointerDown: (event)=>{
|
|
93
|
-
if (event.target.closest(
|
|
93
|
+
if (event.target.closest("button")) return;
|
|
94
94
|
event.preventDefault();
|
|
95
|
-
const control = event.currentTarget.parentElement?.querySelector(
|
|
95
|
+
const control = event.currentTarget.parentElement?.querySelector("input, textarea");
|
|
96
96
|
if (control instanceof HTMLElement) control.focus();
|
|
97
97
|
},
|
|
98
98
|
...props
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
function InputGroupButton({ className, size =
|
|
101
|
+
function InputGroupButton({ className, size = "xs", type = "button", variant = "ghost", ...props }) {
|
|
102
102
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
103
103
|
className: (0, tailwind_variants_namespaceObject.cn)(inputGroupButtonVariants({
|
|
104
104
|
size
|
|
@@ -112,21 +112,21 @@ function InputGroupButton({ className, size = 'xs', type = 'button', variant = '
|
|
|
112
112
|
}
|
|
113
113
|
function InputGroupText({ className, ...props }) {
|
|
114
114
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
115
|
-
className: (0, tailwind_variants_namespaceObject.cn)("
|
|
115
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className),
|
|
116
116
|
"data-slot": "input-group-text",
|
|
117
117
|
...props
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
function InputGroupInput({ className, ...props }) {
|
|
121
121
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
|
|
122
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
122
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex-1 rounded-none border-0 bg-transparent px-3 py-1 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
123
123
|
"data-slot": "input-group-control",
|
|
124
124
|
...props
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
function InputGroupTextarea({ className, ...props }) {
|
|
128
128
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_textarea_cjs_namespaceObject.Textarea, {
|
|
129
|
-
className: (0, tailwind_variants_namespaceObject.cn)(
|
|
129
|
+
className: (0, tailwind_variants_namespaceObject.cn)("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
130
130
|
"data-slot": "input-group-control",
|
|
131
131
|
...props
|
|
132
132
|
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import type { VariantProps } from
|
|
2
|
-
import type { ComponentProps, JSX } from
|
|
3
|
-
import type { ButtonProps } from
|
|
4
|
-
import type { InputProps } from
|
|
5
|
-
import type { TextareaProps } from
|
|
1
|
+
import type { VariantProps } from "@codefast/tailwind-variants";
|
|
2
|
+
import type { ComponentProps, JSX } from "react";
|
|
3
|
+
import type { ButtonProps } from "./button";
|
|
4
|
+
import type { InputProps } from "./input";
|
|
5
|
+
import type { TextareaProps } from "./textarea";
|
|
6
6
|
declare const inputGroupVariants: import("@codefast/tailwind-variants").VariantFunctionType<import("@codefast/tailwind-variants").ConfigurationSchema, Record<string, never>>;
|
|
7
7
|
declare const inputGroupAddonVariants: import("@codefast/tailwind-variants").VariantFunctionType<{
|
|
8
8
|
align: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
"block-end": string;
|
|
10
|
+
"block-start": string;
|
|
11
|
+
"inline-end": string;
|
|
12
|
+
"inline-start": string;
|
|
13
13
|
};
|
|
14
14
|
}, Record<string, never>>;
|
|
15
15
|
declare const inputGroupButtonVariants: import("@codefast/tailwind-variants").VariantFunctionType<{
|
|
16
16
|
size: {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
"icon-sm": string;
|
|
18
|
+
"icon-xs": string;
|
|
19
19
|
sm: string;
|
|
20
20
|
xs: string;
|
|
21
21
|
};
|
|
22
22
|
}, Record<string, never>>;
|
|
23
|
-
type InputGroupProps = ComponentProps<
|
|
23
|
+
type InputGroupProps = ComponentProps<"div">;
|
|
24
24
|
declare function InputGroup({ className, ...props }: InputGroupProps): JSX.Element;
|
|
25
|
-
type InputGroupAddonProps = ComponentProps<
|
|
25
|
+
type InputGroupAddonProps = ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>;
|
|
26
26
|
declare function InputGroupAddon({ align, className, ...props }: InputGroupAddonProps): JSX.Element;
|
|
27
|
-
type InputGroupButtonProps = Omit<ButtonProps,
|
|
27
|
+
type InputGroupButtonProps = Omit<ButtonProps, "size"> & VariantProps<typeof inputGroupButtonVariants>;
|
|
28
28
|
declare function InputGroupButton({ className, size, type, variant, ...props }: InputGroupButtonProps): JSX.Element;
|
|
29
|
-
type InputGroupTextProps = ComponentProps<
|
|
29
|
+
type InputGroupTextProps = ComponentProps<"span">;
|
|
30
30
|
declare function InputGroupText({ className, ...props }: InputGroupTextProps): JSX.Element;
|
|
31
31
|
type InputGroupInputProps = InputProps;
|
|
32
32
|
declare function InputGroupInput({ className, ...props }: InputGroupInputProps): JSX.Element;
|
|
@@ -5,33 +5,33 @@ import { Button } from "./button.js";
|
|
|
5
5
|
import { Input } from "./input.js";
|
|
6
6
|
import { Textarea } from "./textarea.js";
|
|
7
7
|
const inputGroupVariants = tv({
|
|
8
|
-
base: cn(
|
|
8
|
+
base: cn("group/input-group relative flex w-full items-center rounded-lg border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>[data-slot=input-group-control]]:pl-2", "has-[>[data-align=inline-end]]:[&>[data-slot=input-group-control]]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>[data-slot=input-group-control]]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>[data-slot=input-group-control]]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40")
|
|
9
9
|
});
|
|
10
10
|
const inputGroupAddonVariants = tv({
|
|
11
|
-
base: cn("
|
|
11
|
+
base: cn("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4"),
|
|
12
12
|
defaultVariants: {
|
|
13
|
-
align:
|
|
13
|
+
align: "inline-start"
|
|
14
14
|
},
|
|
15
15
|
variants: {
|
|
16
16
|
align: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
"block-end": "order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3",
|
|
18
|
+
"block-start": "order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3",
|
|
19
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
20
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
const inputGroupButtonVariants = tv({
|
|
25
|
-
base: "
|
|
25
|
+
base: "flex items-center gap-2 text-sm shadow-none [&>svg:not([class*='size-'])]:size-4",
|
|
26
26
|
defaultVariants: {
|
|
27
|
-
size:
|
|
27
|
+
size: "xs"
|
|
28
28
|
},
|
|
29
29
|
variants: {
|
|
30
30
|
size: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
sm:
|
|
34
|
-
xs:
|
|
31
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
|
32
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
33
|
+
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
34
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg]:size-3.5"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
});
|
|
@@ -45,7 +45,7 @@ function InputGroup({ className, ...props }) {
|
|
|
45
45
|
...props
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
function InputGroupAddon({ align =
|
|
48
|
+
function InputGroupAddon({ align = "inline-start", className, ...props }) {
|
|
49
49
|
return /*#__PURE__*/ jsx("div", {
|
|
50
50
|
className: cn(inputGroupAddonVariants({
|
|
51
51
|
align
|
|
@@ -54,15 +54,15 @@ function InputGroupAddon({ align = 'inline-start', className, ...props }) {
|
|
|
54
54
|
"data-slot": "input-group-addon",
|
|
55
55
|
role: "group",
|
|
56
56
|
onPointerDown: (event)=>{
|
|
57
|
-
if (event.target.closest(
|
|
57
|
+
if (event.target.closest("button")) return;
|
|
58
58
|
event.preventDefault();
|
|
59
|
-
const control = event.currentTarget.parentElement?.querySelector(
|
|
59
|
+
const control = event.currentTarget.parentElement?.querySelector("input, textarea");
|
|
60
60
|
if (control instanceof HTMLElement) control.focus();
|
|
61
61
|
},
|
|
62
62
|
...props
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function InputGroupButton({ className, size =
|
|
65
|
+
function InputGroupButton({ className, size = "xs", type = "button", variant = "ghost", ...props }) {
|
|
66
66
|
return /*#__PURE__*/ jsx(Button, {
|
|
67
67
|
className: cn(inputGroupButtonVariants({
|
|
68
68
|
size
|
|
@@ -76,21 +76,21 @@ function InputGroupButton({ className, size = 'xs', type = 'button', variant = '
|
|
|
76
76
|
}
|
|
77
77
|
function InputGroupText({ className, ...props }) {
|
|
78
78
|
return /*#__PURE__*/ jsx("span", {
|
|
79
|
-
className: cn("
|
|
79
|
+
className: cn("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className),
|
|
80
80
|
"data-slot": "input-group-text",
|
|
81
81
|
...props
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
function InputGroupInput({ className, ...props }) {
|
|
85
85
|
return /*#__PURE__*/ jsx(Input, {
|
|
86
|
-
className: cn(
|
|
86
|
+
className: cn("flex-1 rounded-none border-0 bg-transparent px-3 py-1 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
87
87
|
"data-slot": "input-group-control",
|
|
88
88
|
...props
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
function InputGroupTextarea({ className, ...props }) {
|
|
92
92
|
return /*#__PURE__*/ jsx(Textarea, {
|
|
93
|
-
className: cn(
|
|
93
|
+
className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
94
94
|
"data-slot": "input-group-control",
|
|
95
95
|
...props
|
|
96
96
|
});
|