@codefast/ui 0.3.16-canary.2 → 0.3.16-canary.3

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 (223) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/dist/components/accordion.mjs +2 -2
  4. package/dist/components/alert-dialog.d.mts +1 -1
  5. package/dist/components/alert-dialog.mjs +4 -4
  6. package/dist/components/alert.d.mts +3 -13
  7. package/dist/components/alert.mjs +3 -23
  8. package/dist/components/badge.d.mts +3 -15
  9. package/dist/components/badge.mjs +2 -44
  10. package/dist/components/breadcrumb.mjs +1 -1
  11. package/dist/components/button-group.d.mts +3 -13
  12. package/dist/components/button-group.mjs +3 -24
  13. package/dist/components/button.d.mts +3 -25
  14. package/dist/components/button.mjs +2 -72
  15. package/dist/components/calendar.mjs +2 -1
  16. package/dist/components/carousel.d.mts +1 -2
  17. package/dist/components/chart.d.mts +2 -4
  18. package/dist/components/checkbox.mjs +2 -2
  19. package/dist/components/context-menu.mjs +2 -2
  20. package/dist/components/dialog.d.mts +1 -1
  21. package/dist/components/dialog.mjs +4 -4
  22. package/dist/components/drawer.d.mts +1 -1
  23. package/dist/components/drawer.mjs +2 -2
  24. package/dist/components/dropdown-menu.mjs +2 -2
  25. package/dist/components/empty.d.mts +3 -13
  26. package/dist/components/empty.mjs +3 -18
  27. package/dist/components/field.d.mts +3 -14
  28. package/dist/components/field.mjs +3 -32
  29. package/dist/components/form.d.mts +2 -4
  30. package/dist/components/hover-card.mjs +1 -1
  31. package/dist/components/input-group.d.mts +4 -31
  32. package/dist/components/input-group.mjs +3 -90
  33. package/dist/components/input-number.mjs +4 -4
  34. package/dist/components/input-otp.mjs +2 -2
  35. package/dist/components/input.mjs +1 -1
  36. package/dist/components/item.d.mts +4 -29
  37. package/dist/components/item.mjs +3 -56
  38. package/dist/components/menubar.mjs +2 -2
  39. package/dist/components/native-select.mjs +1 -1
  40. package/dist/components/navigation-menu.d.mts +1 -6
  41. package/dist/components/navigation-menu.mjs +8 -15
  42. package/dist/components/pagination.d.mts +1 -1
  43. package/dist/components/pagination.mjs +1 -1
  44. package/dist/components/popover.mjs +1 -1
  45. package/dist/components/progress-circle.d.mts +3 -47
  46. package/dist/components/progress-circle.mjs +2 -47
  47. package/dist/components/progress.mjs +1 -1
  48. package/dist/components/radio-group.mjs +1 -1
  49. package/dist/components/radio.mjs +1 -1
  50. package/dist/components/scroll-area.d.mts +3 -19
  51. package/dist/components/scroll-area.mjs +4 -61
  52. package/dist/components/select.d.mts +1 -1
  53. package/dist/components/select.mjs +3 -3
  54. package/dist/components/separator.d.mts +3 -18
  55. package/dist/components/separator.mjs +3 -23
  56. package/dist/components/sheet.d.mts +6 -18
  57. package/dist/components/sheet.mjs +6 -49
  58. package/dist/components/sidebar.d.mts +4 -19
  59. package/dist/components/sidebar.mjs +10 -46
  60. package/dist/components/skeleton.mjs +1 -1
  61. package/dist/components/slider.mjs +1 -1
  62. package/dist/components/spinner.mjs +1 -1
  63. package/dist/components/switch.mjs +2 -2
  64. package/dist/components/table.mjs +1 -1
  65. package/dist/components/tabs.mjs +1 -1
  66. package/dist/components/textarea.mjs +1 -1
  67. package/dist/components/toggle-group.d.mts +3 -2
  68. package/dist/components/toggle-group.mjs +1 -1
  69. package/dist/components/toggle.d.mts +2 -21
  70. package/dist/components/toggle.mjs +2 -39
  71. package/dist/components/tooltip.mjs +1 -1
  72. package/dist/index.d.mts +31 -16
  73. package/dist/index.mjs +30 -15
  74. package/dist/lib/utils.d.mts +1 -12
  75. package/dist/lib/utils.mjs +1 -9
  76. package/dist/primitives/checkbox-group.d.mts +1 -2
  77. package/dist/primitives/input-number.d.mts +1 -2
  78. package/dist/primitives/input.d.mts +1 -2
  79. package/dist/primitives/progress-circle.d.mts +1 -2
  80. package/dist/variants/alert.d.mts +18 -0
  81. package/dist/variants/alert.mjs +25 -0
  82. package/dist/variants/badge.d.mts +20 -0
  83. package/dist/variants/badge.mjs +46 -0
  84. package/dist/variants/button-group.d.mts +18 -0
  85. package/dist/variants/button-group.mjs +26 -0
  86. package/dist/variants/button.d.mts +30 -0
  87. package/dist/variants/button.mjs +76 -0
  88. package/dist/variants/empty.d.mts +18 -0
  89. package/dist/variants/empty.mjs +20 -0
  90. package/dist/variants/field.d.mts +19 -0
  91. package/dist/variants/field.mjs +34 -0
  92. package/dist/variants/input-group.d.mts +43 -0
  93. package/dist/variants/input-group.mjs +93 -0
  94. package/dist/variants/item.d.mts +37 -0
  95. package/dist/variants/item.mjs +60 -0
  96. package/dist/variants/navigation-menu.d.mts +13 -0
  97. package/dist/variants/navigation-menu.mjs +12 -0
  98. package/dist/variants/progress-circle.d.mts +52 -0
  99. package/dist/variants/progress-circle.mjs +49 -0
  100. package/dist/variants/scroll-area.d.mts +24 -0
  101. package/dist/variants/scroll-area.mjs +63 -0
  102. package/dist/variants/separator.d.mts +23 -0
  103. package/dist/variants/separator.mjs +25 -0
  104. package/dist/variants/sheet.d.mts +20 -0
  105. package/dist/variants/sheet.mjs +50 -0
  106. package/dist/variants/sidebar.d.mts +23 -0
  107. package/dist/variants/sidebar.mjs +42 -0
  108. package/dist/variants/toggle.d.mts +23 -0
  109. package/dist/variants/toggle.mjs +43 -0
  110. package/package.json +168 -20
  111. package/src/components/accordion.tsx +156 -0
  112. package/src/components/alert-dialog.tsx +314 -0
  113. package/src/components/alert.tsx +86 -0
  114. package/src/components/aspect-ratio.tsx +28 -0
  115. package/src/components/avatar.tsx +84 -0
  116. package/src/components/badge.tsx +38 -0
  117. package/src/components/breadcrumb.tsx +197 -0
  118. package/src/components/button-group.tsx +107 -0
  119. package/src/components/button.tsx +66 -0
  120. package/src/components/calendar.tsx +277 -0
  121. package/src/components/card.tsx +175 -0
  122. package/src/components/carousel.tsx +367 -0
  123. package/src/components/chart.tsx +587 -0
  124. package/src/components/checkbox-cards.tsx +92 -0
  125. package/src/components/checkbox-group.tsx +83 -0
  126. package/src/components/checkbox.tsx +65 -0
  127. package/src/components/collapsible.tsx +60 -0
  128. package/src/components/command.tsx +311 -0
  129. package/src/components/context-menu.tsx +489 -0
  130. package/src/components/dialog.tsx +295 -0
  131. package/src/components/drawer.tsx +271 -0
  132. package/src/components/dropdown-menu.tsx +498 -0
  133. package/src/components/empty.tsx +169 -0
  134. package/src/components/field.tsx +362 -0
  135. package/src/components/form.tsx +300 -0
  136. package/src/components/hover-card.tsx +116 -0
  137. package/src/components/input-group.tsx +224 -0
  138. package/src/components/input-number.tsx +161 -0
  139. package/src/components/input-otp.tsx +151 -0
  140. package/src/components/input-password.tsx +74 -0
  141. package/src/components/input-search.tsx +98 -0
  142. package/src/components/input.tsx +52 -0
  143. package/src/components/item.tsx +280 -0
  144. package/src/components/kbd.tsx +59 -0
  145. package/src/components/label.tsx +44 -0
  146. package/src/components/menubar.tsx +531 -0
  147. package/src/components/native-select.tsx +96 -0
  148. package/src/components/navigation-menu.tsx +295 -0
  149. package/src/components/pagination.tsx +204 -0
  150. package/src/components/popover.tsx +139 -0
  151. package/src/components/progress-circle.tsx +203 -0
  152. package/src/components/progress.tsx +54 -0
  153. package/src/components/radio-cards.tsx +85 -0
  154. package/src/components/radio-group.tsx +79 -0
  155. package/src/components/radio.tsx +61 -0
  156. package/src/components/resizable.tsx +99 -0
  157. package/src/components/scroll-area.tsx +115 -0
  158. package/src/components/select.tsx +319 -0
  159. package/src/components/separator.tsx +74 -0
  160. package/src/components/sheet.tsx +278 -0
  161. package/src/components/sidebar.tsx +1056 -0
  162. package/src/components/skeleton.tsx +37 -0
  163. package/src/components/slider.tsx +95 -0
  164. package/src/components/sonner.tsx +47 -0
  165. package/src/components/spinner.tsx +75 -0
  166. package/src/components/switch.tsx +66 -0
  167. package/src/components/table.tsx +200 -0
  168. package/src/components/tabs.tsx +128 -0
  169. package/src/components/textarea.tsx +49 -0
  170. package/src/components/toggle-group.tsx +141 -0
  171. package/src/components/toggle.tsx +39 -0
  172. package/src/components/tooltip.tsx +141 -0
  173. package/src/css/amber.css +59 -22
  174. package/src/css/blue.css +59 -22
  175. package/src/css/cyan.css +59 -22
  176. package/src/css/emerald.css +59 -22
  177. package/src/css/fuchsia.css +59 -22
  178. package/src/css/gray.css +59 -22
  179. package/src/css/green.css +59 -22
  180. package/src/css/indigo.css +59 -22
  181. package/src/css/lime.css +59 -22
  182. package/src/css/neutral.css +59 -22
  183. package/src/css/orange.css +59 -22
  184. package/src/css/pink.css +59 -22
  185. package/src/css/preset.css +32 -13
  186. package/src/css/purple.css +59 -22
  187. package/src/css/red.css +59 -22
  188. package/src/css/rose.css +59 -22
  189. package/src/css/sky.css +59 -22
  190. package/src/css/slate.css +59 -22
  191. package/src/css/stone.css +59 -22
  192. package/src/css/teal.css +59 -22
  193. package/src/css/violet.css +59 -22
  194. package/src/css/yellow.css +59 -22
  195. package/src/css/zinc.css +59 -22
  196. package/src/hooks/use-animated-value.ts +97 -0
  197. package/src/hooks/use-copy-to-clipboard.ts +63 -0
  198. package/src/hooks/use-is-mobile.ts +27 -0
  199. package/src/hooks/use-media-query.ts +71 -0
  200. package/src/hooks/use-mutation-observer.ts +54 -0
  201. package/src/hooks/use-pagination.ts +166 -0
  202. package/src/index.ts +720 -0
  203. package/src/lib/utils.ts +5 -0
  204. package/src/primitives/checkbox-group.tsx +360 -0
  205. package/src/primitives/input-number.tsx +1013 -0
  206. package/src/primitives/input.tsx +243 -0
  207. package/src/primitives/progress-circle.tsx +537 -0
  208. package/src/variants/alert.ts +45 -0
  209. package/src/variants/badge.ts +66 -0
  210. package/src/variants/button-group.ts +49 -0
  211. package/src/variants/button.ts +93 -0
  212. package/src/variants/empty.ts +43 -0
  213. package/src/variants/field.ts +50 -0
  214. package/src/variants/input-group.ts +132 -0
  215. package/src/variants/item.ts +90 -0
  216. package/src/variants/navigation-menu.ts +32 -0
  217. package/src/variants/progress-circle.ts +47 -0
  218. package/src/variants/scroll-area.ts +79 -0
  219. package/src/variants/separator.ts +41 -0
  220. package/src/variants/sheet.ts +70 -0
  221. package/src/variants/sidebar.ts +61 -0
  222. package/src/variants/toggle.ts +59 -0
  223. package/dist/node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/clsx.d.mts +0 -6
