@object-ui/components 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/.turbo/turbo-build.log +47 -0
  2. package/README.md +13 -0
  3. package/dist/index.css +1 -1
  4. package/dist/index.js +34610 -24854
  5. package/dist/index.umd.cjs +53 -32
  6. package/dist/src/SchemaRenderer.d.ts +3 -0
  7. package/dist/src/{ui → custom}/button-group.d.ts +1 -1
  8. package/dist/src/custom/field.d.ts +19 -0
  9. package/dist/src/custom/index.d.ts +12 -0
  10. package/dist/src/custom/input-group.d.ts +14 -0
  11. package/dist/src/{ui → custom}/item.d.ts +1 -1
  12. package/dist/src/custom/native-select.d.ts +12 -0
  13. package/dist/src/custom/sort-builder.d.ts +22 -0
  14. package/dist/src/index.d.ts +1 -0
  15. package/dist/src/renderers/data-display/table.d.ts +1 -1
  16. package/dist/src/renderers/layout/page.d.ts +1 -1
  17. package/dist/src/renderers/placeholders.d.ts +1 -1
  18. package/dist/src/ui/accordion.d.ts +4 -4
  19. package/dist/src/ui/alert-dialog.d.ts +17 -11
  20. package/dist/src/ui/alert.d.ts +4 -5
  21. package/dist/src/ui/aspect-ratio.d.ts +1 -1
  22. package/dist/src/ui/avatar.d.ts +3 -3
  23. package/dist/src/ui/badge.d.ts +3 -3
  24. package/dist/src/ui/breadcrumb.d.ts +16 -8
  25. package/dist/src/ui/calendar.d.ts +7 -7
  26. package/dist/src/ui/card.d.ts +7 -8
  27. package/dist/src/ui/carousel.d.ts +5 -6
  28. package/dist/src/ui/chart.d.ts +62 -0
  29. package/dist/src/ui/checkbox.d.ts +1 -1
  30. package/dist/src/ui/collapsible.d.ts +3 -3
  31. package/dist/src/ui/command.d.ts +78 -16
  32. package/dist/src/ui/context-menu.d.ts +14 -12
  33. package/dist/src/ui/dialog.d.ts +17 -13
  34. package/dist/src/ui/drawer.d.ts +19 -10
  35. package/dist/src/ui/dropdown-menu.d.ts +20 -18
  36. package/dist/src/ui/form.d.ts +6 -7
  37. package/dist/src/ui/hover-card.d.ts +3 -3
  38. package/dist/src/ui/index.d.ts +2 -8
  39. package/dist/src/ui/input-otp.d.ts +30 -7
  40. package/dist/src/ui/label.d.ts +2 -1
  41. package/dist/src/ui/menubar.d.ts +19 -17
  42. package/dist/src/ui/navigation-menu.d.ts +9 -11
  43. package/dist/src/ui/pagination.d.ts +25 -10
  44. package/dist/src/ui/popover.d.ts +4 -5
  45. package/dist/src/ui/progress.d.ts +1 -1
  46. package/dist/src/ui/radio-group.d.ts +2 -2
  47. package/dist/src/ui/resizable.d.ts +5 -8
  48. package/dist/src/ui/scroll-area.d.ts +2 -2
  49. package/dist/src/ui/select.d.ts +11 -13
  50. package/dist/src/ui/sheet.d.ts +23 -11
  51. package/dist/src/ui/sidebar.d.ts +27 -29
  52. package/dist/src/ui/skeleton.d.ts +1 -1
  53. package/dist/src/ui/slider.d.ts +1 -1
  54. package/dist/src/ui/sonner.d.ts +2 -1
  55. package/dist/src/ui/switch.d.ts +2 -2
  56. package/dist/src/ui/tabs.d.ts +1 -1
  57. package/dist/src/ui/textarea.d.ts +1 -1
  58. package/dist/src/ui/toast.d.ts +22 -0
  59. package/dist/src/ui/toggle-group.d.ts +8 -3
  60. package/dist/src/ui/toggle.d.ts +4 -1
  61. package/dist/src/ui/tooltip.d.ts +4 -4
  62. package/dist/src/ui/typography.d.ts +21 -0
  63. package/package.json +17 -7
  64. package/shadcn-components.json +52 -47
  65. package/src/SchemaRenderer.tsx +28 -0
  66. package/src/__tests__/PageRendererRegions.test.tsx +59 -0
  67. package/src/__tests__/Registry.test.ts +21 -0
  68. package/src/__tests__/basic-renderers.test.tsx +1 -1
  69. package/src/__tests__/complex-disclosure-renderers.test.tsx +3 -2
  70. package/src/__tests__/feedback-overlay-renderers.test.tsx +1 -1
  71. package/src/__tests__/form-renderers.test.tsx +1 -1
  72. package/src/__tests__/layout-data-renderers.test.tsx +1 -1
  73. package/src/{ui → custom}/button-group.tsx +1 -1
  74. package/src/{ui → custom}/combobox.tsx +3 -3
  75. package/src/{ui → custom}/date-picker.tsx +3 -3
  76. package/src/custom/field.tsx +81 -0
  77. package/src/{ui → custom}/filter-builder.tsx +3 -3
  78. package/src/custom/index.ts +12 -0
  79. package/src/custom/input-group.tsx +53 -0
  80. package/src/{ui → custom}/item.tsx +1 -1
  81. package/src/custom/native-select.tsx +33 -0
  82. package/src/custom/sort-builder.tsx +129 -0
  83. package/src/index.css +20 -1
  84. package/src/index.ts +1 -0
  85. package/src/renderers/basic/button-group.tsx +1 -0
  86. package/src/renderers/basic/div.tsx +12 -1
  87. package/src/renderers/basic/html.tsx +1 -0
  88. package/src/renderers/basic/icon.tsx +1 -0
  89. package/src/renderers/basic/image.tsx +1 -0
  90. package/src/renderers/basic/navigation-menu.tsx +1 -0
  91. package/src/renderers/basic/pagination.tsx +31 -4
  92. package/src/renderers/basic/separator.tsx +1 -0
  93. package/src/renderers/basic/span.tsx +12 -1
  94. package/src/renderers/basic/text.tsx +4 -2
  95. package/src/renderers/complex/carousel.tsx +1 -0
  96. package/src/renderers/complex/data-table.tsx +134 -95
  97. package/src/renderers/complex/filter-builder.tsx +2 -1
  98. package/src/renderers/complex/resizable.tsx +2 -1
  99. package/src/renderers/complex/scroll-area.tsx +25 -7
  100. package/src/renderers/complex/table.tsx +1 -0
  101. package/src/renderers/data-display/alert.tsx +1 -0
  102. package/src/renderers/data-display/avatar.tsx +1 -0
  103. package/src/renderers/data-display/badge.tsx +1 -0
  104. package/src/renderers/data-display/breadcrumb.tsx +1 -0
  105. package/src/renderers/data-display/kbd.tsx +1 -0
  106. package/src/renderers/data-display/list.tsx +21 -49
  107. package/src/renderers/data-display/statistic.tsx +21 -5
  108. package/src/renderers/data-display/table.tsx +21 -11
  109. package/src/renderers/data-display/tree-view.tsx +7 -1
  110. package/src/renderers/disclosure/accordion.tsx +1 -0
  111. package/src/renderers/disclosure/collapsible.tsx +1 -0
  112. package/src/renderers/disclosure/toggle-group.tsx +2 -0
  113. package/src/renderers/feedback/empty.tsx +1 -0
  114. package/src/renderers/feedback/loading.tsx +2 -1
  115. package/src/renderers/feedback/progress.tsx +1 -0
  116. package/src/renderers/feedback/skeleton.tsx +1 -0
  117. package/src/renderers/feedback/sonner.tsx +1 -0
  118. package/src/renderers/feedback/spinner.tsx +1 -0
  119. package/src/renderers/feedback/toast.tsx +1 -0
  120. package/src/renderers/feedback/toaster.tsx +1 -0
  121. package/src/renderers/form/button.tsx +35 -1
  122. package/src/renderers/form/calendar.tsx +1 -0
  123. package/src/renderers/form/checkbox.tsx +38 -16
  124. package/src/renderers/form/combobox.tsx +2 -1
  125. package/src/renderers/form/command.tsx +1 -0
  126. package/src/renderers/form/date-picker.tsx +1 -0
  127. package/src/renderers/form/file-upload.tsx +1 -0
  128. package/src/renderers/form/form.tsx +92 -15
  129. package/src/renderers/form/input-otp.tsx +1 -0
  130. package/src/renderers/form/input.tsx +3 -0
  131. package/src/renderers/form/label.tsx +1 -0
  132. package/src/renderers/form/radio-group.tsx +1 -0
  133. package/src/renderers/form/select.tsx +35 -15
  134. package/src/renderers/form/slider.tsx +1 -0
  135. package/src/renderers/form/switch.tsx +1 -0
  136. package/src/renderers/form/textarea.tsx +50 -27
  137. package/src/renderers/form/toggle.tsx +3 -45
  138. package/src/renderers/layout/aspect-ratio.tsx +2 -1
  139. package/src/renderers/layout/card.tsx +10 -2
  140. package/src/renderers/layout/container.tsx +1 -0
  141. package/src/renderers/layout/flex.tsx +1 -0
  142. package/src/renderers/layout/grid.tsx +23 -8
  143. package/src/renderers/layout/page.tsx +35 -23
  144. package/src/renderers/layout/semantic.tsx +1 -0
  145. package/src/renderers/layout/stack.tsx +2 -1
  146. package/src/renderers/layout/tabs.tsx +43 -17
  147. package/src/renderers/navigation/header-bar.tsx +1 -0
  148. package/src/renderers/navigation/sidebar.tsx +5 -0
  149. package/src/renderers/overlay/alert-dialog.tsx +1 -0
  150. package/src/renderers/overlay/context-menu.tsx +1 -0
  151. package/src/renderers/overlay/dialog.tsx +1 -0
  152. package/src/renderers/overlay/drawer.tsx +1 -0
  153. package/src/renderers/overlay/dropdown-menu.tsx +1 -0
  154. package/src/renderers/overlay/hover-card.tsx +1 -0
  155. package/src/renderers/overlay/menubar.tsx +1 -0
  156. package/src/renderers/overlay/popover.tsx +1 -0
  157. package/src/renderers/overlay/sheet.tsx +1 -0
  158. package/src/renderers/overlay/tooltip.tsx +1 -0
  159. package/src/renderers/placeholders.tsx +2 -2
  160. package/src/stories/CRMApp.stories.tsx +706 -0
  161. package/src/stories/Guide.mdx +55 -0
  162. package/src/stories/Introduction.mdx +34 -0
  163. package/src/stories/MockedData.stories.tsx +71 -0
  164. package/src/stories/assets/accessibility.png +0 -0
  165. package/src/stories/assets/accessibility.svg +1 -0
  166. package/src/stories/assets/addon-library.png +0 -0
  167. package/src/stories/assets/assets.png +0 -0
  168. package/src/stories/assets/avif-test-image.avif +0 -0
  169. package/src/stories/assets/context.png +0 -0
  170. package/src/stories/assets/discord.svg +1 -0
  171. package/src/stories/assets/docs.png +0 -0
  172. package/src/stories/assets/figma-plugin.png +0 -0
  173. package/src/stories/assets/github.svg +1 -0
  174. package/src/stories/assets/share.png +0 -0
  175. package/src/stories/assets/styling.png +0 -0
  176. package/src/stories/assets/testing.png +0 -0
  177. package/src/stories/assets/theming.png +0 -0
  178. package/src/stories/assets/tutorials.svg +1 -0
  179. package/src/stories/assets/youtube.svg +1 -0
  180. package/src/stories/button.css +30 -0
  181. package/src/stories/header.css +32 -0
  182. package/src/stories/page.css +68 -0
  183. package/src/stories-json/accordion.stories.tsx +43 -0
  184. package/src/stories-json/aggrid.stories.tsx +103 -0
  185. package/src/stories-json/alert.stories.tsx +39 -0
  186. package/src/stories-json/aspect-ratio.stories.tsx +34 -0
  187. package/src/stories-json/avatar.stories.tsx +38 -0
  188. package/src/stories-json/badge.stories.tsx +53 -0
  189. package/src/stories-json/breadcrumb.stories.tsx +30 -0
  190. package/src/stories-json/button-group.stories.tsx +43 -0
  191. package/src/stories-json/button.stories.tsx +73 -0
  192. package/src/stories-json/calendar.stories.tsx +85 -0
  193. package/src/stories-json/card.stories.tsx +48 -0
  194. package/src/stories-json/carousel.stories.tsx +33 -0
  195. package/src/stories-json/charts.stories.tsx +195 -0
  196. package/src/stories-json/chatbot.stories.tsx +248 -0
  197. package/src/stories-json/code-editor.stories.tsx +92 -0
  198. package/src/stories-json/collapsible.stories.tsx +40 -0
  199. package/src/stories-json/controls.stories.tsx +36 -0
  200. package/src/stories-json/dashboard.stories.tsx +318 -0
  201. package/src/stories-json/data-table.stories.tsx +60 -0
  202. package/src/stories-json/data_display_extras.stories.tsx +102 -0
  203. package/src/stories-json/date-picker.stories.tsx +28 -0
  204. package/src/stories-json/detail-view.stories.tsx +258 -0
  205. package/src/stories-json/dialog.stories.tsx +43 -0
  206. package/src/stories-json/feedback_extras.stories.tsx +40 -0
  207. package/src/stories-json/feedback_others.stories.tsx +46 -0
  208. package/src/stories-json/form_advanced.stories.tsx +117 -0
  209. package/src/stories-json/form_extras.stories.tsx +123 -0
  210. package/src/stories-json/grid.stories.tsx +56 -0
  211. package/src/stories-json/icon.stories.tsx +36 -0
  212. package/src/stories-json/input.stories.tsx +52 -0
  213. package/src/stories-json/kanban.stories.tsx +295 -0
  214. package/src/stories-json/layout_extended.stories.tsx +76 -0
  215. package/src/stories-json/layout_flex.stories.tsx +107 -0
  216. package/src/stories-json/list-view.stories.tsx +97 -0
  217. package/src/stories-json/markdown.stories.tsx +129 -0
  218. package/src/stories-json/menus.stories.tsx +63 -0
  219. package/src/stories-json/metric-card.stories.tsx +143 -0
  220. package/src/stories-json/navigation-menu.stories.tsx +37 -0
  221. package/src/stories-json/object-aggrid.stories.tsx +252 -0
  222. package/src/stories-json/object-form.stories.tsx +130 -0
  223. package/src/stories-json/object-gantt.stories.tsx +114 -0
  224. package/src/stories-json/object-grid.stories.tsx +157 -0
  225. package/src/stories-json/object-map.stories.tsx +116 -0
  226. package/src/stories-json/object-view.stories.tsx +118 -0
  227. package/src/stories-json/overlay_extras.stories.tsx +113 -0
  228. package/src/stories-json/overlay_others.stories.tsx +76 -0
  229. package/src/stories-json/page.stories.tsx +55 -0
  230. package/src/stories-json/reports.stories.tsx +163 -0
  231. package/src/stories-json/resizable.stories.tsx +44 -0
  232. package/src/stories-json/select.stories.tsx +34 -0
  233. package/src/stories-json/separator.stories.tsx +41 -0
  234. package/src/stories-json/sidebar.stories.tsx +147 -0
  235. package/src/stories-json/statistic.stories.tsx +44 -0
  236. package/src/stories-json/tabs.stories.tsx +51 -0
  237. package/src/stories-json/timeline.stories.tsx +188 -0
  238. package/src/stories-json/typography.stories.tsx +45 -0
  239. package/src/ui/accordion.tsx +47 -53
  240. package/src/ui/alert-dialog.tsx +103 -117
  241. package/src/ui/alert.tsx +35 -36
  242. package/src/ui/aspect-ratio.tsx +1 -5
  243. package/src/ui/avatar.tsx +41 -42
  244. package/src/ui/badge.tsx +6 -15
  245. package/src/ui/breadcrumb.tsx +81 -75
  246. package/src/ui/button.tsx +10 -11
  247. package/src/ui/calendar.tsx +178 -51
  248. package/src/ui/card.tsx +51 -110
  249. package/src/ui/carousel.tsx +136 -113
  250. package/src/ui/chart.tsx +367 -0
  251. package/src/ui/checkbox.tsx +20 -22
  252. package/src/ui/collapsible.tsx +5 -25
  253. package/src/ui/command.tsx +106 -135
  254. package/src/ui/context-menu.tsx +69 -116
  255. package/src/ui/dialog.tsx +94 -113
  256. package/src/ui/drawer.tsx +82 -99
  257. package/src/ui/dropdown-menu.tsx +134 -188
  258. package/src/ui/form.tsx +51 -40
  259. package/src/ui/hover-card.tsx +18 -33
  260. package/src/ui/index.ts +2 -8
  261. package/src/ui/input-otp.tsx +42 -52
  262. package/src/ui/input.tsx +13 -15
  263. package/src/ui/label.tsx +17 -15
  264. package/src/ui/menubar.tsx +188 -206
  265. package/src/ui/navigation-menu.tsx +96 -136
  266. package/src/ui/pagination.tsx +86 -96
  267. package/src/ui/popover.tsx +24 -41
  268. package/src/ui/progress.tsx +21 -22
  269. package/src/ui/radio-group.tsx +19 -20
  270. package/src/ui/resizable.tsx +32 -42
  271. package/src/ui/scroll-area.tsx +38 -48
  272. package/src/ui/select.tsx +129 -157
  273. package/src/ui/separator.tsx +2 -2
  274. package/src/ui/sheet.tsx +110 -107
  275. package/src/ui/sidebar.tsx +442 -408
  276. package/src/ui/skeleton.tsx +6 -11
  277. package/src/ui/slider.tsx +19 -54
  278. package/src/ui/sonner.tsx +19 -1
  279. package/src/ui/switch.tsx +19 -21
  280. package/src/ui/tabs.tsx +6 -37
  281. package/src/ui/textarea.tsx +8 -4
  282. package/src/ui/toast.tsx +137 -0
  283. package/src/ui/toggle-group.tsx +28 -37
  284. package/src/ui/toggle.tsx +19 -19
  285. package/src/ui/tooltip.tsx +21 -52
  286. package/src/ui/typography.tsx +85 -0
  287. package/tsconfig.json +1 -1
  288. package/vite.config.ts +9 -1
  289. package/vitest.config.ts +5 -0
  290. package/ISSUES_FOUND.md +0 -128
  291. /package/dist/src/{ui → custom}/combobox.d.ts +0 -0
  292. /package/dist/src/{ui → custom}/date-picker.d.ts +0 -0
  293. /package/dist/src/{ui → custom}/empty.d.ts +0 -0
  294. /package/dist/src/{ui → custom}/filter-builder.d.ts +0 -0
  295. /package/dist/src/{ui → custom}/kbd.d.ts +0 -0
  296. /package/dist/src/{ui → custom}/spinner.d.ts +0 -0
  297. /package/src/{ui → custom}/empty.tsx +0 -0
  298. /package/src/{ui → custom}/kbd.tsx +0 -0
  299. /package/src/{ui → custom}/spinner.tsx +0 -0
