@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,162 @@
1
+ import * as React from "react"
2
+ import { cn } from "cn"
3
+
4
+ import {
5
+ Collapsible,
6
+ CollapsibleContent,
7
+ CollapsibleTrigger,
8
+ } from "@/components/ui/collapsible"
9
+ import { ChevronRightIcon } from "lucide-react"
10
+
11
+ function Trace({ className, ...props }: React.ComponentProps<"div">) {
12
+ return (
13
+ <div
14
+ data-slot="trace"
15
+ className={cn(
16
+ "flex w-full min-w-0 flex-col gap-2 *:has-[>[data-slot=trace-line]]:flex *:has-[>[data-slot=trace-line]]:w-fit *:has-[>[data-slot=trace-line]]:max-w-full *:has-[>[data-slot=trace-line]]:min-w-0 *:has-[>[data-slot=trace-line]]:rounded-md *:has-[>[data-slot=trace-line]]:text-left *:has-[>[data-slot=trace-line]]:outline-none *:has-[>[data-slot=trace-line]]:focus-visible:ring-3 *:has-[>[data-slot=trace-line]]:focus-visible:ring-ring/50",
17
+ className
18
+ )}
19
+ {...props}
20
+ />
21
+ )
22
+ }
23
+
24
+ function TraceLine({
25
+ className,
26
+ status,
27
+ ...props
28
+ }: React.ComponentProps<"span"> & {
29
+ status?: "running" | "error" | "pending"
30
+ }) {
31
+ return (
32
+ <span
33
+ data-slot="trace-line"
34
+ data-status={status}
35
+ className={cn(
36
+ "flex w-fit max-w-full min-w-0 items-center gap-2 text-sm text-muted-foreground transition-colors in-[a,button]:cursor-pointer in-[a:hover,button:hover]:text-foreground data-[status=error]:text-destructive data-[status=error]:in-[a:hover,button:hover]:text-destructive data-[status=pending]:opacity-60 data-[status=running]:*:data-[slot=trace-title]:shimmer",
37
+ className
38
+ )}
39
+ {...props}
40
+ />
41
+ )
42
+ }
43
+
44
+ function TraceIcon({ className, ...props }: React.ComponentProps<"span">) {
45
+ return (
46
+ <span
47
+ data-slot="trace-icon"
48
+ aria-hidden="true"
49
+ className={cn(
50
+ "flex size-4 shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [[data-slot=trace-title]~&]:-ml-1",
51
+ className
52
+ )}
53
+ {...props}
54
+ />
55
+ )
56
+ }
57
+
58
+ function TraceTitle({ className, ...props }: React.ComponentProps<"span">) {
59
+ return (
60
+ <span
61
+ data-slot="trace-title"
62
+ className={cn("min-w-0 truncate motion-reduce:shimmer-none", className)}
63
+ {...props}
64
+ />
65
+ )
66
+ }
67
+
68
+ function TraceDescription({
69
+ className,
70
+ ...props
71
+ }: React.ComponentProps<"span">) {
72
+ return (
73
+ <span
74
+ data-slot="trace-description"
75
+ className={cn(
76
+ "shrink-0 text-muted-foreground/70 tabular-nums",
77
+ className
78
+ )}
79
+ {...props}
80
+ />
81
+ )
82
+ }
83
+
84
+ function TraceCollapsible({
85
+ className,
86
+ ...props
87
+ }: Omit<React.ComponentProps<typeof Collapsible>, "asChild" | "open"> &
88
+ (
89
+ | { open?: undefined }
90
+ | {
91
+ open: boolean
92
+ onOpenChange: NonNullable<
93
+ React.ComponentProps<typeof Collapsible>["onOpenChange"]
94
+ >
95
+ }
96
+ )) {
97
+ return (
98
+ <Collapsible
99
+ data-slot="trace-collapsible"
100
+ className={cn("flex w-full min-w-0 flex-col", className)}
101
+ {...props}
102
+ />
103
+ )
104
+ }
105
+
106
+ function TraceCollapsibleTrigger({
107
+ className,
108
+ children,
109
+ ...props
110
+ }: Omit<React.ComponentProps<typeof CollapsibleTrigger>, "asChild">) {
111
+ return (
112
+ <CollapsibleTrigger
113
+ data-slot="trace-collapsible-trigger"
114
+ className={cn(
115
+ "group/trace-collapsible-trigger flex w-fit max-w-full min-w-0 cursor-pointer items-center gap-1 rounded-md text-left text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 has-[[data-status=error]]:text-destructive",
116
+ className
117
+ )}
118
+ {...props}
119
+ >
120
+ {children}
121
+ <TraceIcon className="transition-transform group-aria-expanded/trace-collapsible-trigger:rotate-90">
122
+ <ChevronRightIcon
123
+ />
124
+ </TraceIcon>
125
+ </CollapsibleTrigger>
126
+ )
127
+ }
128
+
129
+ function TraceCollapsibleContent({
130
+ className,
131
+ children,
132
+ ...props
133
+ }: Omit<React.ComponentProps<typeof CollapsibleContent>, "asChild">) {
134
+ return (
135
+ <CollapsibleContent
136
+ data-slot="trace-collapsible-content"
137
+ className="min-w-0 overflow-hidden duration-200 [--radix-accordion-content-height:var(--radix-collapsible-content-height)] data-open:animate-accordion-down data-closed:animate-accordion-up"
138
+ {...props}
139
+ >
140
+ <div
141
+ data-slot="trace-collapsible-content-inner"
142
+ className={cn(
143
+ "mt-2 mb-1 ml-[calc(--spacing(2)-1px)] min-w-0 border-l pr-1 pl-4 leading-relaxed wrap-break-word text-muted-foreground",
144
+ className
145
+ )}
146
+ >
147
+ {children}
148
+ </div>
149
+ </CollapsibleContent>
150
+ )
151
+ }
152
+
153
+ export {
154
+ Trace,
155
+ TraceLine,
156
+ TraceIcon,
157
+ TraceTitle,
158
+ TraceDescription,
159
+ TraceCollapsible,
160
+ TraceCollapsibleTrigger,
161
+ TraceCollapsibleContent,
162
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "context-menu",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "lucide-react",
8
+ "radix-ui"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "components/ui/context-menu.tsx",
13
+ "type": "registry:ui"
14
+ }
15
+ ],
16
+ "mostra": {
17
+ "base": "radix"
18
+ }
19
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "dialog",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "lucide-react",
8
+ "radix-ui"
9
+ ],
10
+ "registryDependencies": [
11
+ "button"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/ui/dialog.tsx",
16
+ "type": "registry:ui"
17
+ }
18
+ ],
19
+ "mostra": {
20
+ "base": "radix"
21
+ }
22
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "direction",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "radix-ui"
7
+ ],
8
+ "files": [
9
+ {
10
+ "path": "components/ui/direction.tsx",
11
+ "type": "registry:ui"
12
+ }
13
+ ],
14
+ "mostra": {
15
+ "base": "radix"
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "drawer",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "vaul"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "components/ui/drawer.tsx",
12
+ "type": "registry:ui"
13
+ }
14
+ ],
15
+ "mostra": {
16
+ "base": "radix"
17
+ }
18
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "dropdown-menu",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "lucide-react",
8
+ "radix-ui"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "components/ui/dropdown-menu.tsx",
13
+ "type": "registry:ui"
14
+ }
15
+ ],
16
+ "mostra": {
17
+ "base": "radix"
18
+ }
19
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "empty",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "class-variance-authority",
7
+ "cn"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "components/ui/empty.tsx",
12
+ "type": "registry:ui"
13
+ }
14
+ ],
15
+ "mostra": {
16
+ "base": "radix"
17
+ }
18
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "field",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "class-variance-authority",
7
+ "cn"
8
+ ],
9
+ "registryDependencies": [
10
+ "label",
11
+ "separator"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/ui/field.tsx",
16
+ "type": "registry:ui"
17
+ }
18
+ ],
19
+ "mostra": {
20
+ "base": "radix"
21
+ }
22
+ }
@@ -0,0 +1,75 @@
1
+ import * as React from "react"
2
+
3
+ import { loadHighlighter } from "@/lib/highlighter"
4
+
5
+ export function useHighlightedCode(value: string, language: string) {
6
+ // A trailing newline would render as an extra empty line.
7
+ const code = value.endsWith("\n") ? value.slice(0, -1) : value
8
+ const [loaded, setLoaded] = React.useState<{
9
+ language: string
10
+ highlighter: Awaited<ReturnType<typeof loadHighlighter>>
11
+ } | null>(null)
12
+ const highlighter = loaded?.language === language ? loaded.highlighter : null
13
+
14
+ React.useEffect(() => {
15
+ let cancelled = false
16
+
17
+ loadHighlighter(language)
18
+ .then((next) => {
19
+ if (!cancelled) {
20
+ setLoaded({ language, highlighter: next })
21
+ }
22
+ })
23
+ .catch(() => {})
24
+
25
+ return () => {
26
+ cancelled = true
27
+ }
28
+ }, [language])
29
+
30
+ // The complete lines, highlighted. While the code streams, only the new
31
+ // lines are tokenized, starting from the grammar state of the last one.
32
+ const [done, setDone] = React.useState<{
33
+ highlighter: typeof highlighter
34
+ text: string
35
+ lines: React.ReactNode[]
36
+ state?: Parameters<NonNullable<typeof highlighter>["highlight"]>[1]
37
+ }>({ highlighter: null, text: "", lines: [] })
38
+
39
+ let next = done
40
+
41
+ if (next.highlighter !== highlighter || !code.startsWith(next.text)) {
42
+ next = { highlighter, text: "", lines: [] }
43
+ }
44
+
45
+ const end = code.lastIndexOf("\n") + 1
46
+
47
+ if (highlighter && end > next.text.length) {
48
+ const result = highlighter.highlight(
49
+ code.slice(next.text.length, end - 1),
50
+ next.state
51
+ )
52
+
53
+ next = {
54
+ highlighter,
55
+ text: code.slice(0, end),
56
+ lines: [...next.lines, ...result.lines],
57
+ state: result.state,
58
+ }
59
+ }
60
+
61
+ if (next !== done) {
62
+ setDone(next)
63
+ }
64
+
65
+ // The last line is still being written, so it is tokenized on every render.
66
+ const tail = code.slice(end)
67
+
68
+ return React.useMemo(() => {
69
+ if (!highlighter) {
70
+ return code.split("\n")
71
+ }
72
+
73
+ return [...next.lines, highlighter.highlight(tail, next.state).lines[0]]
74
+ }, [code, highlighter, next, tail])
75
+ }
@@ -0,0 +1,19 @@
1
+ import * as React from "react"
2
+
3
+ const MOBILE_BREAKPOINT = 768
4
+
5
+ export function useIsMobile() {
6
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7
+
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10
+ const onChange = () => {
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12
+ }
13
+ mql.addEventListener("change", onChange)
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15
+ return () => mql.removeEventListener("change", onChange)
16
+ }, [])
17
+
18
+ return !!isMobile
19
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "hover-card",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "radix-ui"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "components/ui/hover-card.tsx",
12
+ "type": "registry:ui"
13
+ }
14
+ ],
15
+ "mostra": {
16
+ "base": "radix"
17
+ }
18
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "input-group",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "class-variance-authority",
7
+ "cn"
8
+ ],
9
+ "registryDependencies": [
10
+ "button",
11
+ "input",
12
+ "textarea"
13
+ ],
14
+ "files": [
15
+ {
16
+ "path": "components/ui/input-group.tsx",
17
+ "type": "registry:ui"
18
+ }
19
+ ],
20
+ "mostra": {
21
+ "base": "radix"
22
+ }
23
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "input-otp",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "input-otp",
8
+ "lucide-react"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "components/ui/input-otp.tsx",
13
+ "type": "registry:ui"
14
+ }
15
+ ],
16
+ "mostra": {
17
+ "base": "radix"
18
+ }
19
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "input",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn"
7
+ ],
8
+ "files": [
9
+ {
10
+ "path": "components/ui/input.tsx",
11
+ "type": "registry:ui"
12
+ }
13
+ ],
14
+ "mostra": {
15
+ "base": "radix"
16
+ }
17
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "item",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "class-variance-authority",
7
+ "cn",
8
+ "radix-ui"
9
+ ],
10
+ "registryDependencies": [
11
+ "separator"
12
+ ],
13
+ "files": [
14
+ {
15
+ "path": "components/ui/item.tsx",
16
+ "type": "registry:ui"
17
+ }
18
+ ],
19
+ "mostra": {
20
+ "base": "radix"
21
+ }
22
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "kbd",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn"
7
+ ],
8
+ "files": [
9
+ {
10
+ "path": "components/ui/kbd.tsx",
11
+ "type": "registry:ui"
12
+ }
13
+ ],
14
+ "mostra": {
15
+ "base": "radix"
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "label",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "cn",
7
+ "radix-ui"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "components/ui/label.tsx",
12
+ "type": "registry:ui"
13
+ }
14
+ ],
15
+ "mostra": {
16
+ "base": "radix"
17
+ }
18
+ }
@@ -0,0 +1,124 @@
1
+ import * as React from "react"
2
+ import {
3
+ createHighlighterCore,
4
+ type GrammarState,
5
+ type HighlighterCore,
6
+ } from "shiki/core"
7
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript"
8
+
9
+ // Add the languages you need. Each one loads the first time it is used.
10
+ const languages = {
11
+ bash: () => import("shiki/langs/shellscript.mjs"),
12
+ css: () => import("shiki/langs/css.mjs"),
13
+ diff: () => import("shiki/langs/diff.mjs"),
14
+ html: () => import("shiki/langs/html.mjs"),
15
+ javascript: () => import("shiki/langs/javascript.mjs"),
16
+ json: () => import("shiki/langs/json.mjs"),
17
+ jsx: () => import("shiki/langs/jsx.mjs"),
18
+ markdown: () => import("shiki/langs/markdown.mjs"),
19
+ python: () => import("shiki/langs/python.mjs"),
20
+ sql: () => import("shiki/langs/sql.mjs"),
21
+ tsx: () => import("shiki/langs/tsx.mjs"),
22
+ typescript: () => import("shiki/langs/typescript.mjs"),
23
+ yaml: () => import("shiki/langs/yaml.mjs"),
24
+ }
25
+
26
+ const aliases: Record<string, keyof typeof languages> = {
27
+ js: "javascript",
28
+ md: "markdown",
29
+ py: "python",
30
+ sh: "bash",
31
+ shell: "bash",
32
+ shellscript: "bash",
33
+ ts: "typescript",
34
+ yml: "yaml",
35
+ zsh: "bash",
36
+ }
37
+
38
+ let highlighter: Promise<HighlighterCore> | undefined
39
+
40
+ function getHighlighter() {
41
+ highlighter ??= createHighlighterCore({
42
+ themes: [
43
+ import("shiki/themes/github-light.mjs"),
44
+ import("shiki/themes/github-dark.mjs"),
45
+ ],
46
+ langs: [],
47
+ engine: createJavaScriptRegexEngine({ forgiving: true }),
48
+ })
49
+
50
+ return highlighter
51
+ }
52
+
53
+ function getLanguage(language: string) {
54
+ const name = language.toLowerCase()
55
+
56
+ if (name === "ansi") {
57
+ return name
58
+ }
59
+
60
+ if (name in languages) {
61
+ return name as keyof typeof languages
62
+ }
63
+
64
+ return aliases[name] ?? null
65
+ }
66
+
67
+ // Loads a language and returns a highlighter for it, or null for a language
68
+ // that is not listed.
69
+ export async function loadHighlighter(language: string) {
70
+ const lang = getLanguage(language)
71
+
72
+ if (!lang) {
73
+ return null
74
+ }
75
+
76
+ const shiki = await getHighlighter()
77
+
78
+ if (lang !== "ansi" && !shiki.getLoadedLanguages().includes(lang)) {
79
+ await shiki.loadLanguage(languages[lang])
80
+ }
81
+
82
+ return {
83
+ // Returns one React node per line, and the grammar state after the last
84
+ // line. Pass that state back to continue where the code left off.
85
+ highlight(code: string, state?: GrammarState) {
86
+ const tokenize = (text: string) =>
87
+ shiki.codeToTokens(text, {
88
+ lang,
89
+ themes: { light: "github-light", dark: "github-dark" },
90
+ defaultColor: false,
91
+ grammarState: state,
92
+ }).tokens
93
+
94
+ // ANSI has no grammar state, so each line is tokenized on its own and
95
+ // gets the same colors whether it arrives in one piece or streams.
96
+ const tokens =
97
+ lang === "ansi"
98
+ ? code.split("\n").flatMap((line) => tokenize(line))
99
+ : tokenize(code)
100
+
101
+ return {
102
+ lines: tokens.map((line) =>
103
+ line.map((token, index) => (
104
+ <span
105
+ key={index}
106
+ style={token.htmlStyle as React.CSSProperties}
107
+ className="text-(--shiki-light) dark:text-(--shiki-dark)"
108
+ >
109
+ {token.content}
110
+ </span>
111
+ ))
112
+ ),
113
+ state: shiki.getLastGrammarState(tokens),
114
+ }
115
+ },
116
+ }
117
+ }
118
+
119
+ // Returns one React node per line, or null for a language that is not listed.
120
+ export async function highlightCode(code: string, language: string) {
121
+ const highlighter = await loadHighlighter(language)
122
+
123
+ return highlighter ? highlighter.highlight(code).lines : null
124
+ }
@@ -0,0 +1 @@
1
+ export { cn } from "cn"
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "marker",
4
+ "type": "registry:ui",
5
+ "dependencies": [
6
+ "class-variance-authority",
7
+ "cn",
8
+ "radix-ui"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "components/ui/marker.tsx",
13
+ "type": "registry:ui"
14
+ }
15
+ ],
16
+ "mostra": {
17
+ "base": "radix"
18
+ }
19
+ }