@ctrl-ui/react 0.8.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 (500) hide show
  1. package/README.md +70 -0
  2. package/dist/action-bar.d.ts +44 -0
  3. package/dist/action-bar.js +89 -0
  4. package/dist/activity.d.ts +53 -0
  5. package/dist/activity.js +188 -0
  6. package/dist/audio-recorder.d.ts +32 -0
  7. package/dist/audio-recorder.js +235 -0
  8. package/dist/audio-visualizer.d.ts +12 -0
  9. package/dist/audio-visualizer.js +58 -0
  10. package/dist/blocks/chat.d.ts +10 -0
  11. package/dist/blocks/chat.js +12 -0
  12. package/dist/blocks/coding-agent.d.ts +61 -0
  13. package/dist/blocks/coding-agent.js +255 -0
  14. package/dist/blocks/file-explorer-data.d.ts +57 -0
  15. package/dist/blocks/file-explorer-data.js +74 -0
  16. package/dist/blocks/file-explorer.d.ts +24 -0
  17. package/dist/blocks/file-explorer.js +427 -0
  18. package/dist/blocks/settings-data.d.ts +36 -0
  19. package/dist/blocks/settings-data.js +66 -0
  20. package/dist/blocks/settings.d.ts +19 -0
  21. package/dist/blocks/settings.js +282 -0
  22. package/dist/blocks/theme-toggle.d.ts +43 -0
  23. package/dist/blocks/theme-toggle.js +180 -0
  24. package/dist/chat-composer-attachment.d.ts +55 -0
  25. package/dist/chat-composer-attachment.js +267 -0
  26. package/dist/chat-composer-editor/extensions/mention.d.ts +14 -0
  27. package/dist/chat-composer-editor/extensions/mention.js +278 -0
  28. package/dist/chat-composer-editor/ghost.d.ts +5 -0
  29. package/dist/chat-composer-editor/ghost.js +55 -0
  30. package/dist/chat-composer-editor/schema.d.ts +6 -0
  31. package/dist/chat-composer-editor/schema.js +25 -0
  32. package/dist/chat-composer-editor/serialize.d.ts +6 -0
  33. package/dist/chat-composer-editor/serialize.js +16 -0
  34. package/dist/chat-composer-editor/types.d.ts +29 -0
  35. package/dist/chat-composer-editor/types.js +0 -0
  36. package/dist/chat-composer-editor.d.ts +9 -0
  37. package/dist/chat-composer-editor.js +154 -0
  38. package/dist/chat-composer.d.ts +60 -0
  39. package/dist/chat-composer.js +134 -0
  40. package/dist/chat-layout.d.ts +27 -0
  41. package/dist/chat-layout.js +114 -0
  42. package/dist/chat-message.d.ts +31 -0
  43. package/dist/chat-message.js +95 -0
  44. package/dist/code-block-editor.d.ts +59 -0
  45. package/dist/code-block-editor.js +250 -0
  46. package/dist/context-model.d.ts +33 -0
  47. package/dist/context-model.js +52 -0
  48. package/dist/context.d.ts +47 -0
  49. package/dist/context.js +335 -0
  50. package/dist/control-props.d.ts +28 -0
  51. package/dist/control-props.js +4 -0
  52. package/dist/control-variants.d.ts +8 -0
  53. package/dist/control-variants.js +14 -0
  54. package/dist/dynamic-notification-glass.d.ts +10 -0
  55. package/dist/dynamic-notification-glass.js +311 -0
  56. package/dist/dynamic-notification-liquid.d.ts +24 -0
  57. package/dist/dynamic-notification-liquid.js +682 -0
  58. package/dist/dynamic-notification-siri-wave.d.ts +4 -0
  59. package/dist/dynamic-notification-siri-wave.js +82 -0
  60. package/dist/dynamic-notification.d.ts +74 -0
  61. package/dist/dynamic-notification.js +342 -0
  62. package/dist/environment-variables.d.ts +124 -0
  63. package/dist/environment-variables.js +492 -0
  64. package/dist/extensions/create-track-highlight.d.ts +12 -0
  65. package/dist/extensions/create-track-highlight.js +147 -0
  66. package/dist/extensions/track-highlight.d.ts +22 -0
  67. package/dist/extensions/track-highlight.js +52 -0
  68. package/dist/hooks/use-audio-recorder.d.ts +107 -0
  69. package/dist/hooks/use-audio-recorder.js +577 -0
  70. package/dist/hooks/use-chat-composer.d.ts +56 -0
  71. package/dist/hooks/use-chat-composer.js +63 -0
  72. package/dist/hooks/use-chat-message.d.ts +28 -0
  73. package/dist/hooks/use-chat-message.js +24 -0
  74. package/dist/hooks/use-color-area.d.ts +18 -0
  75. package/dist/hooks/use-color-area.js +60 -0
  76. package/dist/hooks/use-copy-to-clipboard.d.ts +22 -0
  77. package/dist/hooks/use-copy-to-clipboard.js +90 -0
  78. package/dist/hooks/use-dropzone.d.ts +59 -0
  79. package/dist/hooks/use-dropzone.js +372 -0
  80. package/dist/hooks/use-dynamic-notification.d.ts +37 -0
  81. package/dist/hooks/use-dynamic-notification.js +87 -0
  82. package/dist/hooks/use-environment-variables.d.ts +51 -0
  83. package/dist/hooks/use-environment-variables.js +188 -0
  84. package/dist/hooks/use-mobile.d.ts +5 -0
  85. package/dist/hooks/use-mobile.js +29 -0
  86. package/dist/hooks/use-textarea-trigger-menu.d.ts +8 -0
  87. package/dist/hooks/use-textarea-trigger-menu.js +69 -0
  88. package/dist/hooks/use-trigger-menu.d.ts +49 -0
  89. package/dist/hooks/use-trigger-menu.js +102 -0
  90. package/dist/hooks/use-user-ask.d.ts +48 -0
  91. package/dist/hooks/use-user-ask.js +167 -0
  92. package/dist/inline-attachment.d.ts +37 -0
  93. package/dist/inline-attachment.js +192 -0
  94. package/dist/inline-citation.d.ts +56 -0
  95. package/dist/inline-citation.js +319 -0
  96. package/dist/knob-contracts/accordion-knobs.d.ts +5 -0
  97. package/dist/knob-contracts/accordion-knobs.js +9 -0
  98. package/dist/knob-contracts/action-bar-knobs.d.ts +5 -0
  99. package/dist/knob-contracts/action-bar-knobs.js +4 -0
  100. package/dist/knob-contracts/activity-knobs.d.ts +5 -0
  101. package/dist/knob-contracts/activity-knobs.js +9 -0
  102. package/dist/knob-contracts/alert-knobs.d.ts +5 -0
  103. package/dist/knob-contracts/alert-knobs.js +9 -0
  104. package/dist/knob-contracts/audio-recorder-knobs.d.ts +5 -0
  105. package/dist/knob-contracts/audio-recorder-knobs.js +9 -0
  106. package/dist/knob-contracts/audio-visualizer-knobs.d.ts +5 -0
  107. package/dist/knob-contracts/audio-visualizer-knobs.js +9 -0
  108. package/dist/knob-contracts/avatar-knobs.d.ts +5 -0
  109. package/dist/knob-contracts/avatar-knobs.js +9 -0
  110. package/dist/knob-contracts/badge-knobs.d.ts +5 -0
  111. package/dist/knob-contracts/badge-knobs.js +9 -0
  112. package/dist/knob-contracts/button-group-knobs.d.ts +5 -0
  113. package/dist/knob-contracts/button-group-knobs.js +9 -0
  114. package/dist/knob-contracts/button-knobs.d.ts +5 -0
  115. package/dist/knob-contracts/button-knobs.js +25 -0
  116. package/dist/knob-contracts/calendar-knobs.d.ts +5 -0
  117. package/dist/knob-contracts/calendar-knobs.js +10 -0
  118. package/dist/knob-contracts/card-knobs.d.ts +5 -0
  119. package/dist/knob-contracts/card-knobs.js +11 -0
  120. package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +5 -0
  121. package/dist/knob-contracts/chat-composer-attachment-knobs.js +11 -0
  122. package/dist/knob-contracts/chat-composer-knobs.d.ts +5 -0
  123. package/dist/knob-contracts/chat-composer-knobs.js +18 -0
  124. package/dist/knob-contracts/chat-layout-knobs.d.ts +5 -0
  125. package/dist/knob-contracts/chat-layout-knobs.js +11 -0
  126. package/dist/knob-contracts/chat-message-knobs.d.ts +5 -0
  127. package/dist/knob-contracts/chat-message-knobs.js +17 -0
  128. package/dist/knob-contracts/choice-knobs.d.ts +5 -0
  129. package/dist/knob-contracts/choice-knobs.js +9 -0
  130. package/dist/knob-contracts/code-block-editor-knobs.d.ts +5 -0
  131. package/dist/knob-contracts/code-block-editor-knobs.js +11 -0
  132. package/dist/knob-contracts/code-diff-knobs.d.ts +5 -0
  133. package/dist/knob-contracts/code-diff-knobs.js +18 -0
  134. package/dist/knob-contracts/code-knobs.d.ts +5 -0
  135. package/dist/knob-contracts/code-knobs.js +11 -0
  136. package/dist/knob-contracts/collapsible-knobs.d.ts +5 -0
  137. package/dist/knob-contracts/collapsible-knobs.js +4 -0
  138. package/dist/knob-contracts/color-picker-knobs.d.ts +5 -0
  139. package/dist/knob-contracts/color-picker-knobs.js +12 -0
  140. package/dist/knob-contracts/context-knobs.d.ts +5 -0
  141. package/dist/knob-contracts/context-knobs.js +13 -0
  142. package/dist/knob-contracts/dockable-panel-knobs.d.ts +5 -0
  143. package/dist/knob-contracts/dockable-panel-knobs.js +12 -0
  144. package/dist/knob-contracts/dropzone-knobs.d.ts +5 -0
  145. package/dist/knob-contracts/dropzone-knobs.js +11 -0
  146. package/dist/knob-contracts/dynamic-notification-knobs.d.ts +5 -0
  147. package/dist/knob-contracts/dynamic-notification-knobs.js +18 -0
  148. package/dist/knob-contracts/empty-knobs.d.ts +5 -0
  149. package/dist/knob-contracts/empty-knobs.js +12 -0
  150. package/dist/knob-contracts/environment-variables-knobs.d.ts +5 -0
  151. package/dist/knob-contracts/environment-variables-knobs.js +11 -0
  152. package/dist/knob-contracts/field-knobs.d.ts +5 -0
  153. package/dist/knob-contracts/field-knobs.js +16 -0
  154. package/dist/knob-contracts/gradient-editor-knobs.d.ts +5 -0
  155. package/dist/knob-contracts/gradient-editor-knobs.js +13 -0
  156. package/dist/knob-contracts/infinite-canvas-knobs.d.ts +5 -0
  157. package/dist/knob-contracts/infinite-canvas-knobs.js +13 -0
  158. package/dist/knob-contracts/inline-attachment-knobs.d.ts +5 -0
  159. package/dist/knob-contracts/inline-attachment-knobs.js +14 -0
  160. package/dist/knob-contracts/inline-citation-knobs.d.ts +5 -0
  161. package/dist/knob-contracts/inline-citation-knobs.js +14 -0
  162. package/dist/knob-contracts/item-knobs.d.ts +5 -0
  163. package/dist/knob-contracts/item-knobs.js +10 -0
  164. package/dist/knob-contracts/kbd-knobs.d.ts +5 -0
  165. package/dist/knob-contracts/kbd-knobs.js +10 -0
  166. package/dist/knob-contracts/markdown-block-knobs.d.ts +5 -0
  167. package/dist/knob-contracts/markdown-block-knobs.js +11 -0
  168. package/dist/knob-contracts/markdown-knobs.d.ts +5 -0
  169. package/dist/knob-contracts/markdown-knobs.js +14 -0
  170. package/dist/knob-contracts/morphing-panel-knobs.d.ts +5 -0
  171. package/dist/knob-contracts/morphing-panel-knobs.js +11 -0
  172. package/dist/knob-contracts/pagination-knobs.d.ts +5 -0
  173. package/dist/knob-contracts/pagination-knobs.js +10 -0
  174. package/dist/knob-contracts/phone-input-knobs.d.ts +5 -0
  175. package/dist/knob-contracts/phone-input-knobs.js +10 -0
  176. package/dist/knob-contracts/popup-knobs.d.ts +5 -0
  177. package/dist/knob-contracts/popup-knobs.js +21 -0
  178. package/dist/knob-contracts/range-knobs.d.ts +5 -0
  179. package/dist/knob-contracts/range-knobs.js +13 -0
  180. package/dist/knob-contracts/resizable-knobs.d.ts +5 -0
  181. package/dist/knob-contracts/resizable-knobs.js +14 -0
  182. package/dist/knob-contracts/rich-tooltip-knobs.d.ts +5 -0
  183. package/dist/knob-contracts/rich-tooltip-knobs.js +13 -0
  184. package/dist/knob-contracts/scroll-area-knobs.d.ts +5 -0
  185. package/dist/knob-contracts/scroll-area-knobs.js +8 -0
  186. package/dist/knob-contracts/separator-knobs.d.ts +5 -0
  187. package/dist/knob-contracts/separator-knobs.js +4 -0
  188. package/dist/knob-contracts/sidebar-knobs.d.ts +5 -0
  189. package/dist/knob-contracts/sidebar-knobs.js +26 -0
  190. package/dist/knob-contracts/skeleton-knobs.d.ts +5 -0
  191. package/dist/knob-contracts/skeleton-knobs.js +4 -0
  192. package/dist/knob-contracts/source-badge-knobs.d.ts +5 -0
  193. package/dist/knob-contracts/source-badge-knobs.js +11 -0
  194. package/dist/knob-contracts/spinner-knobs.d.ts +5 -0
  195. package/dist/knob-contracts/spinner-knobs.js +4 -0
  196. package/dist/knob-contracts/stepper-knobs.d.ts +5 -0
  197. package/dist/knob-contracts/stepper-knobs.js +11 -0
  198. package/dist/knob-contracts/switch-knobs.d.ts +5 -0
  199. package/dist/knob-contracts/switch-knobs.js +12 -0
  200. package/dist/knob-contracts/table-knobs.d.ts +5 -0
  201. package/dist/knob-contracts/table-knobs.js +12 -0
  202. package/dist/knob-contracts/table-of-contents-knobs.d.ts +5 -0
  203. package/dist/knob-contracts/table-of-contents-knobs.js +8 -0
  204. package/dist/knob-contracts/tabs-knobs.d.ts +5 -0
  205. package/dist/knob-contracts/tabs-knobs.js +16 -0
  206. package/dist/knob-contracts/task-list-knobs.d.ts +5 -0
  207. package/dist/knob-contracts/task-list-knobs.js +14 -0
  208. package/dist/knob-contracts/thread-rail-knobs.d.ts +5 -0
  209. package/dist/knob-contracts/thread-rail-knobs.js +14 -0
  210. package/dist/knob-contracts/timeline-knobs.d.ts +5 -0
  211. package/dist/knob-contracts/timeline-knobs.js +12 -0
  212. package/dist/knob-contracts/toolbar-knobs.d.ts +5 -0
  213. package/dist/knob-contracts/toolbar-knobs.js +20 -0
  214. package/dist/knob-contracts/track-highlight-knobs.d.ts +5 -0
  215. package/dist/knob-contracts/track-highlight-knobs.js +11 -0
  216. package/dist/knob-contracts/transcript-divider-knobs.d.ts +5 -0
  217. package/dist/knob-contracts/transcript-divider-knobs.js +10 -0
  218. package/dist/knob-contracts/tree-knobs.d.ts +5 -0
  219. package/dist/knob-contracts/tree-knobs.js +13 -0
  220. package/dist/knob-contracts/user-ask-knobs.d.ts +5 -0
  221. package/dist/knob-contracts/user-ask-knobs.js +17 -0
  222. package/dist/lib/cn.d.ts +5 -0
  223. package/dist/lib/cn.js +34 -0
  224. package/dist/lib/code-block-shiki.d.ts +9 -0
  225. package/dist/lib/code-block-shiki.js +6 -0
  226. package/dist/lib/code-tokens.d.ts +28 -0
  227. package/dist/lib/code-tokens.js +160 -0
  228. package/dist/lib/color.d.ts +72 -0
  229. package/dist/lib/color.js +490 -0
  230. package/dist/lib/contrast.d.ts +30 -0
  231. package/dist/lib/contrast.js +64 -0
  232. package/dist/lib/diff.d.ts +50 -0
  233. package/dist/lib/diff.js +315 -0
  234. package/dist/lib/dropzone-validation.d.ts +66 -0
  235. package/dist/lib/dropzone-validation.js +228 -0
  236. package/dist/lib/env-file.d.ts +28 -0
  237. package/dist/lib/env-file.js +218 -0
  238. package/dist/lib/format-audio-recorder-duration.d.ts +4 -0
  239. package/dist/lib/format-audio-recorder-duration.js +7 -0
  240. package/dist/lib/liquid-glass-optics.d.ts +4 -0
  241. package/dist/lib/liquid-glass-optics.js +96 -0
  242. package/dist/lib/phone-input-format.d.ts +6 -0
  243. package/dist/lib/phone-input-format.js +26 -0
  244. package/dist/lib/phone-number.d.ts +18 -0
  245. package/dist/lib/phone-number.js +28 -0
  246. package/dist/lib/trigger-detect.d.ts +15 -0
  247. package/dist/lib/trigger-detect.js +77 -0
  248. package/dist/markdown-block.d.ts +25 -0
  249. package/dist/markdown-block.js +77 -0
  250. package/dist/skin.config.d.ts +5 -0
  251. package/dist/skin.config.js +4 -0
  252. package/dist/skin.d.ts +69 -0
  253. package/dist/skin.js +62 -0
  254. package/dist/source-badge.d.ts +23 -0
  255. package/dist/source-badge.js +72 -0
  256. package/dist/styles/chat-composer-editor.css +44 -0
  257. package/dist/styles/code.css +57 -0
  258. package/dist/styles/effects.css +126 -0
  259. package/dist/styles/index.css +81 -0
  260. package/dist/styles/recipes/accordion.css +87 -0
  261. package/dist/styles/recipes/action-bar.css +19 -0
  262. package/dist/styles/recipes/activity.css +129 -0
  263. package/dist/styles/recipes/alert.css +75 -0
  264. package/dist/styles/recipes/audio-recorder.css +102 -0
  265. package/dist/styles/recipes/audio-visualizer.css +90 -0
  266. package/dist/styles/recipes/avatar.css +52 -0
  267. package/dist/styles/recipes/badge.css +110 -0
  268. package/dist/styles/recipes/button-group.css +64 -0
  269. package/dist/styles/recipes/button.css +305 -0
  270. package/dist/styles/recipes/calendar.css +152 -0
  271. package/dist/styles/recipes/card.css +93 -0
  272. package/dist/styles/recipes/chat-composer-attachment.css +177 -0
  273. package/dist/styles/recipes/chat-composer.css +195 -0
  274. package/dist/styles/recipes/chat-layout.css +108 -0
  275. package/dist/styles/recipes/chat-message.css +160 -0
  276. package/dist/styles/recipes/choice.css +108 -0
  277. package/dist/styles/recipes/code-block-editor.css +136 -0
  278. package/dist/styles/recipes/code-diff.css +256 -0
  279. package/dist/styles/recipes/code.css +136 -0
  280. package/dist/styles/recipes/collapsible.css +27 -0
  281. package/dist/styles/recipes/color-picker-details.css +61 -0
  282. package/dist/styles/recipes/color-picker-values.css +117 -0
  283. package/dist/styles/recipes/color-picker.css +158 -0
  284. package/dist/styles/recipes/context.css +237 -0
  285. package/dist/styles/recipes/dockable-panel.css +106 -0
  286. package/dist/styles/recipes/dropzone.css +149 -0
  287. package/dist/styles/recipes/dynamic-notification-input.css +29 -0
  288. package/dist/styles/recipes/dynamic-notification-motion.css +298 -0
  289. package/dist/styles/recipes/dynamic-notification.css +241 -0
  290. package/dist/styles/recipes/empty.css +96 -0
  291. package/dist/styles/recipes/environment-variables.css +173 -0
  292. package/dist/styles/recipes/field-parts.css +148 -0
  293. package/dist/styles/recipes/field.css +234 -0
  294. package/dist/styles/recipes/gradient-editor.css +109 -0
  295. package/dist/styles/recipes/infinite-canvas.css +78 -0
  296. package/dist/styles/recipes/inline-attachment.css +182 -0
  297. package/dist/styles/recipes/inline-citation.css +174 -0
  298. package/dist/styles/recipes/item.css +107 -0
  299. package/dist/styles/recipes/kbd.css +55 -0
  300. package/dist/styles/recipes/markdown-block.css +75 -0
  301. package/dist/styles/recipes/markdown.css +204 -0
  302. package/dist/styles/recipes/morphing-panel.css +123 -0
  303. package/dist/styles/recipes/pagination.css +86 -0
  304. package/dist/styles/recipes/phone-input.css +105 -0
  305. package/dist/styles/recipes/popup-controls.css +59 -0
  306. package/dist/styles/recipes/popup-drawer.css +162 -0
  307. package/dist/styles/recipes/popup-lists.css +198 -0
  308. package/dist/styles/recipes/popup-motion.css +94 -0
  309. package/dist/styles/recipes/popup-toast.css +126 -0
  310. package/dist/styles/recipes/popup.css +396 -0
  311. package/dist/styles/recipes/range.css +259 -0
  312. package/dist/styles/recipes/resizable.css +170 -0
  313. package/dist/styles/recipes/rich-tooltip.css +272 -0
  314. package/dist/styles/recipes/scroll-area.css +59 -0
  315. package/dist/styles/recipes/separator.css +12 -0
  316. package/dist/styles/recipes/sidebar.css +345 -0
  317. package/dist/styles/recipes/skeleton.css +23 -0
  318. package/dist/styles/recipes/source-badge.css +77 -0
  319. package/dist/styles/recipes/spinner.css +33 -0
  320. package/dist/styles/recipes/stepper.css +178 -0
  321. package/dist/styles/recipes/switch.css +149 -0
  322. package/dist/styles/recipes/table-of-contents.css +107 -0
  323. package/dist/styles/recipes/table.css +124 -0
  324. package/dist/styles/recipes/tabs.css +235 -0
  325. package/dist/styles/recipes/task-list.css +146 -0
  326. package/dist/styles/recipes/thread-rail.css +247 -0
  327. package/dist/styles/recipes/timeline.css +107 -0
  328. package/dist/styles/recipes/toolbar.css +260 -0
  329. package/dist/styles/recipes/track-highlight.css +73 -0
  330. package/dist/styles/recipes/transcript-divider.css +64 -0
  331. package/dist/styles/recipes/tree.css +137 -0
  332. package/dist/styles/recipes/user-ask-details.css +45 -0
  333. package/dist/styles/recipes/user-ask.css +204 -0
  334. package/dist/styles/skin-theme.css +137 -0
  335. package/dist/styles/skin.css +143 -0
  336. package/dist/styles/theme.css +628 -0
  337. package/dist/styles/type-scale.css +45 -0
  338. package/dist/surface-variants.d.ts +6 -0
  339. package/dist/surface-variants.js +16 -0
  340. package/dist/task-list.d.ts +34 -0
  341. package/dist/task-list.js +177 -0
  342. package/dist/thread-rail.d.ts +52 -0
  343. package/dist/thread-rail.js +190 -0
  344. package/dist/transcript-divider.d.ts +15 -0
  345. package/dist/transcript-divider.js +25 -0
  346. package/dist/ui/accordion.d.ts +31 -0
  347. package/dist/ui/accordion.js +60 -0
  348. package/dist/ui/alert-dialog.d.ts +36 -0
  349. package/dist/ui/alert-dialog.js +100 -0
  350. package/dist/ui/alert.d.ts +21 -0
  351. package/dist/ui/alert.js +36 -0
  352. package/dist/ui/aspect-ratio.d.ts +8 -0
  353. package/dist/ui/aspect-ratio.js +17 -0
  354. package/dist/ui/autocomplete.d.ts +70 -0
  355. package/dist/ui/autocomplete.js +150 -0
  356. package/dist/ui/avatar.d.ts +24 -0
  357. package/dist/ui/avatar.js +44 -0
  358. package/dist/ui/badge.d.ts +20 -0
  359. package/dist/ui/badge.js +36 -0
  360. package/dist/ui/button-group.d.ts +24 -0
  361. package/dist/ui/button-group.js +45 -0
  362. package/dist/ui/button.d.ts +36 -0
  363. package/dist/ui/button.js +104 -0
  364. package/dist/ui/calendar.d.ts +11 -0
  365. package/dist/ui/calendar.js +160 -0
  366. package/dist/ui/card.d.ts +36 -0
  367. package/dist/ui/card.js +70 -0
  368. package/dist/ui/checkbox-group.d.ts +11 -0
  369. package/dist/ui/checkbox-group.js +16 -0
  370. package/dist/ui/checkbox.d.ts +23 -0
  371. package/dist/ui/checkbox.js +58 -0
  372. package/dist/ui/code-diff.d.ts +28 -0
  373. package/dist/ui/code-diff.js +561 -0
  374. package/dist/ui/code.d.ts +62 -0
  375. package/dist/ui/code.js +292 -0
  376. package/dist/ui/collapsible.d.ts +31 -0
  377. package/dist/ui/collapsible.js +72 -0
  378. package/dist/ui/color-picker.d.ts +137 -0
  379. package/dist/ui/color-picker.js +797 -0
  380. package/dist/ui/combobox-disabled-selection.d.ts +5 -0
  381. package/dist/ui/combobox-disabled-selection.js +11 -0
  382. package/dist/ui/combobox.d.ts +70 -0
  383. package/dist/ui/combobox.js +194 -0
  384. package/dist/ui/command.d.ts +44 -0
  385. package/dist/ui/command.js +166 -0
  386. package/dist/ui/context-menu.d.ts +86 -0
  387. package/dist/ui/context-menu.js +202 -0
  388. package/dist/ui/dialog.d.ts +38 -0
  389. package/dist/ui/dialog.js +124 -0
  390. package/dist/ui/dockable-panel-geometry.d.ts +18 -0
  391. package/dist/ui/dockable-panel-geometry.js +17 -0
  392. package/dist/ui/dockable-panel.d.ts +58 -0
  393. package/dist/ui/dockable-panel.js +366 -0
  394. package/dist/ui/drawer.d.ts +42 -0
  395. package/dist/ui/drawer.js +182 -0
  396. package/dist/ui/dropdown-menu.d.ts +46 -0
  397. package/dist/ui/dropdown-menu.js +89 -0
  398. package/dist/ui/dropzone.d.ts +66 -0
  399. package/dist/ui/dropzone.js +311 -0
  400. package/dist/ui/empty.d.ts +28 -0
  401. package/dist/ui/empty.js +59 -0
  402. package/dist/ui/field.d.ts +64 -0
  403. package/dist/ui/field.js +166 -0
  404. package/dist/ui/form.d.ts +10 -0
  405. package/dist/ui/form.js +17 -0
  406. package/dist/ui/gradient-editor.d.ts +47 -0
  407. package/dist/ui/gradient-editor.js +301 -0
  408. package/dist/ui/hover-card.d.ts +25 -0
  409. package/dist/ui/hover-card.js +46 -0
  410. package/dist/ui/infinite-canvas.d.ts +40 -0
  411. package/dist/ui/infinite-canvas.js +278 -0
  412. package/dist/ui/input-group.d.ts +21 -0
  413. package/dist/ui/input-group.js +44 -0
  414. package/dist/ui/input-otp.d.ts +38 -0
  415. package/dist/ui/input-otp.js +45 -0
  416. package/dist/ui/input.d.ts +12 -0
  417. package/dist/ui/input.js +18 -0
  418. package/dist/ui/item.d.ts +46 -0
  419. package/dist/ui/item.js +110 -0
  420. package/dist/ui/kbd.d.ts +12 -0
  421. package/dist/ui/kbd.js +23 -0
  422. package/dist/ui/markdown-elements.d.ts +52 -0
  423. package/dist/ui/markdown-elements.js +211 -0
  424. package/dist/ui/markdown.d.ts +14 -0
  425. package/dist/ui/markdown.js +31 -0
  426. package/dist/ui/menubar.d.ts +74 -0
  427. package/dist/ui/menubar.js +162 -0
  428. package/dist/ui/meter.d.ts +34 -0
  429. package/dist/ui/meter.js +57 -0
  430. package/dist/ui/morphing-panel.d.ts +24 -0
  431. package/dist/ui/morphing-panel.js +87 -0
  432. package/dist/ui/native-select.d.ts +12 -0
  433. package/dist/ui/native-select.js +41 -0
  434. package/dist/ui/navigation-menu.d.ts +51 -0
  435. package/dist/ui/navigation-menu.js +135 -0
  436. package/dist/ui/number-field.d.ts +72 -0
  437. package/dist/ui/number-field.js +124 -0
  438. package/dist/ui/pagination.d.ts +26 -0
  439. package/dist/ui/pagination.js +77 -0
  440. package/dist/ui/phone-input.d.ts +30 -0
  441. package/dist/ui/phone-input.js +263 -0
  442. package/dist/ui/popover.d.ts +34 -0
  443. package/dist/ui/popover.js +87 -0
  444. package/dist/ui/progress.d.ts +34 -0
  445. package/dist/ui/progress.js +57 -0
  446. package/dist/ui/radio-group.d.ts +29 -0
  447. package/dist/ui/radio-group.js +37 -0
  448. package/dist/ui/resizable.d.ts +56 -0
  449. package/dist/ui/resizable.js +82 -0
  450. package/dist/ui/responsive-dialog.d.ts +18 -0
  451. package/dist/ui/responsive-dialog.js +121 -0
  452. package/dist/ui/rich-tooltip-tour.d.ts +12 -0
  453. package/dist/ui/rich-tooltip-tour.js +20 -0
  454. package/dist/ui/rich-tooltip.d.ts +83 -0
  455. package/dist/ui/rich-tooltip.js +331 -0
  456. package/dist/ui/scroll-area.d.ts +25 -0
  457. package/dist/ui/scroll-area.js +93 -0
  458. package/dist/ui/select.d.ts +44 -0
  459. package/dist/ui/select.js +124 -0
  460. package/dist/ui/separator.d.ts +9 -0
  461. package/dist/ui/separator.js +16 -0
  462. package/dist/ui/sheet.d.ts +25 -0
  463. package/dist/ui/sheet.js +76 -0
  464. package/dist/ui/sidebar.d.ts +88 -0
  465. package/dist/ui/sidebar.js +362 -0
  466. package/dist/ui/skeleton.d.ts +8 -0
  467. package/dist/ui/skeleton.js +13 -0
  468. package/dist/ui/slider.d.ts +24 -0
  469. package/dist/ui/slider.js +114 -0
  470. package/dist/ui/spinner.d.ts +12 -0
  471. package/dist/ui/spinner.js +26 -0
  472. package/dist/ui/stepper.d.ts +58 -0
  473. package/dist/ui/stepper.js +232 -0
  474. package/dist/ui/switch.d.ts +26 -0
  475. package/dist/ui/switch.js +71 -0
  476. package/dist/ui/table-of-contents.d.ts +22 -0
  477. package/dist/ui/table-of-contents.js +181 -0
  478. package/dist/ui/table.d.ts +37 -0
  479. package/dist/ui/table.js +83 -0
  480. package/dist/ui/tabs.d.ts +36 -0
  481. package/dist/ui/tabs.js +127 -0
  482. package/dist/ui/textarea.d.ts +9 -0
  483. package/dist/ui/textarea.js +16 -0
  484. package/dist/ui/timeline.d.ts +40 -0
  485. package/dist/ui/timeline.js +80 -0
  486. package/dist/ui/toast.d.ts +28 -0
  487. package/dist/ui/toast.js +132 -0
  488. package/dist/ui/toggle.d.ts +20 -0
  489. package/dist/ui/toggle.js +71 -0
  490. package/dist/ui/toolbar.d.ts +40 -0
  491. package/dist/ui/toolbar.js +72 -0
  492. package/dist/ui/tooltip.d.ts +27 -0
  493. package/dist/ui/tooltip.js +93 -0
  494. package/dist/ui/tree.d.ts +56 -0
  495. package/dist/ui/tree.js +438 -0
  496. package/dist/ui/trigger-menu.d.ts +46 -0
  497. package/dist/ui/trigger-menu.js +116 -0
  498. package/dist/user-ask.d.ts +50 -0
  499. package/dist/user-ask.js +398 -0
  500. package/package.json +115 -0
