@mostra/kit 0.0.0-stage → 0.19.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 (298) hide show
  1. package/README.md +43 -2
  2. package/css/kit.css +59 -0
  3. package/css/shadcn.css +638 -0
  4. package/dist/index.d.ts +16 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/layout.d.ts +60 -0
  9. package/dist/layout.d.ts.map +1 -0
  10. package/dist/layout.js +112 -0
  11. package/dist/layout.js.map +1 -0
  12. package/dist/questionnaire.d.ts +100 -0
  13. package/dist/questionnaire.d.ts.map +1 -0
  14. package/dist/questionnaire.js +632 -0
  15. package/dist/questionnaire.js.map +1 -0
  16. package/package.json +120 -3
  17. package/registry/LICENSE.md +21 -0
  18. package/registry/base/accordion.json +19 -0
  19. package/registry/base/alert-dialog.json +21 -0
  20. package/registry/base/alert.json +18 -0
  21. package/registry/base/aspect-ratio.json +17 -0
  22. package/registry/base/attachment.json +22 -0
  23. package/registry/base/avatar.json +18 -0
  24. package/registry/base/badge.json +19 -0
  25. package/registry/base/breadcrumb.json +19 -0
  26. package/registry/base/bubble.json +19 -0
  27. package/registry/base/button-group.json +22 -0
  28. package/registry/base/button.json +19 -0
  29. package/registry/base/calendar.json +22 -0
  30. package/registry/base/card.json +17 -0
  31. package/registry/base/carousel.json +22 -0
  32. package/registry/base/chart.json +21 -0
  33. package/registry/base/checkbox.json +19 -0
  34. package/registry/base/code-block.json +23 -0
  35. package/registry/base/collapsible.json +17 -0
  36. package/registry/base/combobox.json +23 -0
  37. package/registry/base/command.json +23 -0
  38. package/registry/base/components/mostra/layout.tsx +221 -0
  39. package/registry/base/components/mostra/questionnaire.tsx +1005 -0
  40. package/registry/base/components/ui/accordion.tsx +71 -0
  41. package/registry/base/components/ui/alert-dialog.tsx +187 -0
  42. package/registry/base/components/ui/alert.tsx +75 -0
  43. package/registry/base/components/ui/aspect-ratio.tsx +22 -0
  44. package/registry/base/components/ui/attachment.tsx +207 -0
  45. package/registry/base/components/ui/avatar.tsx +108 -0
  46. package/registry/base/components/ui/badge.tsx +54 -0
  47. package/registry/base/components/ui/breadcrumb.tsx +124 -0
  48. package/registry/base/components/ui/bubble.tsx +127 -0
  49. package/registry/base/components/ui/button-group.tsx +87 -0
  50. package/registry/base/components/ui/button.tsx +57 -0
  51. package/registry/base/components/ui/calendar.tsx +221 -0
  52. package/registry/base/components/ui/card.tsx +102 -0
  53. package/registry/base/components/ui/carousel.tsx +242 -0
  54. package/registry/base/components/ui/chart.tsx +372 -0
  55. package/registry/base/components/ui/checkbox.tsx +28 -0
  56. package/registry/base/components/ui/code-block.tsx +249 -0
  57. package/registry/base/components/ui/collapsible.tsx +21 -0
  58. package/registry/base/components/ui/combobox.tsx +297 -0
  59. package/registry/base/components/ui/command.tsx +196 -0
  60. package/registry/base/components/ui/context-menu.tsx +270 -0
  61. package/registry/base/components/ui/dialog.tsx +160 -0
  62. package/registry/base/components/ui/direction.tsx +6 -0
  63. package/registry/base/components/ui/drawer.tsx +227 -0
  64. package/registry/base/components/ui/dropdown-menu.tsx +267 -0
  65. package/registry/base/components/ui/empty.tsx +103 -0
  66. package/registry/base/components/ui/field.tsx +238 -0
  67. package/registry/base/components/ui/hover-card.tsx +50 -0
  68. package/registry/base/components/ui/input-group.tsx +158 -0
  69. package/registry/base/components/ui/input-otp.tsx +86 -0
  70. package/registry/base/components/ui/input.tsx +19 -0
  71. package/registry/base/components/ui/item.tsx +201 -0
  72. package/registry/base/components/ui/kbd.tsx +26 -0
  73. package/registry/base/components/ui/label.tsx +19 -0
  74. package/registry/base/components/ui/marker.tsx +70 -0
  75. package/registry/base/components/ui/menubar.tsx +280 -0
  76. package/registry/base/components/ui/message-scroller.tsx +131 -0
  77. package/registry/base/components/ui/message.tsx +91 -0
  78. package/registry/base/components/ui/native-select.tsx +60 -0
  79. package/registry/base/components/ui/navigation-menu.tsx +167 -0
  80. package/registry/base/components/ui/pagination.tsx +130 -0
  81. package/registry/base/components/ui/popover.tsx +89 -0
  82. package/registry/base/components/ui/progress.tsx +82 -0
  83. package/registry/base/components/ui/questionnaire.tsx +324 -0
  84. package/registry/base/components/ui/radio-group.tsx +37 -0
  85. package/registry/base/components/ui/resizable.tsx +49 -0
  86. package/registry/base/components/ui/scroll-area.tsx +53 -0
  87. package/registry/base/components/ui/select.tsx +200 -0
  88. package/registry/base/components/ui/separator.tsx +24 -0
  89. package/registry/base/components/ui/sheet.tsx +138 -0
  90. package/registry/base/components/ui/sidebar.tsx +723 -0
  91. package/registry/base/components/ui/skeleton.tsx +13 -0
  92. package/registry/base/components/ui/slider.tsx +51 -0
  93. package/registry/base/components/ui/sonner.tsx +65 -0
  94. package/registry/base/components/ui/spinner.tsx +10 -0
  95. package/registry/base/components/ui/switch.tsx +31 -0
  96. package/registry/base/components/ui/table.tsx +116 -0
  97. package/registry/base/components/ui/tabs.tsx +85 -0
  98. package/registry/base/components/ui/textarea.tsx +17 -0
  99. package/registry/base/components/ui/toast.tsx +234 -0
  100. package/registry/base/components/ui/toggle-group.tsx +89 -0
  101. package/registry/base/components/ui/toggle.tsx +44 -0
  102. package/registry/base/components/ui/tooltip.tsx +65 -0
  103. package/registry/base/components/ui/trace.tsx +162 -0
  104. package/registry/base/context-menu.json +19 -0
  105. package/registry/base/dialog.json +22 -0
  106. package/registry/base/direction.json +17 -0
  107. package/registry/base/drawer.json +18 -0
  108. package/registry/base/dropdown-menu.json +19 -0
  109. package/registry/base/empty.json +18 -0
  110. package/registry/base/field.json +22 -0
  111. package/registry/base/hooks/use-highlighted-code.ts +75 -0
  112. package/registry/base/hooks/use-mobile.ts +19 -0
  113. package/registry/base/hover-card.json +18 -0
  114. package/registry/base/input-group.json +23 -0
  115. package/registry/base/input-otp.json +19 -0
  116. package/registry/base/input.json +18 -0
  117. package/registry/base/item.json +22 -0
  118. package/registry/base/kbd.json +17 -0
  119. package/registry/base/label.json +17 -0
  120. package/registry/base/lib/highlighter.tsx +124 -0
  121. package/registry/base/lib/utils.ts +1 -0
  122. package/registry/base/marker.json +19 -0
  123. package/registry/base/menubar.json +22 -0
  124. package/registry/base/message-scroller.json +22 -0
  125. package/registry/base/message.json +17 -0
  126. package/registry/base/mostra-layout.json +20 -0
  127. package/registry/base/mostra-questionnaire.json +22 -0
  128. package/registry/base/native-select.json +18 -0
  129. package/registry/base/navigation-menu.json +20 -0
  130. package/registry/base/pagination.json +21 -0
  131. package/registry/base/popover.json +18 -0
  132. package/registry/base/progress.json +18 -0
  133. package/registry/base/questionnaire.json +22 -0
  134. package/registry/base/radio-group.json +18 -0
  135. package/registry/base/registry.json +287 -0
  136. package/registry/base/resizable.json +18 -0
  137. package/registry/base/scroll-area.json +18 -0
  138. package/registry/base/select.json +19 -0
  139. package/registry/base/separator.json +18 -0
  140. package/registry/base/sheet.json +22 -0
  141. package/registry/base/sidebar.json +29 -0
  142. package/registry/base/skeleton.json +17 -0
  143. package/registry/base/slider.json +18 -0
  144. package/registry/base/sonner.json +18 -0
  145. package/registry/base/spinner.json +18 -0
  146. package/registry/base/switch.json +18 -0
  147. package/registry/base/table.json +17 -0
  148. package/registry/base/tabs.json +19 -0
  149. package/registry/base/textarea.json +17 -0
  150. package/registry/base/toast.json +22 -0
  151. package/registry/base/toggle-group.json +22 -0
  152. package/registry/base/toggle.json +19 -0
  153. package/registry/base/tooltip.json +18 -0
  154. package/registry/base/trace.json +21 -0
  155. package/registry/base/use-highlighted-code.json +21 -0
  156. package/registry/base/use-mobile.json +14 -0
  157. package/registry/base/utils.json +17 -0
  158. package/registry/radix/accordion.json +19 -0
  159. package/registry/radix/alert-dialog.json +21 -0
  160. package/registry/radix/alert.json +18 -0
  161. package/registry/radix/aspect-ratio.json +17 -0
  162. package/registry/radix/attachment.json +22 -0
  163. package/registry/radix/avatar.json +18 -0
  164. package/registry/radix/badge.json +19 -0
  165. package/registry/radix/breadcrumb.json +19 -0
  166. package/registry/radix/bubble.json +19 -0
  167. package/registry/radix/button-group.json +22 -0
  168. package/registry/radix/button.json +19 -0
  169. package/registry/radix/calendar.json +22 -0
  170. package/registry/radix/card.json +17 -0
  171. package/registry/radix/carousel.json +22 -0
  172. package/registry/radix/chart.json +18 -0
  173. package/registry/radix/checkbox.json +19 -0
  174. package/registry/radix/code-block.json +23 -0
  175. package/registry/radix/collapsible.json +17 -0
  176. package/registry/radix/combobox.json +23 -0
  177. package/registry/radix/command.json +23 -0
  178. package/registry/radix/components/mostra/layout.tsx +221 -0
  179. package/registry/radix/components/mostra/questionnaire.tsx +1005 -0
  180. package/registry/radix/components/ui/accordion.tsx +80 -0
  181. package/registry/radix/components/ui/alert-dialog.tsx +199 -0
  182. package/registry/radix/components/ui/alert.tsx +75 -0
  183. package/registry/radix/components/ui/aspect-ratio.tsx +11 -0
  184. package/registry/radix/components/ui/attachment.tsx +204 -0
  185. package/registry/radix/components/ui/avatar.tsx +111 -0
  186. package/registry/radix/components/ui/badge.tsx +51 -0
  187. package/registry/radix/components/ui/breadcrumb.tsx +121 -0
  188. package/registry/radix/components/ui/bubble.tsx +124 -0
  189. package/registry/radix/components/ui/button-group.tsx +83 -0
  190. package/registry/radix/components/ui/button.tsx +66 -0
  191. package/registry/radix/components/ui/calendar.tsx +222 -0
  192. package/registry/radix/components/ui/card.tsx +102 -0
  193. package/registry/radix/components/ui/carousel.tsx +242 -0
  194. package/registry/radix/components/ui/chart.tsx +372 -0
  195. package/registry/radix/components/ui/checkbox.tsx +32 -0
  196. package/registry/radix/components/ui/code-block.tsx +249 -0
  197. package/registry/radix/components/ui/collapsible.tsx +33 -0
  198. package/registry/radix/components/ui/combobox.tsx +299 -0
  199. package/registry/radix/components/ui/command.tsx +195 -0
  200. package/registry/radix/components/ui/context-menu.tsx +262 -0
  201. package/registry/radix/components/ui/dialog.tsx +168 -0
  202. package/registry/radix/components/ui/direction.tsx +22 -0
  203. package/registry/radix/components/ui/drawer.tsx +133 -0
  204. package/registry/radix/components/ui/dropdown-menu.tsx +268 -0
  205. package/registry/radix/components/ui/empty.tsx +103 -0
  206. package/registry/radix/components/ui/field.tsx +238 -0
  207. package/registry/radix/components/ui/hover-card.tsx +43 -0
  208. package/registry/radix/components/ui/input-group.tsx +156 -0
  209. package/registry/radix/components/ui/input-otp.tsx +86 -0
  210. package/registry/radix/components/ui/input.tsx +18 -0
  211. package/registry/radix/components/ui/item.tsx +196 -0
  212. package/registry/radix/components/ui/kbd.tsx +26 -0
  213. package/registry/radix/components/ui/label.tsx +23 -0
  214. package/registry/radix/components/ui/marker.tsx +68 -0
  215. package/registry/radix/components/ui/menubar.tsx +279 -0
  216. package/registry/radix/components/ui/message-scroller.tsx +131 -0
  217. package/registry/radix/components/ui/message.tsx +91 -0
  218. package/registry/radix/components/ui/native-select.tsx +60 -0
  219. package/registry/radix/components/ui/navigation-menu.tsx +163 -0
  220. package/registry/radix/components/ui/pagination.tsx +129 -0
  221. package/registry/radix/components/ui/popover.tsx +88 -0
  222. package/registry/radix/components/ui/progress.tsx +30 -0
  223. package/registry/radix/components/ui/questionnaire.tsx +324 -0
  224. package/registry/radix/components/ui/radio-group.tsx +43 -0
  225. package/registry/radix/components/ui/resizable.tsx +49 -0
  226. package/registry/radix/components/ui/scroll-area.tsx +54 -0
  227. package/registry/radix/components/ui/select.tsx +191 -0
  228. package/registry/radix/components/ui/separator.tsx +27 -0
  229. package/registry/radix/components/ui/sheet.tsx +147 -0
  230. package/registry/radix/components/ui/sidebar.tsx +702 -0
  231. package/registry/radix/components/ui/skeleton.tsx +13 -0
  232. package/registry/radix/components/ui/slider.tsx +62 -0
  233. package/registry/radix/components/ui/sonner.tsx +65 -0
  234. package/registry/radix/components/ui/spinner.tsx +10 -0
  235. package/registry/radix/components/ui/switch.tsx +32 -0
  236. package/registry/radix/components/ui/table.tsx +116 -0
  237. package/registry/radix/components/ui/tabs.tsx +129 -0
  238. package/registry/radix/components/ui/textarea.tsx +17 -0
  239. package/registry/radix/components/ui/toggle-group.tsx +89 -0
  240. package/registry/radix/components/ui/toggle.tsx +46 -0
  241. package/registry/radix/components/ui/tooltip.tsx +56 -0
  242. package/registry/radix/components/ui/trace.tsx +162 -0
  243. package/registry/radix/context-menu.json +19 -0
  244. package/registry/radix/dialog.json +22 -0
  245. package/registry/radix/direction.json +17 -0
  246. package/registry/radix/drawer.json +18 -0
  247. package/registry/radix/dropdown-menu.json +19 -0
  248. package/registry/radix/empty.json +18 -0
  249. package/registry/radix/field.json +22 -0
  250. package/registry/radix/hooks/use-highlighted-code.ts +75 -0
  251. package/registry/radix/hooks/use-mobile.ts +19 -0
  252. package/registry/radix/hover-card.json +18 -0
  253. package/registry/radix/input-group.json +23 -0
  254. package/registry/radix/input-otp.json +19 -0
  255. package/registry/radix/input.json +17 -0
  256. package/registry/radix/item.json +22 -0
  257. package/registry/radix/kbd.json +17 -0
  258. package/registry/radix/label.json +18 -0
  259. package/registry/radix/lib/highlighter.tsx +124 -0
  260. package/registry/radix/lib/utils.ts +1 -0
  261. package/registry/radix/marker.json +19 -0
  262. package/registry/radix/menubar.json +19 -0
  263. package/registry/radix/message-scroller.json +22 -0
  264. package/registry/radix/message.json +17 -0
  265. package/registry/radix/mostra-layout.json +20 -0
  266. package/registry/radix/mostra-questionnaire.json +22 -0
  267. package/registry/radix/native-select.json +18 -0
  268. package/registry/radix/navigation-menu.json +20 -0
  269. package/registry/radix/pagination.json +21 -0
  270. package/registry/radix/popover.json +18 -0
  271. package/registry/radix/progress.json +18 -0
  272. package/registry/radix/questionnaire.json +22 -0
  273. package/registry/radix/radio-group.json +18 -0
  274. package/registry/radix/registry.json +283 -0
  275. package/registry/radix/resizable.json +18 -0
  276. package/registry/radix/scroll-area.json +18 -0
  277. package/registry/radix/select.json +19 -0
  278. package/registry/radix/separator.json +18 -0
  279. package/registry/radix/sheet.json +22 -0
  280. package/registry/radix/sidebar.json +29 -0
  281. package/registry/radix/skeleton.json +17 -0
  282. package/registry/radix/slider.json +18 -0
  283. package/registry/radix/sonner.json +18 -0
  284. package/registry/radix/spinner.json +18 -0
  285. package/registry/radix/switch.json +18 -0
  286. package/registry/radix/table.json +17 -0
  287. package/registry/radix/tabs.json +19 -0
  288. package/registry/radix/textarea.json +17 -0
  289. package/registry/radix/toggle-group.json +22 -0
  290. package/registry/radix/toggle.json +19 -0
  291. package/registry/radix/tooltip.json +18 -0
  292. package/registry/radix/trace.json +21 -0
  293. package/registry/radix/use-highlighted-code.json +21 -0
  294. package/registry/radix/use-mobile.json +14 -0
  295. package/registry/radix/utils.json +17 -0
  296. package/src/index.ts +15 -0
  297. package/src/layout.tsx +221 -0
  298. package/src/questionnaire.tsx +1005 -0
