@a2v2ai/uikit 0.0.38 → 0.0.39

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.
Files changed (183) hide show
  1. package/Alert/Alert.d.ts +13 -0
  2. package/Alert/Alert.js +25 -0
  3. package/AlertDialog/AlertDialog.d.ts +43 -0
  4. package/AlertDialog/AlertDialog.js +71 -0
  5. package/Avatar/Avatar.d.ts +14 -0
  6. package/Avatar/Avatar.js +25 -0
  7. package/Badge/Badge.d.ts +11 -0
  8. package/Badge/Badge.js +23 -0
  9. package/Breadcrumb/Breadcrumb.d.ts +19 -0
  10. package/Breadcrumb/Breadcrumb.js +23 -0
  11. package/Button/Button.d.ts +23 -0
  12. package/Button/Button.js +52 -0
  13. package/Calendar/Calendar.d.ts +20 -0
  14. package/Calendar/Calendar.js +78 -0
  15. package/Card/Card.d.ts +16 -0
  16. package/Card/Card.js +28 -0
  17. package/Carousel/Carousel.d.ts +37 -0
  18. package/Carousel/Carousel.js +132 -0
  19. package/ChatBubble/ChatBubble.d.ts +33 -0
  20. package/ChatBubble/ChatBubble.js +107 -0
  21. package/Checkbox/Checkbox.d.ts +12 -0
  22. package/Checkbox/Checkbox.js +20 -0
  23. package/DataTable/DataTable.d.ts +35 -0
  24. package/DataTable/DataTable.js +51 -0
  25. package/Drawer/Drawer.d.ts +33 -0
  26. package/Drawer/Drawer.js +55 -0
  27. package/DropdownMenu/DropdownMenu.d.ts +27 -0
  28. package/DropdownMenu/DropdownMenu.js +35 -0
  29. package/ErrorMessage/ErrorMessage.d.ts +27 -0
  30. package/ErrorMessage/ErrorMessage.js +14 -0
  31. package/Flex/Flex.d.ts +31 -0
  32. package/Flex/Flex.js +64 -0
  33. package/IconButton/IconButton.d.ts +23 -0
  34. package/IconButton/IconButton.js +48 -0
  35. package/Input/Input.d.ts +27 -0
  36. package/Input/Input.js +42 -0
  37. package/InputOTP/InputOTP.d.ts +20 -0
  38. package/InputOTP/InputOTP.js +44 -0
  39. package/Label/Label.d.ts +13 -0
  40. package/Label/Label.js +19 -0
  41. package/Loader/Loader.d.ts +21 -0
  42. package/Loader/Loader.js +30 -0
  43. package/Menubar/Menubar.d.ts +26 -0
  44. package/Menubar/Menubar.js +54 -0
  45. package/Menubar/index.d.ts +1 -0
  46. package/Menubar/index.js +1 -0
  47. package/Pagination/Pagination.d.ts +35 -0
  48. package/Pagination/Pagination.js +37 -0
  49. package/Popover/Popover.d.ts +7 -0
  50. package/Popover/Popover.js +10 -0
  51. package/Progress/Progress.d.ts +17 -0
  52. package/Progress/Progress.js +33 -0
  53. package/RadioGroup/RadioGroup.d.ts +13 -0
  54. package/RadioGroup/RadioGroup.js +26 -0
  55. package/ScrollArea/ScrollArea.d.ts +5 -0
  56. package/ScrollArea/ScrollArea.js +11 -0
  57. package/Select/Select.d.ts +29 -0
  58. package/Select/Select.js +50 -0
  59. package/Separator/Separator.d.ts +4 -0
  60. package/Separator/Separator.js +7 -0
  61. package/Sidebar/Sidebar.d.ts +48 -0
  62. package/Sidebar/Sidebar.js +116 -0
  63. package/Sidebar/index.d.ts +2 -0
  64. package/Sidebar/index.js +1 -0
  65. package/Skeleton/Skeleton.d.ts +4 -0
  66. package/Skeleton/Skeleton.js +7 -0
  67. package/Slider/Slider.d.ts +6 -0
  68. package/Slider/Slider.js +7 -0
  69. package/Spinner/Spinner.d.ts +19 -0
  70. package/Spinner/Spinner.js +31 -0
  71. package/Switch/Switch.d.ts +12 -0
  72. package/Switch/Switch.js +30 -0
  73. package/Table/Table.d.ts +10 -0
  74. package/Table/Table.js +20 -0
  75. package/Tabs/Tabs.d.ts +15 -0
  76. package/Tabs/Tabs.js +24 -0
  77. package/Textarea/Textarea.d.ts +19 -0
  78. package/Textarea/Textarea.js +31 -0
  79. package/Toast/Toast.d.ts +12 -0
  80. package/Toast/Toast.js +25 -0
  81. package/Tooltip/Tooltip.d.ts +17 -0
  82. package/Tooltip/Tooltip.js +29 -0
  83. package/Typography/Typography.d.ts +20 -0
  84. package/Typography/Typography.js +71 -0
  85. package/helpers.d.ts +4 -0
  86. package/helpers.js +5 -0
  87. package/icons.d.ts +1 -0
  88. package/{icons.ts → icons.js} +1 -1
  89. package/index.css +68 -0
  90. package/index.d.ts +42 -0
  91. package/index.js +45 -0
  92. package/lib/typography-types.d.ts +4 -0
  93. package/lib/typography-types.js +118 -0
  94. package/lib/utils.d.ts +3 -0
  95. package/lib/utils.js +14 -0
  96. package/package.json +1 -1
  97. package/Alert/Alert.stories.tsx +0 -121
  98. package/Alert/Alert.tsx +0 -71
  99. package/AlertDialog/AlertDialog.stories.tsx +0 -665
  100. package/AlertDialog/AlertDialog.tsx +0 -241
  101. package/Avatar/Avatar.stories.tsx +0 -128
  102. package/Avatar/Avatar.tsx +0 -71
  103. package/Badge/Badge.stories.tsx +0 -76
  104. package/Badge/Badge.tsx +0 -39
  105. package/Breadcrumb/Breadcrumb.stories.tsx +0 -231
  106. package/Breadcrumb/Breadcrumb.tsx +0 -114
  107. package/Button/Button.stories.tsx +0 -684
  108. package/Button/Button.tsx +0 -107
  109. package/Calendar/Calendar.stories.tsx +0 -291
  110. package/Calendar/Calendar.tsx +0 -246
  111. package/Card/Card.stories.tsx +0 -136
  112. package/Card/Card.tsx +0 -96
  113. package/Carousel/Carousel.stories.tsx +0 -256
  114. package/Carousel/Carousel.tsx +0 -301
  115. package/ChatBubble/ChatBubble.stories.tsx +0 -339
  116. package/ChatBubble/ChatBubble.tsx +0 -179
  117. package/Checkbox/Checkbox.stories.tsx +0 -137
  118. package/Checkbox/Checkbox.tsx +0 -53
  119. package/DataTable/DataTable.stories.tsx +0 -400
  120. package/DataTable/DataTable.tsx +0 -207
  121. package/Drawer/Drawer.stories.tsx +0 -721
  122. package/Drawer/Drawer.tsx +0 -201
  123. package/DropdownMenu/DropdownMenu.stories.tsx +0 -251
  124. package/DropdownMenu/DropdownMenu.tsx +0 -199
  125. package/ErrorMessage/ErrorMessage.stories.tsx +0 -159
  126. package/ErrorMessage/ErrorMessage.tsx +0 -55
  127. package/Flex/Flex.stories.tsx +0 -390
  128. package/Flex/Flex.tsx +0 -102
  129. package/IconButton/IconButton.stories.tsx +0 -566
  130. package/IconButton/IconButton.tsx +0 -95
  131. package/Input/Input.stories.tsx +0 -566
  132. package/Input/Input.tsx +0 -168
  133. package/InputOTP/InputOTP.stories.tsx +0 -246
  134. package/InputOTP/InputOTP.tsx +0 -127
  135. package/Label/Label.stories.tsx +0 -110
  136. package/Label/Label.tsx +0 -44
  137. package/Loader/Loader.stories.tsx +0 -170
  138. package/Loader/Loader.tsx +0 -62
  139. package/Menubar/Menubar.stories.tsx +0 -382
  140. package/Menubar/Menubar.tsx +0 -274
  141. package/Menubar/index.ts +0 -18
  142. package/Pagination/Pagination.stories.tsx +0 -196
  143. package/Pagination/Pagination.tsx +0 -122
  144. package/Popover/Popover.stories.tsx +0 -133
  145. package/Popover/Popover.tsx +0 -31
  146. package/Progress/Progress.stories.tsx +0 -146
  147. package/Progress/Progress.tsx +0 -67
  148. package/RadioGroup/RadioGroup.stories.tsx +0 -159
  149. package/RadioGroup/RadioGroup.tsx +0 -68
  150. package/ScrollArea/ScrollArea.stories.tsx +0 -136
  151. package/ScrollArea/ScrollArea.tsx +0 -46
  152. package/Select/Select.stories.tsx +0 -378
  153. package/Select/Select.tsx +0 -230
  154. package/Separator/Separator.stories.tsx +0 -110
  155. package/Separator/Separator.tsx +0 -29
  156. package/Sidebar/Sidebar.stories.tsx +0 -340
  157. package/Sidebar/Sidebar.tsx +0 -414
  158. package/Sidebar/index.ts +0 -28
  159. package/Skeleton/Skeleton.stories.tsx +0 -117
  160. package/Skeleton/Skeleton.tsx +0 -16
  161. package/Slider/Slider.stories.tsx +0 -216
  162. package/Slider/Slider.tsx +0 -29
  163. package/Spinner/Spinner.stories.tsx +0 -210
  164. package/Spinner/Spinner.tsx +0 -78
  165. package/Switch/Switch.stories.tsx +0 -146
  166. package/Switch/Switch.tsx +0 -59
  167. package/Table/Table.stories.tsx +0 -510
  168. package/Table/Table.tsx +0 -114
  169. package/Tabs/Tabs.stories.tsx +0 -197
  170. package/Tabs/Tabs.tsx +0 -74
  171. package/Textarea/Textarea.stories.tsx +0 -187
  172. package/Textarea/Textarea.tsx +0 -73
  173. package/Toast/Toast.stories.tsx +0 -285
  174. package/Toast/Toast.tsx +0 -59
  175. package/Tooltip/Tooltip.stories.tsx +0 -463
  176. package/Tooltip/Tooltip.tsx +0 -96
  177. package/Typography/Typography.stories.tsx +0 -425
  178. package/Typography/Typography.tsx +0 -106
  179. package/helpers.ts +0 -5
  180. package/index.ts +0 -217
  181. package/lib/typography-types.ts +0 -223
  182. package/lib/utils.ts +0 -15
  183. package/tsconfig.json +0 -22
