@multicomma/arkcn 0.1.2 → 0.1.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 (148) hide show
  1. package/package.json +1 -1
  2. package/registry/index.json +1 -1
  3. package/registry/items/accordion.json +302 -0
  4. package/registry/items/activity-feed.json +408 -0
  5. package/registry/items/alert-dialog.json +676 -0
  6. package/registry/items/alert.json +113 -0
  7. package/registry/items/angle-slider.json +378 -0
  8. package/registry/items/app-shell.json +2654 -1
  9. package/registry/items/aspect-ratio.json +36 -0
  10. package/registry/items/attachment.json +299 -1
  11. package/registry/items/avatar.json +213 -0
  12. package/registry/items/badge.json +44 -0
  13. package/registry/items/breadcrumb.json +191 -0
  14. package/registry/items/bubble.json +146 -0
  15. package/registry/items/button-group.json +110 -0
  16. package/registry/items/button.json +52 -0
  17. package/registry/items/calendar.json +499 -1
  18. package/registry/items/canvas.json +446 -1
  19. package/registry/items/card.json +192 -0
  20. package/registry/items/carousel.json +208 -1
  21. package/registry/items/cascader.json +797 -1
  22. package/registry/items/chart.json +1764 -1
  23. package/registry/items/chat.json +993 -0
  24. package/registry/items/checkbox.json +503 -0
  25. package/registry/items/clipboard.json +308 -0
  26. package/registry/items/collapsible.json +226 -0
  27. package/registry/items/color-picker.json +1261 -0
  28. package/registry/items/combobox.json +1123 -1
  29. package/registry/items/command.json +837 -1
  30. package/registry/items/comment-thread.json +952 -1
  31. package/registry/items/context-menu.json +1344 -1
  32. package/registry/items/data-grid.json +449 -1
  33. package/registry/items/data-table.json +1310 -1
  34. package/registry/items/date-input.json +476 -0
  35. package/registry/items/dialog.json +592 -0
  36. package/registry/items/direction.json +29 -1
  37. package/registry/items/drawer.json +797 -0
  38. package/registry/items/dropdown-menu.json +1311 -1
  39. package/registry/items/editable.json +503 -0
  40. package/registry/items/empty.json +166 -0
  41. package/registry/items/field.json +286 -1
  42. package/registry/items/file-upload.json +638 -0
  43. package/registry/items/floating-panel.json +720 -0
  44. package/registry/items/floating-toolbar.json +43 -0
  45. package/registry/items/format.json +109 -0
  46. package/registry/items/gantt.json +773 -1
  47. package/registry/items/hooks/use-mobile.json +1 -0
  48. package/registry/items/hotkeys.json +99 -1
  49. package/registry/items/hover-card.json +357 -0
  50. package/registry/items/image-cropper.json +431 -0
  51. package/registry/items/input-group.json +189 -0
  52. package/registry/items/input-otp.json +181 -0
  53. package/registry/items/input.json +28 -0
  54. package/registry/items/item.json +308 -0
  55. package/registry/items/json-tree-view.json +336 -0
  56. package/registry/items/kanban.json +624 -1
  57. package/registry/items/kbd.json +54 -0
  58. package/registry/items/label.json +28 -0
  59. package/registry/items/lib/controllable.json +1 -0
  60. package/registry/items/lib/data-table-adapter.json +1 -0
  61. package/registry/items/lib/drag-preview.json +1 -0
  62. package/registry/items/lib/form.json +1 -0
  63. package/registry/items/lib/history.json +1 -0
  64. package/registry/items/lib/row-layout.json +1 -0
  65. package/registry/items/lib/table.json +1 -0
  66. package/registry/items/lib/time.json +1 -0
  67. package/registry/items/lib/utils.json +1 -0
  68. package/registry/items/live-region.json +43 -0
  69. package/registry/items/marker.json +96 -0
  70. package/registry/items/marquee.json +300 -0
  71. package/registry/items/menubar.json +1282 -1
  72. package/registry/items/message.json +166 -0
  73. package/registry/items/navigation-menu.json +561 -1
  74. package/registry/items/node-graph.json +1037 -1
  75. package/registry/items/number-input.json +519 -0
  76. package/registry/items/pagination.json +244 -1
  77. package/registry/items/password-input.json +311 -0
  78. package/registry/items/popconfirm.json +566 -0
  79. package/registry/items/popover.json +615 -0
  80. package/registry/items/progress.json +516 -0
  81. package/registry/items/qr-code.json +249 -0
  82. package/registry/items/query-builder.json +1368 -1
  83. package/registry/items/radio-group.json +362 -0
  84. package/registry/items/rating-group.json +304 -0
  85. package/registry/items/resizable.json +242 -1
  86. package/registry/items/rich-text-editor.json +934 -1
  87. package/registry/items/scheduler.json +1013 -1
  88. package/registry/items/scroll-area.json +227 -0
  89. package/registry/items/segment-group.json +363 -0
  90. package/registry/items/select.json +956 -0
  91. package/registry/items/separator.json +45 -1
  92. package/registry/items/sheet.json +592 -0
  93. package/registry/items/sidebar.json +785 -1
  94. package/registry/items/signature-pad.json +330 -0
  95. package/registry/items/skeleton.json +28 -0
  96. package/registry/items/slider.json +799 -0
  97. package/registry/items/sonner.json +135 -0
  98. package/registry/items/spinner.json +28 -0
  99. package/registry/items/steps.json +483 -0
  100. package/registry/items/swap.json +107 -0
  101. package/registry/items/switch.json +362 -0
  102. package/registry/items/table.json +210 -0
  103. package/registry/items/tabs.json +326 -0
  104. package/registry/items/tags-input.json +640 -0
  105. package/registry/items/textarea.json +28 -0
  106. package/registry/items/timer.json +289 -0
  107. package/registry/items/toc.json +372 -0
  108. package/registry/items/toggle-group.json +214 -1
  109. package/registry/items/toggle.json +124 -0
  110. package/registry/items/tooltip.json +417 -0
  111. package/registry/items/tour.json +498 -0
  112. package/registry/items/transfer-list.json +609 -1
  113. package/registry/items/tree-select.json +742 -1
  114. package/registry/items/tree-view.json +794 -0
  115. package/registry/items/virtual-list.json +214 -1
  116. package/src/components/ui/app-shell.tsx +11 -0
  117. package/src/components/ui/attachment.tsx +1 -0
  118. package/src/components/ui/calendar.tsx +1 -0
  119. package/src/components/ui/canvas.tsx +8 -0
  120. package/src/components/ui/carousel.tsx +3 -0
  121. package/src/components/ui/cascader.tsx +1 -0
  122. package/src/components/ui/chart.tsx +10 -0
  123. package/src/components/ui/combobox.tsx +3 -0
  124. package/src/components/ui/command.tsx +1 -0
  125. package/src/components/ui/comment-thread.tsx +11 -0
  126. package/src/components/ui/context-menu.tsx +6 -0
  127. package/src/components/ui/data-grid.tsx +8 -0
  128. package/src/components/ui/data-table.tsx +6 -0
  129. package/src/components/ui/direction.tsx +2 -0
  130. package/src/components/ui/dropdown-menu.tsx +6 -0
  131. package/src/components/ui/field.tsx +1 -0
  132. package/src/components/ui/gantt.tsx +15 -0
  133. package/src/components/ui/hotkeys.tsx +3 -0
  134. package/src/components/ui/kanban.tsx +3 -0
  135. package/src/components/ui/menubar.tsx +6 -0
  136. package/src/components/ui/navigation-menu.tsx +1 -0
  137. package/src/components/ui/node-graph.tsx +23 -0
  138. package/src/components/ui/pagination.tsx +1 -0
  139. package/src/components/ui/query-builder.tsx +7 -0
  140. package/src/components/ui/resizable.tsx +1 -0
  141. package/src/components/ui/rich-text-editor.tsx +54 -0
  142. package/src/components/ui/scheduler.tsx +26 -0
  143. package/src/components/ui/separator.tsx +1 -0
  144. package/src/components/ui/sidebar.tsx +5 -0
  145. package/src/components/ui/toggle-group.tsx +3 -0
  146. package/src/components/ui/transfer-list.tsx +11 -0
  147. package/src/components/ui/tree-select.tsx +5 -0
  148. package/src/components/ui/virtual-list.tsx +7 -0