package/src/ui/card.tsx CHANGED
@@ -12,135 +12,76 @@ import { cn } from "../lib/utils"
12
12
 
13
13
  const Card = React.forwardRef<
14
14
  HTMLDivElement,
15
- React.ComponentProps<"div">
16
- >(({ className, ...props }, ref) => {
17
- return (
18
- <div
19
- ref={ref}
20
- data-slot="card"
21
- className={cn(
22
- "bg-card/90 dark:bg-card/40 backdrop-blur-md text-card-foreground flex flex-col gap-6 rounded-xl border border-cyan-500/20 py-6 shadow-[0_0_30px_-10px_rgba(6,182,212,0.15)] transition-all duration-300 hover:shadow-[0_0_40px_-10px_rgba(6,182,212,0.3)] hover:border-cyan-500/40 relative overflow-hidden",
23
- className
24
- )}
25
- {...props}
26
- >
27
- {/* Decorative corner accents */}
28
- <div className="absolute top-0 left-0 w-2 h-2 border-t border-l border-cyan-500/50 rounded-tl-sm" />
29
- <div className="absolute top-0 right-0 w-2 h-2 border-t border-r border-cyan-500/50 rounded-tr-sm" />
30
- <div className="absolute bottom-0 left-0 w-2 h-2 border-b border-l border-cyan-500/50 rounded-bl-sm" />
31
- <div className="absolute bottom-0 right-0 w-2 h-2 border-b border-r border-cyan-500/50 rounded-br-sm" />
32
-
33
- {/* Content */}
34
- <div className="relative z-10 flex flex-col gap-6 h-full">
35
- {props.children}
36
- </div>
37
- </div>
38
- )
39
- })
15
+ React.HTMLAttributes<HTMLDivElement>
16
+ >(({ className, ...props }, ref) => (
17
+ <div
18
+ ref={ref}
19
+ className={cn(
20
+ "rounded-lg border bg-card text-card-foreground shadow-sm",
21
+ className
22
+ )}
23
+ {...props}
24
+ />
25
+ ))
40
26
  Card.displayName = "Card"
