@mbao01/common 0.0.7 → 0.0.9
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/dist/types/components/Avatar/types.d.ts +1 -0
- package/dist/types/components/Badge/types.d.ts +1 -0
- package/dist/types/components/Breadcrumbs/types.d.ts +1 -0
- package/dist/types/components/Button/Button.d.ts +7 -7
- package/dist/types/components/Combobox/Combobox.d.ts +2 -0
- package/dist/types/components/Combobox/index.d.ts +1 -0
- package/dist/types/components/Combobox/types.d.ts +19 -0
- package/dist/types/components/Command/Command.d.ts +67 -0
- package/dist/types/components/Command/constants.d.ts +11 -0
- package/dist/types/components/Command/index.d.ts +1 -0
- package/dist/types/components/Command/types.d.ts +8 -0
- package/dist/types/components/Description/types.d.ts +1 -0
- package/dist/types/components/Dialog/Dialog.d.ts +22 -0
- package/dist/types/components/Dialog/constants.d.ts +7 -0
- package/dist/types/components/Dialog/index.d.ts +1 -0
- package/dist/types/components/Dialog/types.d.ts +11 -0
- package/dist/types/components/Form/Checkbox/Checkbox.d.ts +6 -0
- package/dist/types/components/Form/Checkbox/constants.d.ts +4 -0
- package/dist/types/components/Form/Checkbox/index.d.ts +1 -0
- package/dist/types/components/Form/Checkbox/types.d.ts +4 -0
- package/dist/types/components/Form/Input/Input.d.ts +7 -0
- package/dist/types/components/Form/Input/constants.d.ts +6 -0
- package/dist/types/components/Form/Input/index.d.ts +1 -0
- package/dist/types/components/Form/Input/types.d.ts +4 -0
- package/dist/types/components/Form/Phone/Phone.d.ts +4 -0
- package/dist/types/components/Form/Phone/constants.d.ts +2 -0
- package/dist/types/components/Form/Phone/index.d.ts +1 -0
- package/dist/types/components/Form/Phone/types.d.ts +2 -0
- package/dist/types/components/Form/Radio/Radio.d.ts +6 -0
- package/dist/types/components/Form/Radio/constants.d.ts +4 -0
- package/dist/types/components/Form/Radio/index.d.ts +1 -0
- package/dist/types/components/Form/Radio/types.d.ts +4 -0
- package/dist/types/components/Form/Range/Range.d.ts +8 -0
- package/dist/types/components/Form/Range/constants.d.ts +6 -0
- package/dist/types/components/Form/Range/index.d.ts +1 -0
- package/dist/types/components/Form/Range/types.d.ts +4 -0
- package/dist/types/components/Form/Select/Select.d.ts +27 -0
- package/dist/types/components/Form/Select/constants.d.ts +17 -0
- package/dist/types/components/Form/Select/index.d.ts +1 -0
- package/dist/types/components/Form/Select/types.d.ts +7 -0
- package/dist/types/components/Form/Slider/Slider.d.ts +15 -0
- package/dist/types/components/Form/Slider/constants.d.ts +15 -0
- package/dist/types/components/Form/Slider/index.d.ts +1 -0
- package/dist/types/components/Form/Slider/types.d.ts +5 -0
- package/dist/types/components/Form/Switch/Switch.d.ts +6 -0
- package/dist/types/components/Form/Switch/constants.d.ts +4 -0
- package/dist/types/components/Form/Switch/index.d.ts +1 -0
- package/dist/types/components/Form/Switch/types.d.ts +4 -0
- package/dist/types/components/Form/TextField/TextField.d.ts +10 -0
- package/dist/types/components/Form/TextField/constants.d.ts +1 -0
- package/dist/types/components/Form/TextField/index.d.ts +1 -0
- package/dist/types/components/Form/TextField/types.d.ts +6 -0
- package/dist/types/components/Form/Textarea/Textarea.d.ts +8 -0
- package/dist/types/components/Form/Textarea/constants.d.ts +6 -0
- package/dist/types/components/Form/Textarea/index.d.ts +1 -0
- package/dist/types/components/Form/Textarea/types.d.ts +4 -0
- package/dist/types/components/Form/components/FormControl/FormControl.d.ts +2 -0
- package/dist/types/components/Form/components/FormControl/constants.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/index.d.ts +1 -0
- package/dist/types/components/Form/components/FormControl/types.d.ts +9 -0
- package/dist/types/components/Form/components/Label/Label.d.ts +7 -0
- package/dist/types/components/Form/components/Label/constants.d.ts +1 -0
- package/dist/types/components/Form/components/Label/index.d.ts +1 -0
- package/dist/types/components/Form/components/Label/types.d.ts +6 -0
- package/dist/types/components/Form/index.d.ts +11 -0
- package/dist/types/components/Loading/types.d.ts +1 -0
- package/dist/types/components/Popover/Popover.d.ts +9 -0
- package/dist/types/components/Popover/constants.d.ts +1 -0
- package/dist/types/components/Popover/index.d.ts +1 -0
- package/dist/types/components/Popover/types.d.ts +6 -0
- package/dist/types/components/Progress/Progress.d.ts +3 -3
- package/dist/types/components/Progress/types.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +1 -0
- package/dist/types/components/Skeleton/types.d.ts +1 -0
- package/dist/types/components/Text/Text.d.ts +2 -2
- package/dist/types/components/Text/types.d.ts +6 -2
- package/dist/types/components/Tooltip/Tooltip.d.ts +3 -3
- package/dist/types/components/Tooltip/types.d.ts +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/libs/cva.d.ts +6 -1
- package/package.json +21 -13
- package/src/components/Combobox/Combobox.tsx +82 -0
- package/src/components/Combobox/index.ts +1 -0
- package/src/components/Combobox/types.ts +21 -0
- package/src/components/Command/Command.tsx +142 -0
- package/src/components/Command/constants.ts +39 -0
- package/src/components/Command/index.ts +1 -0
- package/src/components/Command/types.ts +16 -0
- package/src/components/Dialog/Dialog.tsx +105 -0
- package/src/components/Dialog/constants.ts +27 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Dialog/types.ts +40 -0
- package/src/components/Form/Checkbox/Checkbox.tsx +18 -0
- package/src/components/Form/Checkbox/constants.ts +21 -0
- package/src/components/Form/Checkbox/index.ts +1 -0
- package/src/components/Form/Checkbox/types.ts +8 -0
- package/src/components/Form/Input/Input.tsx +18 -0
- package/src/components/Form/Input/constants.ts +37 -0
- package/src/components/Form/Input/index.ts +1 -0
- package/src/components/Form/Input/types.ts +8 -0
- package/src/components/Form/Phone/Phone.tsx +126 -0
- package/src/components/Form/Phone/constants.ts +7 -0
- package/src/components/Form/Phone/index.ts +1 -0
- package/src/components/Form/Phone/types.ts +3 -0
- package/src/components/Form/Radio/Radio.tsx +18 -0
- package/src/components/Form/Radio/constants.ts +21 -0
- package/src/components/Form/Radio/index.ts +1 -0
- package/src/components/Form/Radio/types.ts +8 -0
- package/src/components/Form/Range/Range.tsx +22 -0
- package/src/components/Form/Range/constants.ts +31 -0
- package/src/components/Form/Range/index.ts +1 -0
- package/src/components/Form/Range/types.ts +8 -0
- package/src/components/Form/Select/Select.tsx +151 -0
- package/src/components/Form/Select/constants.ts +80 -0
- package/src/components/Form/Select/index.ts +1 -0
- package/src/components/Form/Select/types.ts +18 -0
- package/src/components/Form/Slider/Slider.tsx +43 -0
- package/src/components/Form/Slider/constants.ts +87 -0
- package/src/components/Form/Slider/index.ts +1 -0
- package/src/components/Form/Slider/types.ts +16 -0
- package/src/components/Form/Switch/Switch.tsx +19 -0
- package/src/components/Form/Switch/constants.ts +21 -0
- package/src/components/Form/Switch/index.ts +1 -0
- package/src/components/Form/Switch/types.ts +8 -0
- package/src/components/Form/TextField/TextField.tsx +37 -0
- package/src/components/Form/TextField/constants.ts +5 -0
- package/src/components/Form/TextField/index.ts +1 -0
- package/src/components/Form/TextField/types.ts +7 -0
- package/src/components/Form/Textarea/Textarea.tsx +22 -0
- package/src/components/Form/Textarea/constants.ts +37 -0
- package/src/components/Form/Textarea/index.ts +1 -0
- package/src/components/Form/Textarea/types.ts +8 -0
- package/src/components/Form/components/FormControl/FormControl.tsx +21 -0
- package/src/components/Form/components/FormControl/constants.ts +3 -0
- package/src/components/Form/components/FormControl/index.ts +1 -0
- package/src/components/Form/components/FormControl/types.ts +13 -0
- package/src/components/Form/components/Label/Label.tsx +22 -0
- package/src/components/Form/components/Label/constants.ts +3 -0
- package/src/components/Form/components/Label/index.ts +1 -0
- package/src/components/Form/components/Label/types.ts +10 -0
- package/src/components/Form/index.ts +11 -0
- package/src/components/Popover/Popover.tsx +30 -0
- package/src/components/Popover/constants.ts +5 -0
- package/src/components/Popover/index.ts +1 -0
- package/src/components/Popover/types.ts +12 -0
- package/src/components/Text/Text.tsx +3 -3
- package/src/components/Text/types.ts +8 -5
- package/src/index.ts +7 -0
- package/src/libs/cva.ts +10 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
2
|
+
import { type VariantProps } from "../../../libs";
|
|
3
|
+
import { getSelectContentClasses, getSelectTriggerClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type SelectTriggerProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof SelectPrimitive.Trigger
|
|
7
|
+
> &
|
|
8
|
+
VariantProps<typeof getSelectTriggerClasses>;
|
|
9
|
+
|
|
10
|
+
export type SelectItemProps = React.ComponentPropsWithoutRef<
|
|
11
|
+
typeof SelectPrimitive.Item
|
|
12
|
+
> &
|
|
13
|
+
VariantProps<typeof getSelectTriggerClasses>;
|
|
14
|
+
|
|
15
|
+
export type SelectContentProps = React.ComponentPropsWithoutRef<
|
|
16
|
+
typeof SelectPrimitive.Content
|
|
17
|
+
> &
|
|
18
|
+
VariantProps<typeof getSelectContentClasses>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
5
|
+
import { cn } from "../../../utilities";
|
|
6
|
+
import {
|
|
7
|
+
getSliderClasses,
|
|
8
|
+
getSliderRootClasses,
|
|
9
|
+
getSliderThumbClasses,
|
|
10
|
+
getSliderTrackClasses,
|
|
11
|
+
} from "./constants";
|
|
12
|
+
import { type SliderProps } from "./types";
|
|
13
|
+
|
|
14
|
+
const Slider = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
|
16
|
+
SliderProps
|
|
17
|
+
>(({ className, size, variant, wide, disabled, name, ...props }, ref) => (
|
|
18
|
+
<SliderPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
name={name}
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
className={cn(getSliderRootClasses({ wide, disabled }), className)}
|
|
23
|
+
data-testid={`${name}-slider-root`}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
<SliderPrimitive.Track
|
|
27
|
+
className={cn(getSliderTrackClasses({ size, variant }))}
|
|
28
|
+
data-testid={`${name}-slider-track`}
|
|
29
|
+
>
|
|
30
|
+
<SliderPrimitive.Range
|
|
31
|
+
className={cn(getSliderClasses({ variant }))}
|
|
32
|
+
data-testid={`${name}-slider-range`}
|
|
33
|
+
/>
|
|
34
|
+
</SliderPrimitive.Track>
|
|
35
|
+
<SliderPrimitive.Thumb
|
|
36
|
+
className={cn(getSliderThumbClasses({ size, variant }))}
|
|
37
|
+
data-testid={`${name}-slider-thumb`}
|
|
38
|
+
/>
|
|
39
|
+
</SliderPrimitive.Root>
|
|
40
|
+
));
|
|
41
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
42
|
+
|
|
43
|
+
export { Slider };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getSliderRootClasses = cva(
|
|
4
|
+
"relative flex touch-none select-none items-center min-w-24",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
disabled: {
|
|
8
|
+
true: "cursor-not-allowed opacity-80",
|
|
9
|
+
},
|
|
10
|
+
wide: {
|
|
11
|
+
true: "w-full",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const getSliderTrackClasses = cva(
|
|
18
|
+
"relative h-2 w-full grow overflow-hidden rounded-full",
|
|
19
|
+
{
|
|
20
|
+
variants: {
|
|
21
|
+
variant: {
|
|
22
|
+
primary: "bg-neutral-content",
|
|
23
|
+
secondary: "bg-neutral-content",
|
|
24
|
+
accent: "bg-neutral-content",
|
|
25
|
+
success: "bg-neutral-content",
|
|
26
|
+
warning: "bg-neutral-content",
|
|
27
|
+
info: "bg-neutral-content",
|
|
28
|
+
error: "bg-neutral-content",
|
|
29
|
+
neutral: "bg-base-200",
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
xs: "h-0.5",
|
|
33
|
+
sm: "h-1",
|
|
34
|
+
md: "h-2",
|
|
35
|
+
lg: "h-3",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
variant: "neutral",
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const getSliderClasses = cva("absolute h-full", {
|
|
45
|
+
variants: {
|
|
46
|
+
variant: {
|
|
47
|
+
primary: "bg-primary",
|
|
48
|
+
secondary: "bg-secondary",
|
|
49
|
+
accent: "bg-accent",
|
|
50
|
+
success: "bg-success",
|
|
51
|
+
warning: "bg-warning",
|
|
52
|
+
info: "bg-info",
|
|
53
|
+
error: "bg-error",
|
|
54
|
+
neutral: "bg-base-content",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
variant: "neutral",
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const getSliderThumbClasses = cva(
|
|
63
|
+
"block h-5 w-5 rounded-full border-2 ring-offset-neutral transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
64
|
+
{
|
|
65
|
+
variants: {
|
|
66
|
+
variant: {
|
|
67
|
+
primary: "border-primary bg-base-100",
|
|
68
|
+
secondary: "border-secondary bg-base-100",
|
|
69
|
+
accent: "border-accent bg-base-100",
|
|
70
|
+
success: "border-success bg-base-100",
|
|
71
|
+
warning: "border-warning bg-base-100",
|
|
72
|
+
info: "border-info bg-base-100",
|
|
73
|
+
error: "border-error bg-base-100",
|
|
74
|
+
neutral: "border-neutral-content bg-neutral",
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
xs: "h-4 w-4",
|
|
78
|
+
sm: "h-4 w-4",
|
|
79
|
+
md: "h-5 w-5",
|
|
80
|
+
lg: "h-7 w-7",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
defaultVariants: {
|
|
84
|
+
variant: "neutral",
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slider } from "./Slider";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type VariantProps } from "../../../libs";
|
|
2
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
3
|
+
import {
|
|
4
|
+
getSliderClasses,
|
|
5
|
+
getSliderRootClasses,
|
|
6
|
+
getSliderThumbClasses,
|
|
7
|
+
getSliderTrackClasses,
|
|
8
|
+
} from "./constants";
|
|
9
|
+
|
|
10
|
+
export type SliderProps = React.ComponentPropsWithoutRef<
|
|
11
|
+
typeof SliderPrimitive.Root
|
|
12
|
+
> &
|
|
13
|
+
VariantProps<typeof getSliderClasses> &
|
|
14
|
+
VariantProps<typeof getSliderTrackClasses> &
|
|
15
|
+
VariantProps<typeof getSliderThumbClasses> &
|
|
16
|
+
VariantProps<typeof getSliderRootClasses>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { type SwitchProps } from "./types";
|
|
4
|
+
import { getSwitchClasses } from "./constants";
|
|
5
|
+
import { cn } from "../../../utilities";
|
|
6
|
+
|
|
7
|
+
const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
|
|
8
|
+
({ className, size, variant, ...props }, ref) => (
|
|
9
|
+
<input
|
|
10
|
+
ref={ref}
|
|
11
|
+
type="checkbox"
|
|
12
|
+
className={cn(getSwitchClasses({ size, variant }), className)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
Switch.displayName = "Switch";
|
|
18
|
+
|
|
19
|
+
export { Switch };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getSwitchClasses = cva("toggle", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
primary: "toggle-primary",
|
|
7
|
+
secondary: "toggle-secondary",
|
|
8
|
+
accent: "toggle-accent",
|
|
9
|
+
success: "toggle-success",
|
|
10
|
+
warning: "toggle-warning",
|
|
11
|
+
info: "toggle-info",
|
|
12
|
+
error: "toggle-error",
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
xs: "toggle-xs",
|
|
16
|
+
sm: "toggle-sm",
|
|
17
|
+
md: "toggle-md",
|
|
18
|
+
lg: "toggle-lg",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch } from "./Switch";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type TextFieldProps } from "./types";
|
|
3
|
+
import { FormControl } from "../components/FormControl/FormControl";
|
|
4
|
+
import { Input } from "../Input";
|
|
5
|
+
|
|
6
|
+
export const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
7
|
+
({ id, name, info, error, label, ...props }: TextFieldProps, ref) => {
|
|
8
|
+
const feedbackId = `${name}-information`;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<FormControl as="label" htmlFor={id}>
|
|
12
|
+
{Boolean(label ?? info) && (
|
|
13
|
+
<div className="label">
|
|
14
|
+
<span className="label-text">{label}</span>
|
|
15
|
+
{info && <span className="label-text-alt">{info}</span>}
|
|
16
|
+
</div>
|
|
17
|
+
)}
|
|
18
|
+
<Input
|
|
19
|
+
id={id}
|
|
20
|
+
ref={ref}
|
|
21
|
+
name={name}
|
|
22
|
+
aria-invalid={error ? true : undefined}
|
|
23
|
+
aria-describedby={feedbackId}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
{Boolean(error) && (
|
|
27
|
+
<div className="label">
|
|
28
|
+
<span className="label-text-alt text-red-500" id={feedbackId}>
|
|
29
|
+
{Array.isArray(error) ? error.join(", ") : error}
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
32
|
+
)}
|
|
33
|
+
</FormControl>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
TextField.displayName = "TextField";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextField } from "./TextField";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type TextareaProps } from "./types";
|
|
3
|
+
import { cn } from "../../../utilities";
|
|
4
|
+
import { getTextareaClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
7
|
+
({ size, variant, wide, outline, className, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<textarea
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
getTextareaClasses({ size, wide, variant, outline }),
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
Textarea.displayName = "Textarea";
|
|
21
|
+
|
|
22
|
+
export { Textarea };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getTextareaClasses = cva(
|
|
4
|
+
"textarea rounded-md transition-all duration-100",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
accent: "textarea-accent",
|
|
9
|
+
error: "textarea-error",
|
|
10
|
+
ghost: "textarea-ghost",
|
|
11
|
+
info: "textarea-info",
|
|
12
|
+
primary: "textarea-primary",
|
|
13
|
+
secondary: "textarea-secondary",
|
|
14
|
+
success: "textarea-success",
|
|
15
|
+
warning: "textarea-warning",
|
|
16
|
+
},
|
|
17
|
+
outline: {
|
|
18
|
+
true: "textarea-bordered",
|
|
19
|
+
},
|
|
20
|
+
wide: {
|
|
21
|
+
true: "w-full",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
xs: "textarea-xs",
|
|
25
|
+
sm: "textarea-sm",
|
|
26
|
+
md: "textarea-md",
|
|
27
|
+
lg: "textarea-lg",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
compoundVariants: [
|
|
31
|
+
{
|
|
32
|
+
size: undefined,
|
|
33
|
+
className: "min-h-fit h-10",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from "./Textarea";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
2
|
+
import type { As, FormControlProps } from "./types";
|
|
3
|
+
import { getFormControlClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../../../utilities";
|
|
5
|
+
import { Label } from "../Label";
|
|
6
|
+
|
|
7
|
+
export const FormControl = <T extends As>({
|
|
8
|
+
as,
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
...props
|
|
12
|
+
}: FormControlProps<T>) => {
|
|
13
|
+
const SlotChild = !as || as === "label" ? Label : as;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Slot className={cn(getFormControlClasses(), className)} {...props}>
|
|
17
|
+
{/* slot merges it's prop into it's immediate child */}
|
|
18
|
+
<SlotChild>{children}</SlotChild>
|
|
19
|
+
</Slot>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FormControl } from "./FormControl";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type VariantProps } from "../../../../libs";
|
|
2
|
+
import { getFormControlClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
export type As = "div" | "span" | "label";
|
|
5
|
+
|
|
6
|
+
type AllowedElements = Pick<JSX.IntrinsicElements, As>;
|
|
7
|
+
|
|
8
|
+
export type FormControlProps<T extends As> = (T extends "label"
|
|
9
|
+
? React.LabelHTMLAttributes<HTMLLabelElement>
|
|
10
|
+
: React.HTMLAttributes<HTMLElement & AllowedElements[T]>) &
|
|
11
|
+
VariantProps<typeof getFormControlClasses> & {
|
|
12
|
+
as?: T;
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import type { LabelProps, LabelTextProps } from "./types";
|
|
3
|
+
import { cn } from "../../../../utilities";
|
|
4
|
+
import { getLabelClasses } from "./constants";
|
|
5
|
+
|
|
6
|
+
const Label = ({ className, ...props }: LabelProps) => (
|
|
7
|
+
<LabelPrimitive.Root
|
|
8
|
+
className={cn(getLabelClasses(), className)}
|
|
9
|
+
{...props}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
12
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
13
|
+
|
|
14
|
+
const LabelText = ({ className, ...props }: LabelTextProps) => (
|
|
15
|
+
<span className={cn("label-text", className)} {...props}>
|
|
16
|
+
Pick the best fantasy franchise
|
|
17
|
+
</span>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
Label.Text = LabelText;
|
|
21
|
+
|
|
22
|
+
export { Label };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Label } from "./Label";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { type VariantProps } from "../../../../libs";
|
|
3
|
+
import { getLabelClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type LabelProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof LabelPrimitive.Root
|
|
7
|
+
> &
|
|
8
|
+
VariantProps<typeof getLabelClasses>;
|
|
9
|
+
|
|
10
|
+
export type LabelTextProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Input } from "./Input";
|
|
2
|
+
export { Phone } from "./Phone";
|
|
3
|
+
export { Radio } from "./Radio";
|
|
4
|
+
export { Range } from "./Range";
|
|
5
|
+
export { Select } from "./Select";
|
|
6
|
+
export { Slider } from "./Slider";
|
|
7
|
+
export { Checkbox } from "./Checkbox";
|
|
8
|
+
export { Textarea } from "./Textarea";
|
|
9
|
+
export { TextField } from "./TextField";
|
|
10
|
+
export { Label } from "./components/Label";
|
|
11
|
+
export { FormControl } from "./components/FormControl";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
|
+
import { getPopoverContentClasses } from "./constants";
|
|
6
|
+
import { cn } from "../../utilities";
|
|
7
|
+
import { PopoverContentProps, PopoverProps } from "./types";
|
|
8
|
+
|
|
9
|
+
const Popover = (props: PopoverProps) => <PopoverPrimitive.Root {...props} />;
|
|
10
|
+
|
|
11
|
+
const PopoverContent = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
13
|
+
PopoverContentProps
|
|
14
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
15
|
+
<PopoverPrimitive.Portal>
|
|
16
|
+
<PopoverPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
align={align}
|
|
19
|
+
sideOffset={sideOffset}
|
|
20
|
+
className={cn(getPopoverContentClasses(), className)}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
</PopoverPrimitive.Portal>
|
|
24
|
+
));
|
|
25
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
26
|
+
|
|
27
|
+
Popover.Content = PopoverContent;
|
|
28
|
+
Popover.Trigger = PopoverPrimitive.Trigger;
|
|
29
|
+
|
|
30
|
+
export { Popover };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
|
|
3
|
+
export const getPopoverContentClasses = cva(
|
|
4
|
+
"z-50 w-72 rounded-md border bg-base-100 p-4 shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
|
5
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from "./Popover";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
2
|
+
import { type VariantProps } from "../../libs";
|
|
3
|
+
import { getPopoverContentClasses } from "./constants";
|
|
4
|
+
|
|
5
|
+
export type PopoverProps = React.ComponentPropsWithoutRef<
|
|
6
|
+
typeof PopoverPrimitive.Root
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export type PopoverContentProps = React.ComponentPropsWithoutRef<
|
|
10
|
+
typeof PopoverPrimitive.Content
|
|
11
|
+
> &
|
|
12
|
+
VariantProps<typeof getPopoverContentClasses>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { As, TextProps } from "./types";
|
|
3
3
|
import { getTextClasses } from "./constants";
|
|
4
4
|
import { cn } from "../../utilities";
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
|
|
7
|
-
export const Text = ({
|
|
7
|
+
export const Text = <T extends As>({
|
|
8
8
|
as,
|
|
9
9
|
size,
|
|
10
10
|
variant,
|
|
11
11
|
children,
|
|
12
12
|
className,
|
|
13
13
|
...props
|
|
14
|
-
}: TextProps) => {
|
|
14
|
+
}: TextProps<T>) => {
|
|
15
15
|
const Comp = as ? Slot : "span";
|
|
16
16
|
const SlotChild = as ? as : React.Fragment;
|
|
17
17
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type VariantProps } from "../../libs";
|
|
2
2
|
import { getTextClasses } from "./constants";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type As = "h1" | "h2" | "h3" | "h4" | "h5" | "p" | "span";
|
|
5
|
+
|
|
6
|
+
type AllowedElements = Pick<JSX.IntrinsicElements, As>;
|
|
7
|
+
|
|
8
|
+
export type TextProps<T extends As> = React.HTMLAttributes<
|
|
9
|
+
HTMLElement & AllowedElements[T]
|
|
10
|
+
> &
|
|
5
11
|
VariantProps<typeof getTextClasses> & {
|
|
6
|
-
as?:
|
|
7
|
-
JSX.IntrinsicElements,
|
|
8
|
-
"h1" | "h2" | "h3" | "h4" | "h5" | "p"
|
|
9
|
-
>;
|
|
12
|
+
as?: As;
|
|
10
13
|
};
|
package/src/index.ts
CHANGED
|
@@ -12,8 +12,15 @@ export * from "./components/Separator";
|
|
|
12
12
|
export * from "./components/Text";
|
|
13
13
|
|
|
14
14
|
/** data input */
|
|
15
|
+
export * from "./components/Form";
|
|
16
|
+
export * from "./components/Combobox";
|
|
15
17
|
|
|
16
18
|
/** feedback */
|
|
17
19
|
export * from "./components/Loading";
|
|
18
20
|
export * from "./components/Skeleton";
|
|
19
21
|
export * from "./components/Tooltip";
|
|
22
|
+
|
|
23
|
+
/** composable */
|
|
24
|
+
export * from "./components/Dialog";
|
|
25
|
+
export * from "./components/Command";
|
|
26
|
+
export * from "./components/Popover";
|
package/src/libs/cva.ts
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { type VariantProps as OriginalVariantProps } from "class-variance-authority";
|
|
2
|
+
|
|
3
|
+
export { cva } from "class-variance-authority";
|
|
4
|
+
|
|
5
|
+
type ExcludeNull<T> = { [P in keyof T]: Exclude<T[P], null> };
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
export type VariantProps<T extends (...args: any) => any> = ExcludeNull<
|
|
9
|
+
OriginalVariantProps<T>
|
|
10
|
+
>;
|