@mzc-fe/design-system 0.0.1 → 0.0.2

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 (219) hide show
  1. package/dist/components/accordion.d.ts +7 -0
  2. package/dist/components/alert-dialog.d.ts +14 -0
  3. package/dist/components/alert.d.ts +9 -0
  4. package/dist/components/aspect-ratio.d.ts +3 -0
  5. package/dist/components/avatar.d.ts +6 -0
  6. package/dist/components/badge.d.ts +9 -0
  7. package/dist/components/breadcrumb.d.ts +11 -0
  8. package/dist/components/button-group.d.ts +11 -0
  9. package/dist/components/button.d.ts +10 -0
  10. package/dist/components/calendar.d.ts +8 -0
  11. package/dist/components/card.d.ts +9 -0
  12. package/dist/components/carousel.d.ts +19 -0
  13. package/dist/components/chart.d.ts +40 -0
  14. package/dist/components/checkbox.d.ts +4 -0
  15. package/dist/components/collapsible.d.ts +5 -0
  16. package/dist/components/command.d.ts +18 -0
  17. package/dist/components/context-menu.d.ts +25 -0
  18. package/dist/components/dialog.d.ts +15 -0
  19. package/dist/components/drawer.d.ts +13 -0
  20. package/dist/components/dropdown-menu.d.ts +25 -0
  21. package/dist/components/empty.d.ts +11 -0
  22. package/dist/components/field.d.ts +24 -0
  23. package/dist/components/form.d.ts +24 -0
  24. package/dist/components/hover-card.d.ts +6 -0
  25. package/dist/components/input-group.d.ts +16 -0
  26. package/dist/components/input-otp.d.ts +11 -0
  27. package/dist/components/input.d.ts +3 -0
  28. package/dist/components/item.d.ts +23 -0
  29. package/dist/components/kbd.d.ts +3 -0
  30. package/dist/components/label.d.ts +4 -0
  31. package/dist/components/menubar.d.ts +26 -0
  32. package/dist/components/navigation-menu.d.ts +14 -0
  33. package/dist/components/pagination.d.ts +13 -0
  34. package/dist/components/popover.d.ts +7 -0
  35. package/dist/components/progress.d.ts +4 -0
  36. package/dist/components/radio-group.d.ts +5 -0
  37. package/dist/components/resizable.d.ts +8 -0
  38. package/dist/components/scroll-area.d.ts +5 -0
  39. package/dist/components/select.d.ts +15 -0
  40. package/dist/components/separator.d.ts +4 -0
  41. package/dist/components/sheet.d.ts +13 -0
  42. package/dist/components/sidebar.d.ts +69 -0
  43. package/dist/components/skeleton.d.ts +2 -0
  44. package/dist/components/slider.d.ts +4 -0
  45. package/dist/components/sonner.d.ts +3 -0
  46. package/dist/components/spinner.d.ts +2 -0
  47. package/dist/components/switch.d.ts +4 -0
  48. package/dist/components/table.d.ts +10 -0
  49. package/dist/components/tabs.d.ts +7 -0
  50. package/dist/components/textarea.d.ts +3 -0
  51. package/dist/components/toggle-group.d.ts +9 -0
  52. package/dist/components/toggle.d.ts +9 -0
  53. package/dist/components/tooltip.d.ts +7 -0
  54. package/dist/design-system.css +1 -0
  55. package/dist/design-system.es.js +30200 -0
  56. package/dist/design-system.umd.js +260 -0
  57. package/dist/foundations/ThemeProvider.d.ts +13 -0
  58. package/dist/hooks/use-mobile.d.ts +1 -0
  59. package/dist/index.d.ts +54 -0
  60. package/dist/lib/utils.d.ts +2 -0
  61. package/package.json +14 -1
  62. package/.husky/pre-push +0 -21
  63. package/.storybook/main.ts +0 -11
  64. package/.storybook/preview.tsx +0 -30
  65. package/.vscode/settings.json +0 -12
  66. package/.vscode/tailwind.json +0 -105
  67. package/bitbucket-pipelines.yml +0 -50
  68. package/components.json +0 -21
  69. package/eslint.config.js +0 -38
  70. package/src/components/accordion.stories.tsx +0 -258
  71. package/src/components/accordion.test.tsx +0 -390
  72. package/src/components/accordion.tsx +0 -64
  73. package/src/components/alert-dialog.stories.tsx +0 -213
  74. package/src/components/alert-dialog.test.tsx +0 -80
  75. package/src/components/alert-dialog.tsx +0 -155
  76. package/src/components/alert.stories.tsx +0 -84
  77. package/src/components/alert.test.tsx +0 -35
  78. package/src/components/alert.tsx +0 -66
  79. package/src/components/aspect-ratio.stories.tsx +0 -97
  80. package/src/components/aspect-ratio.test.tsx +0 -47
  81. package/src/components/aspect-ratio.tsx +0 -11
  82. package/src/components/avatar.stories.tsx +0 -76
  83. package/src/components/avatar.test.tsx +0 -50
  84. package/src/components/avatar.tsx +0 -51
  85. package/src/components/badge.stories.tsx +0 -64
  86. package/src/components/badge.test.tsx +0 -34
  87. package/src/components/badge.tsx +0 -46
  88. package/src/components/breadcrumb.stories.tsx +0 -86
  89. package/src/components/breadcrumb.test.tsx +0 -74
  90. package/src/components/breadcrumb.tsx +0 -109
  91. package/src/components/button-group.stories.tsx +0 -62
  92. package/src/components/button-group.tsx +0 -83
  93. package/src/components/button.stories.tsx +0 -118
  94. package/src/components/button.test.tsx +0 -64
  95. package/src/components/button.tsx +0 -62
  96. package/src/components/calendar.stories.tsx +0 -81
  97. package/src/components/calendar.tsx +0 -220
  98. package/src/components/card.stories.tsx +0 -110
  99. package/src/components/card.test.tsx +0 -56
  100. package/src/components/card.tsx +0 -92
  101. package/src/components/carousel.stories.tsx +0 -90
  102. package/src/components/carousel.tsx +0 -239
  103. package/src/components/chart.tsx +0 -357
  104. package/src/components/checkbox.stories.tsx +0 -108
  105. package/src/components/checkbox.test.tsx +0 -67
  106. package/src/components/checkbox.tsx +0 -32
  107. package/src/components/collapsible.stories.tsx +0 -106
  108. package/src/components/collapsible.test.tsx +0 -92
  109. package/src/components/collapsible.tsx +0 -31
  110. package/src/components/command.stories.tsx +0 -90
  111. package/src/components/command.tsx +0 -182
  112. package/src/components/context-menu.stories.tsx +0 -63
  113. package/src/components/context-menu.tsx +0 -252
  114. package/src/components/dialog.stories.tsx +0 -128
  115. package/src/components/dialog.tsx +0 -141
  116. package/src/components/drawer.stories.tsx +0 -104
  117. package/src/components/drawer.tsx +0 -135
  118. package/src/components/dropdown-menu.stories.tsx +0 -97
  119. package/src/components/dropdown-menu.tsx +0 -255
  120. package/src/components/empty.stories.tsx +0 -90
  121. package/src/components/empty.test.tsx +0 -55
  122. package/src/components/empty.tsx +0 -104
  123. package/src/components/field.tsx +0 -246
  124. package/src/components/form.tsx +0 -168
  125. package/src/components/hover-card.stories.tsx +0 -66
  126. package/src/components/hover-card.tsx +0 -44
  127. package/src/components/input-group.stories.tsx +0 -57
  128. package/src/components/input-group.test.tsx +0 -40
  129. package/src/components/input-group.tsx +0 -170
  130. package/src/components/input-otp.stories.tsx +0 -94
  131. package/src/components/input-otp.test.tsx +0 -60
  132. package/src/components/input-otp.tsx +0 -75
  133. package/src/components/input.stories.tsx +0 -94
  134. package/src/components/input.test.tsx +0 -53
  135. package/src/components/input.tsx +0 -21
  136. package/src/components/item.tsx +0 -193
  137. package/src/components/kbd.stories.tsx +0 -100
  138. package/src/components/kbd.test.tsx +0 -28
  139. package/src/components/kbd.tsx +0 -28
  140. package/src/components/label.stories.tsx +0 -48
  141. package/src/components/label.test.tsx +0 -28
  142. package/src/components/label.tsx +0 -24
  143. package/src/components/menubar.tsx +0 -274
  144. package/src/components/navigation-menu.tsx +0 -168
  145. package/src/components/pagination.stories.tsx +0 -107
  146. package/src/components/pagination.tsx +0 -127
  147. package/src/components/popover.stories.tsx +0 -102
  148. package/src/components/popover.tsx +0 -48
  149. package/src/components/progress.stories.tsx +0 -76
  150. package/src/components/progress.test.tsx +0 -36
  151. package/src/components/progress.tsx +0 -29
  152. package/src/components/radio-group.stories.tsx +0 -73
  153. package/src/components/radio-group.test.tsx +0 -74
  154. package/src/components/radio-group.tsx +0 -45
  155. package/src/components/resizable.stories.tsx +0 -120
  156. package/src/components/resizable.tsx +0 -54
  157. package/src/components/scroll-area.stories.tsx +0 -64
  158. package/src/components/scroll-area.test.tsx +0 -46
  159. package/src/components/scroll-area.tsx +0 -58
  160. package/src/components/select.stories.tsx +0 -111
  161. package/src/components/select.test.tsx +0 -90
  162. package/src/components/select.tsx +0 -188
  163. package/src/components/separator.stories.tsx +0 -76
  164. package/src/components/separator.test.tsx +0 -24
  165. package/src/components/separator.tsx +0 -28
  166. package/src/components/sheet.stories.tsx +0 -122
  167. package/src/components/sheet.tsx +0 -137
  168. package/src/components/sidebar.tsx +0 -726
  169. package/src/components/skeleton.stories.tsx +0 -53
  170. package/src/components/skeleton.test.tsx +0 -24
  171. package/src/components/skeleton.tsx +0 -13
  172. package/src/components/slider.stories.tsx +0 -97
  173. package/src/components/slider.test.tsx +0 -49
  174. package/src/components/slider.tsx +0 -63
  175. package/src/components/sonner.stories.tsx +0 -96
  176. package/src/components/sonner.tsx +0 -38
  177. package/src/components/spinner.stories.tsx +0 -54
  178. package/src/components/spinner.test.tsx +0 -30
  179. package/src/components/spinner.tsx +0 -16
  180. package/src/components/switch.stories.tsx +0 -108
  181. package/src/components/switch.test.tsx +0 -62
  182. package/src/components/switch.tsx +0 -31
  183. package/src/components/table.stories.tsx +0 -139
  184. package/src/components/table.test.tsx +0 -85
  185. package/src/components/table.tsx +0 -114
  186. package/src/components/tabs.stories.tsx +0 -99
  187. package/src/components/tabs.test.tsx +0 -64
  188. package/src/components/tabs.tsx +0 -66
  189. package/src/components/textarea.stories.tsx +0 -89
  190. package/src/components/textarea.test.tsx +0 -53
  191. package/src/components/textarea.tsx +0 -18
  192. package/src/components/toggle-group.stories.tsx +0 -108
  193. package/src/components/toggle-group.test.tsx +0 -66
  194. package/src/components/toggle-group.tsx +0 -81
  195. package/src/components/toggle.stories.tsx +0 -98
  196. package/src/components/toggle.test.tsx +0 -42
  197. package/src/components/toggle.tsx +0 -45
  198. package/src/components/tooltip.stories.tsx +0 -111
  199. package/src/components/tooltip.tsx +0 -61
  200. package/src/foundations/README.md +0 -141
  201. package/src/foundations/ThemeProvider.tsx +0 -77
  202. package/src/foundations/color.css +0 -232
  203. package/src/foundations/color.stories.tsx +0 -719
  204. package/src/foundations/palette.css +0 -249
  205. package/src/foundations/spacing.css +0 -8
  206. package/src/foundations/typography.css +0 -143
  207. package/src/foundations/typography.stories.tsx +0 -17
  208. package/src/hooks/use-mobile.ts +0 -19
  209. package/src/index.css +0 -176
  210. package/src/index.ts +0 -336
  211. package/src/lib/utils.ts +0 -6
  212. package/src/test/setup.ts +0 -8
  213. package/src/vite-env.d.ts +0 -1
  214. package/tsconfig.app.json +0 -33
  215. package/tsconfig.json +0 -13
  216. package/tsconfig.node.json +0 -25
  217. package/vite.config.ts +0 -30
  218. package/vitest.config.ts +0 -25
  219. /package/{public → dist}/vite.svg +0 -0
