@mbao01/common 0.0.6 → 0.0.8
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/Avatar.d.ts +14 -0
- package/dist/types/components/Avatar/constants.d.ts +15 -0
- package/dist/types/components/Avatar/index.d.ts +1 -0
- package/dist/types/components/Avatar/types.d.ts +7 -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/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 +17 -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 +8 -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 +5 -0
- package/dist/types/components/Progress/constants.d.ts +6 -0
- package/dist/types/components/Progress/index.d.ts +1 -0
- package/dist/types/components/Progress/types.d.ts +5 -0
- package/dist/types/components/Separator/Separator.d.ts +2 -0
- package/dist/types/components/Separator/constants.d.ts +3 -0
- package/dist/types/components/Separator/index.d.ts +1 -0
- package/dist/types/components/Separator/types.d.ts +3 -0
- package/dist/types/components/Skeleton/constants.d.ts +2 -2
- 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/types.d.ts +1 -0
- package/dist/types/index.d.ts +9 -0
- package/package.json +24 -13
- package/src/components/Avatar/Avatar.tsx +59 -0
- package/src/components/Avatar/constants.ts +69 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Avatar/types.ts +25 -0
- 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 +120 -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 +12 -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/Progress/Progress.tsx +31 -0
- package/src/components/Progress/constants.ts +49 -0
- package/src/components/Progress/index.ts +1 -0
- package/src/components/Progress/types.ts +9 -0
- package/src/components/Separator/Separator.tsx +20 -0
- package/src/components/Separator/constants.ts +10 -0
- package/src/components/Separator/index.ts +1 -0
- package/src/components/Separator/types.ts +5 -0
- package/src/components/Text/Text.tsx +3 -3
- package/src/components/Text/types.ts +8 -5
- package/src/index.ts +10 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getRadioClasses = cva("radio", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
primary: "radio-primary",
|
|
7
|
+
secondary: "radio-secondary",
|
|
8
|
+
accent: "radio-accent",
|
|
9
|
+
success: "radio-success",
|
|
10
|
+
warning: "radio-warning",
|
|
11
|
+
info: "radio-info",
|
|
12
|
+
error: "radio-error",
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
xs: "radio-xs",
|
|
16
|
+
sm: "radio-sm",
|
|
17
|
+
md: "radio-md",
|
|
18
|
+
lg: "radio-lg",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Radio } from "./Radio";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type RangeProps } from "./types";
|
|
3
|
+
import { getRangeClasses } from "./constants";
|
|
4
|
+
import { cn } from "../../../utilities";
|
|
5
|
+
|
|
6
|
+
const Range = React.forwardRef<HTMLInputElement, RangeProps>(
|
|
7
|
+
({ className, size, variant, wide, disabled, ...props }, ref) => (
|
|
8
|
+
<input
|
|
9
|
+
ref={ref}
|
|
10
|
+
type="range"
|
|
11
|
+
disabled={disabled}
|
|
12
|
+
className={cn(
|
|
13
|
+
getRangeClasses({ size, variant, wide, disabled }),
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
Range.displayName = "Range";
|
|
21
|
+
|
|
22
|
+
export { Range };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getRangeClasses = cva("range", {
|
|
4
|
+
variants: {
|
|
5
|
+
variant: {
|
|
6
|
+
primary: "range-primary",
|
|
7
|
+
secondary: "range-secondary",
|
|
8
|
+
accent: "range-accent",
|
|
9
|
+
success: "range-success",
|
|
10
|
+
warning: "range-warning",
|
|
11
|
+
info: "range-info",
|
|
12
|
+
error: "range-error",
|
|
13
|
+
neutral: "range-neutral",
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
true: "cursor-not-allowed opacity-80",
|
|
17
|
+
},
|
|
18
|
+
wide: {
|
|
19
|
+
true: "w-full",
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
xs: "range-xs",
|
|
23
|
+
sm: "range-sm",
|
|
24
|
+
md: "range-md",
|
|
25
|
+
lg: "range-lg",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
variant: "neutral",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Range } from "./Range";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
CheckIcon,
|
|
6
|
+
ChevronDownIcon,
|
|
7
|
+
ChevronUpIcon,
|
|
8
|
+
} from "@radix-ui/react-icons";
|
|
9
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
10
|
+
import type {
|
|
11
|
+
SelectContentProps,
|
|
12
|
+
SelectItemProps,
|
|
13
|
+
SelectTriggerProps,
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { cn } from "../../../utilities";
|
|
16
|
+
import {
|
|
17
|
+
getSelectContentClasses,
|
|
18
|
+
getSelectItemClasses,
|
|
19
|
+
getSelectLabelClasses,
|
|
20
|
+
getSelectSeparatorClasses,
|
|
21
|
+
getSelectTriggerClasses,
|
|
22
|
+
getSelectViewportClasses,
|
|
23
|
+
} from "./constants";
|
|
24
|
+
|
|
25
|
+
const Select = (
|
|
26
|
+
props: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Root>
|
|
27
|
+
) => <SelectPrimitive.Root {...props} />;
|
|
28
|
+
|
|
29
|
+
const SelectTrigger = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
31
|
+
SelectTriggerProps
|
|
32
|
+
>(({ className, children, size, wide, variant, outline, ...props }, ref) => (
|
|
33
|
+
<SelectPrimitive.Trigger
|
|
34
|
+
ref={ref}
|
|
35
|
+
className={cn(
|
|
36
|
+
getSelectTriggerClasses({ size, wide, variant, outline }),
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</SelectPrimitive.Trigger>
|
|
43
|
+
));
|
|
44
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
45
|
+
|
|
46
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
47
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
48
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
49
|
+
>((props, ref) => (
|
|
50
|
+
<SelectPrimitive.ScrollUpButton
|
|
51
|
+
ref={ref}
|
|
52
|
+
className={cn("flex cursor-default items-center justify-center py-1")}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
<ChevronUpIcon />
|
|
56
|
+
</SelectPrimitive.ScrollUpButton>
|
|
57
|
+
));
|
|
58
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
59
|
+
|
|
60
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
63
|
+
>((props, ref) => (
|
|
64
|
+
<SelectPrimitive.ScrollDownButton
|
|
65
|
+
ref={ref}
|
|
66
|
+
className={cn("flex cursor-default items-center justify-center py-1")}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
<ChevronDownIcon />
|
|
70
|
+
</SelectPrimitive.ScrollDownButton>
|
|
71
|
+
));
|
|
72
|
+
SelectScrollDownButton.displayName =
|
|
73
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
74
|
+
|
|
75
|
+
const SelectContent = React.forwardRef<
|
|
76
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
77
|
+
SelectContentProps
|
|
78
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
79
|
+
<SelectPrimitive.Portal>
|
|
80
|
+
<SelectPrimitive.Content
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={cn(getSelectContentClasses({ position }), className)}
|
|
83
|
+
position={position}
|
|
84
|
+
{...props}
|
|
85
|
+
>
|
|
86
|
+
<SelectScrollUpButton />
|
|
87
|
+
<SelectPrimitive.Viewport
|
|
88
|
+
className={cn(getSelectViewportClasses({ position }))}
|
|
89
|
+
>
|
|
90
|
+
{children}
|
|
91
|
+
</SelectPrimitive.Viewport>
|
|
92
|
+
<SelectScrollDownButton />
|
|
93
|
+
</SelectPrimitive.Content>
|
|
94
|
+
</SelectPrimitive.Portal>
|
|
95
|
+
));
|
|
96
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
97
|
+
|
|
98
|
+
const SelectLabel = React.forwardRef<
|
|
99
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
101
|
+
>((props, ref) => (
|
|
102
|
+
<SelectPrimitive.Label
|
|
103
|
+
ref={ref}
|
|
104
|
+
className={cn(getSelectLabelClasses())}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
));
|
|
108
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
109
|
+
|
|
110
|
+
const SelectItem = React.forwardRef<
|
|
111
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
112
|
+
SelectItemProps
|
|
113
|
+
>(({ className, children, variant, ...props }, ref) => (
|
|
114
|
+
<SelectPrimitive.Item
|
|
115
|
+
ref={ref}
|
|
116
|
+
className={cn(getSelectItemClasses({ variant }), className)}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
120
|
+
<SelectPrimitive.ItemIndicator>
|
|
121
|
+
<CheckIcon className="h-4 w-4" />
|
|
122
|
+
</SelectPrimitive.ItemIndicator>
|
|
123
|
+
</span>
|
|
124
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
125
|
+
</SelectPrimitive.Item>
|
|
126
|
+
));
|
|
127
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
128
|
+
|
|
129
|
+
const SelectSeparator = React.forwardRef<
|
|
130
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
131
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
132
|
+
>((props, ref) => (
|
|
133
|
+
<SelectPrimitive.Separator
|
|
134
|
+
ref={ref}
|
|
135
|
+
className={cn(getSelectSeparatorClasses())}
|
|
136
|
+
{...props}
|
|
137
|
+
/>
|
|
138
|
+
));
|
|
139
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
140
|
+
|
|
141
|
+
Select.Group = SelectPrimitive.Group;
|
|
142
|
+
Select.Value = SelectPrimitive.Value;
|
|
143
|
+
Select.Trigger = SelectTrigger;
|
|
144
|
+
Select.Content = SelectContent;
|
|
145
|
+
Select.Label = SelectLabel;
|
|
146
|
+
Select.Item = SelectItem;
|
|
147
|
+
Select.Separator = SelectSeparator;
|
|
148
|
+
Select.ScrollUpButton = SelectScrollUpButton;
|
|
149
|
+
Select.ScrollDownButton = SelectScrollDownButton;
|
|
150
|
+
|
|
151
|
+
export { Select };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { cva } from "../../../libs";
|
|
2
|
+
|
|
3
|
+
export const getSelectTriggerClasses = cva(
|
|
4
|
+
"select flex items-center justify-between rounded-md text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
5
|
+
{
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
primary: "select-primary",
|
|
9
|
+
secondary: "select-secondary",
|
|
10
|
+
accent: "select-accent",
|
|
11
|
+
success: "select-success",
|
|
12
|
+
warning: "select-warning",
|
|
13
|
+
info: "select-info",
|
|
14
|
+
error: "select-error",
|
|
15
|
+
},
|
|
16
|
+
outline: {
|
|
17
|
+
true: "select-bordered border border-input",
|
|
18
|
+
},
|
|
19
|
+
wide: {
|
|
20
|
+
true: "w-full",
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
23
|
+
xs: "select-xs",
|
|
24
|
+
sm: "select-sm",
|
|
25
|
+
md: "select-md",
|
|
26
|
+
lg: "select-lg",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
compoundVariants: [
|
|
30
|
+
{
|
|
31
|
+
size: undefined,
|
|
32
|
+
className: "min-h-fit h-10",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const getSelectItemClasses = cva(
|
|
39
|
+
"relative flex w-full cursor-pointer select-none items-center focus:bg-neutral focus:text-neutral-content rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
40
|
+
{
|
|
41
|
+
variants: {
|
|
42
|
+
variant: {
|
|
43
|
+
primary: "focus:bg-primary focus:text-primary-content",
|
|
44
|
+
secondary: "focus:bg-secondary focus:text-secondary-content",
|
|
45
|
+
accent: "focus:bg-accent focus:text-accent-content",
|
|
46
|
+
success: "focus:bg-success focus:text-success-content",
|
|
47
|
+
warning: "focus:bg-warning focus:text-warning-content",
|
|
48
|
+
info: "focus:bg-info focus:text-info-content",
|
|
49
|
+
error: "focus:bg-error focus:text-error-content",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const getSelectLabelClasses = cva("px-2 py-1.5 text-sm font-semibold");
|
|
56
|
+
|
|
57
|
+
export const getSelectSeparatorClasses = cva("-mx-1 my-1 h-px bg-muted");
|
|
58
|
+
|
|
59
|
+
export const getSelectContentClasses = cva(
|
|
60
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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",
|
|
61
|
+
{
|
|
62
|
+
variants: {
|
|
63
|
+
position: {
|
|
64
|
+
popper:
|
|
65
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
66
|
+
"item-aligned": "",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
export const getSelectViewportClasses = cva("p-1", {
|
|
73
|
+
variants: {
|
|
74
|
+
position: {
|
|
75
|
+
popper:
|
|
76
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
77
|
+
"item-aligned": "",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from "./Select";
|
|
@@ -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
|
+
);
|