@a2v2ai/uikit 0.0.37 → 0.0.38
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/Alert/Alert.stories.tsx +121 -0
- package/Alert/Alert.tsx +71 -0
- package/AlertDialog/AlertDialog.stories.tsx +665 -0
- package/AlertDialog/AlertDialog.tsx +241 -0
- package/Avatar/Avatar.stories.tsx +128 -0
- package/Avatar/Avatar.tsx +71 -0
- package/Badge/Badge.stories.tsx +76 -0
- package/Badge/Badge.tsx +39 -0
- package/Breadcrumb/Breadcrumb.stories.tsx +231 -0
- package/Breadcrumb/Breadcrumb.tsx +114 -0
- package/Button/Button.stories.tsx +684 -0
- package/Button/Button.tsx +107 -0
- package/Calendar/Calendar.stories.tsx +291 -0
- package/Calendar/Calendar.tsx +246 -0
- package/Card/Card.stories.tsx +136 -0
- package/Card/Card.tsx +96 -0
- package/Carousel/Carousel.stories.tsx +256 -0
- package/Carousel/Carousel.tsx +301 -0
- package/ChatBubble/ChatBubble.stories.tsx +339 -0
- package/ChatBubble/ChatBubble.tsx +179 -0
- package/Checkbox/Checkbox.stories.tsx +137 -0
- package/Checkbox/Checkbox.tsx +53 -0
- package/DataTable/DataTable.stories.tsx +400 -0
- package/DataTable/DataTable.tsx +207 -0
- package/Drawer/Drawer.stories.tsx +721 -0
- package/Drawer/Drawer.tsx +201 -0
- package/DropdownMenu/DropdownMenu.stories.tsx +251 -0
- package/DropdownMenu/DropdownMenu.tsx +199 -0
- package/ErrorMessage/ErrorMessage.stories.tsx +159 -0
- package/ErrorMessage/ErrorMessage.tsx +55 -0
- package/Flex/Flex.stories.tsx +390 -0
- package/Flex/Flex.tsx +102 -0
- package/IconButton/IconButton.stories.tsx +566 -0
- package/IconButton/IconButton.tsx +95 -0
- package/Input/Input.stories.tsx +566 -0
- package/Input/Input.tsx +168 -0
- package/InputOTP/InputOTP.stories.tsx +246 -0
- package/InputOTP/InputOTP.tsx +127 -0
- package/Label/Label.stories.tsx +110 -0
- package/Label/Label.tsx +44 -0
- package/Loader/Loader.stories.tsx +170 -0
- package/Loader/Loader.tsx +62 -0
- package/Menubar/Menubar.stories.tsx +382 -0
- package/Menubar/Menubar.tsx +274 -0
- package/Menubar/index.ts +18 -0
- package/Pagination/Pagination.stories.tsx +196 -0
- package/Pagination/Pagination.tsx +122 -0
- package/Popover/Popover.stories.tsx +133 -0
- package/Popover/Popover.tsx +31 -0
- package/Progress/Progress.stories.tsx +146 -0
- package/Progress/Progress.tsx +67 -0
- package/RadioGroup/RadioGroup.stories.tsx +159 -0
- package/RadioGroup/RadioGroup.tsx +68 -0
- package/ScrollArea/ScrollArea.stories.tsx +136 -0
- package/ScrollArea/ScrollArea.tsx +46 -0
- package/Select/Select.stories.tsx +378 -0
- package/Select/Select.tsx +230 -0
- package/Separator/Separator.stories.tsx +110 -0
- package/Separator/Separator.tsx +29 -0
- package/Sidebar/Sidebar.stories.tsx +340 -0
- package/Sidebar/Sidebar.tsx +414 -0
- package/Sidebar/index.ts +28 -0
- package/Skeleton/Skeleton.stories.tsx +117 -0
- package/Skeleton/Skeleton.tsx +16 -0
- package/Slider/Slider.stories.tsx +216 -0
- package/Slider/Slider.tsx +29 -0
- package/Spinner/Spinner.stories.tsx +210 -0
- package/Spinner/Spinner.tsx +78 -0
- package/Switch/Switch.stories.tsx +146 -0
- package/Switch/Switch.tsx +59 -0
- package/Table/Table.stories.tsx +510 -0
- package/Table/Table.tsx +114 -0
- package/Tabs/Tabs.stories.tsx +197 -0
- package/Tabs/Tabs.tsx +74 -0
- package/Textarea/Textarea.stories.tsx +187 -0
- package/Textarea/Textarea.tsx +73 -0
- package/Toast/Toast.stories.tsx +285 -0
- package/Toast/Toast.tsx +59 -0
- package/Tooltip/Tooltip.stories.tsx +463 -0
- package/Tooltip/Tooltip.tsx +96 -0
- package/Typography/Typography.stories.tsx +425 -0
- package/Typography/Typography.tsx +106 -0
- package/helpers.ts +5 -0
- package/{icons.js → icons.ts} +1 -1
- package/index.ts +217 -0
- package/lib/typography-types.ts +223 -0
- package/lib/utils.ts +15 -0
- package/package.json +5 -2
- package/tsconfig.json +22 -0
- package/Alert/Alert.d.ts +0 -13
- package/Alert/Alert.js +0 -25
- package/AlertDialog/AlertDialog.d.ts +0 -43
- package/AlertDialog/AlertDialog.js +0 -71
- package/Avatar/Avatar.d.ts +0 -14
- package/Avatar/Avatar.js +0 -25
- package/Badge/Badge.d.ts +0 -11
- package/Badge/Badge.js +0 -23
- package/Breadcrumb/Breadcrumb.d.ts +0 -19
- package/Breadcrumb/Breadcrumb.js +0 -23
- package/Button/Button.d.ts +0 -23
- package/Button/Button.js +0 -52
- package/Calendar/Calendar.d.ts +0 -20
- package/Calendar/Calendar.js +0 -78
- package/Card/Card.d.ts +0 -16
- package/Card/Card.js +0 -28
- package/Carousel/Carousel.d.ts +0 -37
- package/Carousel/Carousel.js +0 -132
- package/ChatBubble/ChatBubble.d.ts +0 -33
- package/ChatBubble/ChatBubble.js +0 -107
- package/Checkbox/Checkbox.d.ts +0 -12
- package/Checkbox/Checkbox.js +0 -20
- package/DataTable/DataTable.d.ts +0 -35
- package/DataTable/DataTable.js +0 -51
- package/Drawer/Drawer.d.ts +0 -33
- package/Drawer/Drawer.js +0 -55
- package/DropdownMenu/DropdownMenu.d.ts +0 -27
- package/DropdownMenu/DropdownMenu.js +0 -35
- package/ErrorMessage/ErrorMessage.d.ts +0 -27
- package/ErrorMessage/ErrorMessage.js +0 -14
- package/Flex/Flex.d.ts +0 -31
- package/Flex/Flex.js +0 -64
- package/IconButton/IconButton.d.ts +0 -23
- package/IconButton/IconButton.js +0 -48
- package/Input/Input.d.ts +0 -27
- package/Input/Input.js +0 -42
- package/InputOTP/InputOTP.d.ts +0 -20
- package/InputOTP/InputOTP.js +0 -44
- package/Label/Label.d.ts +0 -13
- package/Label/Label.js +0 -19
- package/Loader/Loader.d.ts +0 -21
- package/Loader/Loader.js +0 -30
- package/Menubar/Menubar.d.ts +0 -26
- package/Menubar/Menubar.js +0 -54
- package/Menubar/index.d.ts +0 -1
- package/Menubar/index.js +0 -1
- package/Pagination/Pagination.d.ts +0 -35
- package/Pagination/Pagination.js +0 -37
- package/Popover/Popover.d.ts +0 -7
- package/Popover/Popover.js +0 -10
- package/Progress/Progress.d.ts +0 -17
- package/Progress/Progress.js +0 -33
- package/RadioGroup/RadioGroup.d.ts +0 -13
- package/RadioGroup/RadioGroup.js +0 -26
- package/ScrollArea/ScrollArea.d.ts +0 -5
- package/ScrollArea/ScrollArea.js +0 -11
- package/Select/Select.d.ts +0 -29
- package/Select/Select.js +0 -50
- package/Separator/Separator.d.ts +0 -4
- package/Separator/Separator.js +0 -7
- package/Sidebar/Sidebar.d.ts +0 -48
- package/Sidebar/Sidebar.js +0 -116
- package/Sidebar/index.d.ts +0 -2
- package/Sidebar/index.js +0 -1
- package/Skeleton/Skeleton.d.ts +0 -4
- package/Skeleton/Skeleton.js +0 -7
- package/Slider/Slider.d.ts +0 -6
- package/Slider/Slider.js +0 -7
- package/Spinner/Spinner.d.ts +0 -19
- package/Spinner/Spinner.js +0 -31
- package/Switch/Switch.d.ts +0 -12
- package/Switch/Switch.js +0 -30
- package/Table/Table.d.ts +0 -10
- package/Table/Table.js +0 -20
- package/Tabs/Tabs.d.ts +0 -15
- package/Tabs/Tabs.js +0 -24
- package/Textarea/Textarea.d.ts +0 -19
- package/Textarea/Textarea.js +0 -31
- package/Toast/Toast.d.ts +0 -12
- package/Toast/Toast.js +0 -25
- package/Tooltip/Tooltip.d.ts +0 -17
- package/Tooltip/Tooltip.js +0 -29
- package/Typography/Typography.d.ts +0 -20
- package/Typography/Typography.js +0 -43
- package/helpers.d.ts +0 -4
- package/helpers.js +0 -5
- package/icons.d.ts +0 -1
- package/index.d.ts +0 -42
- package/index.js +0 -45
- package/lib/typography-types.d.ts +0 -4
- package/lib/typography-types.js +0 -90
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -14
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { cva } from "class-variance-authority"
|
|
3
|
+
|
|
4
|
+
import { cn } from "../lib/utils"
|
|
5
|
+
|
|
6
|
+
type ChatBubbleSide = "left" | "right"
|
|
7
|
+
type ChatBubbleColor = "blue" | "grey" | "green" | "lightGrey"
|
|
8
|
+
type ChatBubbleTheme = "dark" | "light"
|
|
9
|
+
type ChatBubbleSize = "small" | "medium" | "large" | "xlarge"
|
|
10
|
+
|
|
11
|
+
const chatBubbleVariants = cva(
|
|
12
|
+
"flex flex-col gap-1.5 w-full",
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
side: {
|
|
16
|
+
left: "items-start",
|
|
17
|
+
right: "items-end",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
side: "left",
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const bubbleContentVariants = cva(
|
|
27
|
+
"px-4 py-3 leading-normal max-w-[85%]",
|
|
28
|
+
{
|
|
29
|
+
variants: {
|
|
30
|
+
color: {
|
|
31
|
+
blue: "bg-blue-500",
|
|
32
|
+
grey: "",
|
|
33
|
+
green: "bg-green-500",
|
|
34
|
+
lightGrey: "",
|
|
35
|
+
},
|
|
36
|
+
theme: {
|
|
37
|
+
dark: "",
|
|
38
|
+
light: "",
|
|
39
|
+
},
|
|
40
|
+
side: {
|
|
41
|
+
left: "rounded-t-2xl rounded-br-2xl rounded-bl-md",
|
|
42
|
+
right: "rounded-t-2xl rounded-bl-2xl rounded-br-md",
|
|
43
|
+
},
|
|
44
|
+
size: {
|
|
45
|
+
small: "text-sm px-3 py-2",
|
|
46
|
+
medium: "text-base px-4 py-3",
|
|
47
|
+
large: "text-lg px-4 py-3",
|
|
48
|
+
xlarge: "text-xl px-5 py-4",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
compoundVariants: [
|
|
52
|
+
// Blue variants
|
|
53
|
+
{
|
|
54
|
+
color: "blue",
|
|
55
|
+
theme: "dark",
|
|
56
|
+
className: "bg-blue-500 text-white",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
color: "blue",
|
|
60
|
+
theme: "light",
|
|
61
|
+
className: "bg-[#2e9dfb] text-white",
|
|
62
|
+
},
|
|
63
|
+
// Grey variants
|
|
64
|
+
{
|
|
65
|
+
color: "grey",
|
|
66
|
+
theme: "dark",
|
|
67
|
+
className: "bg-[#3F3F46] text-[#F4F4F5]",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
color: "grey",
|
|
71
|
+
theme: "light",
|
|
72
|
+
className: "bg-main-100 text-[#52525B]",
|
|
73
|
+
},
|
|
74
|
+
// Green variants
|
|
75
|
+
{
|
|
76
|
+
color: "green",
|
|
77
|
+
theme: "dark",
|
|
78
|
+
className: "bg-green-500 text-white",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
color: "green",
|
|
82
|
+
theme: "light",
|
|
83
|
+
className: "bg-green-500 text-white",
|
|
84
|
+
},
|
|
85
|
+
// Light-grey variants
|
|
86
|
+
{
|
|
87
|
+
color: "lightGrey",
|
|
88
|
+
theme: "dark",
|
|
89
|
+
className: "bg-background-neutral-100 text-main-600",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
color: "lightGrey",
|
|
93
|
+
theme: "light",
|
|
94
|
+
className: "bg-background-neutral-100 text-main-600",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
defaultVariants: {
|
|
98
|
+
color: "blue",
|
|
99
|
+
theme: "dark",
|
|
100
|
+
side: "left",
|
|
101
|
+
size: "small",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
const labelVariants = cva(
|
|
107
|
+
"text-sm text-neutral-400 mb-0.5",
|
|
108
|
+
{
|
|
109
|
+
variants: {
|
|
110
|
+
side: {
|
|
111
|
+
left: "ml-3",
|
|
112
|
+
right: "mr-3",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
side: "left",
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
export interface ChatBubbleProps
|
|
122
|
+
extends React.HTMLAttributes<HTMLDivElement> {
|
|
123
|
+
/** The side of the chat bubble (left for received, right for sent) */
|
|
124
|
+
side?: ChatBubbleSide
|
|
125
|
+
/** The color variant of the bubble */
|
|
126
|
+
color?: ChatBubbleColor
|
|
127
|
+
/** The theme variant */
|
|
128
|
+
theme?: ChatBubbleTheme
|
|
129
|
+
/** The text size of the bubble */
|
|
130
|
+
size?: ChatBubbleSize
|
|
131
|
+
/** The message content */
|
|
132
|
+
children: React.ReactNode
|
|
133
|
+
/** Optional label shown above the bubble (e.g., sender name) */
|
|
134
|
+
label?: string
|
|
135
|
+
/** Whether to show the label */
|
|
136
|
+
showLabel?: boolean
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const ChatBubble = React.forwardRef<HTMLDivElement, ChatBubbleProps>(
|
|
140
|
+
(
|
|
141
|
+
{
|
|
142
|
+
className,
|
|
143
|
+
side = "left",
|
|
144
|
+
color = "blue",
|
|
145
|
+
theme = "dark",
|
|
146
|
+
size = "small",
|
|
147
|
+
children,
|
|
148
|
+
label,
|
|
149
|
+
showLabel = true,
|
|
150
|
+
...props
|
|
151
|
+
},
|
|
152
|
+
ref
|
|
153
|
+
) => {
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
ref={ref}
|
|
157
|
+
className={cn(chatBubbleVariants({ side, className }))}
|
|
158
|
+
{...props}
|
|
159
|
+
>
|
|
160
|
+
{showLabel && label && (
|
|
161
|
+
<span className={cn(labelVariants({ side }))}>
|
|
162
|
+
{label}
|
|
163
|
+
</span>
|
|
164
|
+
)}
|
|
165
|
+
<div
|
|
166
|
+
className={cn(
|
|
167
|
+
bubbleContentVariants({ color, theme, side, size })
|
|
168
|
+
)}
|
|
169
|
+
>
|
|
170
|
+
{children}
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
ChatBubble.displayName = "ChatBubble"
|
|
177
|
+
|
|
178
|
+
export { ChatBubble, chatBubbleVariants, bubbleContentVariants }
|
|
179
|
+
export type { ChatBubbleSide, ChatBubbleColor, ChatBubbleTheme, ChatBubbleSize }
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { useState } from "react"
|
|
3
|
+
|
|
4
|
+
import { Label } from "../Label/Label"
|
|
5
|
+
import { Flex } from "../Flex/Flex"
|
|
6
|
+
import { Typography } from "../Typography/Typography"
|
|
7
|
+
import { Checkbox } from "./Checkbox"
|
|
8
|
+
|
|
9
|
+
function IndeterminateExample() {
|
|
10
|
+
const [checked, setChecked] = useState<boolean | "indeterminate">("indeterminate")
|
|
11
|
+
return (
|
|
12
|
+
<Flex direction="row" align="center" gap={2}>
|
|
13
|
+
<Checkbox
|
|
14
|
+
id="indeterminate"
|
|
15
|
+
checked={checked}
|
|
16
|
+
onCheckedChange={(value) => setChecked(value)}
|
|
17
|
+
/>
|
|
18
|
+
<Label htmlFor="indeterminate">Indeterminate</Label>
|
|
19
|
+
</Flex>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const meta: Meta<typeof Checkbox> = {
|
|
24
|
+
title: "Components/Checkbox",
|
|
25
|
+
component: Checkbox,
|
|
26
|
+
parameters: {
|
|
27
|
+
layout: "centered",
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
size: {
|
|
31
|
+
control: "select",
|
|
32
|
+
options: ["small", "regular"],
|
|
33
|
+
description: "The size of the checkbox",
|
|
34
|
+
},
|
|
35
|
+
checked: {
|
|
36
|
+
control: "boolean",
|
|
37
|
+
description: "The checked state",
|
|
38
|
+
},
|
|
39
|
+
disabled: {
|
|
40
|
+
control: "boolean",
|
|
41
|
+
description: "Whether the checkbox is disabled",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
tags: ["autodocs"],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default meta
|
|
48
|
+
type Story = StoryObj<typeof meta>
|
|
49
|
+
|
|
50
|
+
export const Default: Story = {
|
|
51
|
+
render: () => <Checkbox />,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const Checked: Story = {
|
|
55
|
+
render: () => <Checkbox defaultChecked />,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const WithLabel: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<Flex direction="row" align="center" gap={2}>
|
|
61
|
+
<Checkbox id="terms" />
|
|
62
|
+
<Label htmlFor="terms">Accept terms and conditions</Label>
|
|
63
|
+
</Flex>
|
|
64
|
+
),
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Disabled: Story = {
|
|
68
|
+
render: () => (
|
|
69
|
+
<Flex gap={3}>
|
|
70
|
+
<Flex direction="row" align="center" gap={2}>
|
|
71
|
+
<Checkbox id="disabled" disabled />
|
|
72
|
+
<Label htmlFor="disabled" className="opacity-50">Disabled</Label>
|
|
73
|
+
</Flex>
|
|
74
|
+
<Flex direction="row" align="center" gap={2}>
|
|
75
|
+
<Checkbox id="disabled-checked" disabled defaultChecked />
|
|
76
|
+
<Label htmlFor="disabled-checked" className="opacity-50">Disabled checked</Label>
|
|
77
|
+
</Flex>
|
|
78
|
+
</Flex>
|
|
79
|
+
),
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const Indeterminate: Story = {
|
|
83
|
+
render: () => <IndeterminateExample />,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const Small: Story = {
|
|
87
|
+
render: () => (
|
|
88
|
+
<Flex direction="row" align="center" gap={2}>
|
|
89
|
+
<Checkbox id="small" size="small" />
|
|
90
|
+
<Label htmlFor="small" className="text-sm">Small checkbox</Label>
|
|
91
|
+
</Flex>
|
|
92
|
+
),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const AllVariants: Story = {
|
|
96
|
+
render: () => (
|
|
97
|
+
<Flex gap={6}>
|
|
98
|
+
<Typography variant="h4" className="text-white">Checkbox States</Typography>
|
|
99
|
+
|
|
100
|
+
<Flex gap={4}>
|
|
101
|
+
<Flex direction="row" align="center" gap={2}>
|
|
102
|
+
<Checkbox id="unchecked" />
|
|
103
|
+
<Label htmlFor="unchecked">Unchecked</Label>
|
|
104
|
+
</Flex>
|
|
105
|
+
|
|
106
|
+
<Flex direction="row" align="center" gap={2}>
|
|
107
|
+
<Checkbox id="checked" defaultChecked />
|
|
108
|
+
<Label htmlFor="checked">Checked</Label>
|
|
109
|
+
</Flex>
|
|
110
|
+
|
|
111
|
+
<Flex direction="row" align="center" gap={2}>
|
|
112
|
+
<Checkbox id="disabled-state" disabled />
|
|
113
|
+
<Label htmlFor="disabled-state" className="opacity-50">Disabled</Label>
|
|
114
|
+
</Flex>
|
|
115
|
+
|
|
116
|
+
<Flex direction="row" align="center" gap={2}>
|
|
117
|
+
<Checkbox id="disabled-checked-state" disabled defaultChecked />
|
|
118
|
+
<Label htmlFor="disabled-checked-state" className="opacity-50">Disabled Checked</Label>
|
|
119
|
+
</Flex>
|
|
120
|
+
</Flex>
|
|
121
|
+
|
|
122
|
+
<Typography variant="h4" className="text-white mt-4">Sizes</Typography>
|
|
123
|
+
|
|
124
|
+
<Flex gap={4}>
|
|
125
|
+
<Flex direction="row" align="center" gap={2}>
|
|
126
|
+
<Checkbox id="small-size" size="small" defaultChecked />
|
|
127
|
+
<Label htmlFor="small-size" className="text-sm">Small</Label>
|
|
128
|
+
</Flex>
|
|
129
|
+
|
|
130
|
+
<Flex direction="row" align="center" gap={2}>
|
|
131
|
+
<Checkbox id="regular-size" size="regular" defaultChecked />
|
|
132
|
+
<Label htmlFor="regular-size">Regular</Label>
|
|
133
|
+
</Flex>
|
|
134
|
+
</Flex>
|
|
135
|
+
</Flex>
|
|
136
|
+
),
|
|
137
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
|
3
|
+
import { Check, Minus } from "lucide-react"
|
|
4
|
+
import { cva } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../lib/utils"
|
|
7
|
+
|
|
8
|
+
type CheckboxSize = "small" | "regular"
|
|
9
|
+
|
|
10
|
+
const checkboxVariants = cva(
|
|
11
|
+
"peer shrink-0 border border-grey-300 bg-white ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-600 focus-visible:ring-offset-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-accent-600 data-[state=checked]:border-accent-600 data-[state=checked]:text-white data-[state=indeterminate]:bg-accent-600 data-[state=indeterminate]:border-accent-600 data-[state=indeterminate]:text-white",
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
small: "size-4 rounded-[4px]",
|
|
16
|
+
regular: "size-5 rounded-md",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
size: "regular",
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
export interface CheckboxProps
|
|
26
|
+
extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> {
|
|
27
|
+
size?: CheckboxSize
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const Checkbox = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
32
|
+
CheckboxProps
|
|
33
|
+
>(({ className, size, ...props }, ref) => (
|
|
34
|
+
<CheckboxPrimitive.Root
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn(checkboxVariants({ size }), className)}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
<CheckboxPrimitive.Indicator
|
|
40
|
+
className={cn("flex items-center justify-center text-current")}
|
|
41
|
+
>
|
|
42
|
+
{props.checked === "indeterminate" ? (
|
|
43
|
+
<Minus className={cn(size === "small" ? "size-3" : "size-3.5")} />
|
|
44
|
+
) : (
|
|
45
|
+
<Check className={cn(size === "small" ? "size-3" : "size-3.5")} />
|
|
46
|
+
)}
|
|
47
|
+
</CheckboxPrimitive.Indicator>
|
|
48
|
+
</CheckboxPrimitive.Root>
|
|
49
|
+
))
|
|
50
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
|
51
|
+
|
|
52
|
+
export { Checkbox, checkboxVariants }
|
|
53
|
+
export type { CheckboxSize }
|