@@ -1,133 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
-
3
- import { Button } from "../Button/Button"
4
- import { Input } from "../Input/Input"
5
- import { Label } from "../Label/Label"
6
- import { Flex } from "../Flex/Flex"
7
- import { Typography } from "../Typography/Typography"
8
- import { Popover, PopoverTrigger, PopoverContent } from "./Popover"
9
-
10
- const meta: Meta<typeof Popover> = {
11
- title: "Components/Popover",
12
- component: Popover,
13
- parameters: {
14
- layout: "centered",
15
- },
16
- tags: ["autodocs"],
17
- }
18
-
19
- export default meta
20
- type Story = StoryObj<typeof meta>
21
-
22
- export const Default: Story = {
23
- render: () => (
24
- <Popover>
25
- <PopoverTrigger asChild>
26
- <Button variant="outline">Open popover</Button>
27
- </PopoverTrigger>
28
- <PopoverContent>
29
- <Flex gap={2}>
30
- <Typography variant="body1" className="font-medium">Dimensions</Typography>
31
- <Typography variant="body2" color="grey-500">Set the dimensions for the layer.</Typography>
32
- </Flex>
33
- <Flex gap={4} className="mt-4">
34
- <Flex gap={2}>
35
- <Label htmlFor="width">Width</Label>
36
- <Input id="width" defaultValue="100%" />
37
- </Flex>
38
- <Flex gap={2}>
39
- <Label htmlFor="height">Height</Label>
40
- <Input id="height" defaultValue="25px" />
41
- </Flex>
42
- </Flex>
43
- </PopoverContent>
44
- </Popover>
45
- ),
46
- }
47
-
48
- export const Simple: Story = {
49
- render: () => (
50
- <Popover>
51
- <PopoverTrigger asChild>
52
- <Button variant="outline">Info</Button>
53
- </PopoverTrigger>
54
- <PopoverContent className="w-80">
55
- <Typography variant="body2">
56
- This is a simple popover with some informational text.
57
- </Typography>
58
- </PopoverContent>
59
- </Popover>
60
- ),
61
- }
62
-
63
- export const WithForm: Story = {
64
- render: () => (
65
- <Popover>
66
- <PopoverTrigger asChild>
67
- <Button>Update email</Button>
68
- </PopoverTrigger>
69
- <PopoverContent className="w-80">
70
- <Flex gap={4}>
71
- <Flex gap={1}>
72
- <Typography variant="body1" className="font-medium">Update email</Typography>
73
- <Typography variant="caption" color="grey-500">Change your account email address.</Typography>
74
- </Flex>
75
- <Flex gap={2}>
76
- <Label htmlFor="new-email">New email</Label>
77
- <Input id="new-email" type="email" placeholder="Enter new email" />
78
- </Flex>
79
- <Button size="small">Save changes</Button>
80
- </Flex>
81
- </PopoverContent>
82
- </Popover>
83
- ),
84
- }
85
-
86
- export const AllVariants: Story = {
87
- render: () => (
88
- <Flex gap={6}>
89
- <Typography variant="h4" className="text-white">Popover Examples</Typography>
90
-
91
- <Flex direction="row" gap={4}>
92
- <Popover>
93
- <PopoverTrigger asChild>
94
- <Button variant="outline">Simple</Button>
95
- </PopoverTrigger>
96
- <PopoverContent>
97
- <Typography variant="body2">A simple popover content.</Typography>
98
- </PopoverContent>
99
- </Popover>
100
-
101
- <Popover>
102
- <PopoverTrigger asChild>
103
- <Button variant="outline">With Title</Button>
104
- </PopoverTrigger>
105
- <PopoverContent className="w-80">
106
- <Flex gap={2}>
107
- <Typography variant="body1" className="font-medium">Popover Title</Typography>
108
- <Typography variant="body2" color="grey-500">
109
- This popover has a title and description.
110
- </Typography>
111
- </Flex>
112
- </PopoverContent>
113
- </Popover>
114
-
115
- <Popover>
116
- <PopoverTrigger asChild>
117
- <Button variant="outline">With Form</Button>
118
- </PopoverTrigger>
119
- <PopoverContent className="w-80">
120
- <Flex gap={3}>
121
- <Typography variant="body1" className="font-medium">Settings</Typography>
122
- <Flex gap={2}>
123
- <Label htmlFor="setting-name">Name</Label>
124
- <Input id="setting-name" placeholder="Enter name" />
125
- </Flex>
126
- <Button size="small">Save</Button>
127
- </Flex>
128
- </PopoverContent>
129
- </Popover>
130
- </Flex>
131
- </Flex>
132
- ),
133
- }
@@ -1,31 +0,0 @@
1
- import * as React from "react"
2
- import * as PopoverPrimitive from "@radix-ui/react-popover"
3
-
4
- import { cn } from "../lib/utils"
5
-
6
- const Popover = PopoverPrimitive.Root
7
-
8
- const PopoverTrigger = PopoverPrimitive.Trigger
9
-
10
- const PopoverAnchor = PopoverPrimitive.Anchor
11
-
12
- const PopoverContent = React.forwardRef<
13
- React.ElementRef<typeof PopoverPrimitive.Content>,
14
- React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
15
- >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
- <PopoverPrimitive.Portal>
17
- <PopoverPrimitive.Content
18
- ref={ref}
19
- align={align}
20
- sideOffset={sideOffset}
21
- className={cn(
22
- "z-50 w-72 rounded-lg border border-grey-200 bg-white p-4 text-main-950 shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
23
- className
24
- )}
25
- {...props}
26
- />
27
- </PopoverPrimitive.Portal>
28
- ))
29
- PopoverContent.displayName = PopoverPrimitive.Content.displayName
30
-
31
- export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
@@ -1,146 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
- import { useState, useEffect } from "react"
3
-
4
- import { Flex } from "../Flex/Flex"
5
- import { Typography } from "../Typography/Typography"
6
- import { Progress } from "./Progress"
7
-
8
- function AnimatedProgress() {
9
- const [progress, setProgress] = useState(13)
10
-
11
- useEffect(() => {
12
- const timer = setTimeout(() => setProgress(66), 500)
13
- return () => clearTimeout(timer)
14
- }, [])
15
-
16
- return <Progress value={progress} className="w-[300px]" />
17
- }
18
-
19
- const meta: Meta<typeof Progress> = {
20
- title: "Components/Progress",
21
- component: Progress,
22
- parameters: {
23
- layout: "centered",
24
- },
25
- argTypes: {
26
- value: {
27
- control: { type: "range", min: 0, max: 100 },
28
- description: "The progress value (0-100)",
29
- },
30
- size: {
31
- control: "select",
32
- options: ["small", "regular", "large"],
33
- description: "The size of the progress bar",
34
- },
35
- variant: {
36
- control: "select",
37
- options: ["default", "success", "warning", "destructive"],
38
- description: "The visual variant",
39
- },
40
- },
41
- tags: ["autodocs"],
42
- }
43
-
44
- export default meta
45
- type Story = StoryObj<typeof meta>
46
-
47
- export const Default: Story = {
48
- render: () => <Progress value={33} className="w-[300px]" />,
49
- }
50
-
51
- export const Complete: Story = {
52
- render: () => <Progress value={100} className="w-[300px]" />,
53
- }
54
-
55
- export const Animated: Story = {
56
- render: () => <AnimatedProgress />,
57
- }
58
-
59
- export const Small: Story = {
60
- render: () => <Progress value={60} size="small" className="w-[300px]" />,
61
- }
62
-
63
- export const Large: Story = {
64
- render: () => <Progress value={60} size="large" className="w-[300px]" />,
65
- }
66
-
67
- export const Success: Story = {
68
- render: () => <Progress value={100} variant="success" className="w-[300px]" />,
69
- }
70
-
71
- export const Warning: Story = {
72
- render: () => <Progress value={75} variant="warning" className="w-[300px]" />,
73
- }
74
-
75
- export const Destructive: Story = {
76
- render: () => <Progress value={90} variant="destructive" className="w-[300px]" />,
77
- }
78
-
79
- export const AllVariants: Story = {
80
- render: () => (
81
- <Flex gap={6} className="w-[400px]">
82
- <Typography variant="h4" className="text-white">Progress Sizes</Typography>
83
-
84
- <Flex gap={4}>
85
- <Flex gap={2}>
86
- <Typography variant="caption" className="text-grey-400">Small</Typography>
87
- <Progress value={40} size="small" />
88
- </Flex>
89
-
90
- <Flex gap={2}>
91
- <Typography variant="caption" className="text-grey-400">Regular</Typography>
92
- <Progress value={60} size="regular" />
93
- </Flex>
94
-
95
- <Flex gap={2}>
96
- <Typography variant="caption" className="text-grey-400">Large</Typography>
97
- <Progress value={80} size="large" />
98
- </Flex>
99
- </Flex>
100
-
101
- <Typography variant="h4" className="text-white mt-4">Progress Variants</Typography>
102
-
103
- <Flex gap={4}>
104
- <Flex gap={2}>
105
- <Typography variant="caption" className="text-grey-400">Default (25%)</Typography>
106
- <Progress value={25} />
107
- </Flex>
108
-
109
- <Flex gap={2}>
110
- <Typography variant="caption" className="text-grey-400">Success (100%)</Typography>
111
- <Progress value={100} variant="success" />
112
- </Flex>
113
-
114
- <Flex gap={2}>
115
- <Typography variant="caption" className="text-grey-400">Warning (75%)</Typography>
116
- <Progress value={75} variant="warning" />
117
- </Flex>
118
-
119
- <Flex gap={2}>
120
- <Typography variant="caption" className="text-grey-400">Destructive (90%)</Typography>
121
- <Progress value={90} variant="destructive" />
122
- </Flex>
123
- </Flex>
124
-
125
- <Typography variant="h4" className="text-white mt-4">Use Cases</Typography>
126
-
127
- <Flex gap={4}>
128
- <Flex gap={2}>
129
- <Flex justify="between">
130
- <Typography variant="body2">Upload progress</Typography>
131
- <Typography variant="body2" color="grey-500">67%</Typography>
132
- </Flex>
133
- <Progress value={67} />
134
- </Flex>
135
-
136
- <Flex gap={2}>
137
- <Flex justify="between">
138
- <Typography variant="body2">Storage used</Typography>
139
- <Typography variant="body2" color="grey-500">8.2 GB / 10 GB</Typography>
140
- </Flex>
141
- <Progress value={82} variant="warning" />
142
- </Flex>
143
- </Flex>
144
- </Flex>
145
- ),
146
- }
@@ -1,67 +0,0 @@
1
- import * as React from "react"
2
- import * as ProgressPrimitive from "@radix-ui/react-progress"
3
- import { cva } from "class-variance-authority"
4
-
5
- import { cn } from "../lib/utils"
6
-
7
- type ProgressSize = "small" | "regular" | "large"
8
- type ProgressVariant = "default" | "success" | "warning" | "destructive"
9
-
10
- const progressVariants = cva(
11
- "relative w-full overflow-hidden rounded-full bg-grey-100",
12
- {
13
- variants: {
14
- size: {
15
- small: "h-1",
16
- regular: "h-2",
17
- large: "h-3",
18
- },
19
- },
20
- defaultVariants: {
21
- size: "regular",
22
- },
23
- }
24
- )
25
-
26
- const progressIndicatorVariants = cva(
27
- "h-full w-full flex-1 transition-all",
28
- {
29
- variants: {
30
- variant: {
31
- default: "bg-accent-600",
32
- success: "bg-success-600",
33
- warning: "bg-warning-500",
34
- destructive: "bg-error-600",
35
- },
36
- },
37
- defaultVariants: {
38
- variant: "default",
39
- },
40
- }
41
- )
42
-
43
- export interface ProgressProps
44
- extends React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root> {
45
- size?: ProgressSize
46
- variant?: ProgressVariant
47
- }
48
-
49
- const Progress = React.forwardRef<
50
- React.ElementRef<typeof ProgressPrimitive.Root>,
51
- ProgressProps
52
- >(({ className, value, size, variant, ...props }, ref) => (
53
- <ProgressPrimitive.Root
54
- ref={ref}
55
- className={cn(progressVariants({ size }), className)}
56
- {...props}
57
- >
58
- <ProgressPrimitive.Indicator
59
- className={cn(progressIndicatorVariants({ variant }))}
60
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
61
- />
62
- </ProgressPrimitive.Root>
63
- ))
64
- Progress.displayName = ProgressPrimitive.Root.displayName
65
-
66
- export { Progress, progressVariants, progressIndicatorVariants }
67
- export type { ProgressSize, ProgressVariant }
@@ -1,159 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react"
2
-
3
- import { Label } from "../Label/Label"
4
- import { Flex } from "../Flex/Flex"
5
- import { Typography } from "../Typography/Typography"
6
- import { RadioGroup, RadioGroupItem } from "./RadioGroup"
7
-
8
- const meta: Meta<typeof RadioGroup> = {
9
- title: "Components/RadioGroup",
10
- component: RadioGroup,
11
- parameters: {
12
- layout: "centered",
13
- },
14
- tags: ["autodocs"],
15
- }
16
-
17
- export default meta
18
- type Story = StoryObj<typeof meta>
19
-
20
- export const Default: Story = {
21
- render: () => (
22
- <RadioGroup defaultValue="comfortable">
23
- <Flex direction="row" align="center" gap={2}>
24
- <RadioGroupItem value="default" id="r1" />
25
- <Label htmlFor="r1">Default</Label>
26
- </Flex>
27
- <Flex direction="row" align="center" gap={2}>
28
- <RadioGroupItem value="comfortable" id="r2" />
29
- <Label htmlFor="r2">Comfortable</Label>
30
- </Flex>
31
- <Flex direction="row" align="center" gap={2}>
32
- <RadioGroupItem value="compact" id="r3" />
33
- <Label htmlFor="r3">Compact</Label>
34
- </Flex>
35
- </RadioGroup>
36
- ),
37
- }
38
-
39
- export const Small: Story = {
40
- render: () => (
41
- <RadioGroup defaultValue="option1">
42
- <Flex direction="row" align="center" gap={2}>
43
- <RadioGroupItem value="option1" id="s1" size="small" />
44
- <Label htmlFor="s1" className="text-sm">Option 1</Label>
45
- </Flex>
46
- <Flex direction="row" align="center" gap={2}>
47
- <RadioGroupItem value="option2" id="s2" size="small" />
48
- <Label htmlFor="s2" className="text-sm">Option 2</Label>
49
- </Flex>
50
- </RadioGroup>
51
- ),
52
- }
53
-
54
- export const Disabled: Story = {
55
- render: () => (
56
- <RadioGroup defaultValue="option1" disabled>
57
- <Flex direction="row" align="center" gap={2}>
58
- <RadioGroupItem value="option1" id="d1" />
59
- <Label htmlFor="d1" className="opacity-50">Option 1</Label>
60
- </Flex>
61
- <Flex direction="row" align="center" gap={2}>
62
- <RadioGroupItem value="option2" id="d2" />
63
- <Label htmlFor="d2" className="opacity-50">Option 2</Label>
64
- </Flex>
65
- </RadioGroup>
66
- ),
67
- }
68
-
69
- export const Horizontal: Story = {
70
- render: () => (
71
- <RadioGroup defaultValue="left" className="flex flex-row gap-4">
72
- <Flex direction="row" align="center" gap={2}>
73
- <RadioGroupItem value="left" id="h1" />
74
- <Label htmlFor="h1">Left</Label>
75
- </Flex>
76
- <Flex direction="row" align="center" gap={2}>
77
- <RadioGroupItem value="center" id="h2" />
78
- <Label htmlFor="h2">Center</Label>
79
- </Flex>
80
- <Flex direction="row" align="center" gap={2}>
81
- <RadioGroupItem value="right" id="h3" />
82
- <Label htmlFor="h3">Right</Label>
83
- </Flex>
84
- </RadioGroup>
85
- ),
86
- }
87
-
88
- export const AllVariants: Story = {
89
- render: () => (
90
- <Flex gap={6}>
91
- <Typography variant="h4" className="text-white">Radio Group</Typography>
92
-
93
- <Flex gap={4}>
94
- <Typography variant="body2" className="text-grey-400">Plan Selection</Typography>
95
- <RadioGroup defaultValue="pro">
96
- <Flex direction="row" align="center" gap={2}>
97
- <RadioGroupItem value="free" id="plan1" />
98
- <Label htmlFor="plan1">Free - $0/month</Label>
99
- </Flex>
100
- <Flex direction="row" align="center" gap={2}>
101
- <RadioGroupItem value="pro" id="plan2" />
102
- <Label htmlFor="plan2">Pro - $9/month</Label>
103
- </Flex>
104
- <Flex direction="row" align="center" gap={2}>
105
- <RadioGroupItem value="enterprise" id="plan3" />
106
- <Label htmlFor="plan3">Enterprise - $29/month</Label>
107
- </Flex>
108
- </RadioGroup>
109
- </Flex>
110
-
111
- <Flex gap={4}>
112
- <Typography variant="body2" className="text-grey-400">Size Comparison</Typography>
113
- <Flex direction="row" gap={8}>
114
- <Flex gap={2}>
115
- <Typography variant="caption" className="text-grey-500">Small</Typography>
116
- <RadioGroup defaultValue="a" className="gap-3">
117
- <Flex direction="row" align="center" gap={2}>
118
- <RadioGroupItem value="a" id="size-s1" size="small" />
119
- <Label htmlFor="size-s1" className="text-sm">Option A</Label>
120
- </Flex>
121
- <Flex direction="row" align="center" gap={2}>
122
- <RadioGroupItem value="b" id="size-s2" size="small" />
123
- <Label htmlFor="size-s2" className="text-sm">Option B</Label>
124
- </Flex>
125
- </RadioGroup>
126
- </Flex>
127
-
128
- <Flex gap={2}>
129
- <Typography variant="caption" className="text-grey-500">Regular</Typography>
130
- <RadioGroup defaultValue="a" className="gap-3">
131
- <Flex direction="row" align="center" gap={2}>
132
- <RadioGroupItem value="a" id="size-r1" />
133
- <Label htmlFor="size-r1">Option A</Label>
134
- </Flex>
135
- <Flex direction="row" align="center" gap={2}>
136
- <RadioGroupItem value="b" id="size-r2" />
137
- <Label htmlFor="size-r2">Option B</Label>
138
- </Flex>
139
- </RadioGroup>
140
- </Flex>
141
- </Flex>
142
- </Flex>
143
-
144
- <Flex gap={4}>
145
- <Typography variant="body2" className="text-grey-400">Horizontal Layout</Typography>
146
- <RadioGroup defaultValue="monthly" className="flex flex-row gap-6">
147
- <Flex direction="row" align="center" gap={2}>
148
- <RadioGroupItem value="monthly" id="billing1" />
149
- <Label htmlFor="billing1">Monthly</Label>
150
- </Flex>
151
- <Flex direction="row" align="center" gap={2}>
152
- <RadioGroupItem value="yearly" id="billing2" />
153
- <Label htmlFor="billing2">Yearly</Label>
154
- </Flex>
155
- </RadioGroup>
156
- </Flex>
157
- </Flex>
158
- ),
159
- }
@@ -1,68 +0,0 @@
1
- import * as React from "react"
2
- import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
3
- import { Circle } from "lucide-react"
4
- import { cva } from "class-variance-authority"
5
-
6
- import { cn } from "../lib/utils"
7
-
8
- type RadioGroupItemSize = "small" | "regular"
9
-
10
- const RadioGroup = React.forwardRef<
11
- React.ElementRef<typeof RadioGroupPrimitive.Root>,
12
- React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
13
- >(({ className, ...props }, ref) => {
14
- return (
15
- <RadioGroupPrimitive.Root
16
- className={cn("grid gap-2", className)}
17
- {...props}
18
- ref={ref}
19
- />
20
- )
21
- })
22
- RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
23
-
24
- const radioGroupItemVariants = cva(
25
- "aspect-square rounded-full border border-grey-300 bg-white text-main-950 ring-offset-white focus:outline-none focus-visible:ring-2 focus-visible:ring-main-950 focus-visible:ring-offset-2 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-main-950",
26
- {
27
- variants: {
28
- size: {
29
- small: "size-4",
30
- regular: "size-5",
31
- },
32
- },
33
- defaultVariants: {
34
- size: "regular",
35
- },
36
- }
37
- )
38
-
39
- export interface RadioGroupItemProps
40
- extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> {
41
- size?: RadioGroupItemSize
42
- }
43
-
44
- const RadioGroupItem = React.forwardRef<
45
- React.ElementRef<typeof RadioGroupPrimitive.Item>,
46
- RadioGroupItemProps
47
- >(({ className, size, ...props }, ref) => {
48
- return (
49
- <RadioGroupPrimitive.Item
50
- ref={ref}
51
- className={cn(radioGroupItemVariants({ size }), className)}
52
- {...props}
53
- >
54
- <RadioGroupPrimitive.Indicator className="flex items-center justify-center">
55
- <Circle
56
- className={cn(
57
- "fill-main-950 text-main-950",
58
- size === "small" ? "size-2" : "size-2.5"
59
- )}
60
- />
61
- </RadioGroupPrimitive.Indicator>
62
- </RadioGroupPrimitive.Item>
63
- )
64
- })
65
- RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
66
-
67
- export { RadioGroup, RadioGroupItem, radioGroupItemVariants }
68
- export type { RadioGroupItemSize }