@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/form.js
CHANGED
|
@@ -1,97 +1,92 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { Label } from "./label.js";
|
|
3
3
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
-
import { createContextScope } from "@radix-ui/react-context";
|
|
5
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { useId } from "react";
|
|
7
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
7
8
|
import { Controller, FormProvider, useFormContext, useFormState } from "react-hook-form";
|
|
8
|
-
|
|
9
|
+
//#region src/components/form.tsx
|
|
9
10
|
const Form = FormProvider;
|
|
10
11
|
const FORM_FIELD_NAME = "FormField";
|
|
11
12
|
const [createFormFieldContext, createFormFieldScope] = createContextScope(FORM_FIELD_NAME);
|
|
12
13
|
const [FormFieldContextProvider, useFormFieldContext] = createFormFieldContext(FORM_FIELD_NAME);
|
|
13
14
|
function useFormItem(consumerName, scope) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name,
|
|
27
|
-
...fieldState
|
|
28
|
-
};
|
|
15
|
+
const { id } = useFormItemContext(consumerName, scope);
|
|
16
|
+
const { name } = useFormFieldContext(consumerName, scope);
|
|
17
|
+
const { getFieldState } = useFormContext();
|
|
18
|
+
const fieldState = getFieldState(name, useFormState({ name }));
|
|
19
|
+
return {
|
|
20
|
+
formDescriptionId: `form-item-description-${id}`,
|
|
21
|
+
formItemId: `form-item-${id}`,
|
|
22
|
+
formMessageId: `form-item-message-${id}`,
|
|
23
|
+
id,
|
|
24
|
+
name,
|
|
25
|
+
...fieldState
|
|
26
|
+
};
|
|
29
27
|
}
|
|
30
28
|
function FormField(formFieldProps) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
});
|
|
29
|
+
const { __scopeFormField, ...props } = formFieldProps;
|
|
30
|
+
return /* @__PURE__ */ jsx(FormFieldContextProvider, {
|
|
31
|
+
name: props.name,
|
|
32
|
+
scope: __scopeFormField,
|
|
33
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
34
|
+
});
|
|
39
35
|
}
|
|
40
|
-
const
|
|
41
|
-
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext(FORM_ITEM_NAME);
|
|
36
|
+
const [FormItemContextProvider, useFormItemContext] = createFormFieldContext("FormItem");
|
|
42
37
|
function FormItem({ __scopeFormField, className, ...props }) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
38
|
+
return /* @__PURE__ */ jsx(FormItemContextProvider, {
|
|
39
|
+
id: useId(),
|
|
40
|
+
scope: __scopeFormField,
|
|
41
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: cn("grid gap-2", className),
|
|
43
|
+
"data-slot": "form-item",
|
|
44
|
+
...props
|
|
45
|
+
})
|
|
46
|
+
});
|
|
53
47
|
}
|
|
54
48
|
const FORM_LABEL_NAME = "FormLabel";
|
|
55
49
|
function FormLabel({ __scopeFormField, ...props }) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
const { error, formItemId } = useFormItem(FORM_LABEL_NAME, __scopeFormField);
|
|
51
|
+
return /* @__PURE__ */ jsx(Label, {
|
|
52
|
+
"data-invalid": error ? true : void 0,
|
|
53
|
+
"data-slot": "form-label",
|
|
54
|
+
htmlFor: formItemId,
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
63
57
|
}
|
|
64
58
|
const FORM_CONTROL_NAME = "FormControl";
|
|
65
59
|
function FormControl({ __scopeFormField, ...props }) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
60
|
+
const { error, formDescriptionId, formItemId, formMessageId } = useFormItem(FORM_CONTROL_NAME, __scopeFormField);
|
|
61
|
+
return /* @__PURE__ */ jsx(Slot, {
|
|
62
|
+
"aria-describedby": error ? `${formDescriptionId} ${formMessageId}` : formDescriptionId,
|
|
63
|
+
"aria-invalid": Boolean(error),
|
|
64
|
+
"data-slot": "form-control",
|
|
65
|
+
id: formItemId,
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
74
68
|
}
|
|
75
69
|
function FormDescription({ __scopeFormField, className, ...props }) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
const { formDescriptionId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
71
|
+
return /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: cn("text-xs text-muted-foreground", className),
|
|
73
|
+
"data-slot": "form-description",
|
|
74
|
+
id: formDescriptionId,
|
|
75
|
+
...props
|
|
76
|
+
});
|
|
83
77
|
}
|
|
84
78
|
const FORM_MESSAGE_NAME = "FormMessage";
|
|
85
79
|
function FormMessage({ __scopeFormField, children, className, ...props }) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
const { error, formMessageId } = useFormItem(FORM_MESSAGE_NAME, __scopeFormField);
|
|
81
|
+
const body = error?.message ?? children;
|
|
82
|
+
if (!body) return null;
|
|
83
|
+
return /* @__PURE__ */ jsx("p", {
|
|
84
|
+
className: cn("text-xs", error?.message ? "font-medium text-destructive" : "text-muted-foreground", className),
|
|
85
|
+
"data-slot": "form-message",
|
|
86
|
+
id: formMessageId,
|
|
87
|
+
...props,
|
|
88
|
+
children: body
|
|
89
|
+
});
|
|
96
90
|
}
|
|
91
|
+
//#endregion
|
|
97
92
|
export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, createFormFieldScope };
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentProps, JSX } from "react";
|
|
2
2
|
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
3
|
+
|
|
4
|
+
//#region src/components/hover-card.d.ts
|
|
3
5
|
type HoverCardProps = ComponentProps<typeof HoverCardPrimitive.Root>;
|
|
4
|
-
declare function HoverCard({
|
|
6
|
+
declare function HoverCard({
|
|
7
|
+
...props
|
|
8
|
+
}: HoverCardProps): JSX.Element;
|
|
5
9
|
type HoverCardTriggerProps = ComponentProps<typeof HoverCardPrimitive.Trigger>;
|
|
6
|
-
declare function HoverCardTrigger({
|
|
10
|
+
declare function HoverCardTrigger({
|
|
11
|
+
...props
|
|
12
|
+
}: HoverCardTriggerProps): JSX.Element;
|
|
7
13
|
type HoverCardContentProps = ComponentProps<typeof HoverCardPrimitive.Content>;
|
|
8
|
-
declare function HoverCardContent({
|
|
14
|
+
declare function HoverCardContent({
|
|
15
|
+
align,
|
|
16
|
+
className,
|
|
17
|
+
sideOffset,
|
|
18
|
+
...props
|
|
19
|
+
}: HoverCardContentProps): JSX.Element;
|
|
9
20
|
type HoverCardArrowProps = ComponentProps<typeof HoverCardPrimitive.Arrow>;
|
|
10
|
-
declare function HoverCardArrow({
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
declare function HoverCardArrow({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: HoverCardArrowProps): JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { HoverCard, HoverCardArrow, type HoverCardArrowProps, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps };
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { cn } from "@codefast/tailwind-variants";
|
|
4
|
-
import {
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
5
|
+
//#region src/components/hover-card.tsx
|
|
5
6
|
function HoverCard({ ...props }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
return /* @__PURE__ */ jsx(HoverCardPrimitive.Root, {
|
|
8
|
+
"data-slot": "hover-card",
|
|
9
|
+
...props
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
12
|
function HoverCardTrigger({ ...props }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
return /* @__PURE__ */ jsx(HoverCardPrimitive.Trigger, {
|
|
14
|
+
"data-slot": "hover-card-trigger",
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
18
|
function HoverCardContent({ align = "center", className, sideOffset = 4, ...props }) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
});
|
|
19
|
+
return /* @__PURE__ */ jsx(HoverCardPrimitive.Portal, { children: /* @__PURE__ */ jsx(HoverCardPrimitive.Content, {
|
|
20
|
+
align,
|
|
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
|
+
"data-slot": "hover-card-content",
|
|
23
|
+
sideOffset,
|
|
24
|
+
...props
|
|
25
|
+
}) });
|
|
27
26
|
}
|
|
28
27
|
function HoverCardArrow({ className, ...props }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
return /* @__PURE__ */ jsx(HoverCardPrimitive.Arrow, {
|
|
29
|
+
className: cn("fill-popover", className),
|
|
30
|
+
"data-slot": "hover-card-arrow",
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
34
33
|
}
|
|
34
|
+
//#endregion
|
|
35
35
|
export { HoverCard, HoverCardArrow, HoverCardContent, HoverCardTrigger };
|
|
@@ -1,36 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { ButtonProps } from "./button.js";
|
|
2
|
+
import { InputProps } from "./input.js";
|
|
3
|
+
import { TextareaProps } from "./textarea.js";
|
|
4
|
+
import * as _$_codefast_tailwind_variants0 from "@codefast/tailwind-variants";
|
|
5
|
+
import { VariantProps } from "@codefast/tailwind-variants";
|
|
6
|
+
import { ComponentProps, JSX } from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/components/input-group.d.ts
|
|
9
|
+
declare const inputGroupVariants: _$_codefast_tailwind_variants0.VariantFunctionType<_$_codefast_tailwind_variants0.ConfigurationSchema, Record<string, never>>;
|
|
10
|
+
declare const inputGroupAddonVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
11
|
+
align: {
|
|
12
|
+
"block-end": string;
|
|
13
|
+
"block-start": string;
|
|
14
|
+
"inline-end": string;
|
|
15
|
+
"inline-start": string;
|
|
16
|
+
};
|
|
14
17
|
}, Record<string, never>>;
|
|
15
|
-
declare const inputGroupButtonVariants:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
declare const inputGroupButtonVariants: _$_codefast_tailwind_variants0.VariantFunctionType<{
|
|
19
|
+
size: {
|
|
20
|
+
"icon-sm": string;
|
|
21
|
+
"icon-xs": string;
|
|
22
|
+
sm: string;
|
|
23
|
+
xs: string;
|
|
24
|
+
};
|
|
22
25
|
}, Record<string, never>>;
|
|
23
26
|
type InputGroupProps = ComponentProps<"div">;
|
|
24
|
-
declare function InputGroup({
|
|
27
|
+
declare function InputGroup({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: InputGroupProps): JSX.Element;
|
|
25
31
|
type InputGroupAddonProps = ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>;
|
|
26
|
-
declare function InputGroupAddon({
|
|
32
|
+
declare function InputGroupAddon({
|
|
33
|
+
align,
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: InputGroupAddonProps): JSX.Element;
|
|
27
37
|
type InputGroupButtonProps = Omit<ButtonProps, "size"> & VariantProps<typeof inputGroupButtonVariants>;
|
|
28
|
-
declare function InputGroupButton({
|
|
38
|
+
declare function InputGroupButton({
|
|
39
|
+
className,
|
|
40
|
+
size,
|
|
41
|
+
type,
|
|
42
|
+
variant,
|
|
43
|
+
...props
|
|
44
|
+
}: InputGroupButtonProps): JSX.Element;
|
|
29
45
|
type InputGroupTextProps = ComponentProps<"span">;
|
|
30
|
-
declare function InputGroupText({
|
|
46
|
+
declare function InputGroupText({
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}: InputGroupTextProps): JSX.Element;
|
|
31
50
|
type InputGroupInputProps = InputProps;
|
|
32
|
-
declare function InputGroupInput({
|
|
51
|
+
declare function InputGroupInput({
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: InputGroupInputProps): JSX.Element;
|
|
33
55
|
type InputGroupTextareaProps = TextareaProps;
|
|
34
|
-
declare function InputGroupTextarea({
|
|
35
|
-
|
|
36
|
-
|
|
56
|
+
declare function InputGroupTextarea({
|
|
57
|
+
className,
|
|
58
|
+
...props
|
|
59
|
+
}: InputGroupTextareaProps): JSX.Element;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { InputGroup, InputGroupAddon, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, InputGroupInput, type InputGroupInputProps, type InputGroupProps, InputGroupText, type InputGroupTextProps, InputGroupTextarea, type InputGroupTextareaProps, inputGroupAddonVariants, inputGroupButtonVariants, inputGroupVariants };
|
|
@@ -1,98 +1,84 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { cn, tv } from "@codefast/tailwind-variants";
|
|
4
2
|
import { Button } from "./button.js";
|
|
5
3
|
import { Input } from "./input.js";
|
|
6
4
|
import { Textarea } from "./textarea.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { cn, tv } from "@codefast/tailwind-variants";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/input-group.tsx
|
|
8
|
+
const inputGroupVariants = tv({ 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") });
|
|
10
9
|
const inputGroupAddonVariants = tv({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
}
|
|
22
|
-
}
|
|
10
|
+
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"),
|
|
11
|
+
defaultVariants: { align: "inline-start" },
|
|
12
|
+
variants: { align: {
|
|
13
|
+
"block-end": "order-last w-full justify-start px-3 pb-3 group-has-[>input]/input-group:pb-2.5 [.border-t]:pt-3",
|
|
14
|
+
"block-start": "order-first w-full justify-start px-3 pt-3 group-has-[>input]/input-group:pt-2.5 [.border-b]:pb-3",
|
|
15
|
+
"inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
|
|
16
|
+
"inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]"
|
|
17
|
+
} }
|
|
23
18
|
});
|
|
24
19
|
const inputGroupButtonVariants = tv({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
}
|
|
36
|
-
}
|
|
20
|
+
base: "flex items-center gap-2 text-sm shadow-none [&>svg:not([class*='size-'])]:size-4",
|
|
21
|
+
defaultVariants: { size: "xs" },
|
|
22
|
+
variants: { size: {
|
|
23
|
+
"icon-sm": "size-8 p-0 has-[>svg]:p-0",
|
|
24
|
+
"icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",
|
|
25
|
+
sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
|
|
26
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg]:size-3.5"
|
|
27
|
+
} }
|
|
37
28
|
});
|
|
38
29
|
function InputGroup({ className, ...props }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
...props
|
|
46
|
-
});
|
|
30
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31
|
+
className: inputGroupVariants({ className }),
|
|
32
|
+
"data-slot": "input-group",
|
|
33
|
+
role: "group",
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
47
36
|
}
|
|
48
37
|
function InputGroupAddon({ align = "inline-start", className, ...props }) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...props
|
|
63
|
-
});
|
|
38
|
+
return /* @__PURE__ */ jsx("div", {
|
|
39
|
+
className: cn(inputGroupAddonVariants({ align }), className),
|
|
40
|
+
"data-align": align,
|
|
41
|
+
"data-slot": "input-group-addon",
|
|
42
|
+
role: "group",
|
|
43
|
+
onPointerDown: (event) => {
|
|
44
|
+
if (event.target.closest("button")) return;
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
const control = event.currentTarget.parentElement?.querySelector("input, textarea");
|
|
47
|
+
if (control instanceof HTMLElement) control.focus();
|
|
48
|
+
},
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
64
51
|
}
|
|
65
52
|
function InputGroupButton({ className, size = "xs", type = "button", variant = "ghost", ...props }) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...props
|
|
75
|
-
});
|
|
53
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
54
|
+
className: cn(inputGroupButtonVariants({ size }), className),
|
|
55
|
+
"data-size": size,
|
|
56
|
+
"data-slot": "input-group-button",
|
|
57
|
+
type,
|
|
58
|
+
variant,
|
|
59
|
+
...props
|
|
60
|
+
});
|
|
76
61
|
}
|
|
77
62
|
function InputGroupText({ className, ...props }) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
return /* @__PURE__ */ jsx("span", {
|
|
64
|
+
className: cn("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", className),
|
|
65
|
+
"data-slot": "input-group-text",
|
|
66
|
+
...props
|
|
67
|
+
});
|
|
83
68
|
}
|
|
84
69
|
function InputGroupInput({ className, ...props }) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
71
|
+
className: cn("flex-1 rounded-none border-0 bg-transparent px-3 py-1 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
72
|
+
"data-slot": "input-group-control",
|
|
73
|
+
...props
|
|
74
|
+
});
|
|
90
75
|
}
|
|
91
76
|
function InputGroupTextarea({ className, ...props }) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
return /* @__PURE__ */ jsx(Textarea, {
|
|
78
|
+
className: cn("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", className),
|
|
79
|
+
"data-slot": "input-group-control",
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
97
82
|
}
|
|
83
|
+
//#endregion
|
|
98
84
|
export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupAddonVariants, inputGroupButtonVariants, inputGroupVariants };
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Field as InputNumberField, InputNumber as InputNumber$1 } from "../primitives/input-number.js";
|
|
2
|
+
import { ComponentProps, JSX } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/input-number.d.ts
|
|
5
|
+
interface InputNumberProps extends ComponentProps<typeof InputNumberField>, ComponentProps<typeof InputNumber$1> {}
|
|
6
|
+
declare function InputNumber({
|
|
7
|
+
ariaDecrementLabel,
|
|
8
|
+
ariaIncrementLabel,
|
|
9
|
+
className,
|
|
10
|
+
defaultValue,
|
|
11
|
+
disabled,
|
|
12
|
+
formatOptions,
|
|
13
|
+
id,
|
|
14
|
+
loaderPosition,
|
|
15
|
+
loading,
|
|
16
|
+
max,
|
|
17
|
+
min,
|
|
18
|
+
onChange,
|
|
19
|
+
prefix,
|
|
20
|
+
readOnly,
|
|
21
|
+
spinner,
|
|
22
|
+
step,
|
|
23
|
+
suffix,
|
|
24
|
+
value,
|
|
25
|
+
...props
|
|
26
|
+
}: InputNumberProps): JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { InputNumber, type InputNumberProps };
|