@@ -11,6 +11,198 @@
11
11
  "CardDescription",
12
12
  "CardContent"
13
13
  ],
14
+ "parts": [
15
+ {
16
+ "name": "Card",
17
+ "props": [
18
+ {
19
+ "name": "size",
20
+ "type": "\"default\" | \"sm\"",
21
+ "required": false,
22
+ "default": "\"default\"",
23
+ "description": "Size variant; sets a `data-size` attribute.",
24
+ "from": "arkcn"
25
+ },
26
+ {
27
+ "name": "children",
28
+ "type": "ReactNode",
29
+ "required": false,
30
+ "description": "Content rendered inside the part.",
31
+ "from": "@types/react"
32
+ },
33
+ {
34
+ "name": "className",
35
+ "type": "string",
36
+ "required": false,
37
+ "description": "Extra classes merged into the part's own classes with `cn`.",
38
+ "from": "@types/react"
39
+ },
40
+ {
41
+ "name": "style",
42
+ "type": "CSSProperties",
43
+ "required": false,
44
+ "description": "Inline styles applied to the rendered element.",
45
+ "from": "@types/react"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "name": "CardHeader",
51
+ "props": [
52
+ {
53
+ "name": "children",
54
+ "type": "ReactNode",
55
+ "required": false,
56
+ "description": "Content rendered inside the part.",
57
+ "from": "@types/react"
58
+ },
59
+ {
60
+ "name": "className",
61
+ "type": "string",
62
+ "required": false,
63
+ "description": "Extra classes merged into the part's own classes with `cn`.",
64
+ "from": "@types/react"
65
+ },
66
+ {
67
+ "name": "style",
68
+ "type": "CSSProperties",
69
+ "required": false,
70
+ "description": "Inline styles applied to the rendered element.",
71
+ "from": "@types/react"
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "name": "CardFooter",
77
+ "props": [
78
+ {
79
+ "name": "children",
80
+ "type": "ReactNode",
81
+ "required": false,
82
+ "description": "Content rendered inside the part.",
83
+ "from": "@types/react"
84
+ },
85
+ {
86
+ "name": "className",
87
+ "type": "string",
88
+ "required": false,
89
+ "description": "Extra classes merged into the part's own classes with `cn`.",
90
+ "from": "@types/react"
91
+ },
92
+ {
93
+ "name": "style",
94
+ "type": "CSSProperties",
95
+ "required": false,
96
+ "description": "Inline styles applied to the rendered element.",
97
+ "from": "@types/react"
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ "name": "CardTitle",
103
+ "props": [
104
+ {
105
+ "name": "children",
106
+ "type": "ReactNode",
107
+ "required": false,
108
+ "description": "Content rendered inside the part.",
109
+ "from": "@types/react"
110
+ },
111
+ {
112
+ "name": "className",
113
+ "type": "string",
114
+ "required": false,
115
+ "description": "Extra classes merged into the part's own classes with `cn`.",
116
+ "from": "@types/react"
117
+ },
118
+ {
119
+ "name": "style",
120
+ "type": "CSSProperties",
121
+ "required": false,
122
+ "description": "Inline styles applied to the rendered element.",
123
+ "from": "@types/react"
124
+ }
125
+ ]
126
+ },
127
+ {
128
+ "name": "CardAction",
129
+ "props": [
130
+ {
131
+ "name": "children",
132
+ "type": "ReactNode",
133
+ "required": false,
134
+ "description": "Content rendered inside the part.",
135
+ "from": "@types/react"
136
+ },
137
+ {
138
+ "name": "className",
139
+ "type": "string",
140
+ "required": false,
141
+ "description": "Extra classes merged into the part's own classes with `cn`.",
142
+ "from": "@types/react"
143
+ },
144
+ {
145
+ "name": "style",
146
+ "type": "CSSProperties",
147
+ "required": false,
148
+ "description": "Inline styles applied to the rendered element.",
149
+ "from": "@types/react"
150
+ }
151
+ ]
152
+ },
153
+ {
154
+ "name": "CardDescription",
155
+ "props": [
156
+ {
157
+ "name": "children",
158
+ "type": "ReactNode",
159
+ "required": false,
160
+ "description": "Content rendered inside the part.",
161
+ "from": "@types/react"
162
+ },
163
+ {
164
+ "name": "className",
165
+ "type": "string",
166
+ "required": false,
167
+ "description": "Extra classes merged into the part's own classes with `cn`.",
168
+ "from": "@types/react"
169
+ },
170
+ {
171
+ "name": "style",
172
+ "type": "CSSProperties",
173
+ "required": false,
174
+ "description": "Inline styles applied to the rendered element.",
175
+ "from": "@types/react"
176
+ }
177
+ ]
178
+ },
179
+ {
180
+ "name": "CardContent",
181
+ "props": [
182
+ {
183
+ "name": "children",
184
+ "type": "ReactNode",
185
+ "required": false,
186
+ "description": "Content rendered inside the part.",
187
+ "from": "@types/react"
188
+ },
189
+ {
190
+ "name": "className",
191
+ "type": "string",
192
+ "required": false,
193
+ "description": "Extra classes merged into the part's own classes with `cn`.",
194
+ "from": "@types/react"
195
+ },
196
+ {
197
+ "name": "style",
198
+ "type": "CSSProperties",
199
+ "required": false,
200
+ "description": "Inline styles applied to the rendered element.",
201
+ "from": "@types/react"
202
+ }
203
+ ]
204
+ }
205
+ ],
14
206
  "dependencies": {},
15
207
  "registryDependencies": [
16
208
  "lib/utils"
@@ -10,6 +10,213 @@
10
10
  "CarouselNext",
11
11
  "useCarousel"
12
12
  ],
13
+ "parts": [
14
+ {
15
+ "name": "Carousel",
16
+ "props": [
17
+ {
18
+ "name": "opts",
19
+ "type": "Partial<OptionsType>",
20
+ "required": false,
21
+ "description": "Embla carousel options.",
22
+ "from": "arkcn"
23
+ },
24
+ {
25
+ "name": "orientation",
26
+ "type": "\"horizontal\" | \"vertical\"",
27
+ "required": false,
28
+ "default": "\"horizontal\"",
29
+ "description": "Layout direction of the part.",
30
+ "from": "arkcn"
31
+ },
32
+ {
33
+ "name": "plugins",
34
+ "type": "CreatePluginType<LoosePluginType, {}>[]",
35
+ "required": false,
36
+ "description": "Embla plugins.",
37
+ "from": "arkcn"
38
+ },
39
+ {
40
+ "name": "setApi",
41
+ "type": "((api: EmblaCarouselType | undefined) => void)",
42
+ "required": false,
43
+ "description": "Receives the Embla API once the carousel mounts.",
44
+ "from": "arkcn"
45
+ },
46
+ {
47
+ "name": "children",
48
+ "type": "ReactNode",
49
+ "required": false,
50
+ "description": "Content rendered inside the part.",
51
+ "from": "@types/react"
52
+ },
53
+ {
54
+ "name": "className",
55
+ "type": "string",
56
+ "required": false,
57
+ "description": "Extra classes merged into the part's own classes with `cn`.",
58
+ "from": "@types/react"
59
+ },
60
+ {
61
+ "name": "style",
62
+ "type": "CSSProperties",
63
+ "required": false,
64
+ "description": "Inline styles applied to the rendered element.",
65
+ "from": "@types/react"
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "name": "CarouselContent",
71
+ "props": [
72
+ {
73
+ "name": "children",
74
+ "type": "ReactNode",
75
+ "required": false,
76
+ "description": "Content rendered inside the part.",
77
+ "from": "@types/react"
78
+ },
79
+ {
80
+ "name": "className",
81
+ "type": "string",
82
+ "required": false,
83
+ "description": "Extra classes merged into the part's own classes with `cn`.",
84
+ "from": "@types/react"
85
+ },
86
+ {
87
+ "name": "style",
88
+ "type": "CSSProperties",
89
+ "required": false,
90
+ "description": "Inline styles applied to the rendered element.",
91
+ "from": "@types/react"
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ "name": "CarouselItem",
97
+ "props": [
98
+ {
99
+ "name": "children",
100
+ "type": "ReactNode",
101
+ "required": false,
102
+ "description": "Content rendered inside the part.",
103
+ "from": "@types/react"
104
+ },
105
+ {
106
+ "name": "className",
107
+ "type": "string",
108
+ "required": false,
109
+ "description": "Extra classes merged into the part's own classes with `cn`.",
110
+ "from": "@types/react"
111
+ },
112
+ {
113
+ "name": "style",
114
+ "type": "CSSProperties",
115
+ "required": false,
116
+ "description": "Inline styles applied to the rendered element.",
117
+ "from": "@types/react"
118
+ }
119
+ ]
120
+ },
121
+ {
122
+ "name": "CarouselPrevious",
123
+ "props": [
124
+ {
125
+ "name": "asChild",
126
+ "type": "boolean",
127
+ "required": false,
128
+ "description": "Render the child element instead of the default one, merging props and behaviour onto it.",
129
+ "from": "arkcn"
130
+ },
131
+ {
132
+ "name": "size",
133
+ "type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
134
+ "required": false,
135
+ "default": "\"icon-sm\"",
136
+ "description": "Size variant; sets a `data-size` attribute.",
137
+ "from": "arkcn"
138
+ },
139
+ {
140
+ "name": "variant",
141
+ "type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
142
+ "required": false,
143
+ "default": "\"outline\"",
144
+ "description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
145
+ "from": "arkcn"
146
+ },
147
+ {
148
+ "name": "children",
149
+ "type": "ReactNode",
150
+ "required": false,
151
+ "description": "Content rendered inside the part.",
152
+ "from": "@types/react"
153
+ },
154
+ {
155
+ "name": "className",
156
+ "type": "string",
157
+ "required": false,
158
+ "description": "Extra classes merged into the part's own classes with `cn`.",
159
+ "from": "@types/react"
160
+ },
161
+ {
162
+ "name": "style",
163
+ "type": "CSSProperties",
164
+ "required": false,
165
+ "description": "Inline styles applied to the rendered element.",
166
+ "from": "@types/react"
167
+ }
168
+ ]
169
+ },
170
+ {
171
+ "name": "CarouselNext",
172
+ "props": [
173
+ {
174
+ "name": "asChild",
175
+ "type": "boolean",
176
+ "required": false,
177
+ "description": "Render the child element instead of the default one, merging props and behaviour onto it.",
178
+ "from": "arkcn"
179
+ },
180
+ {
181
+ "name": "size",
182
+ "type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
183
+ "required": false,
184
+ "default": "\"icon-sm\"",
185
+ "description": "Size variant; sets a `data-size` attribute.",
186
+ "from": "arkcn"
187
+ },
188
+ {
189
+ "name": "variant",
190
+ "type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
191
+ "required": false,
192
+ "default": "\"outline\"",
193
+ "description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
194
+ "from": "arkcn"
195
+ },
196
+ {
197
+ "name": "children",
198
+ "type": "ReactNode",
199
+ "required": false,
200
+ "description": "Content rendered inside the part.",
201
+ "from": "@types/react"
202
+ },
203
+ {
204
+ "name": "className",
205
+ "type": "string",
206
+ "required": false,
207
+ "description": "Extra classes merged into the part's own classes with `cn`.",
208
+ "from": "@types/react"
209
+ },
210
+ {
211
+ "name": "style",
212
+ "type": "CSSProperties",
213
+ "required": false,
214
+ "description": "Inline styles applied to the rendered element.",
215
+ "from": "@types/react"
216
+ }
217
+ ]
218
+ }
219
+ ],
13
220
  "dependencies": {
14
221
  "embla-carousel-react": "^8.6.0",
15
222
  "lucide-react": "^1.41.0"
@@ -21,7 +228,7 @@
21
228
  "files": [
22
229
  {
23
230
  "path": "components/ui/carousel.tsx",
24
- "content": "import * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport useEmblaCarousel, { type UseEmblaCarouselType } from \"embla-carousel-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\n\ntype CarouselApi = UseEmblaCarouselType[1]\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>\ntype CarouselOptions = UseCarouselParameters[0]\ntype CarouselPlugin = UseCarouselParameters[1]\n\ntype CarouselProps = {\n opts?: CarouselOptions\n plugins?: CarouselPlugin\n orientation?: \"horizontal\" | \"vertical\"\n setApi?: (api: CarouselApi) => void\n}\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0]\n api: ReturnType<typeof useEmblaCarousel>[1]\n scrollPrev: () => void\n scrollNext: () => void\n canScrollPrev: boolean\n canScrollNext: boolean\n} & CarouselProps\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null)\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext)\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\")\n }\n\n return context\n}\n\nfunction Carousel({\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & CarouselProps) {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins\n )\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const onSelect = React.useCallback((api: CarouselApi) => {\n if (!api) return\n setCanScrollPrev(api.canScrollPrev())\n setCanScrollNext(api.canScrollNext())\n }, [])\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev()\n }, [api])\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext()\n }, [api])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault()\n scrollPrev()\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault()\n scrollNext()\n }\n },\n [scrollPrev, scrollNext]\n )\n\n React.useEffect(() => {\n if (!api || !setApi) return\n setApi(api)\n }, [api, setApi])\n\n React.useEffect(() => {\n if (!api) return\n onSelect(api)\n api.on(\"reInit\", onSelect)\n api.on(\"select\", onSelect)\n\n return () => {\n api?.off(\"select\", onSelect)\n }\n }, [api, onSelect])\n\n return (\n <CarouselContext.Provider\n value={{\n carouselRef,\n api: api,\n opts,\n orientation: orientation || (opts?.axis === \"y\" ? \"vertical\" : \"horizontal\"),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n }}\n >\n <div\n onKeyDownCapture={handleKeyDown}\n className={cn(\"relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n data-slot=\"carousel\"\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nfunction CarouselContent({ className, ...props }: React.ComponentProps<\"div\">) {\n const { carouselRef, orientation } = useCarousel()\n\n return (\n <div ref={carouselRef} className=\"overflow-hidden\" data-slot=\"carousel-content\">\n <div className={cn(\"flex\", orientation === \"horizontal\" ? \"-ml-4\" : \"-mt-4 flex-col\", className)} {...props} />\n </div>\n )\n}\n\nfunction CarouselItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const { orientation } = useCarousel()\n\n return (\n <div\n role=\"group\"\n aria-roledescription=\"slide\"\n data-slot=\"carousel-item\"\n className={cn(\"min-w-0 shrink-0 grow-0 basis-full\", orientation === \"horizontal\" ? \"pl-4\" : \"pt-4\", className)}\n {...props}\n />\n )\n}\n\nfunction CarouselPrevious({\n className,\n variant = \"outline\",\n size = \"icon-sm\",\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel()\n\n return (\n <Button\n data-slot=\"carousel-previous\"\n variant={variant}\n size={size}\n className={cn(\n \"absolute touch-manipulation rounded-full\",\n orientation === \"horizontal\" ? \"inset-y-0 -left-12 my-auto\" : \"-top-12 left-1/2 -translate-x-1/2 rotate-90\",\n className\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n asChild={asChild}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <ChevronLeftIcon />\n <span className=\"sr-only\">Previous slide</span>\n </>\n ))}\n </Button>\n )\n}\n\nfunction CarouselNext({\n className,\n variant = \"outline\",\n size = \"icon-sm\",\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollNext, canScrollNext } = useCarousel()\n\n return (\n <Button\n data-slot=\"carousel-next\"\n variant={variant}\n size={size}\n className={cn(\n \"absolute touch-manipulation rounded-full\",\n orientation === \"horizontal\" ? \"inset-y-0 -right-12 my-auto\" : \"-bottom-12 left-1/2 -translate-x-1/2 rotate-90\",\n className\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n asChild={asChild}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <ChevronRightIcon />\n <span className=\"sr-only\">Next slide</span>\n </>\n ))}\n </Button>\n )\n}\n\nexport { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, useCarousel }\n"
231
+ "content": "import * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport useEmblaCarousel, { type UseEmblaCarouselType } from \"embla-carousel-react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\"\n\ntype CarouselApi = UseEmblaCarouselType[1]\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>\ntype CarouselOptions = UseCarouselParameters[0]\ntype CarouselPlugin = UseCarouselParameters[1]\n\ntype CarouselProps = {\n /** Embla carousel options. */\n opts?: CarouselOptions\n /** Embla plugins. */\n plugins?: CarouselPlugin\n orientation?: \"horizontal\" | \"vertical\"\n /** Receives the Embla API once the carousel mounts. */\n setApi?: (api: CarouselApi) => void\n}\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0]\n api: ReturnType<typeof useEmblaCarousel>[1]\n scrollPrev: () => void\n scrollNext: () => void\n canScrollPrev: boolean\n canScrollNext: boolean\n} & CarouselProps\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null)\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext)\n\n if (!context) {\n throw new Error(\"useCarousel must be used within a <Carousel />\")\n }\n\n return context\n}\n\nfunction Carousel({\n orientation = \"horizontal\",\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & CarouselProps) {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n },\n plugins\n )\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const onSelect = React.useCallback((api: CarouselApi) => {\n if (!api) return\n setCanScrollPrev(api.canScrollPrev())\n setCanScrollNext(api.canScrollNext())\n }, [])\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev()\n }, [api])\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext()\n }, [api])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"ArrowLeft\") {\n event.preventDefault()\n scrollPrev()\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault()\n scrollNext()\n }\n },\n [scrollPrev, scrollNext]\n )\n\n React.useEffect(() => {\n if (!api || !setApi) return\n setApi(api)\n }, [api, setApi])\n\n React.useEffect(() => {\n if (!api) return\n onSelect(api)\n api.on(\"reInit\", onSelect)\n api.on(\"select\", onSelect)\n\n return () => {\n api?.off(\"select\", onSelect)\n }\n }, [api, onSelect])\n\n return (\n <CarouselContext.Provider\n value={{\n carouselRef,\n api: api,\n opts,\n orientation: orientation || (opts?.axis === \"y\" ? \"vertical\" : \"horizontal\"),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n }}\n >\n <div\n onKeyDownCapture={handleKeyDown}\n className={cn(\"relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n data-slot=\"carousel\"\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nfunction CarouselContent({ className, ...props }: React.ComponentProps<\"div\">) {\n const { carouselRef, orientation } = useCarousel()\n\n return (\n <div ref={carouselRef} className=\"overflow-hidden\" data-slot=\"carousel-content\">\n <div className={cn(\"flex\", orientation === \"horizontal\" ? \"-ml-4\" : \"-mt-4 flex-col\", className)} {...props} />\n </div>\n )\n}\n\nfunction CarouselItem({ className, ...props }: React.ComponentProps<\"div\">) {\n const { orientation } = useCarousel()\n\n return (\n <div\n role=\"group\"\n aria-roledescription=\"slide\"\n data-slot=\"carousel-item\"\n className={cn(\"min-w-0 shrink-0 grow-0 basis-full\", orientation === \"horizontal\" ? \"pl-4\" : \"pt-4\", className)}\n {...props}\n />\n )\n}\n\nfunction CarouselPrevious({\n className,\n variant = \"outline\",\n size = \"icon-sm\",\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel()\n\n return (\n <Button\n data-slot=\"carousel-previous\"\n variant={variant}\n size={size}\n className={cn(\n \"absolute touch-manipulation rounded-full\",\n orientation === \"horizontal\" ? \"inset-y-0 -left-12 my-auto\" : \"-top-12 left-1/2 -translate-x-1/2 rotate-90\",\n className\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n asChild={asChild}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <ChevronLeftIcon />\n <span className=\"sr-only\">Previous slide</span>\n </>\n ))}\n </Button>\n )\n}\n\nfunction CarouselNext({\n className,\n variant = \"outline\",\n size = \"icon-sm\",\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollNext, canScrollNext } = useCarousel()\n\n return (\n <Button\n data-slot=\"carousel-next\"\n variant={variant}\n size={size}\n className={cn(\n \"absolute touch-manipulation rounded-full\",\n orientation === \"horizontal\" ? \"inset-y-0 -right-12 my-auto\" : \"-bottom-12 left-1/2 -translate-x-1/2 rotate-90\",\n className\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n asChild={asChild}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n <ChevronRightIcon />\n <span className=\"sr-only\">Next slide</span>\n </>\n ))}\n </Button>\n )\n}\n\nexport { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, useCarousel }\n"
25
232
  }
26
233
  ]
27
234
  }