@@ -0,0 +1,561 @@
1
+ "use client";
2
+ import { cn } from "../lib/cn.js";
3
+ import { ScrollArea } from "./scroll-area.js";
4
+ import { highlightToTokens, mergeCodeTokenLineWithEmphasis } from "../lib/code-tokens.js";
5
+ import { CodeCopy, CodeFloatingCopy, CodeTokenLine } from "./code.js";
6
+ import { buildDiffFromFiles, buildDiffFromPatch, diffRunEnd } from "../lib/diff.js";
7
+ import { useEffect, useMemo, useRef, useState } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { useVirtualizer } from "@tanstack/react-virtual";
10
+ //#region src/ui/code-diff.tsx
11
+ const ESTIMATED_ROW_HEIGHT = 20;
12
+ const VIRTUALIZE_THRESHOLD = 150;
13
+ function sideTexts(file) {
14
+ if (!file.isPartial) return {
15
+ old: file.oldLines.join("\n"),
16
+ new: file.newLines.join("\n")
17
+ };
18
+ const oldArr = [];
19
+ const newArr = [];
20
+ for (const hunk of file.hunks) for (const line of hunk.lines) {
21
+ if (line.oldNo !== void 0) oldArr[line.oldNo - 1] = line.text;
22
+ if (line.newNo !== void 0) newArr[line.newNo - 1] = line.text;
23
+ }
24
+ return {
25
+ old: oldArr.join("\n"),
26
+ new: newArr.join("\n")
27
+ };
28
+ }
29
+ function useSideTokens(oldText, newText, lang, enabled) {
30
+ const requestKey = `${lang ?? ""}\n${oldText.length}:${oldText}${newText}`;
31
+ const [state, setState] = useState(null);
32
+ useEffect(() => {
33
+ if (!enabled || !lang) return;
34
+ let cancelled = false;
35
+ Promise.all([highlightToTokens(oldText, lang), highlightToTokens(newText, lang)]).then(([oldTokens, newTokens]) => {
36
+ if (!cancelled) setState({
37
+ key: requestKey,
38
+ tokens: {
39
+ old: oldTokens,
40
+ new: newTokens
41
+ }
42
+ });
43
+ }).catch(() => {
44
+ if (!cancelled) setState({
45
+ key: requestKey,
46
+ tokens: {
47
+ old: null,
48
+ new: null
49
+ }
50
+ });
51
+ });
52
+ return () => {
53
+ cancelled = true;
54
+ };
55
+ }, [
56
+ oldText,
57
+ newText,
58
+ lang,
59
+ enabled,
60
+ requestKey
61
+ ]);
62
+ if (!enabled) return {
63
+ old: null,
64
+ new: null
65
+ };
66
+ return state?.key === requestKey ? state.tokens : {
67
+ old: null,
68
+ new: null
69
+ };
70
+ }
71
+ function lineTokens(line, tokens) {
72
+ if (line.type === "del") return tokens.old?.[(line.oldNo ?? 1) - 1] ?? null;
73
+ if (line.type === "add") return tokens.new?.[(line.newNo ?? 1) - 1] ?? null;
74
+ return tokens.new?.[(line.newNo ?? 1) - 1] ?? tokens.old?.[(line.oldNo ?? 1) - 1] ?? null;
75
+ }
76
+ function splitPairs(lines) {
77
+ const rows = [];
78
+ let index = 0;
79
+ while (index < lines.length) {
80
+ const line = lines[index];
81
+ if (!line) break;
82
+ if (line.type === "context") {
83
+ rows.push({
84
+ left: line,
85
+ right: line
86
+ });
87
+ index += 1;
88
+ continue;
89
+ }
90
+ const delEnd = diffRunEnd(lines, index, "del");
91
+ const addEnd = diffRunEnd(lines, delEnd, "add");
92
+ const dels = lines.slice(index, delEnd);
93
+ const adds = lines.slice(delEnd, addEnd);
94
+ const count = Math.max(dels.length, adds.length);
95
+ for (let pair = 0; pair < count; pair += 1) rows.push({
96
+ left: dels[pair] ?? null,
97
+ right: adds[pair] ?? null
98
+ });
99
+ index = addEnd;
100
+ }
101
+ return rows;
102
+ }
103
+ function expandedContext(file, gapIndex) {
104
+ const hunk = file.hunks[gapIndex];
105
+ if (!hunk) return [];
106
+ const offset = hunk.newStart - hunk.oldStart;
107
+ const lines = [];
108
+ for (let oldNo = hunk.oldStart - hunk.collapsedBefore; oldNo < hunk.oldStart; oldNo += 1) {
109
+ const text = file.oldLines[oldNo - 1] ?? "";
110
+ lines.push({
111
+ type: "context",
112
+ oldNo,
113
+ newNo: oldNo + offset,
114
+ text
115
+ });
116
+ }
117
+ return lines;
118
+ }
119
+ function gapRows(file, hunk, gapIndex, diffStyle, expanded) {
120
+ if (!(gapIndex > 0 || hunk.collapsedBefore > 0)) return [];
121
+ if (expanded.has(gapIndex) && !file.isPartial) return expandedContext(file, gapIndex).map((line) => rowForLine(diffStyle, line, `exp-${gapIndex}-${line.oldNo ?? line.newNo ?? 0}`));
122
+ const label = hunk.header ?? `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`;
123
+ return [{
124
+ kind: "separator",
125
+ id: `sep-${gapIndex}`,
126
+ gapIndex,
127
+ label,
128
+ canExpand: !file.isPartial && hunk.collapsedBefore > 0
129
+ }];
130
+ }
131
+ function changedRows(hunk, gapIndex, diffStyle) {
132
+ if (diffStyle === "unified") return hunk.lines.map((line, lineIndex) => rowForLine("unified", line, `u-${gapIndex}-${lineIndex}`));
133
+ return splitPairs(hunk.lines).map((pair, pairIndex) => ({
134
+ kind: "split",
135
+ id: `s-${gapIndex}-${pairIndex}`,
136
+ left: pair.left,
137
+ right: pair.right
138
+ }));
139
+ }
140
+ function buildRows(file, diffStyle, expanded) {
141
+ const rows = [];
142
+ for (const [gapIndex, hunk] of file.hunks.entries()) {
143
+ rows.push(...gapRows(file, hunk, gapIndex, diffStyle, expanded));
144
+ rows.push(...changedRows(hunk, gapIndex, diffStyle));
145
+ }
146
+ return rows;
147
+ }
148
+ function rowForLine(diffStyle, line, id) {
149
+ if (diffStyle === "unified") return {
150
+ kind: "unified",
151
+ id,
152
+ line
153
+ };
154
+ if (line.type === "context") return {
155
+ kind: "split",
156
+ id,
157
+ left: line,
158
+ right: line
159
+ };
160
+ if (line.type === "del") return {
161
+ kind: "split",
162
+ id,
163
+ left: line,
164
+ right: null
165
+ };
166
+ return {
167
+ kind: "split",
168
+ id,
169
+ left: null,
170
+ right: line
171
+ };
172
+ }
173
+ const markerFor = {
174
+ add: "+",
175
+ del: "-",
176
+ context: ""
177
+ };
178
+ function DiffCode({ line, tokens, overflow }) {
179
+ const wrapClass = overflow === "wrap" ? "whitespace-pre-wrap break-words" : "whitespace-pre";
180
+ if (line.segments && line.segments.length > 0) {
181
+ const runs = mergeCodeTokenLineWithEmphasis(line.text, tokens, line.segments);
182
+ return /* @__PURE__ */ jsx("code", {
183
+ className: cn("min-w-0 flex-1", wrapClass),
184
+ children: runs.map((run) => {
185
+ const style = run.style || void 0;
186
+ if (run.emphasis) return /* @__PURE__ */ jsx("span", {
187
+ "data-control-ui": "code-diff",
188
+ "data-control-family": "code-diff",
189
+ "data-slot": "emphasis",
190
+ "data-line-type": line.type,
191
+ style,
192
+ children: run.content
193
+ }, run.start);
194
+ return /* @__PURE__ */ jsx("span", {
195
+ style,
196
+ children: run.content
197
+ }, run.start);
198
+ })
199
+ });
200
+ }
201
+ return /* @__PURE__ */ jsx("code", {
202
+ className: cn("min-w-0 flex-1", wrapClass),
203
+ children: /* @__PURE__ */ jsx(CodeTokenLine, {
204
+ tokens,
205
+ plain: line.text
206
+ })
207
+ });
208
+ }
209
+ function Gutter({ children, type }) {
210
+ return /* @__PURE__ */ jsx("span", {
211
+ "data-control-ui": "code-diff",
212
+ "data-control-family": "code-diff",
213
+ "data-line-type": type,
214
+ "data-slot": "gutter",
215
+ "aria-hidden": "true",
216
+ className: "shrink-0 select-none",
217
+ children
218
+ });
219
+ }
220
+ function Marker({ type, indicators }) {
221
+ if (indicators !== "classic") return null;
222
+ return /* @__PURE__ */ jsx("span", {
223
+ "data-control-ui": "code-diff",
224
+ "data-control-family": "code-diff",
225
+ "data-slot": "marker",
226
+ "data-line-type": type,
227
+ "aria-hidden": "true",
228
+ className: "shrink-0 select-none",
229
+ children: markerFor[type] || " "
230
+ });
231
+ }
232
+ function UnifiedRow({ line, tokens, indicators, overflow }) {
233
+ return /* @__PURE__ */ jsxs("div", {
234
+ "data-control-ui": "code-diff",
235
+ "data-control-family": "code-diff",
236
+ "data-slot": "line",
237
+ "data-line-type": line.type,
238
+ "data-indicators": indicators,
239
+ "aria-hidden": "true",
240
+ className: "flex w-full",
241
+ children: [
242
+ /* @__PURE__ */ jsx(Gutter, {
243
+ type: line.type,
244
+ children: line.oldNo ?? ""
245
+ }),
246
+ /* @__PURE__ */ jsx(Gutter, {
247
+ type: line.type,
248
+ children: line.newNo ?? ""
249
+ }),
250
+ /* @__PURE__ */ jsx(Marker, {
251
+ type: line.type,
252
+ indicators
253
+ }),
254
+ /* @__PURE__ */ jsx(DiffCode, {
255
+ line,
256
+ tokens,
257
+ overflow
258
+ })
259
+ ]
260
+ });
261
+ }
262
+ function SplitHalf({ line, tokens, indicators, overflow, side }) {
263
+ if (!line) return /* @__PURE__ */ jsx("div", {
264
+ "data-control-ui": "code-diff",
265
+ "data-control-family": "code-diff",
266
+ "data-slot": "empty-half",
267
+ "data-side": side,
268
+ "aria-hidden": "true",
269
+ className: "flex min-w-0 flex-1"
270
+ });
271
+ return /* @__PURE__ */ jsxs("div", {
272
+ "data-control-ui": "code-diff",
273
+ "data-control-family": "code-diff",
274
+ "data-slot": "line",
275
+ "data-line-type": line.type,
276
+ "data-indicators": indicators,
277
+ "data-side": side,
278
+ "aria-hidden": "true",
279
+ className: "flex min-w-0 flex-1",
280
+ children: [
281
+ /* @__PURE__ */ jsx(Gutter, {
282
+ type: line.type,
283
+ children: side === "left" ? line.oldNo ?? "" : line.newNo ?? ""
284
+ }),
285
+ /* @__PURE__ */ jsx(Marker, {
286
+ type: line.type,
287
+ indicators
288
+ }),
289
+ /* @__PURE__ */ jsx(DiffCode, {
290
+ line,
291
+ tokens,
292
+ overflow
293
+ })
294
+ ]
295
+ });
296
+ }
297
+ function fileTitle(file) {
298
+ return file.oldName && file.type === "rename" ? `${file.oldName} → ${file.name}` : file.name;
299
+ }
300
+ function DiffStats({ additions, deletions }) {
301
+ return /* @__PURE__ */ jsxs("span", {
302
+ "data-control-ui": "code-diff",
303
+ "data-control-family": "code-diff",
304
+ "data-slot": "stat",
305
+ className: "flex items-center",
306
+ children: [/* @__PURE__ */ jsxs("span", {
307
+ "data-control-ui": "code-diff",
308
+ "data-control-family": "code-diff",
309
+ "data-slot": "stat-additions",
310
+ children: ["+", additions]
311
+ }), /* @__PURE__ */ jsxs("span", {
312
+ "data-control-ui": "code-diff",
313
+ "data-control-family": "code-diff",
314
+ "data-slot": "stat-deletions",
315
+ children: ["−", deletions]
316
+ })]
317
+ });
318
+ }
319
+ function lineDescription(label, line, number) {
320
+ return `${label} line ${number ?? "?"}: ${line.text}`;
321
+ }
322
+ function unifiedLineDescription(line) {
323
+ if (line.type === "add") return lineDescription("Added", line, line.newNo);
324
+ if (line.type === "del") return lineDescription("Deleted", line, line.oldNo);
325
+ return lineDescription("Unchanged", line, line.newNo ?? line.oldNo);
326
+ }
327
+ function splitRowDescriptions(row) {
328
+ if (row.left?.type === "context") return [lineDescription("Unchanged", row.left, row.left.newNo ?? row.left.oldNo)];
329
+ const descriptions = [];
330
+ if (row.left) descriptions.push(lineDescription(row.right ? "Original" : "Deleted", row.left, row.left.oldNo));
331
+ if (row.right) descriptions.push(lineDescription(row.left ? "Modified" : "Added", row.right, row.right.newNo));
332
+ return descriptions;
333
+ }
334
+ function rowDescriptions(row) {
335
+ if (row.kind === "separator") return [];
336
+ if (row.kind === "unified") return [unifiedLineDescription(row.line)];
337
+ return splitRowDescriptions(row);
338
+ }
339
+ function accessibleDiffText(file, rows) {
340
+ return [fileTitle(file), ...rows.flatMap(rowDescriptions)].join("\n");
341
+ }
342
+ function fileIdentity(file) {
343
+ const hunks = file.hunks.map((hunk) => `${hunk.oldStart}:${hunk.newStart}:${hunk.lines.map((line) => `${line.type}:${line.text}`).join("\n")}`).join("\n");
344
+ return `${file.oldName ?? ""}->${file.name}:${file.type}:${hunks}`;
345
+ }
346
+ function CodeDiffFileSection({ file, lang, diffStyle, diffIndicators, overflow, maxHeight, showFileHeader }) {
347
+ const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
348
+ const texts = useMemo(() => sideTexts(file), [file]);
349
+ const tokens = useSideTokens(texts.old, texts.new, lang, Boolean(lang));
350
+ const rows = useMemo(() => buildRows(file, diffStyle, expanded), [
351
+ file,
352
+ diffStyle,
353
+ expanded
354
+ ]);
355
+ const scrollRef = useRef(null);
356
+ const shouldVirtualize = rows.length > VIRTUALIZE_THRESHOLD;
357
+ const virtualizer = useVirtualizer({
358
+ count: rows.length,
359
+ getScrollElement: () => scrollRef.current,
360
+ estimateSize: () => ESTIMATED_ROW_HEIGHT,
361
+ overscan: 24,
362
+ enabled: shouldVirtualize
363
+ });
364
+ function expandGap(gapIndex) {
365
+ setExpanded((current) => new Set(current).add(gapIndex));
366
+ }
367
+ const gridClassName = overflow === "scroll" ? "w-max min-w-full" : "w-full";
368
+ function renderRow(row) {
369
+ if (row.kind === "separator") return /* @__PURE__ */ jsxs("div", {
370
+ "data-control-ui": "code-diff",
371
+ "data-control-family": "code-diff",
372
+ "data-slot": "expander",
373
+ className: "flex items-center",
374
+ children: [row.canExpand ? /* @__PURE__ */ jsx("button", {
375
+ type: "button",
376
+ "data-control-ui": "code-diff",
377
+ "data-control-family": "code-diff",
378
+ "data-slot": "expand-button",
379
+ "data-control": "true",
380
+ onClick: () => expandGap(row.gapIndex),
381
+ className: "cursor-pointer",
382
+ "aria-label": "Expand hidden lines",
383
+ children: "⋯"
384
+ }) : /* @__PURE__ */ jsx("span", {
385
+ "aria-hidden": "true",
386
+ children: "⋯"
387
+ }), /* @__PURE__ */ jsx("span", {
388
+ "data-control-ui": "code-diff",
389
+ "data-control-family": "code-diff",
390
+ "data-slot": "expander-label",
391
+ className: "truncate",
392
+ children: row.label
393
+ })]
394
+ });
395
+ if (row.kind === "unified") return /* @__PURE__ */ jsx(UnifiedRow, {
396
+ line: row.line,
397
+ tokens: lineTokens(row.line, tokens),
398
+ indicators: diffIndicators,
399
+ overflow
400
+ });
401
+ return /* @__PURE__ */ jsxs("div", {
402
+ "data-control-ui": "code-diff",
403
+ "data-control-family": "code-diff",
404
+ "data-slot": "row",
405
+ className: "flex w-full",
406
+ children: [/* @__PURE__ */ jsx(SplitHalf, {
407
+ line: row.left,
408
+ tokens: row.left ? lineTokens(row.left, tokens) : null,
409
+ indicators: diffIndicators,
410
+ overflow,
411
+ side: "left"
412
+ }), /* @__PURE__ */ jsx(SplitHalf, {
413
+ line: row.right,
414
+ tokens: row.right ? lineTokens(row.right, tokens) : null,
415
+ indicators: diffIndicators,
416
+ overflow,
417
+ side: "right"
418
+ })]
419
+ });
420
+ }
421
+ return /* @__PURE__ */ jsxs("section", {
422
+ "data-control-ui": "code-diff",
423
+ "data-control-family": "code-diff",
424
+ "data-slot": "file",
425
+ "data-file-name": file.name,
426
+ children: [
427
+ showFileHeader ? /* @__PURE__ */ jsxs("div", {
428
+ "data-control-ui": "code-diff",
429
+ "data-control-family": "code-diff",
430
+ "data-slot": "file-header",
431
+ className: "flex items-center justify-between",
432
+ children: [/* @__PURE__ */ jsx("span", {
433
+ "data-control-ui": "code-diff",
434
+ "data-control-family": "code-diff",
435
+ "data-slot": "file-title",
436
+ className: "min-w-0 truncate",
437
+ children: fileTitle(file)
438
+ }), /* @__PURE__ */ jsx(DiffStats, {
439
+ additions: file.additions,
440
+ deletions: file.deletions
441
+ })]
442
+ }) : null,
443
+ /* @__PURE__ */ jsx("pre", {
444
+ "data-control-ui": "code-diff",
445
+ "data-control-family": "code-diff",
446
+ "data-slot": "accessible-source",
447
+ className: "sr-only",
448
+ children: /* @__PURE__ */ jsx("code", { children: accessibleDiffText(file, rows) })
449
+ }),
450
+ /* @__PURE__ */ jsx(ScrollArea, {
451
+ maxHeight,
452
+ viewportClassName: void 0,
453
+ viewportProps: {
454
+ "data-control-ui": "code-diff",
455
+ "data-control-family": "code-diff",
456
+ "data-slot": "body"
457
+ },
458
+ viewportRef: scrollRef,
459
+ children: shouldVirtualize ? /* @__PURE__ */ jsx("div", {
460
+ className: gridClassName,
461
+ style: {
462
+ position: "relative",
463
+ height: `${virtualizer.getTotalSize()}px`
464
+ },
465
+ children: virtualizer.getVirtualItems().map((item) => {
466
+ const row = rows[item.index];
467
+ if (!row) return null;
468
+ return /* @__PURE__ */ jsx("div", {
469
+ ref: virtualizer.measureElement,
470
+ "data-index": item.index,
471
+ style: {
472
+ position: "absolute",
473
+ top: 0,
474
+ left: 0,
475
+ width: "100%",
476
+ transform: `translateY(${item.start}px)`
477
+ },
478
+ children: renderRow(row)
479
+ }, row.id);
480
+ })
481
+ }) : /* @__PURE__ */ jsx("div", {
482
+ className: gridClassName,
483
+ children: rows.map((row) => /* @__PURE__ */ jsx("div", { children: renderRow(row) }, row.id))
484
+ })
485
+ })
486
+ ]
487
+ });
488
+ }
489
+ function CodeDiff({ patch, oldText, newText, lang, name, diffStyle = "unified", diffIndicators = "bars", lineDiffType = "word", overflow = "scroll", maxLineDiffLength, maxHeight = "32rem", header = true, className, style, ...props }) {
490
+ const options = {
491
+ name,
492
+ lang,
493
+ lineDiffType,
494
+ maxLineDiffLength
495
+ };
496
+ const parsedFiles = patch === void 0 ? [buildDiffFromFiles(oldText ?? "", newText ?? "", options)] : buildDiffFromPatch(patch, options);
497
+ const files = parsedFiles.length > 0 ? parsedFiles : [emptyFile(name)];
498
+ const additions = files.reduce((total, file) => total + file.additions, 0);
499
+ const deletions = files.reduce((total, file) => total + file.deletions, 0);
500
+ const copyValue = patch ?? newText ?? "";
501
+ const firstFile = files[0];
502
+ return /* @__PURE__ */ jsxs("figure", {
503
+ "data-control-ui": "code-diff",
504
+ "data-control-family": "code-diff",
505
+ "data-slot": "root",
506
+ "data-surface": "panel",
507
+ "data-diff-style": diffStyle,
508
+ "data-file-count": files.length,
509
+ "data-header": header ? "true" : void 0,
510
+ className: cn("overflow-hidden", className),
511
+ style,
512
+ ...props,
513
+ children: [header ? /* @__PURE__ */ jsxs("figcaption", {
514
+ "data-control-ui": "code-diff",
515
+ "data-control-family": "code-diff",
516
+ "data-slot": "header",
517
+ className: "flex items-center justify-between",
518
+ children: [/* @__PURE__ */ jsx("span", {
519
+ "data-control-ui": "code-diff",
520
+ "data-control-family": "code-diff",
521
+ "data-slot": "title",
522
+ className: "min-w-0 truncate",
523
+ children: files.length === 1 && firstFile ? fileTitle(firstFile) : `${files.length} files`
524
+ }), /* @__PURE__ */ jsxs("div", {
525
+ "data-control-ui": "code-diff",
526
+ "data-control-family": "code-diff",
527
+ "data-slot": "actions",
528
+ className: "flex shrink-0 items-center",
529
+ children: [/* @__PURE__ */ jsx(DiffStats, {
530
+ additions,
531
+ deletions
532
+ }), /* @__PURE__ */ jsx(CodeDiffCopy, { value: copyValue })]
533
+ })]
534
+ }) : /* @__PURE__ */ jsx(CodeFloatingCopy, { value: copyValue }), files.map((file) => /* @__PURE__ */ jsx(CodeDiffFileSection, {
535
+ file,
536
+ lang,
537
+ diffStyle,
538
+ diffIndicators,
539
+ overflow,
540
+ maxHeight,
541
+ showFileHeader: files.length > 1
542
+ }, fileIdentity(file)))]
543
+ });
544
+ }
545
+ function CodeDiffCopy(props) {
546
+ return /* @__PURE__ */ jsx(CodeCopy, { ...props });
547
+ }
548
+ function emptyFile(name) {
549
+ return {
550
+ name: name ?? "file",
551
+ type: "change",
552
+ hunks: [],
553
+ oldLines: [],
554
+ newLines: [],
555
+ isPartial: true,
556
+ additions: 0,
557
+ deletions: 0
558
+ };
559
+ }
560
+ //#endregion
561
+ export { CodeDiff, CodeDiffCopy };
@@ -0,0 +1,62 @@
1
+ import { Button } from "./button.js";
2
+ import { CodeKnobStyle } from "../knob-contracts/code-knobs.js";
3
+ import { CodeTokenLines } from "../lib/code-tokens.js";
4
+ import { CSSProperties, ComponentProps, ReactNode } from "react";
5
+ //#region src/ui/code.d.ts
6
+ type CodeOverflow = "wrap" | "scroll";
7
+ type CodeHighlight = "auto" | "none";
8
+ type CodeDensity = "default" | "compact";
9
+ type CodeChrome = "standalone" | "embedded";
10
+ type CodeProps = Omit<ComponentProps<"figure">, "style"> & {
11
+ overflow?: CodeOverflow;
12
+ chrome?: CodeChrome;
13
+ density?: CodeDensity;
14
+ style?: CSSProperties & CodeKnobStyle;
15
+ };
16
+ declare function Code({ overflow, chrome, density, className, children, ...props }: CodeProps): import("react").JSX.Element;
17
+ type CodeHeaderProps = Omit<ComponentProps<"figcaption">, "style"> & {
18
+ style?: CSSProperties & CodeKnobStyle;
19
+ };
20
+ declare function CodeHeader({ className, ...props }: CodeHeaderProps): import("react").JSX.Element;
21
+ type CodeTitleProps = Omit<ComponentProps<"span">, "style"> & {
22
+ style?: CSSProperties & CodeKnobStyle;
23
+ };
24
+ declare function CodeTitle({ className, ...props }: CodeTitleProps): import("react").JSX.Element;
25
+ type CodeActionsProps = ComponentProps<"div"> & {
26
+ style?: CSSProperties & CodeKnobStyle;
27
+ };
28
+ declare function CodeActions({ className, ...props }: CodeActionsProps): import("react").JSX.Element;
29
+ type CodeCopyProps = Omit<ComponentProps<typeof Button>, "children" | "onClick"> & {
30
+ value: string;
31
+ children?: ReactNode;
32
+ copiedLabel?: ReactNode;
33
+ copiedAriaLabel?: string;
34
+ };
35
+ declare function CodeCopy({ value, copiedLabel, copiedAriaLabel, children, className, "aria-label": ariaLabel, ...props }: CodeCopyProps): import("react").JSX.Element;
36
+ type CodeFloatingCopyProps = Omit<CodeCopyProps, "children" | "copiedLabel">;
37
+ declare function CodeFloatingCopy({ className, ...props }: CodeFloatingCopyProps): import("react").JSX.Element;
38
+ /** Null until resolved, and whenever highlighting is off or language is unknown — callers fall back to plain text. */
39
+ declare function useCodeTokens({ code, lang, tokens, highlight }: {
40
+ code: string;
41
+ lang?: string;
42
+ tokens?: CodeTokenLines | null;
43
+ highlight: CodeHighlight;
44
+ }): CodeTokenLines | null;
45
+ declare function CodeTokenLine({ tokens, plain }: {
46
+ tokens: CodeTokenLines[number] | null;
47
+ plain: string;
48
+ }): ReactNode;
49
+ type CodeContentProps = Omit<ComponentProps<"div">, "children" | "style"> & {
50
+ code: string;
51
+ lang?: string;
52
+ tokens?: CodeTokenLines | null;
53
+ highlight?: CodeHighlight;
54
+ showLineNumbers?: boolean;
55
+ startLine?: number;
56
+ maxHeight?: string;
57
+ virtualize?: boolean;
58
+ style?: CSSProperties & CodeKnobStyle;
59
+ };
60
+ declare function CodeContent({ code, lang, tokens, highlight, showLineNumbers, startLine, maxHeight, virtualize, className, ref, style, ...props }: CodeContentProps): import("react").JSX.Element;
61
+ //#endregion
62
+ export { Code, CodeActions, CodeActionsProps, CodeChrome, CodeContent, CodeContentProps, CodeCopy, CodeCopyProps, CodeDensity, CodeFloatingCopy, CodeFloatingCopyProps, CodeHeader, CodeHeaderProps, CodeHighlight, CodeOverflow, CodeProps, CodeTitle, CodeTitleProps, CodeTokenLine, useCodeTokens };