41
27
 
42
28
  const CardHeader = React.forwardRef<
43
29
  HTMLDivElement,
44
- React.ComponentProps<"div">
45
- >(({ className, ...props }, ref) => {
46
- return (
47
- <div
48
- ref={ref}
49
- data-slot="card-header"
50
- className={cn(
51
- "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
52
- className
53
- )}
54
- {...props}
55
- />
56
- )
57
- })
30
+ React.HTMLAttributes<HTMLDivElement>
31
+ >(({ className, ...props }, ref) => (
32
+ <div
33
+ ref={ref}
34
+ className={cn("flex flex-col space-y-1.5 p-6", className)}
35
+ {...props}
36
+ />
37
+ ))
58
38
  CardHeader.displayName = "CardHeader"
59
39
 
60
40
  const CardTitle = React.forwardRef<
61
41
  HTMLDivElement,
62
- React.ComponentProps<"div">
63
- >(({ className, ...props }, ref) => {
64
- return (
65
- <div
66
- ref={ref}
67
- data-slot="card-title"
68
- className={cn("leading-none font-semibold", className)}
69
- {...props}
70
- />
71
- )
72
- })
42
+ React.HTMLAttributes<HTMLDivElement>
43
+ >(({ className, ...props }, ref) => (
44
+ <div
45
+ ref={ref}
46
+ className={cn(
47
+ "text-2xl font-semibold leading-none tracking-tight",
48
+ className
49
+ )}
50
+ {...props}
51
+ />
52
+ ))
73
53
  CardTitle.displayName = "CardTitle"