@@ -0,0 +1,37 @@
1
+ import type { ComponentProps, JSX } from "react";
2
+
3
+ import { cn } from "#/lib/utils";
4
+
5
+ /* -----------------------------------------------------------------------------
6
+ * Component: Skeleton
7
+ * -------------------------------------------------------------------------- */
8
+
9
+ /**
10
+ * @since 0.3.16-canary.0
11
+ */
12
+ type SkeletonProps = ComponentProps<"div">;
13
+
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ function Skeleton({ className, ...props }: SkeletonProps): JSX.Element {
18
+ return (
19
+ <div
20
+ className={cn(
21
+ "rounded-lg",
22
+ "bg-gradient-to-r from-muted via-white/15 to-muted bg-[length:400%_100%]",
23
+ "animate-shimmer motion-reduce:animate-none",
24
+ className,
25
+ )}
26
+ data-slot="skeleton"
27
+ {...props}
28
+ />
29
+ );
30
+ }
31
+
32
+ /* -----------------------------------------------------------------------------
33
+ * Exports
34
+ * -------------------------------------------------------------------------- */
35
+
36
+ export { Skeleton };
37
+ export type { SkeletonProps };
@@ -0,0 +1,95 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps, JSX } from "react";
4
+
5
+ import { cn } from "#/lib/utils";
6
+ import * as SliderPrimitive from "@radix-ui/react-slider";
7
+ import { useMemo } from "react";
8
+
9
+ /* -----------------------------------------------------------------------------
10
+ * Component: Slider
11
+ * -------------------------------------------------------------------------- */
12
+
13
+ /**
14
+ * @since 0.3.16-canary.0
15
+ */
16
+ type SliderProps = ComponentProps<typeof SliderPrimitive.Root>;
17
+
18
+ /**
19
+ * @since 0.3.16-canary.0
20
+ */
21
+ function Slider({
22
+ className,
23
+ defaultValue,
24
+ max = 100,
25
+ min = 0,
26
+ value,
27
+ ...props
28
+ }: SliderProps): JSX.Element {
29
+ const _values = useMemo(() => {
30
+ if (Array.isArray(value)) {
31
+ return value;
32
+ }
33
+
34
+ return Array.isArray(defaultValue) ? defaultValue : [min, max];
35
+ }, [value, defaultValue, min, max]);
36
+
37
+ return (
38
+ <SliderPrimitive.Root
39
+ className={cn(
40
+ "relative flex w-full items-center",
41
+ "touch-none select-none",
42
+ "data-vertical:h-full data-vertical:min-h-44 data-vertical:w-auto data-vertical:flex-col",
43
+ "data-disabled:opacity-50",
44
+ className,
45
+ )}
46
+ data-slot="slider"
47
+ defaultValue={defaultValue}
48
+ max={max}
49
+ min={min}
50
+ value={value}
51
+ {...props}
52
+ >
53
+ <SliderPrimitive.Track
54
+ className={cn(
55
+ "relative",
56
+ "w-full grow overflow-hidden",
57
+ "rounded-full",
58
+ "bg-input",
59
+ "data-horizontal:h-1 data-horizontal:w-full",
60
+ "data-vertical:h-full data-vertical:w-1",
61
+ )}
62
+ data-slot="slider-track"
63
+ >
64
+ <SliderPrimitive.Range
65
+ className={cn("absolute", "bg-primary", "data-horizontal:h-full", "data-vertical:w-full")}
66
+ data-slot="slider-range"
67
+ />
68
+ </SliderPrimitive.Track>
69
+ {Array.from({ length: _values.length }, (_, index) => (
70
+ <SliderPrimitive.Thumb
71
+ key={index}
72
+ aria-label="Volume"
73
+ className={cn(
74
+ "flex size-4 items-center justify-center",
75
+ "rounded-full border-2 border-primary",
76
+ "bg-primary shadow-sm outline-hidden",
77
+ "after:size-full after:rounded-full after:bg-background after:transition-[width,height] after:duration-200 after:ease-spring",
78
+ "motion-reduce:after:transition-none motion-reduce:after:duration-0",
79
+ "focus-visible:ring-4 focus-visible:ring-primary/20",
80
+ "active:not-data-disabled:after:size-1",
81
+ "dark:focus-visible:ring-primary/40",
82
+ )}
83
+ data-slot="slider-thumb"
84
+ />
85
+ ))}
86
+ </SliderPrimitive.Root>
87
+ );
88
+ }
89
+
90
+ /* -----------------------------------------------------------------------------
91
+ * Exports
92
+ * -------------------------------------------------------------------------- */
93
+
94
+ export { Slider };
95
+ export type { SliderProps };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+
3
+ import { cn } from "#/lib/utils";
4
+ import type { CSSProperties, JSX } from "react";
5
+ import type { ToasterProps as SonnerToasterProps } from "sonner";
6
+
7
+ import { useTheme } from "next-themes";
8
+ import { Toaster as Sonner } from "sonner";
9
+
10
+ /* -----------------------------------------------------------------------------
11
+ * Component: Sonner
12
+ * -------------------------------------------------------------------------- */
13
+
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ type ToasterProps = SonnerToasterProps;
18
+
19
+ /**
20
+ * @since 0.3.16-canary.0
21
+ */
22
+ function Toaster({ ...props }: ToasterProps): JSX.Element {
23
+ const { theme = "system" } = useTheme();
24
+
25
+ return (
26
+ <Sonner
27
+ className={cn("group", "toaster")}
28
+ style={
29
+ {
30
+ "--normal-bg": "var(--popover)",
31
+ "--normal-border": "var(--border)",
32
+ "--normal-text": "var(--popover-foreground)",
33
+ } as CSSProperties
34
+ }
35
+ theme={theme as ToasterProps["theme"]}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ /* -----------------------------------------------------------------------------
42
+ * Exports
43
+ * -------------------------------------------------------------------------- */
44
+
45
+ export { toast, useSonner } from "sonner";
46
+ export { Toaster };
47
+ export type { ToasterProps };
@@ -0,0 +1,75 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps, CSSProperties, ReactNode } from "react";
4
+
5
+ import { cn } from "#/lib/utils";
6
+ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
7
+
8
+ /* -----------------------------------------------------------------------------
9
+ * Component: Spinner
10
+ * -------------------------------------------------------------------------- */
11
+
12
+ const SPINNER_COUNT = 8;
13
+
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ interface SpinnerProps extends ComponentProps<"span"> {
18
+ loading?: boolean;
19
+ }
20
+
21
+ /**
22
+ * @since 0.3.16-canary.0
23
+ */
24
+ function Spinner({ children, className, loading = true, ...props }: SpinnerProps): ReactNode {
25
+ if (!loading) {
26
+ return children;
27
+ }
28
+
29
+ const spinner = (
30
+ <span
31
+ className={cn("relative flex size-4 items-center justify-center", "opacity-60", className)}
32
+ {...props}
33
+ >
34
+ {Array.from({ length: SPINNER_COUNT }, (_, index) => (
35
+ <span
36
+ key={index}
37
+ className={cn(
38
+ "absolute",
39
+ "h-full rotate-(--spinner-rotate)",
40
+ "before:block before:h-1/3 before:w-full before:animate-out before:rounded-full before:bg-current before:delay-(--spinner-delay) before:animation-duration-(--spinner-duration) before:fade-out-25 before:repeat-infinite motion-reduce:before:animate-none",
41
+ )}
42
+ style={
43
+ {
44
+ "--spinner-delay": `-${((SPINNER_COUNT - index) * 100).toString()}ms`,
45
+ "--spinner-duration": `${(SPINNER_COUNT * 100).toString()}ms`,
46
+ "--spinner-rotate": `${((360 / SPINNER_COUNT) * index).toString()}deg`,
47
+ width: `${(100 / SPINNER_COUNT).toString()}%`,
48
+ } as CSSProperties
49
+ }
50
+ />
51
+ ))}
52
+ </span>
53
+ );
54
+
55
+ if (children === undefined) {
56
+ return spinner;
57
+ }
58
+
59
+ return (
60
+ <span className="relative">
61
+ <span aria-hidden className={cn("contents", "invisible")}>
62
+ {children}
63
+ </span>
64
+ <VisuallyHidden>{children}</VisuallyHidden>
65
+ <span className={cn("absolute flex items-center justify-center", "inset-0")}>{spinner}</span>
66
+ </span>
67
+ );
68
+ }
69
+
70
+ /* -----------------------------------------------------------------------------
71
+ * Exports
72
+ * -------------------------------------------------------------------------- */
73
+
74
+ export { Spinner };
75
+ export type { SpinnerProps };
@@ -0,0 +1,66 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps, JSX } from "react";
4
+
5
+ import { cn } from "#/lib/utils";
6
+ import * as SwitchPrimitives from "@radix-ui/react-switch";
7
+
8
+ /* -----------------------------------------------------------------------------
9
+ * Component: Switch
10
+ * -------------------------------------------------------------------------- */
11
+
12
+ /**
13
+ * @since 0.3.16-canary.0
14
+ */
15
+ type SwitchProps = ComponentProps<typeof SwitchPrimitives.Root>;
16
+
17
+ /**
18
+ * @since 0.3.16-canary.0
19
+ */
20
+ function Switch({ className, ...props }: SwitchProps): JSX.Element {
21
+ return (
22
+ <SwitchPrimitives.Root
23
+ className={cn(
24
+ "peer group/switch inline-flex h-5 w-9 shrink-0 items-center p-0.75",
25
+ "rounded-full border border-transparent shadow-xs outline-hidden",
26
+ "transition-[background-color,box-shadow] duration-200 ease-snappy",
27
+ "motion-reduce:transition-none motion-reduce:duration-0",
28
+ "active:not-disabled:inset-shadow-sm",
29
+ "focus-visible:ring-3 focus-visible:ring-ring/50",
30
+ "focus-visible:not-data-checked:border-ring/60",
31
+ "disabled:opacity-50",
32
+ "data-checked:bg-primary",
33
+ "data-checked:focus-visible:ring-primary/20",
34
+ "dark:data-checked:focus-visible:ring-primary/40",
35
+ "data-unchecked:bg-input",
36
+ "dark:data-unchecked:bg-input/80",
37
+ className,
38
+ )}
39
+ data-slot="switch"
40
+ {...props}
41
+ >
42
+ <SwitchPrimitives.Thumb
43
+ className={cn(
44
+ "block",
45
+ "size-3.5",
46
+ "rounded-full",
47
+ "bg-background shadow-sm",
48
+ "pointer-events-none",
49
+ "transition-transform duration-300 ease-spring",
50
+ "motion-reduce:transition-none motion-reduce:duration-0",
51
+ "dark:not-data-checked:bg-foreground",
52
+ "data-checked:translate-x-3.5",
53
+ "data-unchecked:translate-x-0",
54
+ )}
55
+ data-slot="switch-thumb"
56
+ />
57
+ </SwitchPrimitives.Root>
58
+ );
59
+ }
60
+
61
+ /* -----------------------------------------------------------------------------
62
+ * Exports
63
+ * -------------------------------------------------------------------------- */
64
+
65
+ export { Switch };
66
+ export type { SwitchProps };
@@ -0,0 +1,200 @@
1
+ import type { ComponentProps, JSX } from "react";
2
+
3
+ import { cn } from "#/lib/utils";
4
+
5
+ /* -----------------------------------------------------------------------------
6
+ * Component: Table
7
+ * -------------------------------------------------------------------------- */
8
+
9
+ /**
10
+ * @since 0.3.16-canary.0
11
+ */
12
+ type TableProps = ComponentProps<"table">;
13
+
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ function Table({ className, ...props }: TableProps): JSX.Element {
18
+ return (
19
+ <div className={cn("relative", "w-full overflow-auto")} data-slot="table-cotainer">
20
+ <table
21
+ className={cn("w-full text-sm", "caption-bottom", className)}
22
+ data-slot="table"
23
+ {...props}
24
+ />
25
+ </div>
26
+ );
27
+ }
28
+
29
+ /* -----------------------------------------------------------------------------
30
+ * Component: TableHeader
31
+ * -------------------------------------------------------------------------- */
32
+
33
+ /**
34
+ * @since 0.3.16-canary.0
35
+ */
36
+ type TableHeaderProps = ComponentProps<"thead">;
37
+
38
+ /**
39
+ * @since 0.3.16-canary.0
40
+ */
41
+ function TableHeader({ className, ...props }: TableHeaderProps): JSX.Element {
42
+ return (
43
+ <thead
44
+ className={cn("*:border-b", "*:has-aria-expanded:bg-transparent", className)}
45
+ data-slot="table-header"
46
+ {...props}
47
+ />
48
+ );
49
+ }
50
+
51
+ /* -----------------------------------------------------------------------------
52
+ * Component: TableBody
53
+ * -------------------------------------------------------------------------- */
54
+
55
+ /**
56
+ * @since 0.3.16-canary.0
57
+ */
58
+ type TableBodyProps = ComponentProps<"tbody">;
59
+
60
+ /**
61
+ * @since 0.3.16-canary.0
62
+ */
63
+ function TableBody({ className, ...props }: TableBodyProps): JSX.Element {
64
+ return (
65
+ <tbody className={cn("*:last-child:border-0", className)} data-slot="table-body" {...props} />
66
+ );
67
+ }
68
+
69
+ /* -----------------------------------------------------------------------------
70
+ * Component: TableFooter
71
+ * -------------------------------------------------------------------------- */
72
+
73
+ /**
74
+ * @since 0.3.16-canary.0
75
+ */
76
+ type TableFooterProps = ComponentProps<"tfoot">;
77
+
78
+ /**
79
+ * @since 0.3.16-canary.0
80
+ */
81
+ function TableFooter({ className, ...props }: TableFooterProps): JSX.Element {
82
+ return (
83
+ <tfoot
84
+ className={cn(
85
+ "bg-muted/50 font-medium",
86
+ "*:border-t *:border-b-0",
87
+ "*:has-aria-expanded:bg-transparent",
88
+ className,
89
+ )}
90
+ data-slot="table-footer"
91
+ {...props}
92
+ />
93
+ );
94
+ }
95
+
96
+ /* -----------------------------------------------------------------------------
97
+ * Component: TableRow
98
+ * -------------------------------------------------------------------------- */
99
+
100
+ /**
101
+ * @since 0.3.16-canary.0
102
+ */
103
+ type TableRowProps = ComponentProps<"tr">;
104
+
105
+ /**
106
+ * @since 0.3.16-canary.0
107
+ */
108
+ function TableRow({ className, ...props }: TableRowProps): JSX.Element {
109
+ return (
110
+ <tr
111
+ className={cn(
112
+ "border-b",
113
+ "transition-colors",
114
+ "motion-reduce:transition-none",
115
+ "hover:bg-muted/50",
116
+ "has-aria-expanded:bg-muted/50",
117
+ "data-selected:bg-muted",
118
+ className,
119
+ )}
120
+ data-slot="table-row"
121
+ {...props}
122
+ />
123
+ );
124
+ }
125
+
126
+ /* -----------------------------------------------------------------------------
127
+ * Component: TableHead
128
+ * -------------------------------------------------------------------------- */
129
+
130
+ /**
131
+ * @since 0.3.16-canary.0
132
+ */
133
+ type TableHeadProps = ComponentProps<"th">;
134
+
135
+ /**
136
+ * @since 0.3.16-canary.0
137
+ */
138
+ function TableHead({ className, ...props }: TableHeadProps): JSX.Element {
139
+ return (
140
+ <th
141
+ className={cn("p-2", "text-left align-middle font-medium", className)}
142
+ data-slot="table-head"
143
+ {...props}
144
+ />
145
+ );
146
+ }
147
+
148
+ /* -----------------------------------------------------------------------------
149
+ * Component: TableCell
150
+ * -------------------------------------------------------------------------- */
151
+
152
+ /**
153
+ * @since 0.3.16-canary.0
154
+ */
155
+ type TableCellProps = ComponentProps<"td">;
156
+
157
+ /**
158
+ * @since 0.3.16-canary.0
159
+ */
160
+ function TableCell({ className, ...props }: TableCellProps): JSX.Element {
161
+ return <td className={cn("p-2", "align-middle", className)} data-slot="table-cell" {...props} />;
162
+ }
163
+
164
+ /* -----------------------------------------------------------------------------
165
+ * Component: TableCaption
166
+ * -------------------------------------------------------------------------- */
167
+
168
+ /**
169
+ * @since 0.3.16-canary.0
170
+ */
171
+ type TableCaptionProps = ComponentProps<"caption">;
172
+
173
+ /**
174
+ * @since 0.3.16-canary.0
175
+ */
176
+ function TableCaption({ className, ...props }: TableCaptionProps): JSX.Element {
177
+ return (
178
+ <caption
179
+ className={cn("mt-4", "text-sm text-muted-foreground", className)}
180
+ data-slot="table-caption"
181
+ {...props}
182
+ />
183
+ );
184
+ }
185
+
186
+ /* -----------------------------------------------------------------------------
187
+ * Exports
188
+ * -------------------------------------------------------------------------- */
189
+
190
+ export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
191
+ export type {
192
+ TableBodyProps,
193
+ TableCaptionProps,
194
+ TableCellProps,
195
+ TableFooterProps,
196
+ TableHeaderProps,
197
+ TableHeadProps,
198
+ TableProps,
199
+ TableRowProps,
200
+ };
@@ -0,0 +1,128 @@
1
+ "use client";
2
+
3
+ import type { ComponentProps, JSX } from "react";
4
+
5
+ import { cn } from "#/lib/utils";
6
+ import * as TabsPrimitive from "@radix-ui/react-tabs";
7
+
8
+ /* -----------------------------------------------------------------------------
9
+ * Component: Tabs
10
+ * -------------------------------------------------------------------------- */
11
+
12
+ /**
13
+ * @since 0.3.16-canary.0
14
+ */
15
+ type TabsProps = ComponentProps<typeof TabsPrimitive.Root>;
16
+
17
+ /**
18
+ * @since 0.3.16-canary.0
19
+ */
20
+ function Tabs({ className, ...props }: TabsProps): JSX.Element {
21
+ return (
22
+ <TabsPrimitive.Root
23
+ className={cn("flex flex-col gap-2", className)}
24
+ data-slot="tabs"
25
+ {...props}
26
+ />
27
+ );
28
+ }
29
+
30
+ /* -----------------------------------------------------------------------------
31
+ * Component: TabsList
32
+ * -------------------------------------------------------------------------- */
33
+
34
+ /**
35
+ * @since 0.3.16-canary.0
36
+ */
37
+ type TabsListProps = ComponentProps<typeof TabsPrimitive.List>;
38
+
39
+ /**
40
+ * @since 0.3.16-canary.0
41
+ */
42
+ function TabsList({ className, ...props }: TabsListProps): JSX.Element {
43
+ return (
44
+ <TabsPrimitive.List
45
+ className={cn(
46
+ "inline-flex w-fit items-center justify-center gap-1 px-1 py-1",
47
+ "rounded-xl",
48
+ "bg-muted text-muted-foreground",
49
+ className,
50
+ )}
51
+ data-slot="tabs-list"
52
+ {...props}
53
+ />
54
+ );
55
+ }
56
+
57
+ /* -----------------------------------------------------------------------------
58
+ * Component: TabsTrigger
59
+ * -------------------------------------------------------------------------- */
60
+
61
+ /**
62
+ * @since 0.3.16-canary.0
63
+ */
64
+ type TabsTriggerProps = ComponentProps<typeof TabsPrimitive.Trigger>;
65
+
66
+ /**
67
+ * @since 0.3.16-canary.0
68
+ */
69
+ function TabsTrigger({ className, ...props }: TabsTriggerProps): JSX.Element {
70
+ return (
71
+ <TabsPrimitive.Trigger
72
+ className={cn(
73
+ "inline-flex items-center justify-center gap-1.5",
74
+ "px-2 py-1.5",
75
+ "rounded-lg",
76
+ "text-sm font-medium whitespace-nowrap text-muted-foreground",
77
+ "transition-[color,background-color,box-shadow] duration-150 ease-snappy",
78
+ "motion-reduce:transition-none motion-reduce:duration-0",
79
+ "not-dark:outline-hidden",
80
+ "hover:not-disabled:text-foreground",
81
+ "focus-visible:ring-3 focus-visible:ring-ring/50",
82
+ "disabled:opacity-50",
83
+ "dark:focus-visible:-outline-offset-1 dark:focus-visible:outline-ring",
84
+ "data-active:bg-background data-active:text-foreground data-active:shadow-sm",
85
+ "dark:data-active:bg-input/50",
86
+ "dark:focus-visible:data-active:outline-1",
87
+ "[&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
88
+ className,
89
+ )}
90
+ data-slot="tabs-trigger"
91
+ {...props}
92
+ />
93
+ );
94
+ }
95
+
96
+ /* -----------------------------------------------------------------------------
97
+ * Component: TabsContent
98
+ * -------------------------------------------------------------------------- */
99
+
100
+ /**
101
+ * @since 0.3.16-canary.0
102
+ */
103
+ type TabsContentProps = ComponentProps<typeof TabsPrimitive.Content>;
104
+
105
+ /**
106
+ * @since 0.3.16-canary.0
107
+ */
108
+ function TabsContent({ className, ...props }: TabsContentProps): JSX.Element {
109
+ return (
110
+ <TabsPrimitive.Content
111
+ className={cn(
112
+ "mt-2",
113
+ "rounded-xl ring-ring/50 outline-ring",
114
+ "focus-visible:ring-4 focus-visible:outline-1",
115
+ className,
116
+ )}
117
+ data-slot="tabs-content"
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ /* -----------------------------------------------------------------------------
124
+ * Exports
125
+ * -------------------------------------------------------------------------- */
126
+
127
+ export { Tabs, TabsContent, TabsList, TabsTrigger };
128
+ export type { TabsContentProps, TabsListProps, TabsProps, TabsTriggerProps };
@@ -0,0 +1,49 @@
1
+ import type { ComponentProps, JSX } from "react";
2
+
3
+ import { cn } from "#/lib/utils";
4
+
5
+ /* -----------------------------------------------------------------------------
6
+ * Component: Textarea
7
+ * -------------------------------------------------------------------------- */
8
+
9
+ /**
10
+ * @since 0.3.16-canary.0
11
+ */
12
+ type TextareaProps = ComponentProps<"textarea">;
13
+
14
+ /**
15
+ * @since 0.3.16-canary.0
16
+ */
17
+ function Textarea({ className, ...props }: TextareaProps): JSX.Element {
18
+ return (
19
+ <textarea
20
+ className={cn(
21
+ "flex min-h-16 w-full grow px-3 py-2",
22
+ "rounded-lg border border-input shadow-xs outline-hidden",
23
+ "text-base",
24
+ "transition-[color,box-shadow] duration-150 ease-snappy",
25
+ "motion-reduce:transition-none motion-reduce:duration-0",
26
+ "placeholder:text-muted-foreground",
27
+ "hover:not-disabled:not-focus-visible:border-ring/60",
28
+ "focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
29
+ "disabled:opacity-50",
30
+ "aria-invalid:border-destructive",
31
+ "focus-within:aria-invalid:ring-destructive/20",
32
+ "hover:not-disabled:not-focus-within:aria-invalid:border-destructive/60",
33
+ "md:text-sm",
34
+ "dark:bg-input/30",
35
+ "dark:focus-within:aria-invalid:ring-destructive/40",
36
+ className,
37
+ )}
38
+ data-slot="textarea"
39
+ {...props}
40
+ />
41
+ );
42
+ }
43
+
44
+ /* -----------------------------------------------------------------------------
45
+ * Exports
46
+ * -------------------------------------------------------------------------- */
47
+
48
+ export { Textarea };
49
+ export type { TextareaProps };