@@ -0,0 +1,32 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cn } from "cn"
5
+ import { Checkbox as CheckboxPrimitive } from "radix-ui"
6
+ import { CheckIcon } from "lucide-react"
7
+
8
+ function Checkbox({
9
+ className,
10
+ ...props
11
+ }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
12
+ return (
13
+ <CheckboxPrimitive.Root
14
+ data-slot="checkbox"
15
+ className={cn(
16
+ "peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",
17
+ className
18
+ )}
19
+ {...props}
20
+ >
21
+ <CheckboxPrimitive.Indicator
22
+ data-slot="checkbox-indicator"
23
+ className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
24
+ >
25
+ <CheckIcon
26
+ />
27
+ </CheckboxPrimitive.Indicator>
28
+ </CheckboxPrimitive.Root>
29
+ )
30
+ }
31
+
32
+ export { Checkbox }
@@ -0,0 +1,249 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+ import { cn } from "cn"
6
+
7
+ import { Button } from "@/components/ui/button"
8
+ import { CheckIcon, CopyIcon } from "lucide-react"
9
+
10
+ const codeBlockVariants = cva(
11
+ "group/code-block relative flex w-full min-w-0 flex-col overflow-hidden rounded-lg text-sm has-[>[data-slot=code-block-content]:focus-visible]:ring-3 has-[>[data-slot=code-block-content]:focus-visible]:ring-ring/50 data-[size=sm]:text-xs",
12
+ {
13
+ variants: {
14
+ variant: {
15
+ default:
16
+ "border border-input text-foreground has-[>[data-slot=code-block-content]:focus-visible]:border-ring dark:bg-input/30",
17
+ destructive:
18
+ "border border-destructive/30 text-destructive dark:border-destructive/40",
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ variant: "default",
23
+ },
24
+ }
25
+ )
26
+
27
+ function CodeBlock({
28
+ className,
29
+ variant = "default",
30
+ size = "default",
31
+ ...props
32
+ }: React.ComponentProps<"div"> &
33
+ VariantProps<typeof codeBlockVariants> & { size?: "default" | "sm" }) {
34
+ return (
35
+ <div
36
+ data-slot="code-block"
37
+ data-variant={variant}
38
+ data-size={size}
39
+ className={cn(codeBlockVariants({ variant }), className)}
40
+ {...props}
41
+ />
42
+ )
43
+ }
44
+
45
+ function CodeBlockHeader({ className, ...props }: React.ComponentProps<"div">) {
46
+ return (
47
+ <div
48
+ data-slot="code-block-header"
49
+ className={cn(
50
+ "flex min-w-0 shrink-0 items-center gap-2 px-3 pt-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pt-2.5 group-data-[variant=destructive]/code-block:text-destructive *:has-[>[data-slot=code-block-title]]:min-w-0",
51
+ className
52
+ )}
53
+ {...props}
54
+ />
55
+ )
56
+ }
57
+
58
+ function CodeBlockTitle({ className, ...props }: React.ComponentProps<"div">) {
59
+ return (
60
+ <div
61
+ data-slot="code-block-title"
62
+ className={cn(
63
+ "min-w-0 truncate font-sans text-sm font-medium text-foreground group-data-[size=sm]/code-block:text-xs group-data-[variant=destructive]/code-block:text-destructive [&_svg]:pointer-events-none [&_svg]:inline-block [&_svg]:align-middle [&_svg:not([class*='size-'])]:size-3.5 *:[svg]:me-1.5",
64
+ className
65
+ )}
66
+ {...props}
67
+ />
68
+ )
69
+ }
70
+
71
+ function CodeBlockActions({
72
+ className,
73
+ ...props
74
+ }: React.ComponentProps<"div">) {
75
+ return (
76
+ <div
77
+ data-slot="code-block-actions"
78
+ className={cn(
79
+ "-my-1 ms-auto -me-1.5 flex shrink-0 items-center gap-1 [[data-slot=code-block]>&]:absolute [[data-slot=code-block]>&]:end-2 [[data-slot=code-block]>&]:top-2 [[data-slot=code-block]>&]:z-10 [[data-slot=code-block]>&]:m-0 [[data-slot=code-block]>&]:opacity-0 [[data-slot=code-block]>&]:transition-opacity [[data-slot=code-block]>&]:group-focus-within/code-block:opacity-100 [[data-slot=code-block]>&]:group-hover/code-block:opacity-100 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:end-1.5 group-data-[size=sm]/code-block:[[data-slot=code-block]>&]:top-1.5 [[data-slot=code-block]>&]:pointer-coarse:opacity-100 [[data-slot=code-block]>&]:*:[button]:bg-background [[data-slot=code-block]>&]:*:[button]:ring-1 [[data-slot=code-block]>&]:*:[button]:ring-foreground/10",
80
+ className
81
+ )}
82
+ {...props}
83
+ />
84
+ )
85
+ }
86
+
87
+ function CodeBlockCopyButton({
88
+ value,
89
+ variant = "ghost",
90
+ size = "icon-xs",
91
+ className,
92
+ onClick,
93
+ ...props
94
+ }: React.ComponentProps<typeof Button> & { value: string }) {
95
+ const [copied, setCopied] = React.useState(false)
96
+
97
+ React.useEffect(() => {
98
+ if (!copied) {
99
+ return
100
+ }
101
+
102
+ const timeout = setTimeout(() => setCopied(false), 2000)
103
+ return () => clearTimeout(timeout)
104
+ }, [copied])
105
+
106
+ return (
107
+ <>
108
+ <Button
109
+ data-slot="code-block-copy-button"
110
+ data-copied={copied || undefined}
111
+ variant={variant}
112
+ size={size}
113
+ aria-label={copied ? "Copied" : "Copy"}
114
+ className={cn(className)}
115
+ onClick={(event) => {
116
+ onClick?.(event)
117
+ navigator.clipboard
118
+ .writeText(value)
119
+ .then(() => setCopied(true))
120
+ .catch(() => {})
121
+ }}
122
+ {...props}
123
+ >
124
+ {copied ? (
125
+ <CheckIcon
126
+ />
127
+ ) : (
128
+ <CopyIcon
129
+ />
130
+ )}
131
+ </Button>
132
+ <span aria-live="polite" className="sr-only">
133
+ {copied ? "Copied" : ""}
134
+ </span>
135
+ </>
136
+ )
137
+ }
138
+
139
+ function CodeBlockContent({
140
+ className,
141
+ children,
142
+ style,
143
+ wrap = false,
144
+ lineNumbers = false,
145
+ startLine = 1,
146
+ ...props
147
+ }: React.ComponentProps<"pre"> & {
148
+ wrap?: boolean
149
+ lineNumbers?: boolean
150
+ startLine?: number
151
+ }) {
152
+ return (
153
+ <pre
154
+ data-slot="code-block-content"
155
+ data-wrap={wrap || undefined}
156
+ data-numbered={lineNumbers || undefined}
157
+ dir="ltr"
158
+ tabIndex={0}
159
+ style={{ counterReset: `line ${startLine - 1}`, ...style }}
160
+ className={cn(
161
+ "min-h-0 min-w-0 scroll-fade-x scrollbar-thin overflow-auto px-3 py-3 text-start font-mono leading-relaxed outline-none group-has-data-[slot=code-block-footer]/code-block:pb-2 group-has-data-[slot=code-block-header]/code-block:pt-2 group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:py-2.5 group-data-[size=sm]/code-block:group-has-data-[slot=code-block-header]/code-block:pt-1.5 data-wrap:scroll-fade-y data-wrap:wrap-break-word data-wrap:whitespace-pre-wrap",
162
+ className
163
+ )}
164
+ {...props}
165
+ >
166
+ <code
167
+ data-slot="code-block-code"
168
+ className="grid min-h-lh min-w-max content-start in-data-numbered:grid-cols-[auto_1fr] in-data-wrap:min-w-0"
169
+ >
170
+ {lineNumbers && typeof children === "string"
171
+ ? children
172
+ .replace(/\n$/, "")
173
+ .split("\n")
174
+ .map((line, index) => (
175
+ <CodeBlockLine key={index}>{line}</CodeBlockLine>
176
+ ))
177
+ : children}
178
+ </code>
179
+ </pre>
180
+ )
181
+ }
182
+
183
+ const codeBlockLineVariants = cva(
184
+ "relative -mx-3 block min-h-lh px-3 group-data-[size=sm]/code-block:-mx-2.5 group-data-[size=sm]/code-block:px-2.5 before:min-w-6 before:text-end before:text-muted-foreground after:absolute after:start-1 after:top-0 after:text-muted-foreground after:select-none in-data-numbered:col-span-2 in-data-numbered:grid in-data-numbered:grid-cols-subgrid in-data-numbered:gap-x-3 in-data-numbered:[counter-increment:line] in-data-numbered:before:content-[counter(line)] in-data-numbered:before:select-none in-data-numbered:supports-[content:counter(line)_/_'']:before:content-[counter(line)_/_'']",
185
+ {
186
+ variants: {
187
+ variant: {
188
+ default: "",
189
+ added: "bg-muted after:content-['+']",
190
+ removed: "bg-destructive/10 after:text-destructive after:content-['−']",
191
+ highlighted: "bg-muted",
192
+ },
193
+ },
194
+ defaultVariants: {
195
+ variant: "default",
196
+ },
197
+ }
198
+ )
199
+
200
+ function CodeBlockLine({
201
+ className,
202
+ variant = "default",
203
+ children,
204
+ ...props
205
+ }: React.ComponentProps<"span"> & VariantProps<typeof codeBlockLineVariants>) {
206
+ // An empty line holds a newline so copying a selection keeps blank lines.
207
+ const empty =
208
+ children === undefined ||
209
+ children === null ||
210
+ children === "" ||
211
+ (Array.isArray(children) && children.length === 0)
212
+
213
+ return (
214
+ <span
215
+ data-slot="code-block-line"
216
+ data-variant={variant}
217
+ className={cn(codeBlockLineVariants({ variant }), className)}
218
+ {...props}
219
+ >
220
+ <span data-slot="code-block-line-content" className="min-w-0">
221
+ {empty ? "\n" : children}
222
+ </span>
223
+ </span>
224
+ )
225
+ }
226
+
227
+ function CodeBlockFooter({ className, ...props }: React.ComponentProps<"div">) {
228
+ return (
229
+ <div
230
+ data-slot="code-block-footer"
231
+ className={cn(
232
+ "flex min-w-0 shrink-0 items-center gap-2 px-3 pb-3 text-muted-foreground group-data-[size=sm]/code-block:px-2.5 group-data-[size=sm]/code-block:pb-2.5",
233
+ className
234
+ )}
235
+ {...props}
236
+ />
237
+ )
238
+ }
239
+
240
+ export {
241
+ CodeBlock,
242
+ CodeBlockHeader,
243
+ CodeBlockTitle,
244
+ CodeBlockActions,
245
+ CodeBlockCopyButton,
246
+ CodeBlockContent,
247
+ CodeBlockLine,
248
+ CodeBlockFooter,
249
+ }
@@ -0,0 +1,33 @@
1
+ "use client"
2
+
3
+ import { Collapsible as CollapsiblePrimitive } from "radix-ui"
4
+
5
+ function Collapsible({
6
+ ...props
7
+ }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
8
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
9
+ }
10
+
11
+ function CollapsibleTrigger({
12
+ ...props
13
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
14
+ return (
15
+ <CollapsiblePrimitive.CollapsibleTrigger
16
+ data-slot="collapsible-trigger"
17
+ {...props}
18
+ />
19
+ )
20
+ }
21
+
22
+ function CollapsibleContent({
23
+ ...props
24
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25
+ return (
26
+ <CollapsiblePrimitive.CollapsibleContent
27
+ data-slot="collapsible-content"
28
+ {...props}
29
+ />
30
+ )
31
+ }
32
+
33
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }
@@ -0,0 +1,299 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react"
5
+ import { cn } from "cn"
6
+
7
+ import { Button } from "@/components/ui/button"
8
+ import {
9
+ InputGroup,
10
+ InputGroupAddon,
11
+ InputGroupButton,
12
+ InputGroupInput,
13
+ } from "@/components/ui/input-group"
14
+ import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react"
15
+
16
+ const Combobox = ComboboxPrimitive.Root
17
+
18
+ function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
19
+ return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
20
+ }
21
+
22
+ function ComboboxTrigger({
23
+ className,
24
+ children,
25
+ ...props
26
+ }: ComboboxPrimitive.Trigger.Props) {
27
+ return (
28
+ <ComboboxPrimitive.Trigger
29
+ data-slot="combobox-trigger"
30
+ className={cn("[&_svg:not([class*='size-'])]:size-4", className)}
31
+ {...props}
32
+ >
33
+ {children}
34
+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
35
+ </ComboboxPrimitive.Trigger>
36
+ )
37
+ }
38
+
39
+ function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
40
+ return (
41
+ <ComboboxPrimitive.Clear
42
+ data-slot="combobox-clear"
43
+ render={<InputGroupButton variant="ghost" size="icon-xs" />}
44
+ className={cn(className)}
45
+ {...props}
46
+ >
47
+ <XIcon className="pointer-events-none" />
48
+ </ComboboxPrimitive.Clear>
49
+ )
50
+ }
51
+
52
+ function ComboboxInput({
53
+ className,
54
+ children,
55
+ disabled = false,
56
+ showTrigger = true,
57
+ showClear = false,
58
+ ...props
59
+ }: ComboboxPrimitive.Input.Props & {
60
+ showTrigger?: boolean
61
+ showClear?: boolean
62
+ }) {
63
+ return (
64
+ <InputGroup className={cn("w-auto", className)}>
65
+ <ComboboxPrimitive.Input
66
+ render={<InputGroupInput disabled={disabled} />}
67
+ {...props}
68
+ />
69
+ <InputGroupAddon align="inline-end">
70
+ {showTrigger && (
71
+ <InputGroupButton
72
+ size="icon-xs"
73
+ variant="ghost"
74
+ asChild
75
+ data-slot="input-group-button"
76
+ className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
77
+ disabled={disabled}
78
+ >
79
+ <ComboboxTrigger />
80
+ </InputGroupButton>
81
+ )}
82
+ {showClear && <ComboboxClear disabled={disabled} />}
83
+ </InputGroupAddon>
84
+ {children}
85
+ </InputGroup>
86
+ )
87
+ }
88
+
89
+ function ComboboxContent({
90
+ className,
91
+ side = "bottom",
92
+ sideOffset = 6,
93
+ align = "start",
94
+ alignOffset = 0,
95
+ anchor,
96
+ ...props
97
+ }: ComboboxPrimitive.Popup.Props &
98
+ Pick<
99
+ ComboboxPrimitive.Positioner.Props,
100
+ "side" | "align" | "sideOffset" | "alignOffset" | "anchor"
101
+ >) {
102
+ return (
103
+ <ComboboxPrimitive.Portal>
104
+ <ComboboxPrimitive.Positioner
105
+ side={side}
106
+ sideOffset={sideOffset}
107
+ align={align}
108
+ alignOffset={alignOffset}
109
+ anchor={anchor}
110
+ className="isolate z-50"
111
+ >
112
+ <ComboboxPrimitive.Popup
113
+ data-slot="combobox-content"
114
+ data-chips={!!anchor}
115
+ className={cn("group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-popover bg-popover text-popover-foreground duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 shadow-popover", className )}
116
+ {...props}
117
+ />
118
+ </ComboboxPrimitive.Positioner>
119
+ </ComboboxPrimitive.Portal>
120
+ )
121
+ }
122
+
123
+ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
124
+ return (
125
+ <ComboboxPrimitive.List
126
+ data-slot="combobox-list"
127
+ className={cn(
128
+ "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",
129
+ className
130
+ )}
131
+ {...props}
132
+ />
133
+ )
134
+ }
135
+
136
+ function ComboboxItem({
137
+ className,
138
+ children,
139
+ ...props
140
+ }: ComboboxPrimitive.Item.Props) {
141
+ return (
142
+ <ComboboxPrimitive.Item
143
+ data-slot="combobox-item"
144
+ className={cn(
145
+ "relative flex w-full cursor-default items-center gap-2 rounded-(--menu-item-radius) py-2 pr-8 pl-2.5 text-[0.9375rem] outline-hidden select-none data-highlighted:bg-(--menu-highlight) data-highlighted:text-(--menu-highlight-fg) not-data-[variant=destructive]:data-highlighted:**:text-(--menu-highlight-fg) data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
146
+ className
147
+ )}
148
+ {...props}
149
+ >
150
+ {children}
151
+ <ComboboxPrimitive.ItemIndicator
152
+ render={
153
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
154
+ }
155
+ >
156
+ <CheckIcon className="pointer-events-none" />
157
+ </ComboboxPrimitive.ItemIndicator>
158
+ </ComboboxPrimitive.Item>
159
+ )
160
+ }
161
+
162
+ function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
163
+ return (
164
+ <ComboboxPrimitive.Group
165
+ data-slot="combobox-group"
166
+ className={cn(className)}
167
+ {...props}
168
+ />
169
+ )
170
+ }
171
+
172
+ function ComboboxLabel({
173
+ className,
174
+ ...props
175
+ }: ComboboxPrimitive.GroupLabel.Props) {
176
+ return (
177
+ <ComboboxPrimitive.GroupLabel
178
+ data-slot="combobox-label"
179
+ className={cn("px-2 py-1.5 text-xs text-muted-foreground", className)}
180
+ {...props}
181
+ />
182
+ )
183
+ }
184
+
185
+ function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
186
+ return (
187
+ <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
188
+ )
189
+ }
190
+
191
+ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
192
+ return (
193
+ <ComboboxPrimitive.Empty
194
+ data-slot="combobox-empty"
195
+ className={cn(
196
+ "hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
197
+ className
198
+ )}
199
+ {...props}
200
+ />
201
+ )
202
+ }
203
+
204
+ function ComboboxSeparator({
205
+ className,
206
+ ...props
207
+ }: ComboboxPrimitive.Separator.Props) {
208
+ return (
209
+ <ComboboxPrimitive.Separator
210
+ data-slot="combobox-separator"
211
+ className={cn("-mx-1 my-1 h-px bg-border", className)}
212
+ {...props}
213
+ />
214
+ )
215
+ }
216
+
217
+ function ComboboxChips({
218
+ className,
219
+ ...props
220
+ }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
221
+ ComboboxPrimitive.Chips.Props) {
222
+ return (
223
+ <ComboboxPrimitive.Chips
224
+ data-slot="combobox-chips"
225
+ className={cn(
226
+ "flex min-h-(--control-h) flex-wrap items-center gap-1 rounded-control border border-input bg-(--field) bg-clip-padding px-3.5 text-sm transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40 shadow-control duration-(--state-ms)",
227
+ className
228
+ )}
229
+ {...props}
230
+ />
231
+ )
232
+ }
233
+
234
+ function ComboboxChip({
235
+ className,
236
+ children,
237
+ showRemove = true,
238
+ ...props
239
+ }: ComboboxPrimitive.Chip.Props & {
240
+ showRemove?: boolean
241
+ }) {
242
+ return (
243
+ <ComboboxPrimitive.Chip
244
+ data-slot="combobox-chip"
245
+ className={cn(
246
+ "flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
247
+ className
248
+ )}
249
+ {...props}
250
+ >
251
+ {children}
252
+ {showRemove && (
253
+ <ComboboxPrimitive.ChipRemove
254
+ render={<Button variant="ghost" size="icon-xs" />}
255
+ className="-ml-1 opacity-50 hover:opacity-100"
256
+ data-slot="combobox-chip-remove"
257
+ >
258
+ <XIcon className="pointer-events-none" />
259
+ </ComboboxPrimitive.ChipRemove>
260
+ )}
261
+ </ComboboxPrimitive.Chip>
262
+ )
263
+ }
264
+
265
+ function ComboboxChipsInput({
266
+ className,
267
+ ...props
268
+ }: ComboboxPrimitive.Input.Props) {
269
+ return (
270
+ <ComboboxPrimitive.Input
271
+ data-slot="combobox-chip-input"
272
+ className={cn("min-w-16 flex-1 outline-none", className)}
273
+ {...props}
274
+ />
275
+ )
276
+ }
277
+
278
+ function useComboboxAnchor() {
279
+ return React.useRef<HTMLDivElement | null>(null)
280
+ }
281
+
282
+ export {
283
+ Combobox,
284
+ ComboboxInput,
285
+ ComboboxContent,
286
+ ComboboxList,
287
+ ComboboxItem,
288
+ ComboboxGroup,
289
+ ComboboxLabel,
290
+ ComboboxCollection,
291
+ ComboboxEmpty,
292
+ ComboboxSeparator,
293
+ ComboboxChips,
294
+ ComboboxChip,
295
+ ComboboxChipsInput,
296
+ ComboboxTrigger,
297
+ ComboboxValue,
298
+ useComboboxAnchor,
299
+ }