@@ -1,102 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import { Popover, PopoverContent, PopoverTrigger } from "./popover";
3
- import { Button } from "./button";
4
-
5
- const meta = {
6
- title: "Components/Popover",
7
- component: Popover,
8
- parameters: {
9
- layout: "padded",
10
- },
11
- tags: ["autodocs"],
12
- } satisfies Meta<typeof Popover>;
13
-
14
- export default meta;
15
- type Story = StoryObj<typeof meta>;
16
-
17
- export const Default: Story = {
18
- render: () => (
19
- <Popover>
20
- <PopoverTrigger asChild>
21
- <Button variant="outline">Open popover</Button>
22
- </PopoverTrigger>
23
- <PopoverContent>
24
- <div className="space-y-2">
25
- <h4 className="font-medium leading-none">Dimensions</h4>
26
- <p className="text-sm text-muted-foreground">
27
- Set the dimensions for the layer.
28
- </p>
29
- </div>
30
- </PopoverContent>
31
- </Popover>
32
- ),
33
- };
34
-
35
- export const WithForm: Story = {
36
- render: () => (
37
- <Popover>
38
- <PopoverTrigger asChild>
39
- <Button variant="outline">Open form</Button>
40
- </PopoverTrigger>
41
- <PopoverContent className="w-80">
42
- <div className="space-y-4">
43
- <div className="space-y-2">
44
- <h4 className="font-medium leading-none">Dimensions</h4>
45
- <p className="text-sm text-muted-foreground">
46
- Set the dimensions for the layer.
47
- </p>
48
- </div>
49
- <div className="grid gap-2">
50
- <div className="grid grid-cols-3 items-center gap-4">
51
- <label htmlFor="width" className="text-sm">
52
- Width
53
- </label>
54
- <input
55
- id="width"
56
- defaultValue="100%"
57
- className="col-span-2 h-8 rounded-md border px-2 text-sm"
58
- />
59
- </div>
60
- <div className="grid grid-cols-3 items-center gap-4">
61
- <label htmlFor="height" className="text-sm">
62
- Height
63
- </label>
64
- <input
65
- id="height"
66
- defaultValue="25px"
67
- className="col-span-2 h-8 rounded-md border px-2 text-sm"
68
- />
69
- </div>
70
- </div>
71
- </div>
72
- </PopoverContent>
73
- </Popover>
74
- ),
75
- };
76
-
77
- export const WithList: Story = {
78
- render: () => (
79
- <Popover>
80
- <PopoverTrigger asChild>
81
- <Button variant="outline">View options</Button>
82
- </PopoverTrigger>
83
- <PopoverContent className="w-56">
84
- <div className="space-y-2">
85
- <h4 className="font-medium">Options</h4>
86
- <ul className="space-y-1 text-sm">
87
- <li className="cursor-pointer hover:bg-accent p-2 rounded">
88
- Option 1
89
- </li>
90
- <li className="cursor-pointer hover:bg-accent p-2 rounded">
91
- Option 2
92
- </li>
93
- <li className="cursor-pointer hover:bg-accent p-2 rounded">
94
- Option 3
95
- </li>
96
- </ul>
97
- </div>
98
- </PopoverContent>
99
- </Popover>
100
- ),
101
- };
102
-
@@ -1,48 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as PopoverPrimitive from "@radix-ui/react-popover"
5
-
6
- import { cn } from "@/lib/utils"
7
-
8
- function Popover({
9
- ...props
10
- }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
11
- return <PopoverPrimitive.Root data-slot="popover" {...props} />
12
- }
13
-
14
- function PopoverTrigger({
15
- ...props
16
- }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
17
- return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
18
- }
19
-
20
- function PopoverContent({
21
- className,
22
- align = "center",
23
- sideOffset = 4,
24
- ...props
25
- }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
26
- return (
27
- <PopoverPrimitive.Portal>
28
- <PopoverPrimitive.Content
29
- data-slot="popover-content"
30
- align={align}
31
- sideOffset={sideOffset}
32
- className={cn(
33
- "bg-popover text-popover-foreground 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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
34
- className
35
- )}
36
- {...props}
37
- />
38
- </PopoverPrimitive.Portal>
39
- )
40
- }
41
-
42
- function PopoverAnchor({
43
- ...props
44
- }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
45
- return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
46
- }
47
-
48
- export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
@@ -1,76 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import { Progress } from "./progress";
3
-
4
- const meta = {
5
- title: "Components/Progress",
6
- component: Progress,
7
- parameters: {
8
- layout: "padded",
9
- },
10
- tags: ["autodocs"],
11
- argTypes: {
12
- value: {
13
- control: { type: "range", min: 0, max: 100, step: 1 },
14
- description: "The progress value (0-100).",
15
- },
16
- },
17
- } satisfies Meta<typeof Progress>;
18
-
19
- export default meta;
20
- type Story = StoryObj<typeof meta>;
21
-
22
- export const Default: Story = {
23
- args: {
24
- value: 33,
25
- },
26
- };
27
-
28
- export const Values: Story = {
29
- render: () => (
30
- <div className="space-y-4 w-[350px]">
31
- <div className="space-y-2">
32
- <div className="flex justify-between text-sm">
33
- <span>0%</span>
34
- </div>
35
- <Progress value={0} />
36
- </div>
37
- <div className="space-y-2">
38
- <div className="flex justify-between text-sm">
39
- <span>25%</span>
40
- </div>
41
- <Progress value={25} />
42
- </div>
43
- <div className="space-y-2">
44
- <div className="flex justify-between text-sm">
45
- <span>50%</span>
46
- </div>
47
- <Progress value={50} />
48
- </div>
49
- <div className="space-y-2">
50
- <div className="flex justify-between text-sm">
51
- <span>75%</span>
52
- </div>
53
- <Progress value={75} />
54
- </div>
55
- <div className="space-y-2">
56
- <div className="flex justify-between text-sm">
57
- <span>100%</span>
58
- </div>
59
- <Progress value={100} />
60
- </div>
61
- </div>
62
- ),
63
- };
64
-
65
- export const WithLabel: Story = {
66
- render: () => (
67
- <div className="space-y-2 w-[350px]">
68
- <div className="flex justify-between text-sm">
69
- <span>Uploading...</span>
70
- <span>45%</span>
71
- </div>
72
- <Progress value={45} />
73
- </div>
74
- ),
75
- };
76
-
@@ -1,36 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { render } from "@testing-library/react";
3
- import { Progress } from "./progress";
4
-
5
- describe("Progress", () => {
6
- it("should render progress", () => {
7
- const { container } = render(<Progress value={50} />);
8
- const progress = container.querySelector('[data-slot="progress"]');
9
- expect(progress).toBeInTheDocument();
10
- });
11
-
12
- it("should render progress indicator", () => {
13
- const { container } = render(<Progress value={50} />);
14
- const indicator = container.querySelector('[data-slot="progress-indicator"]');
15
- expect(indicator).toBeInTheDocument();
16
- });
17
-
18
- it("should apply value correctly", () => {
19
- const { container } = render(<Progress value={75} />);
20
- const indicator = container.querySelector('[data-slot="progress-indicator"]') as HTMLElement;
21
- expect(indicator.style.transform).toContain("25%");
22
- });
23
-
24
- it("should handle 0 value", () => {
25
- const { container } = render(<Progress value={0} />);
26
- const indicator = container.querySelector('[data-slot="progress-indicator"]') as HTMLElement;
27
- expect(indicator.style.transform).toContain("100%");
28
- });
29
-
30
- it("should handle 100 value", () => {
31
- const { container } = render(<Progress value={100} />);
32
- const indicator = container.querySelector('[data-slot="progress-indicator"]') as HTMLElement;
33
- expect(indicator.style.transform).toContain("0%");
34
- });
35
- });
36
-
@@ -1,29 +0,0 @@
1
- import * as React from "react"
2
- import * as ProgressPrimitive from "@radix-ui/react-progress"
3
-
4
- import { cn } from "@/lib/utils"
5
-
6
- function Progress({
7
- className,
8
- value,
9
- ...props
10
- }: React.ComponentProps<typeof ProgressPrimitive.Root>) {
11
- return (
12
- <ProgressPrimitive.Root
13
- data-slot="progress"
14
- className={cn(
15
- "bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",
16
- className
17
- )}
18
- {...props}
19
- >
20
- <ProgressPrimitive.Indicator
21
- data-slot="progress-indicator"
22
- className="bg-primary h-full w-full flex-1 transition-all"
23
- style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
24
- />
25
- </ProgressPrimitive.Root>
26
- )
27
- }
28
-
29
- export { Progress }
@@ -1,73 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import { RadioGroup, RadioGroupItem } from "./radio-group";
3
- import { Label } from "./label";
4
-
5
- const meta = {
6
- title: "Components/RadioGroup",
7
- component: RadioGroup,
8
- parameters: {
9
- layout: "padded",
10
- },
11
- tags: ["autodocs"],
12
- } satisfies Meta<typeof RadioGroup>;
13
-
14
- export default meta;
15
- type Story = StoryObj<typeof meta>;
16
-
17
- export const Default: Story = {
18
- render: () => (
19
- <RadioGroup defaultValue="option-one">
20
- <div className="flex items-center space-x-2">
21
- <RadioGroupItem value="option-one" id="option-one" />
22
- <Label htmlFor="option-one">Option One</Label>
23
- </div>
24
- <div className="flex items-center space-x-2">
25
- <RadioGroupItem value="option-two" id="option-two" />
26
- <Label htmlFor="option-two">Option Two</Label>
27
- </div>
28
- <div className="flex items-center space-x-2">
29
- <RadioGroupItem value="option-three" id="option-three" />
30
- <Label htmlFor="option-three">Option Three</Label>
31
- </div>
32
- </RadioGroup>
33
- ),
34
- };
35
-
36
- export const Horizontal: Story = {
37
- render: () => (
38
- <RadioGroup defaultValue="option-one" className="flex gap-6">
39
- <div className="flex items-center space-x-2">
40
- <RadioGroupItem value="option-one" id="h-option-one" />
41
- <Label htmlFor="h-option-one">Option One</Label>
42
- </div>
43
- <div className="flex items-center space-x-2">
44
- <RadioGroupItem value="option-two" id="h-option-two" />
45
- <Label htmlFor="h-option-two">Option Two</Label>
46
- </div>
47
- <div className="flex items-center space-x-2">
48
- <RadioGroupItem value="option-three" id="h-option-three" />
49
- <Label htmlFor="h-option-three">Option Three</Label>
50
- </div>
51
- </RadioGroup>
52
- ),
53
- };
54
-
55
- export const Disabled: Story = {
56
- render: () => (
57
- <RadioGroup defaultValue="option-one">
58
- <div className="flex items-center space-x-2">
59
- <RadioGroupItem value="option-one" id="d-option-one" />
60
- <Label htmlFor="d-option-one">Option One</Label>
61
- </div>
62
- <div className="flex items-center space-x-2">
63
- <RadioGroupItem value="option-two" id="d-option-two" disabled />
64
- <Label htmlFor="d-option-two">Option Two (Disabled)</Label>
65
- </div>
66
- <div className="flex items-center space-x-2">
67
- <RadioGroupItem value="option-three" id="d-option-three" />
68
- <Label htmlFor="d-option-three">Option Three</Label>
69
- </div>
70
- </RadioGroup>
71
- ),
72
- };
73
-
@@ -1,74 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { render } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
- import { RadioGroup, RadioGroupItem } from "./radio-group";
5
-
6
- describe("RadioGroup", () => {
7
- it("should render radio group with items", () => {
8
- const { container } = render(
9
- <RadioGroup>
10
- <RadioGroupItem value="option1" id="option1" />
11
- <RadioGroupItem value="option2" id="option2" />
12
- </RadioGroup>
13
- );
14
- const radioGroup = container.querySelector('[data-slot="radio-group"]');
15
- expect(radioGroup).toBeInTheDocument();
16
- });
17
-
18
- it("should have default value when defaultValue is provided", () => {
19
- const { container } = render(
20
- <RadioGroup defaultValue="option1">
21
- <RadioGroupItem value="option1" id="option1" />
22
- <RadioGroupItem value="option2" id="option2" />
23
- </RadioGroup>
24
- );
25
- const option1 = container.querySelector('[value="option1"]') as HTMLInputElement;
26
- // Radix UI radio group uses data attributes for state
27
- expect(option1).toBeInTheDocument();
28
- });
29
-
30
- it("should call onValueChange when item is clicked", async () => {
31
- const user = userEvent.setup();
32
- const handleChange = vi.fn();
33
- const { container } = render(
34
- <RadioGroup onValueChange={handleChange}>
35
- <RadioGroupItem value="option1" id="option1" />
36
- <RadioGroupItem value="option2" id="option2" />
37
- </RadioGroup>
38
- );
39
- const option2 = container.querySelector('[value="option2"]') as HTMLElement;
40
- await user.click(option2);
41
- expect(handleChange).toHaveBeenCalledWith("option2");
42
- });
43
-
44
- it("should only allow one item to be selected at a time", async () => {
45
- const user = userEvent.setup();
46
- const handleChange = vi.fn();
47
- const { container } = render(
48
- <RadioGroup onValueChange={handleChange}>
49
- <RadioGroupItem value="option1" id="option1" />
50
- <RadioGroupItem value="option2" id="option2" />
51
- </RadioGroup>
52
- );
53
- const option1 = container.querySelector('[value="option1"]') as HTMLElement;
54
- const option2 = container.querySelector('[value="option2"]') as HTMLElement;
55
-
56
- await user.click(option1);
57
- expect(handleChange).toHaveBeenCalledWith("option1");
58
-
59
- await user.click(option2);
60
- expect(handleChange).toHaveBeenCalledWith("option2");
61
- });
62
-
63
- it("should disable items when disabled prop is true", () => {
64
- const { container } = render(
65
- <RadioGroup disabled>
66
- <RadioGroupItem value="option1" id="option1" />
67
- <RadioGroupItem value="option2" id="option2" />
68
- </RadioGroup>
69
- );
70
- const option1 = container.querySelector('[value="option1"]') as HTMLInputElement;
71
- expect(option1).toBeDisabled();
72
- });
73
- });
74
-
@@ -1,45 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
5
- import { CircleIcon } from "lucide-react"
6
-
7
- import { cn } from "@/lib/utils"
8
-
9
- function RadioGroup({
10
- className,
11
- ...props
12
- }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
13
- return (
14
- <RadioGroupPrimitive.Root
15
- data-slot="radio-group"
16
- className={cn("grid gap-3", className)}
17
- {...props}
18
- />
19
- )
20
- }
21
-
22
- function RadioGroupItem({
23
- className,
24
- ...props
25
- }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
26
- return (
27
- <RadioGroupPrimitive.Item
28
- data-slot="radio-group-item"
29
- className={cn(
30
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
31
- className
32
- )}
33
- {...props}
34
- >
35
- <RadioGroupPrimitive.Indicator
36
- data-slot="radio-group-indicator"
37
- className="relative flex items-center justify-center"
38
- >
39
- <CircleIcon className="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
40
- </RadioGroupPrimitive.Indicator>
41
- </RadioGroupPrimitive.Item>
42
- )
43
- }
44
-
45
- export { RadioGroup, RadioGroupItem }
@@ -1,120 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react-vite";
2
- import {
3
- ResizableHandle,
4
- ResizablePanel,
5
- ResizablePanelGroup,
6
- } from "./resizable";
7
-
8
- const meta = {
9
- title: "Components/Resizable",
10
- component: ResizablePanelGroup,
11
- parameters: {
12
- layout: "padded",
13
- },
14
- tags: ["autodocs"],
15
- } satisfies Meta<typeof ResizablePanelGroup>;
16
-
17
- export default meta;
18
- type Story = StoryObj<typeof meta>;
19
-
20
- export const Default: Story = {
21
- args: {
22
- direction: "horizontal",
23
- },
24
- render: () => (
25
- <ResizablePanelGroup
26
- direction="horizontal"
27
- className="max-w-md rounded-lg border"
28
- >
29
- <ResizablePanel defaultSize={50}>
30
- <div className="flex h-[200px] items-center justify-center p-6">
31
- <span className="font-semibold">One</span>
32
- </div>
33
- </ResizablePanel>
34
- <ResizableHandle />
35
- <ResizablePanel defaultSize={50}>
36
- <div className="flex h-[200px] items-center justify-center p-6">
37
- <span className="font-semibold">Two</span>
38
- </div>
39
- </ResizablePanel>
40
- </ResizablePanelGroup>
41
- ),
42
- };
43
-
44
- export const Vertical: Story = {
45
- args: {
46
- direction: "vertical",
47
- },
48
- render: () => (
49
- <ResizablePanelGroup
50
- direction="vertical"
51
- className="min-h-[200px] max-w-md rounded-lg border"
52
- >
53
- <ResizablePanel defaultSize={50}>
54
- <div className="flex h-full items-center justify-center p-6">
55
- <span className="font-semibold">One</span>
56
- </div>
57
- </ResizablePanel>
58
- <ResizableHandle />
59
- <ResizablePanel defaultSize={50}>
60
- <div className="flex h-full items-center justify-center p-6">
61
- <span className="font-semibold">Two</span>
62
- </div>
63
- </ResizablePanel>
64
- </ResizablePanelGroup>
65
- ),
66
- };
67
-
68
- export const ThreePanels: Story = {
69
- args: {
70
- direction: "horizontal",
71
- },
72
- render: () => (
73
- <ResizablePanelGroup
74
- direction="horizontal"
75
- className="max-w-md rounded-lg border"
76
- >
77
- <ResizablePanel defaultSize={25}>
78
- <div className="flex h-[200px] items-center justify-center p-6">
79
- <span className="font-semibold">One</span>
80
- </div>
81
- </ResizablePanel>
82
- <ResizableHandle />
83
- <ResizablePanel defaultSize={50}>
84
- <div className="flex h-[200px] items-center justify-center p-6">
85
- <span className="font-semibold">Two</span>
86
- </div>
87
- </ResizablePanel>
88
- <ResizableHandle />
89
- <ResizablePanel defaultSize={25}>
90
- <div className="flex h-[200px] items-center justify-center p-6">
91
- <span className="font-semibold">Three</span>
92
- </div>
93
- </ResizablePanel>
94
- </ResizablePanelGroup>
95
- ),
96
- };
97
-
98
- export const WithHandle: Story = {
99
- args: {
100
- direction: "horizontal",
101
- },
102
- render: () => (
103
- <ResizablePanelGroup
104
- direction="horizontal"
105
- className="max-w-md rounded-lg border"
106
- >
107
- <ResizablePanel defaultSize={50}>
108
- <div className="flex h-[200px] items-center justify-center p-6">
109
- <span className="font-semibold">One</span>
110
- </div>
111
- </ResizablePanel>
112
- <ResizableHandle withHandle />
113
- <ResizablePanel defaultSize={50}>
114
- <div className="flex h-[200px] items-center justify-center p-6">
115
- <span className="font-semibold">Two</span>
116
- </div>
117
- </ResizablePanel>
118
- </ResizablePanelGroup>
119
- ),
120
- };
@@ -1,54 +0,0 @@
1
- import * as React from "react"
2
- import { GripVerticalIcon } from "lucide-react"
3
- import * as ResizablePrimitive from "react-resizable-panels"
4
-
5
- import { cn } from "@/lib/utils"
6
-
7
- function ResizablePanelGroup({
8
- className,
9
- ...props
10
- }: React.ComponentProps<typeof ResizablePrimitive.PanelGroup>) {
11
- return (
12
- <ResizablePrimitive.PanelGroup
13
- data-slot="resizable-panel-group"
14
- className={cn(
15
- "flex h-full w-full data-[panel-group-direction=vertical]:flex-col",
16
- className
17
- )}
18
- {...props}
19
- />
20
- )
21
- }
22
-
23
- function ResizablePanel({
24
- ...props
25
- }: React.ComponentProps<typeof ResizablePrimitive.Panel>) {
26
- return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
27
- }
28
-
29
- function ResizableHandle({
30
- withHandle,
31
- className,
32
- ...props
33
- }: React.ComponentProps<typeof ResizablePrimitive.PanelResizeHandle> & {
34
- withHandle?: boolean
35
- }) {
36
- return (
37
- <ResizablePrimitive.PanelResizeHandle
38
- data-slot="resizable-handle"
39
- className={cn(
40
- "bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",
41
- className
42
- )}
43
- {...props}
44
- >
45
- {withHandle && (
46
- <div className="bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border">
47
- <GripVerticalIcon className="size-2.5" />
48
- </div>
49
- )}
50
- </ResizablePrimitive.PanelResizeHandle>
51
- )
52
- }
53
-
54
- export { ResizablePanelGroup, ResizablePanel, ResizableHandle }