74
54
 
75
55
  const CardDescription = React.forwardRef<
76
56
  HTMLDivElement,
77
- React.ComponentProps<"div">
78
- >(({ className, ...props }, ref) => {
79
- return (
80
- <div
81
- ref={ref}
82
- data-slot="card-description"
83
- className={cn("text-muted-foreground text-sm", className)}
84
- {...props}
85
- />
86
- )
87
- })
57
+ React.HTMLAttributes<HTMLDivElement>
58
+ >(({ className, ...props }, ref) => (
59
+ <div
60
+ ref={ref}
61
+ className={cn("text-sm text-muted-foreground", className)}
62
+ {...props}
63
+ />
64
+ ))
88
65
  CardDescription.displayName = "CardDescription"
89
66
 
90
- const CardAction = React.forwardRef<
91
- HTMLDivElement,
92
- React.ComponentProps<"div">
93
- >(({ className, ...props }, ref) => {
94
- return (
95
- <div
96
- ref={ref}
97
- data-slot="card-action"
98
- className={cn(
99
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
100
- className
101
- )}
102
- {...props}
103
- />
104
- )
105
- })
106
- CardAction.displayName = "CardAction"
107
-
108
67
  const CardContent = React.forwardRef<
109
68
  HTMLDivElement,
110
- React.ComponentProps<"div">
111
- >(({ className, ...props }, ref) => {
112
- return (
113
- <div
114
- ref={ref}
115
- data-slot="card-content"
116
- className={cn("px-6", className)}
117
- {...props}
118
- />
119
- )
120
- })
69
+ React.HTMLAttributes<HTMLDivElement>
70
+ >(({ className, ...props }, ref) => (
71
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
72
+ ))
121
73
  CardContent.displayName = "CardContent"
