@mbao01/common 0.5.2 → 0.6.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/dist/types/components/Alert/constants.d.ts +1 -1
- package/dist/types/components/AlertDialog/AlertDialog.d.ts +7 -5
- package/dist/types/components/Anchor/{constant.d.ts → constants.d.ts} +1 -1
- package/dist/types/components/Anchor/types.d.ts +1 -1
- package/dist/types/components/AspectRatio/AspectRatio.d.ts +6 -0
- package/dist/types/components/AspectRatio/constants.d.ts +3 -0
- package/dist/types/components/AspectRatio/index.d.ts +2 -0
- package/dist/types/components/AspectRatio/types.d.ts +5 -0
- package/dist/types/components/Avatar/constants.d.ts +6 -6
- package/dist/types/components/Badge/constants.d.ts +1 -1
- package/dist/types/components/Banner/Banner.d.ts +11 -0
- package/dist/types/components/Banner/constants.d.ts +4 -0
- package/dist/types/components/Banner/index.d.ts +2 -0
- package/dist/types/components/Banner/types.d.ts +9 -0
- package/dist/types/components/Blockquote/Blockquote.d.ts +6 -0
- package/dist/types/components/Blockquote/constants.d.ts +3 -0
- package/dist/types/components/Blockquote/index.d.ts +2 -0
- package/dist/types/components/Blockquote/types.d.ts +5 -0
- package/dist/types/components/Box/Box.d.ts +6 -0
- package/dist/types/components/Box/constants.d.ts +5 -0
- package/dist/types/components/Box/index.d.ts +2 -0
- package/dist/types/components/Box/types.d.ts +3 -0
- package/dist/types/components/Breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/types/components/Breadcrumb/types.d.ts +1 -1
- package/dist/types/components/Button/Button.d.ts +3 -2
- package/dist/types/components/Button/constants.d.ts +2 -1
- package/dist/types/components/Carousel/Carousel.d.ts +6 -4
- package/dist/types/components/Center/Center.d.ts +5 -0
- package/dist/types/components/Center/constants.d.ts +4 -0
- package/dist/types/components/Center/index.d.ts +2 -0
- package/dist/types/components/Center/types.d.ts +3 -0
- package/dist/types/components/Chart/constants.d.ts +2 -2
- package/dist/types/components/Code/Code.d.ts +8 -0
- package/dist/types/components/Code/constants.d.ts +4 -0
- package/dist/types/components/Code/helper.d.ts +2 -0
- package/dist/types/components/Code/index.d.ts +2 -0
- package/dist/types/components/Code/types.d.ts +6 -0
- package/dist/types/components/Combobox/Combobox.d.ts +1 -1
- package/dist/types/components/Combobox/types.d.ts +1 -0
- package/dist/types/components/Container/Container.d.ts +6 -0
- package/dist/types/components/Container/constants.d.ts +5 -0
- package/dist/types/components/Container/index.d.ts +2 -0
- package/dist/types/components/Container/types.d.ts +3 -0
- package/dist/types/components/DatetimePicker/DatetimeGrid.d.ts +2 -2
- package/dist/types/components/DatetimePicker/DatetimePicker.d.ts +2 -2
- package/dist/types/components/DatetimePicker/constants.d.ts +1 -1
- package/dist/types/components/Dialog/Dialog.d.ts +1 -1
- package/dist/types/components/Dialog/constants.d.ts +1 -1
- package/dist/types/components/Dock/constants.d.ts +2 -2
- package/dist/types/components/Empty/Empty.d.ts +8 -0
- package/dist/types/components/Empty/constants.d.ts +6 -0
- package/dist/types/components/Empty/index.d.ts +2 -0
- package/dist/types/components/Empty/types.d.ts +3 -0
- package/dist/types/components/Flex/Flex.d.ts +8 -0
- package/dist/types/components/Flex/constants.d.ts +7 -0
- package/dist/types/components/Flex/index.d.ts +2 -0
- package/dist/types/components/Flex/types.d.ts +3 -0
- package/dist/types/components/Footer/Footer.d.ts +6 -0
- package/dist/types/components/Footer/constants.d.ts +4 -0
- package/dist/types/components/Footer/index.d.ts +2 -0
- package/dist/types/components/Footer/types.d.ts +4 -0
- package/dist/types/components/Form/DatetimeInput/DatetimeInput.d.ts +3 -3
- package/dist/types/components/Form/Input/Input.d.ts +4 -4
- package/dist/types/components/Form/Input/constants.d.ts +2 -2
- package/dist/types/components/Form/NativeSelect/NativeSelect.d.ts +8 -0
- package/dist/types/components/Form/NativeSelect/constants.d.ts +7 -0
- package/dist/types/components/Form/NativeSelect/index.d.ts +2 -0
- package/dist/types/components/Form/NativeSelect/types.d.ts +3 -0
- package/dist/types/components/Form/Radio/Radio.d.ts +1 -1
- package/dist/types/components/Form/Range/Range.d.ts +1 -1
- package/dist/types/components/Form/Select/Select.d.ts +4 -4
- package/dist/types/components/Form/Select/constants.d.ts +2 -2
- package/dist/types/components/Form/Switch/Switch.d.ts +1 -1
- package/dist/types/components/Form/TagsInput/TagsInput.d.ts +2 -2
- package/dist/types/components/Form/TextField/TextField.d.ts +4 -4
- package/dist/types/components/Form/Textarea/Textarea.d.ts +3 -3
- package/dist/types/components/Form/Textarea/constants.d.ts +1 -1
- package/dist/types/components/Form/components/Field/Field.d.ts +8 -0
- package/dist/types/components/Form/components/Field/FieldContext.d.ts +2 -0
- package/dist/types/components/Form/components/Field/constants.d.ts +6 -0
- package/dist/types/components/Form/components/Field/hooks/index.d.ts +1 -0
- package/dist/types/components/Form/components/Field/hooks/useField/index.d.ts +1 -0
- package/dist/types/components/Form/components/Field/hooks/useField/useField.d.ts +1 -0
- package/dist/types/components/Form/components/Field/index.d.ts +2 -0
- package/dist/types/components/Form/components/Field/types.d.ts +12 -0
- package/dist/types/components/Form/index.d.ts +2 -0
- package/dist/types/components/Grid/Grid.d.ts +11 -0
- package/dist/types/components/Grid/constants.d.ts +10 -0
- package/dist/types/components/Grid/index.d.ts +2 -0
- package/dist/types/components/Grid/types.d.ts +4 -0
- package/dist/types/components/Header/Header.d.ts +7 -0
- package/dist/types/components/Header/constants.d.ts +3 -0
- package/dist/types/components/Header/index.d.ts +2 -0
- package/dist/types/components/Header/types.d.ts +3 -0
- package/dist/types/components/Heading/Heading.d.ts +7 -0
- package/dist/types/components/Heading/constants.d.ts +4 -0
- package/dist/types/components/Heading/index.d.ts +2 -0
- package/dist/types/components/Heading/types.d.ts +7 -0
- package/dist/types/components/Image/Image.d.ts +7 -0
- package/dist/types/components/Image/constants.d.ts +4 -0
- package/dist/types/components/Image/index.d.ts +2 -0
- package/dist/types/components/Image/types.d.ts +5 -0
- package/dist/types/components/Kbd/constants.d.ts +1 -1
- package/dist/types/components/List/constants.d.ts +1 -1
- package/dist/types/components/Loading/Loading.d.ts +1 -1
- package/dist/types/components/Loading/constants.d.ts +2 -2
- package/dist/types/components/Menu/ContextMenu/ContextMenu.d.ts +4 -4
- package/dist/types/components/Menu/DropdownMenu/DropdownMenu.d.ts +4 -4
- package/dist/types/components/Menu/Menubar/Menubar.d.ts +5 -5
- package/dist/types/components/Menu/Menubar/constants.d.ts +5 -5
- package/dist/types/components/Menu/NavigationMenu/NavigationMenu.d.ts +1 -1
- package/dist/types/components/Menu/NavigationMenu/constants.d.ts +1 -1
- package/dist/types/components/Panel/Panel.d.ts +11 -0
- package/dist/types/components/Panel/constants.d.ts +7 -0
- package/dist/types/components/Panel/index.d.ts +2 -0
- package/dist/types/components/Panel/types.d.ts +8 -0
- package/dist/types/components/Paragraph/Paragraph.d.ts +3 -0
- package/dist/types/components/Paragraph/constants.d.ts +3 -0
- package/dist/types/components/Paragraph/index.d.ts +2 -0
- package/dist/types/components/Paragraph/types.d.ts +5 -0
- package/dist/types/components/Progress/Progress.d.ts +1 -1
- package/dist/types/components/Progress/constants.d.ts +2 -2
- package/dist/types/components/Resizable/Resizable.d.ts +1 -1
- package/dist/types/components/ScrollArea/ScrollArea.d.ts +1 -1
- package/dist/types/components/ScrollArea/constants.d.ts +1 -1
- package/dist/types/components/Sheet/Sheet.d.ts +12 -0
- package/dist/types/components/Sheet/constants.d.ts +7 -0
- package/dist/types/components/Sheet/index.d.ts +2 -0
- package/dist/types/components/Sheet/types.d.ts +5 -0
- package/dist/types/components/Sidebar/Sidebar.d.ts +8 -7
- package/dist/types/components/Sidebar/SidebarMenu.d.ts +3 -2
- package/dist/types/components/Sidebar/constants.d.ts +5 -4
- package/dist/types/components/Sidebar/types.d.ts +1 -1
- package/dist/types/components/Skeleton/Skeleton.d.ts +1 -1
- package/dist/types/components/Skeleton/constants.d.ts +3 -3
- package/dist/types/components/Sonner/constants.d.ts +2 -2
- package/dist/types/components/Spacer/Spacer.d.ts +5 -0
- package/dist/types/components/Spacer/constants.d.ts +4 -0
- package/dist/types/components/Spacer/index.d.ts +2 -0
- package/dist/types/components/Spacer/types.d.ts +3 -0
- package/dist/types/components/Spinner/Spinner.d.ts +5 -0
- package/dist/types/components/Spinner/constants.d.ts +4 -0
- package/dist/types/components/Spinner/index.d.ts +2 -0
- package/dist/types/components/Spinner/types.d.ts +3 -0
- package/dist/types/components/Status/constants.d.ts +1 -1
- package/dist/types/components/Stepper/Stepper.d.ts +9 -0
- package/dist/types/components/Stepper/constants.d.ts +6 -0
- package/dist/types/components/Stepper/index.d.ts +2 -0
- package/dist/types/components/Stepper/types.d.ts +6 -0
- package/dist/types/components/Text/constants.d.ts +1 -1
- package/dist/types/components/Timeline/Timeline.d.ts +5 -5
- package/dist/types/components/Timeline/constants.d.ts +5 -5
- package/dist/types/components/Toggle/Toggle.d.ts +5 -3
- package/dist/types/components/Toggle/constants.d.ts +2 -1
- package/dist/types/components/ToggleGroup/ToggleGroup.d.ts +5 -3
- package/dist/types/index.d.ts +24 -0
- package/dist/types/utilities/createVariants/createVariants.d.ts +2 -0
- package/dist/types/utilities/createVariants/index.d.ts +1 -0
- package/dist/types/utilities/createVariants/type.d.ts +10 -0
- package/dist/types/utilities/index.d.ts +1 -0
- package/package.json +41 -41
- package/src/components/Alert/constants.ts +3 -2
- package/src/components/Anchor/Anchor.tsx +1 -1
- package/src/components/Anchor/{constant.ts → constants.ts} +4 -4
- package/src/components/Anchor/types.ts +1 -1
- package/src/components/AspectRatio/AspectRatio.tsx +23 -0
- package/src/components/AspectRatio/constants.ts +17 -0
- package/src/components/AspectRatio/index.ts +2 -0
- package/src/components/AspectRatio/types.ts +7 -0
- package/src/components/Avatar/constants.ts +17 -22
- package/src/components/Badge/constants.ts +3 -2
- package/src/components/Banner/Banner.tsx +36 -0
- package/src/components/Banner/constants.ts +18 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/Banner/types.ts +11 -0
- package/src/components/Blockquote/Blockquote.tsx +21 -0
- package/src/components/Blockquote/constants.ts +22 -0
- package/src/components/Blockquote/index.ts +2 -0
- package/src/components/Blockquote/types.ts +7 -0
- package/src/components/Box/Box.tsx +20 -0
- package/src/components/Box/constants.ts +34 -0
- package/src/components/Box/index.ts +2 -0
- package/src/components/Box/types.ts +4 -0
- package/src/components/Breadcrumb/types.ts +1 -1
- package/src/components/Button/Button.tsx +3 -4
- package/src/components/Button/constants.ts +6 -3
- package/src/components/Card/constants.ts +3 -2
- package/src/components/Carousel/constants.ts +9 -8
- package/src/components/Center/Center.tsx +16 -0
- package/src/components/Center/constants.ts +20 -0
- package/src/components/Center/index.ts +2 -0
- package/src/components/Center/types.ts +5 -0
- package/src/components/Chart/constants.ts +9 -8
- package/src/components/Code/Code.tsx +51 -0
- package/src/components/Code/constants.ts +28 -0
- package/src/components/Code/helper.ts +10 -0
- package/src/components/Code/index.ts +2 -0
- package/src/components/Code/types.ts +8 -0
- package/src/components/Combobox/Combobox.tsx +2 -3
- package/src/components/Combobox/types.ts +1 -0
- package/src/components/Container/Container.tsx +20 -0
- package/src/components/Container/constants.ts +31 -0
- package/src/components/Container/index.ts +2 -0
- package/src/components/Container/types.ts +5 -0
- package/src/components/DatetimePicker/constants.ts +5 -4
- package/src/components/Dialog/Dialog.tsx +3 -3
- package/src/components/Dialog/constants.ts +5 -4
- package/src/components/Dock/constants.ts +14 -13
- package/src/components/DragAndDrop/Draggable/constants.ts +5 -4
- package/src/components/DragAndDrop/Droppable/constants.ts +3 -2
- package/src/components/DragAndDrop/Sortable/constants.ts +3 -2
- package/src/components/Empty/Empty.tsx +66 -0
- package/src/components/Empty/constants.ts +30 -0
- package/src/components/Empty/index.ts +2 -0
- package/src/components/Empty/types.ts +5 -0
- package/src/components/Flex/Flex.tsx +20 -0
- package/src/components/Flex/constants.ts +51 -0
- package/src/components/Flex/index.ts +2 -0
- package/src/components/Flex/types.ts +4 -0
- package/src/components/Footer/Footer.tsx +26 -0
- package/src/components/Footer/constants.ts +12 -0
- package/src/components/Footer/index.ts +2 -0
- package/src/components/Footer/types.ts +6 -0
- package/src/components/Form/Checkbox/constants.ts +5 -4
- package/src/components/Form/DatetimeInput/constants.ts +9 -8
- package/src/components/Form/Input/constants.ts +7 -6
- package/src/components/Form/MultiSelect/constants.ts +10 -9
- package/src/components/Form/NativeSelect/NativeSelect.tsx +23 -0
- package/src/components/Form/NativeSelect/constants.ts +39 -0
- package/src/components/Form/NativeSelect/index.ts +2 -0
- package/src/components/Form/NativeSelect/types.ts +5 -0
- package/src/components/Form/Radio/constants.ts +3 -2
- package/src/components/Form/Range/constants.ts +3 -2
- package/src/components/Form/Select/constants.ts +14 -13
- package/src/components/Form/Slider/constants.ts +9 -8
- package/src/components/Form/Switch/constants.ts +3 -2
- package/src/components/Form/TagsInput/TagsInput.tsx +1 -1
- package/src/components/Form/TagsInput/constants.ts +7 -6
- package/src/components/Form/Textarea/constants.ts +3 -2
- package/src/components/Form/Validator/constants.ts +3 -2
- package/src/components/Form/components/Field/Field.tsx +81 -0
- package/src/components/Form/components/Field/FieldContext.tsx +4 -0
- package/src/components/Form/components/Field/constants.ts +20 -0
- package/src/components/Form/components/Field/hooks/index.ts +1 -0
- package/src/components/Form/components/Field/hooks/useField/index.ts +1 -0
- package/src/components/Form/components/Field/hooks/useField/useField.ts +10 -0
- package/src/components/Form/components/Field/index.ts +2 -0
- package/src/components/Form/components/Field/types.ts +19 -0
- package/src/components/Form/index.ts +2 -0
- package/src/components/Grid/Grid.tsx +32 -0
- package/src/components/Grid/constants.ts +84 -0
- package/src/components/Grid/index.ts +2 -0
- package/src/components/Grid/types.ts +7 -0
- package/src/components/Header/Header.tsx +49 -0
- package/src/components/Header/constants.ts +18 -0
- package/src/components/Header/index.ts +2 -0
- package/src/components/Header/types.ts +4 -0
- package/src/components/Heading/Heading.tsx +23 -0
- package/src/components/Heading/constants.ts +25 -0
- package/src/components/Heading/index.ts +2 -0
- package/src/components/Heading/types.ts +10 -0
- package/src/components/Image/Image.tsx +30 -0
- package/src/components/Image/constants.ts +25 -0
- package/src/components/Image/index.ts +2 -0
- package/src/components/Image/types.ts +7 -0
- package/src/components/Kbd/constants.ts +3 -2
- package/src/components/List/constants.ts +3 -2
- package/src/components/Loading/Loading.tsx +2 -4
- package/src/components/Loading/constants.ts +5 -4
- package/src/components/Menu/Menubar/constants.ts +16 -14
- package/src/components/Menu/NavigationMenu/constants.ts +5 -3
- package/src/components/Panel/Panel.tsx +58 -0
- package/src/components/Panel/constants.ts +31 -0
- package/src/components/Panel/index.ts +2 -0
- package/src/components/Panel/types.ts +11 -0
- package/src/components/Paragraph/Paragraph.tsx +17 -0
- package/src/components/Paragraph/constants.ts +18 -0
- package/src/components/Paragraph/index.ts +2 -0
- package/src/components/Paragraph/types.ts +8 -0
- package/src/components/Progress/constants.ts +9 -10
- package/src/components/Resizable/constants.ts +3 -2
- package/src/components/ScrollArea/constants.ts +6 -5
- package/src/components/Separator/constants.ts +3 -2
- package/src/components/Sheet/Sheet.tsx +126 -0
- package/src/components/Sheet/constants.ts +45 -0
- package/src/components/Sheet/index.ts +9 -0
- package/src/components/Sheet/types.ts +7 -0
- package/src/components/Sidebar/Sidebar.tsx +5 -5
- package/src/components/Sidebar/SidebarMenu.tsx +3 -3
- package/src/components/Sidebar/constants.ts +32 -25
- package/src/components/Sidebar/types.ts +1 -1
- package/src/components/Skeleton/Skeleton.tsx +2 -2
- package/src/components/Skeleton/constants.ts +4 -3
- package/src/components/Sonner/Toaster.tsx +1 -1
- package/src/components/Sonner/constants.ts +6 -5
- package/src/components/Sonner/helpers.ts +1 -1
- package/src/components/Spacer/Spacer.tsx +19 -0
- package/src/components/Spacer/constants.ts +55 -0
- package/src/components/Spacer/index.ts +2 -0
- package/src/components/Spacer/types.ts +5 -0
- package/src/components/Spinner/Spinner.tsx +24 -0
- package/src/components/Spinner/constants.ts +29 -0
- package/src/components/Spinner/index.ts +2 -0
- package/src/components/Spinner/types.ts +5 -0
- package/src/components/Stack/constants.ts +3 -2
- package/src/components/Stat/constants.ts +5 -4
- package/src/components/Status/constants.ts +3 -2
- package/src/components/Stepper/Stepper.tsx +30 -0
- package/src/components/Stepper/constants.ts +29 -0
- package/src/components/Stepper/index.ts +2 -0
- package/src/components/Stepper/types.ts +10 -0
- package/src/components/Table/constants.ts +3 -2
- package/src/components/Text/constants.ts +4 -7
- package/src/components/Timeline/Timeline.example.tsx +1 -1
- package/src/components/Timeline/constants.ts +19 -22
- package/src/components/Toggle/Toggle.tsx +3 -3
- package/src/components/Toggle/constants.ts +6 -3
- package/src/components/ToggleGroup/ToggleGroup.tsx +4 -2
- package/src/components/Tooltip/constants.ts +5 -4
- package/src/index.ts +27 -0
- package/src/utilities/createVariants/createVariants.ts +5 -0
- package/src/utilities/createVariants/index.ts +1 -0
- package/src/utilities/createVariants/type.ts +29 -0
- package/src/utilities/index.ts +1 -0
- package/vitest-setup.ts +4 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { cva } from "../../../libs";
|
|
2
|
+
import { createVariants } from "../../../utilities";
|
|
2
3
|
|
|
3
4
|
export const getSliderRootClasses = cva(
|
|
4
5
|
"relative flex touch-none select-none items-center min-w-24",
|
|
5
6
|
{
|
|
6
|
-
variants: {
|
|
7
|
+
variants: createVariants({
|
|
7
8
|
disabled: {
|
|
8
9
|
true: "cursor-not-allowed opacity-80",
|
|
9
10
|
},
|
|
10
11
|
wide: {
|
|
11
12
|
true: "w-full",
|
|
12
13
|
},
|
|
13
|
-
},
|
|
14
|
+
}),
|
|
14
15
|
}
|
|
15
16
|
);
|
|
16
17
|
|
|
17
18
|
export const getSliderTrackClasses = cva("relative h-2 w-full grow overflow-hidden rounded-full", {
|
|
18
|
-
variants: {
|
|
19
|
+
variants: createVariants({
|
|
19
20
|
variant: {
|
|
20
21
|
primary: "bg-neutral-content",
|
|
21
22
|
secondary: "bg-neutral-content",
|
|
@@ -32,14 +33,14 @@ export const getSliderTrackClasses = cva("relative h-2 w-full grow overflow-hidd
|
|
|
32
33
|
md: "h-2",
|
|
33
34
|
lg: "h-3",
|
|
34
35
|
},
|
|
35
|
-
},
|
|
36
|
+
}),
|
|
36
37
|
defaultVariants: {
|
|
37
38
|
variant: "neutral",
|
|
38
39
|
},
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
export const getSliderClasses = cva("absolute h-full", {
|
|
42
|
-
variants: {
|
|
43
|
+
variants: createVariants({
|
|
43
44
|
variant: {
|
|
44
45
|
primary: "bg-primary",
|
|
45
46
|
secondary: "bg-secondary",
|
|
@@ -50,7 +51,7 @@ export const getSliderClasses = cva("absolute h-full", {
|
|
|
50
51
|
error: "bg-error",
|
|
51
52
|
neutral: "bg-base-content",
|
|
52
53
|
},
|
|
53
|
-
},
|
|
54
|
+
}),
|
|
54
55
|
defaultVariants: {
|
|
55
56
|
variant: "neutral",
|
|
56
57
|
},
|
|
@@ -59,7 +60,7 @@ export const getSliderClasses = cva("absolute h-full", {
|
|
|
59
60
|
export const getSliderThumbClasses = cva(
|
|
60
61
|
"block h-5 w-5 rounded-full border-2 ring-offset-neutral transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
61
62
|
{
|
|
62
|
-
variants: {
|
|
63
|
+
variants: createVariants({
|
|
63
64
|
variant: {
|
|
64
65
|
primary: "border-primary bg-base-100",
|
|
65
66
|
secondary: "border-secondary bg-base-100",
|
|
@@ -76,7 +77,7 @@ export const getSliderThumbClasses = cva(
|
|
|
76
77
|
md: "h-5 w-5",
|
|
77
78
|
lg: "h-7 w-7",
|
|
78
79
|
},
|
|
79
|
-
},
|
|
80
|
+
}),
|
|
80
81
|
defaultVariants: {
|
|
81
82
|
variant: "neutral",
|
|
82
83
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { cva } from "../../../libs";
|
|
2
|
+
import { createVariants } from "../../../utilities";
|
|
2
3
|
|
|
3
4
|
export const getSwitchClasses = cva("toggle", {
|
|
4
|
-
variants: {
|
|
5
|
+
variants: createVariants({
|
|
5
6
|
variant: {
|
|
6
7
|
primary: "toggle-primary",
|
|
7
8
|
secondary: "toggle-secondary",
|
|
@@ -17,5 +18,5 @@ export const getSwitchClasses = cva("toggle", {
|
|
|
17
18
|
md: "toggle-md",
|
|
18
19
|
lg: "toggle-lg",
|
|
19
20
|
},
|
|
20
|
-
},
|
|
21
|
+
}),
|
|
21
22
|
});
|
|
@@ -264,7 +264,7 @@ export const TagsInput = forwardRef<HTMLDivElement, TagsInputProps>(
|
|
|
264
264
|
tabIndex={0}
|
|
265
265
|
onSelect={handleSelect}
|
|
266
266
|
aria-label={ariaLabel}
|
|
267
|
-
disabled={disabled
|
|
267
|
+
disabled={disabled ?? disableInput}
|
|
268
268
|
onKeyDown={handleKeyDown}
|
|
269
269
|
onPaste={handlePaste}
|
|
270
270
|
value={inputValue}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { cva } from "../../../libs";
|
|
2
|
+
import { createVariants } from "../../../utilities";
|
|
2
3
|
|
|
3
4
|
export const SPLITTER_REGEX = /[\n#?=&\t,./-]+/; // used for identifying the split char and used with pasting
|
|
4
5
|
|
|
5
6
|
export const FORMATTING_REGEX = /^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g; // used for formatting the pasted element for the correct value format to be added
|
|
6
7
|
|
|
7
8
|
export const getTagsClasses = cva("flex-wrap h-fit py-2 overflow-hidden", {
|
|
8
|
-
variants: {
|
|
9
|
+
variants: createVariants({
|
|
9
10
|
size: {
|
|
10
11
|
xs: "min-h-6 leading-relaxed px-2 py-1 text-xs",
|
|
11
12
|
sm: "min-h-8 leading-8 px-3 py-1.5 text-sm",
|
|
12
13
|
md: "min-h-12 leading-loose px-4 text-sm",
|
|
13
14
|
lg: "min-h-16 leading-loose px-5 text-lg",
|
|
14
15
|
},
|
|
15
|
-
},
|
|
16
|
+
}),
|
|
16
17
|
compoundVariants: [
|
|
17
18
|
{
|
|
18
19
|
size: undefined,
|
|
@@ -24,28 +25,28 @@ export const getTagsClasses = cva("flex-wrap h-fit py-2 overflow-hidden", {
|
|
|
24
25
|
export const getTagClasses = cva(
|
|
25
26
|
"relative flex items-center gap-1 [&>span]:truncate [&>span]:max-w-24 aria-disabled:opacity-50 aria-disabled:cursor-not-allowed focus-visible:outline-hidden",
|
|
26
27
|
{
|
|
27
|
-
variants: {
|
|
28
|
+
variants: createVariants({
|
|
28
29
|
size: {
|
|
29
30
|
xs: "px-0.5 [&>span]:max-w-20 rounded-sm",
|
|
30
31
|
sm: "px-1",
|
|
31
32
|
md: "px-1.5 [&>span]:max-w-28",
|
|
32
33
|
lg: "px-2 [&>span]:max-w-32",
|
|
33
34
|
},
|
|
34
|
-
},
|
|
35
|
+
}),
|
|
35
36
|
}
|
|
36
37
|
);
|
|
37
38
|
|
|
38
39
|
export const getTagsInputClasses = cva(
|
|
39
40
|
"outline-0 border-none h-5 min-w-fit shadow-none flex-1 focus-visible:outline-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:border-0 placeholder:text-muted-foreground px-1",
|
|
40
41
|
{
|
|
41
|
-
variants: {
|
|
42
|
+
variants: createVariants({
|
|
42
43
|
size: {
|
|
43
44
|
xs: "h-3 leading-relaxed text-xs",
|
|
44
45
|
sm: "h-4 leading-8 text-sm",
|
|
45
46
|
md: "h-5 text-sm",
|
|
46
47
|
lg: "h-6 text-lg",
|
|
47
48
|
},
|
|
48
|
-
},
|
|
49
|
+
}),
|
|
49
50
|
}
|
|
50
51
|
);
|
|
51
52
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { cva } from "../../../libs";
|
|
2
|
+
import { createVariants } from "../../../utilities";
|
|
2
3
|
|
|
3
4
|
export const getTextareaClasses = cva("textarea rounded-md transition-all duration-100", {
|
|
4
|
-
variants: {
|
|
5
|
+
variants: createVariants({
|
|
5
6
|
variant: {
|
|
6
7
|
default: "bg-transparent",
|
|
7
8
|
accent: "textarea-accent",
|
|
@@ -25,7 +26,7 @@ export const getTextareaClasses = cva("textarea rounded-md transition-all durati
|
|
|
25
26
|
md: "textarea-md",
|
|
26
27
|
lg: "textarea-lg",
|
|
27
28
|
},
|
|
28
|
-
},
|
|
29
|
+
}),
|
|
29
30
|
compoundVariants: [
|
|
30
31
|
{
|
|
31
32
|
size: undefined,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { cva } from "../../../libs";
|
|
2
|
+
import { createVariants } from "../../../utilities";
|
|
2
3
|
|
|
3
4
|
export const getValidatorClasses = cva("border-color-[unset] validator");
|
|
4
5
|
|
|
5
6
|
export const getValidatorHintClasses = cva("validator-hint", {
|
|
6
|
-
variants: {
|
|
7
|
+
variants: createVariants({
|
|
7
8
|
visible: {
|
|
8
9
|
true: "block",
|
|
9
10
|
false: "hidden",
|
|
10
11
|
},
|
|
11
|
-
},
|
|
12
|
+
}),
|
|
12
13
|
compoundVariants: [
|
|
13
14
|
{
|
|
14
15
|
visible: undefined,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useId } from "react";
|
|
2
|
+
import { cn } from "../../../../utilities";
|
|
3
|
+
import {
|
|
4
|
+
getFieldClasses,
|
|
5
|
+
getFieldDescriptionClasses,
|
|
6
|
+
getFieldErrorClasses,
|
|
7
|
+
getFieldLabelClasses,
|
|
8
|
+
} from "./constants";
|
|
9
|
+
import { FieldContext } from "./FieldContext";
|
|
10
|
+
import { useField } from "./hooks";
|
|
11
|
+
import {
|
|
12
|
+
type FieldDescriptionProps,
|
|
13
|
+
type FieldErrorProps,
|
|
14
|
+
type FieldLabelProps,
|
|
15
|
+
type FieldProps,
|
|
16
|
+
} from "./types";
|
|
17
|
+
|
|
18
|
+
export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
|
|
19
|
+
({ className, children, ...props }, ref) => {
|
|
20
|
+
const id = useId();
|
|
21
|
+
const inputId = `${id}-input`;
|
|
22
|
+
const descriptionId = `${id}-description`;
|
|
23
|
+
const errorId = `${id}-error`;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<FieldContext.Provider value={{ id, inputId, descriptionId, errorId }}>
|
|
27
|
+
<div ref={ref} className={cn(getFieldClasses(), className)} {...props}>
|
|
28
|
+
{children}
|
|
29
|
+
</div>
|
|
30
|
+
</FieldContext.Provider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
Field.displayName = "Field";
|
|
35
|
+
|
|
36
|
+
export const FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(
|
|
37
|
+
({ className, required, children, htmlFor, ...props }, ref) => {
|
|
38
|
+
const { inputId } = useField();
|
|
39
|
+
return (
|
|
40
|
+
<label
|
|
41
|
+
ref={ref}
|
|
42
|
+
htmlFor={htmlFor ?? inputId}
|
|
43
|
+
className={cn(getFieldLabelClasses({ required }), className)}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
<span className="label-text">{children}</span>
|
|
47
|
+
</label>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
FieldLabel.displayName = "FieldLabel";
|
|
52
|
+
|
|
53
|
+
export const FieldDescription = React.forwardRef<HTMLParagraphElement, FieldDescriptionProps>(
|
|
54
|
+
({ className, children, ...props }, ref) => {
|
|
55
|
+
const { descriptionId } = useField();
|
|
56
|
+
return (
|
|
57
|
+
<p
|
|
58
|
+
ref={ref}
|
|
59
|
+
id={descriptionId}
|
|
60
|
+
className={cn(getFieldDescriptionClasses(), className)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</p>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
FieldDescription.displayName = "FieldDescription";
|
|
69
|
+
|
|
70
|
+
export const FieldError = React.forwardRef<HTMLParagraphElement, FieldErrorProps>(
|
|
71
|
+
({ className, children, ...props }, ref) => {
|
|
72
|
+
const { errorId } = useField();
|
|
73
|
+
if (!children) return null;
|
|
74
|
+
return (
|
|
75
|
+
<p ref={ref} id={errorId} className={cn(getFieldErrorClasses(), className)} {...props}>
|
|
76
|
+
{children}
|
|
77
|
+
</p>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
FieldError.displayName = "FieldError";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cva } from "../../../../libs";
|
|
2
|
+
import { createVariants } from "../../../../utilities";
|
|
3
|
+
|
|
4
|
+
export const getFieldClasses = cva("form-control w-full", {
|
|
5
|
+
variants: createVariants({
|
|
6
|
+
// Add variants if needed, e.g. layout direction
|
|
7
|
+
}),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const getFieldLabelClasses = cva("label", {
|
|
11
|
+
variants: createVariants({
|
|
12
|
+
required: {
|
|
13
|
+
true: "after:content-['*'] after:ml-0.5 after:text-error",
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const getFieldDescriptionClasses = cva("label-text-alt text-base-content/70 mt-1");
|
|
19
|
+
|
|
20
|
+
export const getFieldErrorClasses = cva("label-text-alt text-error mt-1");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useField } from "./useField";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useField } from "./useField";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { FieldContext } from "../../FieldContext";
|
|
3
|
+
|
|
4
|
+
export const useField = () => {
|
|
5
|
+
const context = useContext(FieldContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error("Field compound components must be used within a Field component");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type VariantProps } from "../../../../libs";
|
|
2
|
+
import { getFieldClasses, getFieldLabelClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
export type FieldProps = React.HTMLAttributes<HTMLDivElement> &
|
|
5
|
+
VariantProps<typeof getFieldClasses>;
|
|
6
|
+
|
|
7
|
+
export type FieldLabelProps = React.LabelHTMLAttributes<HTMLLabelElement> &
|
|
8
|
+
VariantProps<typeof getFieldLabelClasses>;
|
|
9
|
+
|
|
10
|
+
export type FieldDescriptionProps = React.HTMLAttributes<HTMLParagraphElement>;
|
|
11
|
+
|
|
12
|
+
export type FieldErrorProps = React.HTMLAttributes<HTMLParagraphElement>;
|
|
13
|
+
|
|
14
|
+
export type FieldContextValue = {
|
|
15
|
+
id: string;
|
|
16
|
+
inputId: string;
|
|
17
|
+
descriptionId: string;
|
|
18
|
+
errorId: string;
|
|
19
|
+
};
|
|
@@ -6,6 +6,7 @@ export { Phone } from "./Phone";
|
|
|
6
6
|
export { Radio } from "./Radio";
|
|
7
7
|
export { Range } from "./Range";
|
|
8
8
|
export { Select } from "./Select";
|
|
9
|
+
export { NativeSelect } from "./NativeSelect";
|
|
9
10
|
export { Slider } from "./Slider";
|
|
10
11
|
export { Switch } from "./Switch";
|
|
11
12
|
export { Checkbox, CheckboxControlled } from "./Checkbox";
|
|
@@ -14,4 +15,5 @@ export { Textarea } from "./Textarea";
|
|
|
14
15
|
export { TextField } from "./TextField";
|
|
15
16
|
export { Validator } from "./Validator";
|
|
16
17
|
export { Label } from "./components/Label";
|
|
18
|
+
export { Field, FieldLabel, FieldDescription, FieldError } from "./components/Field";
|
|
17
19
|
export { Fieldset } from "./components/Fieldset";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../utilities";
|
|
3
|
+
import { getGridClasses, getGridItemClasses } from "./constants";
|
|
4
|
+
import { type GridItemProps, type GridProps } from "./types";
|
|
5
|
+
|
|
6
|
+
export const Grid = React.forwardRef<HTMLDivElement, GridProps>(
|
|
7
|
+
({ className, columns, rows, gap, flow, children, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(getGridClasses({ columns, rows, gap, flow }), className)}
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
Grid.displayName = "Grid";
|
|
21
|
+
|
|
22
|
+
export const GridItem = React.forwardRef<HTMLDivElement, GridItemProps>(
|
|
23
|
+
({ className, colSpan, rowSpan, children, ...props }, ref) => {
|
|
24
|
+
return (
|
|
25
|
+
<div ref={ref} className={cn(getGridItemClasses({ colSpan, rowSpan }), className)} {...props}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
GridItem.displayName = "GridItem";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
import { createVariants } from "../../utilities";
|
|
3
|
+
|
|
4
|
+
export const getGridClasses = cva("grid", {
|
|
5
|
+
variants: createVariants({
|
|
6
|
+
columns: {
|
|
7
|
+
1: "grid-cols-1",
|
|
8
|
+
2: "grid-cols-2",
|
|
9
|
+
3: "grid-cols-3",
|
|
10
|
+
4: "grid-cols-4",
|
|
11
|
+
5: "grid-cols-5",
|
|
12
|
+
6: "grid-cols-6",
|
|
13
|
+
7: "grid-cols-7",
|
|
14
|
+
8: "grid-cols-8",
|
|
15
|
+
9: "grid-cols-9",
|
|
16
|
+
10: "grid-cols-10",
|
|
17
|
+
11: "grid-cols-11",
|
|
18
|
+
12: "grid-cols-12",
|
|
19
|
+
},
|
|
20
|
+
rows: {
|
|
21
|
+
1: "grid-rows-1",
|
|
22
|
+
2: "grid-rows-2",
|
|
23
|
+
3: "grid-rows-3",
|
|
24
|
+
4: "grid-rows-4",
|
|
25
|
+
5: "grid-rows-5",
|
|
26
|
+
6: "grid-rows-6",
|
|
27
|
+
7: "grid-rows-7",
|
|
28
|
+
8: "grid-rows-8",
|
|
29
|
+
9: "grid-rows-9",
|
|
30
|
+
10: "grid-rows-10",
|
|
31
|
+
11: "grid-rows-11",
|
|
32
|
+
12: "grid-rows-12",
|
|
33
|
+
},
|
|
34
|
+
gap: {
|
|
35
|
+
0: "gap-0",
|
|
36
|
+
1: "gap-1",
|
|
37
|
+
2: "gap-2",
|
|
38
|
+
3: "gap-3",
|
|
39
|
+
4: "gap-4",
|
|
40
|
+
5: "gap-5",
|
|
41
|
+
6: "gap-6",
|
|
42
|
+
8: "gap-8",
|
|
43
|
+
10: "gap-10",
|
|
44
|
+
12: "gap-12",
|
|
45
|
+
16: "gap-16",
|
|
46
|
+
},
|
|
47
|
+
flow: {
|
|
48
|
+
row: "grid-flow-row",
|
|
49
|
+
col: "grid-flow-col",
|
|
50
|
+
dense: "grid-flow-dense",
|
|
51
|
+
"row-dense": "grid-flow-row-dense",
|
|
52
|
+
"col-dense": "grid-flow-col-dense",
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const getGridItemClasses = cva("", {
|
|
58
|
+
variants: createVariants({
|
|
59
|
+
colSpan: {
|
|
60
|
+
1: "col-span-1",
|
|
61
|
+
2: "col-span-2",
|
|
62
|
+
3: "col-span-3",
|
|
63
|
+
4: "col-span-4",
|
|
64
|
+
5: "col-span-5",
|
|
65
|
+
6: "col-span-6",
|
|
66
|
+
7: "col-span-7",
|
|
67
|
+
8: "col-span-8",
|
|
68
|
+
9: "col-span-9",
|
|
69
|
+
10: "col-span-10",
|
|
70
|
+
11: "col-span-11",
|
|
71
|
+
12: "col-span-12",
|
|
72
|
+
full: "col-span-full",
|
|
73
|
+
},
|
|
74
|
+
rowSpan: {
|
|
75
|
+
1: "row-span-1",
|
|
76
|
+
2: "row-span-2",
|
|
77
|
+
3: "row-span-3",
|
|
78
|
+
4: "row-span-4",
|
|
79
|
+
5: "row-span-5",
|
|
80
|
+
6: "row-span-6",
|
|
81
|
+
full: "row-span-full",
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getGridClasses, getGridItemClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
export type GridProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof getGridClasses>;
|
|
5
|
+
|
|
6
|
+
export type GridItemProps = React.HTMLAttributes<HTMLDivElement> &
|
|
7
|
+
VariantProps<typeof getGridItemClasses>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../utilities";
|
|
3
|
+
import { getHeaderClasses } from "./constants";
|
|
4
|
+
import { type HeaderProps } from "./types";
|
|
5
|
+
|
|
6
|
+
export const Header = React.forwardRef<HTMLElement, HeaderProps>(
|
|
7
|
+
({ className, position, children, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<header ref={ref} className={cn(getHeaderClasses({ position }), className)} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</header>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
Header.displayName = "Header";
|
|
17
|
+
|
|
18
|
+
export const HeaderStart = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
19
|
+
({ className, children, ...props }, ref) => {
|
|
20
|
+
return (
|
|
21
|
+
<div ref={ref} className={cn("navbar-start", className)} {...props}>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
HeaderStart.displayName = "HeaderStart";
|
|
28
|
+
|
|
29
|
+
export const HeaderCenter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
30
|
+
({ className, children, ...props }, ref) => {
|
|
31
|
+
return (
|
|
32
|
+
<div ref={ref} className={cn("navbar-center", className)} {...props}>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
HeaderCenter.displayName = "HeaderCenter";
|
|
39
|
+
|
|
40
|
+
export const HeaderEnd = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
41
|
+
({ className, children, ...props }, ref) => {
|
|
42
|
+
return (
|
|
43
|
+
<div ref={ref} className={cn("navbar-end", className)} {...props}>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
HeaderEnd.displayName = "HeaderEnd";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
import { createVariants } from "../../utilities";
|
|
3
|
+
|
|
4
|
+
export const getHeaderClasses = cva(
|
|
5
|
+
"navbar bg-base-100 border-b border-base-200 sticky top-0 z-30 w-full",
|
|
6
|
+
{
|
|
7
|
+
variants: createVariants({
|
|
8
|
+
position: {
|
|
9
|
+
static: "static",
|
|
10
|
+
sticky: "sticky top-0",
|
|
11
|
+
fixed: "fixed top-0 left-0 right-0",
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
position: "sticky",
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { cn } from "../../utilities";
|
|
3
|
+
import { getHeadingClasses } from "./constants";
|
|
4
|
+
import { type HeadingProps } from "./types";
|
|
5
|
+
|
|
6
|
+
export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
|
|
7
|
+
({ className, level, weight, as, children, ...props }, ref) => {
|
|
8
|
+
// Determine the element from 'as' prop or 'level' prop, default to h2
|
|
9
|
+
const Component = (as ?? (level ? `h${level}` : "h2")) as React.ElementType;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<Component
|
|
13
|
+
ref={ref}
|
|
14
|
+
className={cn(getHeadingClasses({ level, weight }), className)}
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</Component>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
Heading.displayName = "Heading";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cva } from "../../libs";
|
|
2
|
+
import { createVariants } from "../../utilities";
|
|
3
|
+
|
|
4
|
+
export const getHeadingClasses = cva("", {
|
|
5
|
+
variants: createVariants({
|
|
6
|
+
level: {
|
|
7
|
+
1: "text-5xl",
|
|
8
|
+
2: "text-4xl",
|
|
9
|
+
3: "text-3xl",
|
|
10
|
+
4: "text-2xl",
|
|
11
|
+
5: "text-xl",
|
|
12
|
+
6: "text-lg",
|
|
13
|
+
},
|
|
14
|
+
weight: {
|
|
15
|
+
normal: "font-normal",
|
|
16
|
+
medium: "font-medium",
|
|
17
|
+
semibold: "font-semibold",
|
|
18
|
+
bold: "font-bold",
|
|
19
|
+
extrabold: "font-extrabold",
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
weight: "bold",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type VariantProps } from "../../libs";
|
|
2
|
+
import { getHeadingClasses } from "./constants";
|
|
3
|
+
|
|
4
|
+
type HeadingElement = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
5
|
+
|
|
6
|
+
export type HeadingProps<T extends HeadingElement = HeadingElement> =
|
|
7
|
+
React.HTMLAttributes<HTMLHeadingElement> &
|
|
8
|
+
VariantProps<typeof getHeadingClasses> & {
|
|
9
|
+
as?: T;
|
|
10
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { cn } from "../../utilities";
|
|
3
|
+
import { getImageClasses } from "./constants";
|
|
4
|
+
import { type ImageProps } from "./types";
|
|
5
|
+
|
|
6
|
+
export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
|
7
|
+
({ className, fit, radius, src, fallbackSrc, alt, onError, ...props }, ref) => {
|
|
8
|
+
const [imgSrc, setImgSrc] = useState(src);
|
|
9
|
+
|
|
10
|
+
const handleError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {
|
|
11
|
+
if (fallbackSrc && imgSrc !== fallbackSrc) {
|
|
12
|
+
setImgSrc(fallbackSrc);
|
|
13
|
+
}
|
|
14
|
+
onError?.(e);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<img
|
|
19
|
+
ref={ref}
|
|
20
|
+
src={imgSrc}
|
|
21
|
+
alt={alt}
|
|
22
|
+
className={cn(getImageClasses({ fit, radius }), className)}
|
|
23
|
+
onError={handleError}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
Image.displayName = "Image";
|