122
74
 
123
75
  const CardFooter = React.forwardRef<
124
76
  HTMLDivElement,
125
- React.ComponentProps<"div">
126
- >(({ className, ...props }, ref) => {
127
- return (
128
- <div
129
- ref={ref}
130
- data-slot="card-footer"
131
- className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
132
- {...props}
133
- />
134
- )
135
- })
77
+ React.HTMLAttributes<HTMLDivElement>
78
+ >(({ className, ...props }, ref) => (
79
+ <div
80
+ ref={ref}
81
+ className={cn("flex items-center p-6 pt-0", className)}
82
+ {...props}
83
+ />
84
+ ))
136
85
  CardFooter.displayName = "CardFooter"
137
86
 
138
- export {
139
- Card,
140
- CardHeader,
141
- CardFooter,
142
- CardTitle,
143
- CardAction,
144
- CardDescription,
145
- CardContent,
146
- }
87
+ export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
@@ -6,6 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
+ "use client"
10
+
9
11
  import * as React from "react"
10
12
  import useEmblaCarousel, {
11
13
  type UseEmblaCarouselType,
@@ -48,106 +50,124 @@ function useCarousel() {
48
50
  return context
49
51
  }
50
52
 
51
- function Carousel({
52
- orientation = "horizontal",
53
- opts,
54
- setApi,
55
- plugins,
56
- className,
57
- children,
58
- ...props
59
- }: React.ComponentProps<"div"> & CarouselProps) {
60
- const [carouselRef, api] = useEmblaCarousel(
53
+ const Carousel = React.forwardRef<
54
+ HTMLDivElement,
55
+ React.HTMLAttributes<HTMLDivElement> & CarouselProps
56
+ >(
57
+ (
61
58
  {
62
- ...opts,
63
- axis: orientation === "horizontal" ? "x" : "y",
59
+ orientation = "horizontal",
60
+ opts,
61
+ setApi,
62
+ plugins,
63
+ className,
64
+ children,
65
+ ...props
64
66
  },
65
- plugins
66
- )
67
- const [canScrollPrev, setCanScrollPrev] = React.useState(false)
68
- const [canScrollNext, setCanScrollNext] = React.useState(false)
69
-
70
- const onSelect = React.useCallback((api: CarouselApi) => {
71
- if (!api) return
72
- setCanScrollPrev(api.canScrollPrev())
73
- setCanScrollNext(api.canScrollNext())
74
- }, [])
75
-
76
- const scrollPrev = React.useCallback(() => {
77
- api?.scrollPrev()
78
- }, [api])
79
-
80
- const scrollNext = React.useCallback(() => {
81
- api?.scrollNext()
82
- }, [api])
83
-
84
- const handleKeyDown = React.useCallback(
85
- (event: React.KeyboardEvent<HTMLDivElement>) => {
86
- if (event.key === "ArrowLeft") {
87
- event.preventDefault()
88
- scrollPrev()
89
- } else if (event.key === "ArrowRight") {
90
- event.preventDefault()
91
- scrollNext()
67
+ ref
68
+ ) => {
69
+ const [carouselRef, api] = useEmblaCarousel(
70
+ {
71
+ ...opts,
72
+ axis: orientation === "horizontal" ? "x" : "y",
73
+ },
74
+ plugins
75
+ )
76
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
77
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
78
+
79
+ const onSelect = React.useCallback((api: CarouselApi) => {
80
+ if (!api) {
81
+ return
92
82
  }
93
- },
94
- [scrollPrev, scrollNext]
95
- )
96
83
 
97
- React.useEffect(() => {
98
- if (!api || !setApi) return
99
- setApi(api)
100
- }, [api, setApi])
84
+ setCanScrollPrev(api.canScrollPrev())
85
+ setCanScrollNext(api.canScrollNext())
86
+ }, [])
101
87
 
102
- React.useEffect(() => {
103
- if (!api) return
104
- onSelect(api)
105
- api.on("reInit", onSelect)
106
- api.on("select", onSelect)
88
+ const scrollPrev = React.useCallback(() => {
89
+ api?.scrollPrev()
90
+ }, [api])
107
91
 
108
- return () => {
109
- api?.off("select", onSelect)
110
- }
111
- }, [api, onSelect])
92
+ const scrollNext = React.useCallback(() => {
93
+ api?.scrollNext()
94
+ }, [api])
112
95
 
113
- return (
114
- <CarouselContext.Provider
115
- value={{
116
- carouselRef,
117
- api: api,
118
- opts,
119
- orientation:
120
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
121
- scrollPrev,
122
- scrollNext,
123
- canScrollPrev,
124
- canScrollNext,
125
- }}
126
- >
127
- <div
128
- onKeyDownCapture={handleKeyDown}
129
- className={cn("relative", className)}
130
- role="region"
131
- aria-roledescription="carousel"
132
- data-slot="carousel"
133
- {...props}
96
+ const handleKeyDown = React.useCallback(
97
+ (event: React.KeyboardEvent<HTMLDivElement>) => {
98
+ if (event.key === "ArrowLeft") {
99
+ event.preventDefault()
100
+ scrollPrev()
101
+ } else if (event.key === "ArrowRight") {
102
+ event.preventDefault()
103
+ scrollNext()
104
+ }
105
+ },
106
+ [scrollPrev, scrollNext]
107
+ )
108
+
109
+ React.useEffect(() => {
110
+ if (!api || !setApi) {
111
+ return
112
+ }
113
+
114
+ setApi(api)
115
+ }, [api, setApi])
116
+
117
+ React.useEffect(() => {
118
+ if (!api) {
119
+ return
120
+ }
121
+
122
+ onSelect(api)
123
+ api.on("reInit", onSelect)
124
+ api.on("select", onSelect)
125
+
126
+ return () => {
127
+ api?.off("select", onSelect)
128
+ }
129
+ }, [api, onSelect])
130
+
131
+ return (
132
+ <CarouselContext.Provider
133
+ value={{
134
+ carouselRef,
135
+ api: api,
136
+ opts,
137
+ orientation:
138
+ orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
139
+ scrollPrev,
140
+ scrollNext,
141
+ canScrollPrev,
142
+ canScrollNext,
143
+ }}
134
144
  >
135
- {children}
136
- </div>
137
- </CarouselContext.Provider>
138
- )
139
- }
145
+ <div
146
+ ref={ref}
147
+ onKeyDownCapture={handleKeyDown}
148
+ className={cn("relative", className)}
149
+ role="region"
150
+ aria-roledescription="carousel"
151
+ {...props}
152
+ >
153
+ {children}
154
+ </div>
155
+ </CarouselContext.Provider>
156
+ )
157
+ }
158
+ )
159
+ Carousel.displayName = "Carousel"
140
160
 
141
- function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
161
+ const CarouselContent = React.forwardRef<
162
+ HTMLDivElement,
163
+ React.HTMLAttributes<HTMLDivElement>
164
+ >(({ className, ...props }, ref) => {
142
165
  const { carouselRef, orientation } = useCarousel()
143
166
 
144
167
  return (
145
- <div
146
- ref={carouselRef}
147
- className="overflow-hidden"
148
- data-slot="carousel-content"
149
- >
168
+ <div ref={carouselRef} className="overflow-hidden">
150
169
  <div
170
+ ref={ref}
151
171
  className={cn(
152
172
  "flex",
153
173
  orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
@@ -157,16 +177,20 @@ function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
157
177
  />
158
178
  </div>
159
179
  )
160
- }
180
+ })
181
+ CarouselContent.displayName = "CarouselContent"
161
182
 
162
- function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
183
+ const CarouselItem = React.forwardRef<
184
+ HTMLDivElement,
185
+ React.HTMLAttributes<HTMLDivElement>
186
+ >(({ className, ...props }, ref) => {
163
187
  const { orientation } = useCarousel()
164
188
 
165
189
  return (
166
190
  <div
191
+ ref={ref}
167
192
  role="group"
168
193
  aria-roledescription="slide"
169
- data-slot="carousel-item"
170
194
  className={cn(
171
195
  "min-w-0 shrink-0 grow-0 basis-full",
172
196
  orientation === "horizontal" ? "pl-4" : "pt-4",
@@ -175,25 +199,24 @@ function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
175
199
  {...props}
176
200
  />
177
201
  )
178
- }
202
+ })
203
+ CarouselItem.displayName = "CarouselItem"
179
204
 
180
- function CarouselPrevious({
181
- className,
182
- variant = "outline",
183
- size = "icon",
184
- ...props
185
- }: React.ComponentProps<typeof Button>) {
205
+ const CarouselPrevious = React.forwardRef<
206
+ HTMLButtonElement,
207
+ React.ComponentProps<typeof Button>
208
+ >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
186
209
  const { orientation, scrollPrev, canScrollPrev } = useCarousel()
187
210
 
188
211
  return (
189
212
  <Button
190
- data-slot="carousel-previous"
213
+ ref={ref}
191
214
  variant={variant}
192
215
  size={size}
193
216
  className={cn(
194
- "absolute size-8 rounded-full",
217
+ "absolute h-8 w-8 rounded-full",
195
218
  orientation === "horizontal"
196
- ? "top-1/2 -left-12 -translate-y-1/2"
219
+ ? "-left-12 top-1/2 -translate-y-1/2"
197
220
  : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
198
221
  className
199
222
  )}
@@ -201,29 +224,28 @@ function CarouselPrevious({
201
224
  onClick={scrollPrev}
202
225
  {...props}
203
226
  >
204
- <ArrowLeft />
227
+ <ArrowLeft className="h-4 w-4" />
205
228
  <span className="sr-only">Previous slide</span>
206
229
  </Button>
207
230
  )
208
- }
231
+ })
232
+ CarouselPrevious.displayName = "CarouselPrevious"
209
233
 
210
- function CarouselNext({
211
- className,
212
- variant = "outline",
213
- size = "icon",
214
- ...props
215
- }: React.ComponentProps<typeof Button>) {
234
+ const CarouselNext = React.forwardRef<
235
+ HTMLButtonElement,
236
+ React.ComponentProps<typeof Button>
237
+ >(({ className, variant = "outline", size = "icon", ...props }, ref) => {
216
238
  const { orientation, scrollNext, canScrollNext } = useCarousel()
217
239
 
218
240
  return (
219
241
  <Button
220
- data-slot="carousel-next"
242
+ ref={ref}
221
243
  variant={variant}
222
244
  size={size}
223
245
  className={cn(
224
- "absolute size-8 rounded-full",
246
+ "absolute h-8 w-8 rounded-full",
225
247
  orientation === "horizontal"
226
- ? "top-1/2 -right-12 -translate-y-1/2"
248
+ ? "-right-12 top-1/2 -translate-y-1/2"
227
249
  : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
228
250
  className
229
251
  )}
@@ -231,11 +253,12 @@ function CarouselNext({
231
253
  onClick={scrollNext}
232
254
  {...props}
233
255
  >
234
- <ArrowRight />
256
+ <ArrowRight className="h-4 w-4" />
235
257
  <span className="sr-only">Next slide</span>
236
258
  </Button>
237
259
  )
238
- }
260
+ })
261
+ CarouselNext.displayName = "CarouselNext"
239
262
 
240
263
  export {
241
264
  type CarouselApi,