@agimon-ai/doompi-web-components 0.0.1-alpha.37 → 0.0.1-alpha.39

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 (339) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.d.mts +2 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/src/components/Accordion.cjs +1 -1
  5. package/dist/src/components/Accordion.cjs.map +1 -1
  6. package/dist/src/components/Accordion.mjs +1 -1
  7. package/dist/src/components/Accordion.mjs.map +1 -1
  8. package/dist/src/components/AnsiText.cjs +3 -3
  9. package/dist/src/components/AnsiText.cjs.map +1 -1
  10. package/dist/src/components/AnsiText.mjs +3 -3
  11. package/dist/src/components/AnsiText.mjs.map +1 -1
  12. package/dist/src/components/Avatar.cjs +1 -1
  13. package/dist/src/components/Avatar.cjs.map +1 -1
  14. package/dist/src/components/Avatar.mjs +1 -1
  15. package/dist/src/components/Avatar.mjs.map +1 -1
  16. package/dist/src/components/Badge.cjs +1 -1
  17. package/dist/src/components/Badge.cjs.map +1 -1
  18. package/dist/src/components/Badge.mjs +1 -1
  19. package/dist/src/components/Badge.mjs.map +1 -1
  20. package/dist/src/components/Breadcrumb.cjs +1 -1
  21. package/dist/src/components/Breadcrumb.cjs.map +1 -1
  22. package/dist/src/components/Breadcrumb.mjs +1 -1
  23. package/dist/src/components/Breadcrumb.mjs.map +1 -1
  24. package/dist/src/components/Button.cjs +1 -1
  25. package/dist/src/components/Button.cjs.map +1 -1
  26. package/dist/src/components/Button.mjs +1 -1
  27. package/dist/src/components/Button.mjs.map +1 -1
  28. package/dist/src/components/Checkbox.cjs +1 -1
  29. package/dist/src/components/Checkbox.cjs.map +1 -1
  30. package/dist/src/components/Checkbox.mjs +1 -1
  31. package/dist/src/components/Checkbox.mjs.map +1 -1
  32. package/dist/src/components/CodeBlock.cjs +1 -1
  33. package/dist/src/components/CodeBlock.cjs.map +1 -1
  34. package/dist/src/components/CodeBlock.mjs +1 -1
  35. package/dist/src/components/CodeBlock.mjs.map +1 -1
  36. package/dist/src/components/CodeEditor.cjs +1 -1
  37. package/dist/src/components/CodeEditor.cjs.map +1 -1
  38. package/dist/src/components/CodeEditor.mjs +1 -1
  39. package/dist/src/components/CodeEditor.mjs.map +1 -1
  40. package/dist/src/components/CodeEditorView.cjs +1 -1
  41. package/dist/src/components/CodeEditorView.cjs.map +1 -1
  42. package/dist/src/components/CodeEditorView.mjs +1 -1
  43. package/dist/src/components/CodeEditorView.mjs.map +1 -1
  44. package/dist/src/components/Collapsible.cjs +1 -1
  45. package/dist/src/components/Collapsible.cjs.map +1 -1
  46. package/dist/src/components/Collapsible.mjs +1 -1
  47. package/dist/src/components/Collapsible.mjs.map +1 -1
  48. package/dist/src/components/Command.cjs +1 -1
  49. package/dist/src/components/Command.cjs.map +1 -1
  50. package/dist/src/components/Command.mjs +1 -1
  51. package/dist/src/components/Command.mjs.map +1 -1
  52. package/dist/src/components/CopyButton.cjs +1 -1
  53. package/dist/src/components/CopyButton.cjs.map +1 -1
  54. package/dist/src/components/CopyButton.mjs +1 -1
  55. package/dist/src/components/CopyButton.mjs.map +1 -1
  56. package/dist/src/components/Dialog.cjs +1 -1
  57. package/dist/src/components/Dialog.cjs.map +1 -1
  58. package/dist/src/components/Dialog.mjs +1 -1
  59. package/dist/src/components/Dialog.mjs.map +1 -1
  60. package/dist/src/components/Dot.cjs +1 -1
  61. package/dist/src/components/Dot.cjs.map +1 -1
  62. package/dist/src/components/Dot.mjs +1 -1
  63. package/dist/src/components/Dot.mjs.map +1 -1
  64. package/dist/src/components/Drawer.cjs +2 -0
  65. package/dist/src/components/Drawer.cjs.map +1 -0
  66. package/dist/src/components/Drawer.d.mts +17 -0
  67. package/dist/src/components/Drawer.d.mts.map +1 -0
  68. package/dist/src/components/Drawer.mjs +2 -0
  69. package/dist/src/components/Drawer.mjs.map +1 -0
  70. package/dist/src/components/DropdownMenu.cjs +1 -1
  71. package/dist/src/components/DropdownMenu.cjs.map +1 -1
  72. package/dist/src/components/DropdownMenu.mjs +1 -1
  73. package/dist/src/components/DropdownMenu.mjs.map +1 -1
  74. package/dist/src/components/EmptyState.cjs +1 -1
  75. package/dist/src/components/EmptyState.cjs.map +1 -1
  76. package/dist/src/components/EmptyState.mjs +1 -1
  77. package/dist/src/components/EmptyState.mjs.map +1 -1
  78. package/dist/src/components/HashlineLines.cjs +1 -1
  79. package/dist/src/components/HashlineLines.cjs.map +1 -1
  80. package/dist/src/components/HashlineLines.mjs +1 -1
  81. package/dist/src/components/HashlineLines.mjs.map +1 -1
  82. package/dist/src/components/Input.cjs +1 -1
  83. package/dist/src/components/Input.cjs.map +1 -1
  84. package/dist/src/components/Input.mjs +1 -1
  85. package/dist/src/components/Input.mjs.map +1 -1
  86. package/dist/src/components/Kbd.cjs +1 -1
  87. package/dist/src/components/Kbd.cjs.map +1 -1
  88. package/dist/src/components/Kbd.mjs +1 -1
  89. package/dist/src/components/Kbd.mjs.map +1 -1
  90. package/dist/src/components/Label.cjs +1 -1
  91. package/dist/src/components/Label.cjs.map +1 -1
  92. package/dist/src/components/Label.mjs +1 -1
  93. package/dist/src/components/Label.mjs.map +1 -1
  94. package/dist/src/components/Markdown.cjs +1 -1
  95. package/dist/src/components/Markdown.cjs.map +1 -1
  96. package/dist/src/components/Markdown.mjs +1 -1
  97. package/dist/src/components/Markdown.mjs.map +1 -1
  98. package/dist/src/components/MediaPreview.cjs +1 -1
  99. package/dist/src/components/MediaPreview.cjs.map +1 -1
  100. package/dist/src/components/MediaPreview.mjs +1 -1
  101. package/dist/src/components/MediaPreview.mjs.map +1 -1
  102. package/dist/src/components/MermaidDiagram.cjs +1 -1
  103. package/dist/src/components/MermaidDiagram.cjs.map +1 -1
  104. package/dist/src/components/MermaidDiagram.mjs +1 -1
  105. package/dist/src/components/MermaidDiagram.mjs.map +1 -1
  106. package/dist/src/components/MessageItem.cjs +1 -1
  107. package/dist/src/components/MessageItem.cjs.map +1 -1
  108. package/dist/src/components/MessageItem.mjs +1 -1
  109. package/dist/src/components/MessageItem.mjs.map +1 -1
  110. package/dist/src/components/MessageLines.cjs +1 -1
  111. package/dist/src/components/MessageLines.cjs.map +1 -1
  112. package/dist/src/components/MessageLines.mjs +1 -1
  113. package/dist/src/components/MessageLines.mjs.map +1 -1
  114. package/dist/src/components/OptionList.cjs +1 -1
  115. package/dist/src/components/OptionList.cjs.map +1 -1
  116. package/dist/src/components/OptionList.mjs +1 -1
  117. package/dist/src/components/OptionList.mjs.map +1 -1
  118. package/dist/src/components/Panel.cjs +1 -1
  119. package/dist/src/components/Panel.cjs.map +1 -1
  120. package/dist/src/components/Panel.mjs +1 -1
  121. package/dist/src/components/Panel.mjs.map +1 -1
  122. package/dist/src/components/PdfPreview.cjs +1 -1
  123. package/dist/src/components/PdfPreview.cjs.map +1 -1
  124. package/dist/src/components/PdfPreview.mjs +1 -1
  125. package/dist/src/components/PdfPreview.mjs.map +1 -1
  126. package/dist/src/components/Popover.cjs +1 -1
  127. package/dist/src/components/Popover.cjs.map +1 -1
  128. package/dist/src/components/Popover.mjs +1 -1
  129. package/dist/src/components/Popover.mjs.map +1 -1
  130. package/dist/src/components/Progress.cjs +1 -1
  131. package/dist/src/components/Progress.cjs.map +1 -1
  132. package/dist/src/components/Progress.mjs +1 -1
  133. package/dist/src/components/Progress.mjs.map +1 -1
  134. package/dist/src/components/RadioGroup.cjs +1 -1
  135. package/dist/src/components/RadioGroup.cjs.map +1 -1
  136. package/dist/src/components/RadioGroup.mjs +1 -1
  137. package/dist/src/components/RadioGroup.mjs.map +1 -1
  138. package/dist/src/components/ScrollArea.cjs +1 -1
  139. package/dist/src/components/ScrollArea.cjs.map +1 -1
  140. package/dist/src/components/ScrollArea.mjs +1 -1
  141. package/dist/src/components/ScrollArea.mjs.map +1 -1
  142. package/dist/src/components/SectionLabel.cjs +1 -1
  143. package/dist/src/components/SectionLabel.cjs.map +1 -1
  144. package/dist/src/components/SectionLabel.mjs +1 -1
  145. package/dist/src/components/SectionLabel.mjs.map +1 -1
  146. package/dist/src/components/Select.cjs +1 -1
  147. package/dist/src/components/Select.cjs.map +1 -1
  148. package/dist/src/components/Select.mjs +1 -1
  149. package/dist/src/components/Select.mjs.map +1 -1
  150. package/dist/src/components/Separator.cjs +1 -1
  151. package/dist/src/components/Separator.cjs.map +1 -1
  152. package/dist/src/components/Separator.mjs +1 -1
  153. package/dist/src/components/Separator.mjs.map +1 -1
  154. package/dist/src/components/Sheet.cjs +1 -1
  155. package/dist/src/components/Sheet.cjs.map +1 -1
  156. package/dist/src/components/Sheet.mjs +1 -1
  157. package/dist/src/components/Sheet.mjs.map +1 -1
  158. package/dist/src/components/Skeleton.cjs +1 -1
  159. package/dist/src/components/Skeleton.cjs.map +1 -1
  160. package/dist/src/components/Skeleton.mjs +1 -1
  161. package/dist/src/components/Skeleton.mjs.map +1 -1
  162. package/dist/src/components/Spinner.cjs +1 -1
  163. package/dist/src/components/Spinner.cjs.map +1 -1
  164. package/dist/src/components/Spinner.mjs +1 -1
  165. package/dist/src/components/Spinner.mjs.map +1 -1
  166. package/dist/src/components/StatusBadge.cjs +1 -1
  167. package/dist/src/components/StatusBadge.cjs.map +1 -1
  168. package/dist/src/components/StatusBadge.mjs +1 -1
  169. package/dist/src/components/StatusBadge.mjs.map +1 -1
  170. package/dist/src/components/StreamCursor.cjs +1 -1
  171. package/dist/src/components/StreamCursor.cjs.map +1 -1
  172. package/dist/src/components/StreamCursor.mjs +1 -1
  173. package/dist/src/components/StreamCursor.mjs.map +1 -1
  174. package/dist/src/components/Switch.cjs +1 -1
  175. package/dist/src/components/Switch.cjs.map +1 -1
  176. package/dist/src/components/Switch.mjs +1 -1
  177. package/dist/src/components/Switch.mjs.map +1 -1
  178. package/dist/src/components/SyntaxText.cjs +3 -3
  179. package/dist/src/components/SyntaxText.cjs.map +1 -1
  180. package/dist/src/components/SyntaxText.mjs +3 -3
  181. package/dist/src/components/SyntaxText.mjs.map +1 -1
  182. package/dist/src/components/Tabs.cjs +1 -1
  183. package/dist/src/components/Tabs.cjs.map +1 -1
  184. package/dist/src/components/Tabs.mjs +1 -1
  185. package/dist/src/components/Tabs.mjs.map +1 -1
  186. package/dist/src/components/TerminalView.cjs +1 -1
  187. package/dist/src/components/TerminalView.cjs.map +1 -1
  188. package/dist/src/components/TerminalView.mjs +1 -1
  189. package/dist/src/components/TerminalView.mjs.map +1 -1
  190. package/dist/src/components/Textarea.cjs +1 -1
  191. package/dist/src/components/Textarea.cjs.map +1 -1
  192. package/dist/src/components/Textarea.mjs +1 -1
  193. package/dist/src/components/Textarea.mjs.map +1 -1
  194. package/dist/src/components/Toast.cjs +1 -1
  195. package/dist/src/components/Toast.cjs.map +1 -1
  196. package/dist/src/components/Toast.mjs +1 -1
  197. package/dist/src/components/Toast.mjs.map +1 -1
  198. package/dist/src/components/ToolPathLink.cjs +1 -1
  199. package/dist/src/components/ToolPathLink.cjs.map +1 -1
  200. package/dist/src/components/ToolPathLink.mjs +1 -1
  201. package/dist/src/components/ToolPathLink.mjs.map +1 -1
  202. package/dist/src/components/Tooltip.cjs +1 -1
  203. package/dist/src/components/Tooltip.cjs.map +1 -1
  204. package/dist/src/components/Tooltip.mjs +1 -1
  205. package/dist/src/components/Tooltip.mjs.map +1 -1
  206. package/package.json +11 -11
  207. package/dist/components/Accordion.d.cts +0 -11
  208. package/dist/components/Accordion.d.cts.map +0 -1
  209. package/dist/components/AnsiText.d.cts +0 -16
  210. package/dist/components/AnsiText.d.cts.map +0 -1
  211. package/dist/components/Avatar.d.cts +0 -10
  212. package/dist/components/Avatar.d.cts.map +0 -1
  213. package/dist/components/Badge.d.cts +0 -17
  214. package/dist/components/Badge.d.cts.map +0 -1
  215. package/dist/components/Breadcrumb.d.cts +0 -36
  216. package/dist/components/Breadcrumb.d.cts.map +0 -1
  217. package/dist/components/Button.d.cts +0 -24
  218. package/dist/components/Button.d.cts.map +0 -1
  219. package/dist/components/Checkbox.d.cts +0 -8
  220. package/dist/components/Checkbox.d.cts.map +0 -1
  221. package/dist/components/CodeEditor.d.cts +0 -5
  222. package/dist/components/CodeEditor.d.cts.map +0 -1
  223. package/dist/components/Collapsible.d.cts +0 -10
  224. package/dist/components/Collapsible.d.cts.map +0 -1
  225. package/dist/components/Command.d.cts +0 -41
  226. package/dist/components/Command.d.cts.map +0 -1
  227. package/dist/components/Dialog.d.cts +0 -39
  228. package/dist/components/Dialog.d.cts.map +0 -1
  229. package/dist/components/Dot.d.cts +0 -15
  230. package/dist/components/Dot.d.cts.map +0 -1
  231. package/dist/components/DropdownMenu.d.cts +0 -34
  232. package/dist/components/DropdownMenu.d.cts.map +0 -1
  233. package/dist/components/EmptyState.d.cts +0 -17
  234. package/dist/components/EmptyState.d.cts.map +0 -1
  235. package/dist/components/HashlineLines.d.cts +0 -23
  236. package/dist/components/HashlineLines.d.cts.map +0 -1
  237. package/dist/components/Input.d.cts +0 -19
  238. package/dist/components/Input.d.cts.map +0 -1
  239. package/dist/components/Kbd.d.cts +0 -6
  240. package/dist/components/Kbd.d.cts.map +0 -1
  241. package/dist/components/Label.d.cts +0 -8
  242. package/dist/components/Label.d.cts.map +0 -1
  243. package/dist/components/Markdown.d.cts +0 -17
  244. package/dist/components/Markdown.d.cts.map +0 -1
  245. package/dist/components/MediaPreview.d.cts +0 -61
  246. package/dist/components/MediaPreview.d.cts.map +0 -1
  247. package/dist/components/MessageItem.d.cts +0 -102
  248. package/dist/components/MessageItem.d.cts.map +0 -1
  249. package/dist/components/MessageLines.d.cts +0 -23
  250. package/dist/components/MessageLines.d.cts.map +0 -1
  251. package/dist/components/OptionList.d.cts +0 -49
  252. package/dist/components/OptionList.d.cts.map +0 -1
  253. package/dist/components/Panel.d.cts +0 -14
  254. package/dist/components/Panel.d.cts.map +0 -1
  255. package/dist/components/PdfPreview.d.cts +0 -52
  256. package/dist/components/PdfPreview.d.cts.map +0 -1
  257. package/dist/components/Popover.d.cts +0 -19
  258. package/dist/components/Popover.d.cts.map +0 -1
  259. package/dist/components/Progress.d.cts +0 -8
  260. package/dist/components/Progress.d.cts.map +0 -1
  261. package/dist/components/RadioGroup.d.cts +0 -15
  262. package/dist/components/RadioGroup.d.cts.map +0 -1
  263. package/dist/components/ScrollArea.d.cts +0 -13
  264. package/dist/components/ScrollArea.d.cts.map +0 -1
  265. package/dist/components/SectionLabel.d.cts +0 -6
  266. package/dist/components/SectionLabel.d.cts.map +0 -1
  267. package/dist/components/Select.d.cts +0 -19
  268. package/dist/components/Select.d.cts.map +0 -1
  269. package/dist/components/Separator.d.cts +0 -13
  270. package/dist/components/Separator.d.cts.map +0 -1
  271. package/dist/components/Sheet.d.cts +0 -35
  272. package/dist/components/Sheet.d.cts.map +0 -1
  273. package/dist/components/Skeleton.d.cts +0 -10
  274. package/dist/components/Skeleton.d.cts.map +0 -1
  275. package/dist/components/Spinner.d.cts +0 -14
  276. package/dist/components/Spinner.d.cts.map +0 -1
  277. package/dist/components/StatusBadge.d.cts +0 -23
  278. package/dist/components/StatusBadge.d.cts.map +0 -1
  279. package/dist/components/StreamCursor.d.cts +0 -6
  280. package/dist/components/StreamCursor.d.cts.map +0 -1
  281. package/dist/components/Switch.d.cts +0 -8
  282. package/dist/components/Switch.d.cts.map +0 -1
  283. package/dist/components/SyntaxText.d.cts +0 -50
  284. package/dist/components/SyntaxText.d.cts.map +0 -1
  285. package/dist/components/Tabs.d.cts +0 -36
  286. package/dist/components/Tabs.d.cts.map +0 -1
  287. package/dist/components/TerminalView.d.cts +0 -31
  288. package/dist/components/TerminalView.d.cts.map +0 -1
  289. package/dist/components/Textarea.d.cts +0 -9
  290. package/dist/components/Textarea.d.cts.map +0 -1
  291. package/dist/components/Toast.d.cts +0 -24
  292. package/dist/components/Toast.d.cts.map +0 -1
  293. package/dist/components/ToolPathLink.d.cts +0 -22
  294. package/dist/components/ToolPathLink.d.cts.map +0 -1
  295. package/dist/components/Tooltip.d.cts +0 -11
  296. package/dist/components/Tooltip.d.cts.map +0 -1
  297. package/dist/icons/icons.d.cts +0 -2
  298. package/dist/index.d.cts +0 -59
  299. package/dist/lib/ansiSpans.d.cts +0 -42
  300. package/dist/lib/ansiSpans.d.cts.map +0 -1
  301. package/dist/lib/cn.d.cts +0 -6
  302. package/dist/lib/cn.d.cts.map +0 -1
  303. package/dist/lib/collapse.d.cts +0 -14
  304. package/dist/lib/collapse.d.cts.map +0 -1
  305. package/dist/lib/editorLanguage.d.cts +0 -21
  306. package/dist/lib/editorLanguage.d.cts.map +0 -1
  307. package/dist/lib/editorTheme.d.cts +0 -76
  308. package/dist/lib/editorTheme.d.cts.map +0 -1
  309. package/dist/lib/hashlineHighlight.d.cts +0 -30
  310. package/dist/lib/hashlineHighlight.d.cts.map +0 -1
  311. package/dist/lib/hashlineView.d.cts +0 -60
  312. package/dist/lib/hashlineView.d.cts.map +0 -1
  313. package/dist/lib/media.d.cts +0 -11
  314. package/dist/lib/media.d.cts.map +0 -1
  315. package/dist/lib/optionList.d.cts +0 -21
  316. package/dist/lib/optionList.d.cts.map +0 -1
  317. package/dist/lib/syntaxHighlight.d.cts +0 -54
  318. package/dist/lib/syntaxHighlight.d.cts.map +0 -1
  319. package/dist/lib/tone.d.cts +0 -25
  320. package/dist/lib/tone.d.cts.map +0 -1
  321. package/dist/theme/apply.d.cts +0 -25
  322. package/dist/theme/apply.d.cts.map +0 -1
  323. package/dist/theme/builtinThemes.d.cts +0 -11
  324. package/dist/theme/builtinThemes.d.cts.map +0 -1
  325. package/dist/theme/derive.d.cts +0 -14
  326. package/dist/theme/derive.d.cts.map +0 -1
  327. package/dist/theme/parse.d.cts +0 -10
  328. package/dist/theme/parse.d.cts.map +0 -1
  329. package/dist/theme/piTheme.d.cts +0 -19
  330. package/dist/theme/piTheme.d.cts.map +0 -1
  331. package/dist/theme/preference.d.cts +0 -15
  332. package/dist/theme/preference.d.cts.map +0 -1
  333. package/dist/theme.d.cts +0 -8
  334. package/dist/types/editor.d.cts +0 -78
  335. package/dist/types/editor.d.cts.map +0 -1
  336. package/dist/types/theme.d.cts +0 -38
  337. package/dist/types/theme.d.cts.map +0 -1
  338. package/dist/types/tone.d.cts +0 -28
  339. package/dist/types/tone.d.cts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","names":["CheckboxPrimitive","cn","CheckIcon"],"sources":["../../../src/components/Checkbox.tsx"],"sourcesContent":["import { Checkbox as CheckboxPrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { CheckIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\n\n/** A box that is on, off, or indeterminate; the tick is the accent on the deep well. */\nexport function Checkbox({ className, ...props }: ComponentProps<typeof CheckboxPrimitive.Root>) {\n return (\n <CheckboxPrimitive.Root\n data-slot=\"checkbox\"\n className={cn(\n 'flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue',\n className,\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator data-slot=\"checkbox-indicator\" className=\"text-doom-blue\">\n <CheckIcon className=\"h-2.5 w-2.5\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n"],"mappings":"kJAOA,SAAgB,EAAS,CAAE,YAAW,GAAG,GAAwD,CAC/F,OACE,EAAA,EAAA,IAAA,CAACA,EAAAA,SAAkB,KAAnB,CACE,YAAU,WACV,UAAWC,EAAAA,GACT,gVACA,CACF,EACA,GAAI,EAEJ,UAAA,EAAA,EAAA,IAAA,CAACD,EAAAA,SAAkB,UAAnB,CAA6B,YAAU,qBAAqB,UAAU,iBACpE,UAAA,EAAA,EAAA,IAAA,CAACE,EAAAA,MAAD,CAAW,UAAU,aAAe,CAAA,CACT,CAAA,CACP,CAAA,CAE5B"}
1
+ {"version":3,"file":"Checkbox.cjs","names":["CheckboxPrimitive","cn","CheckIcon"],"sources":["../../../src/components/Checkbox.tsx"],"sourcesContent":["import { Checkbox as CheckboxPrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { CheckIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\n\n/** A box that is on, off, or indeterminate; the tick is the accent on the deep well. */\nexport function Checkbox({ className, ...props }: ComponentProps<typeof CheckboxPrimitive.Root>) {\n return (\n <CheckboxPrimitive.Root\n data-slot=\"checkbox\"\n className={cn(\n 'flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue',\n className,\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator data-slot=\"checkbox-indicator\" className=\"text-doom-blue\">\n <CheckIcon className=\"h-2.5 w-2.5\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n"],"mappings":"kJAOA,SAAgB,EAAS,CAAE,YAAW,GAAG,GAAwD,CAC/F,MACE,iBAAA,EAAA,EAAA,IAAA,CAACA,EAAAA,SAAkB,KAAnB,CACE,YAAU,WACV,UAAWC,EAAAA,GACT,gVACA,CACF,EACA,GAAI,EAEJ,SAAA,iBAAA,EAAA,EAAA,IAAA,CAACD,EAAAA,SAAkB,UAAnB,CAA6B,YAAU,qBAAqB,UAAU,iBACpE,SAAA,iBAAA,EAAA,EAAA,IAAA,CAACE,EAAAA,MAAD,CAAW,UAAU,aAAe,CAAA,CACT,CAAA,CACP,CAAA,CAE5B"}
@@ -1,2 +1,2 @@
1
- import{CheckIcon as e}from"../icons/icons.mjs";import{cn as t}from"../lib/cn.mjs";import{Checkbox as n}from"radix-ui";import{jsx as r}from"react/jsx-runtime";function i({className:i,...a}){return r(n.Root,{"data-slot":`checkbox`,className:t(`flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue`,i),...a,children:r(n.Indicator,{"data-slot":`checkbox-indicator`,className:`text-doom-blue`,children:r(e,{className:`h-2.5 w-2.5`})})})}export{i as Checkbox};
1
+ import{CheckIcon as e}from"../icons/icons.mjs";import{cn as t}from"../lib/cn.mjs";import{Checkbox as n}from"radix-ui";import{jsx as r}from"react/jsx-runtime";function i({className:i,...a}){return/* @__PURE__ */ r(n.Root,{"data-slot":`checkbox`,className:t(`flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue`,i),...a,children:/* @__PURE__ */ r(n.Indicator,{"data-slot":`checkbox-indicator`,className:`text-doom-blue`,children:/* @__PURE__ */ r(e,{className:`h-2.5 w-2.5`})})})}export{i as Checkbox};
2
2
  //# sourceMappingURL=Checkbox.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.mjs","names":["Checkbox","CheckboxPrimitive"],"sources":["../../../src/components/Checkbox.tsx"],"sourcesContent":["import { Checkbox as CheckboxPrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { CheckIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\n\n/** A box that is on, off, or indeterminate; the tick is the accent on the deep well. */\nexport function Checkbox({ className, ...props }: ComponentProps<typeof CheckboxPrimitive.Root>) {\n return (\n <CheckboxPrimitive.Root\n data-slot=\"checkbox\"\n className={cn(\n 'flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue',\n className,\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator data-slot=\"checkbox-indicator\" className=\"text-doom-blue\">\n <CheckIcon className=\"h-2.5 w-2.5\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n"],"mappings":"8JAOA,SAAgBA,EAAS,CAAE,YAAW,GAAG,GAAwD,CAC/F,OACE,EAACC,EAAkB,KAAnB,CACE,YAAU,WACV,UAAW,EACT,gVACA,CACF,EACA,GAAI,EAEJ,SAAA,EAACA,EAAkB,UAAnB,CAA6B,YAAU,qBAAqB,UAAU,iBACpE,SAAA,EAAC,EAAD,CAAW,UAAU,aAAe,CAAA,CACT,CAAA,CACP,CAAA,CAE5B"}
1
+ {"version":3,"file":"Checkbox.mjs","names":["Checkbox","CheckboxPrimitive"],"sources":["../../../src/components/Checkbox.tsx"],"sourcesContent":["import { Checkbox as CheckboxPrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { CheckIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\n\n/** A box that is on, off, or indeterminate; the tick is the accent on the deep well. */\nexport function Checkbox({ className, ...props }: ComponentProps<typeof CheckboxPrimitive.Root>) {\n return (\n <CheckboxPrimitive.Root\n data-slot=\"checkbox\"\n className={cn(\n 'flex h-3.5 w-3.5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-doom-border bg-doom-deep outline-none transition-colors focus-visible:ring-2 focus-visible:ring-doom-blue/50 disabled:pointer-events-none disabled:opacity-40 data-[state=checked]:border-doom-blue data-[state=indeterminate]:border-doom-blue',\n className,\n )}\n {...props}\n >\n <CheckboxPrimitive.Indicator data-slot=\"checkbox-indicator\" className=\"text-doom-blue\">\n <CheckIcon className=\"h-2.5 w-2.5\" />\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n"],"mappings":"8JAOA,SAAgBA,EAAS,CAAE,YAAW,GAAG,GAAwD,CAC/F,MACE,kBAACC,EAAkB,KAAnB,CACE,YAAU,WACV,UAAW,EACT,gVACA,CACF,EACA,GAAI,EAEJ,SAAA,kBAACA,EAAkB,UAAnB,CAA6B,YAAU,qBAAqB,UAAU,iBACpE,SAAA,kBAAC,EAAD,CAAW,UAAU,aAAe,CAAA,CACT,CAAA,CACP,CAAA,CAE5B"}
@@ -1,2 +1,2 @@
1
- const e=require("./SyntaxText.cjs"),t=require("../lib/fenceGrammar.cjs"),n=require("./CopyButton.cjs"),r=require("./MermaidDiagram.cjs");let i=require("react/jsx-runtime");function a({text:a,className:o}){let s=t.fenceLanguageOf(o),c=s===`mermaid`?(0,i.jsx)(r.MermaidDiagram,{code:a}):(0,i.jsx)(e.SyntaxText,{text:a,grammar:t.fenceGrammarOf(s),className:`overflow-x-auto text-sm leading-relaxed text-doom-text`});return(0,i.jsxs)(`div`,{"data-slot":`code-block`,"data-language":s??``,className:`relative rounded border border-doom-border bg-doom-deep p-2.5`,children:[c,(0,i.jsx)(n.CopyButton,{text:a,className:`absolute top-1.5 right-1.5`})]})}exports.CodeBlock=a;
1
+ const e=require("./SyntaxText.cjs"),t=require("../lib/fenceGrammar.cjs"),n=require("./CopyButton.cjs"),r=require("./MermaidDiagram.cjs");let i=require("react/jsx-runtime");function a({text:a,className:o}){let s=t.fenceLanguageOf(o),c=s===`mermaid`?/* @__PURE__ */ (0,i.jsx)(r.MermaidDiagram,{code:a}):/* @__PURE__ */ (0,i.jsx)(e.SyntaxText,{text:a,grammar:t.fenceGrammarOf(s),className:`overflow-x-auto text-sm leading-relaxed text-doom-text`});return/* @__PURE__ */ (0,i.jsxs)(`div`,{"data-slot":`code-block`,"data-language":s??``,className:`relative rounded border border-doom-border bg-doom-deep p-2.5`,children:[c,/* @__PURE__ */ (0,i.jsx)(n.CopyButton,{text:a,className:`absolute top-1.5 right-1.5`})]})}exports.CodeBlock=a;
2
2
  //# sourceMappingURL=CodeBlock.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.cjs","names":["fenceLanguageOf","MermaidDiagram","SyntaxText","fenceGrammarOf","CopyButton"],"sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["import { fenceGrammarOf, fenceLanguageOf, MERMAID_LANGUAGE } from '../lib/fenceGrammar';\nimport { CopyButton } from './CopyButton';\nimport { MermaidDiagram } from './MermaidDiagram';\nimport { SyntaxText } from './SyntaxText';\n\n/**\n * A fenced code block: coloured, copyable, and a picture when it is mermaid.\n *\n * DESIGN PATTERNS:\n * - The fence's own word picks the grammar, and an unknown word means plain\n * text rather than a guess at the wrong language.\n * - Colour and the diagram both arrive asynchronously, so the block always has\n * the source on screen from the first frame of a streaming reply.\n *\n * AVOID:\n * - Reading the language anywhere but the fence. A block in a message has no\n * path, and guessing from the body colours prose as code.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The `language-*` class react-markdown puts on the inner <code>. */\n className?: string | undefined;\n}\n\nexport function CodeBlock({ text, className }: CodeBlockProps) {\n const language = fenceLanguageOf(className);\n const body =\n language === MERMAID_LANGUAGE ? (\n <MermaidDiagram code={text} />\n ) : (\n <SyntaxText\n text={text}\n grammar={fenceGrammarOf(language)}\n className=\"overflow-x-auto text-sm leading-relaxed text-doom-text\"\n />\n );\n return (\n <div\n data-slot=\"code-block\"\n data-language={language ?? ''}\n className=\"relative rounded border border-doom-border bg-doom-deep p-2.5\"\n >\n {body}\n <CopyButton text={text} className=\"absolute top-1.5 right-1.5\" />\n </div>\n );\n}\n"],"mappings":"4KA0BA,SAAgB,EAAU,CAAE,OAAM,aAA6B,CAC7D,IAAM,EAAWA,EAAAA,gBAAgB,CAAS,EACpC,EACJ,IAAA,WACE,EAAA,EAAA,IAAA,CAACC,EAAAA,eAAD,CAAgB,KAAM,CAAO,CAAA,GAE7B,EAAA,EAAA,IAAA,CAACC,EAAAA,WAAD,CACQ,OACN,QAASC,EAAAA,eAAe,CAAQ,EAChC,UAAU,wDACX,CAAA,EAEL,OACE,EAAA,EAAA,KAAA,CAAC,MAAD,CACE,YAAU,aACV,gBAAe,GAAY,GAC3B,UAAU,gEAHZ,SAAA,CAKG,GACD,EAAA,EAAA,IAAA,CAACC,EAAAA,WAAD,CAAkB,OAAM,UAAU,4BAA8B,CAAA,CAC7D,GAET"}
1
+ {"version":3,"file":"CodeBlock.cjs","names":["fenceLanguageOf","MermaidDiagram","SyntaxText","fenceGrammarOf","CopyButton"],"sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["import { fenceGrammarOf, fenceLanguageOf, MERMAID_LANGUAGE } from '../lib/fenceGrammar';\nimport { CopyButton } from './CopyButton';\nimport { MermaidDiagram } from './MermaidDiagram';\nimport { SyntaxText } from './SyntaxText';\n\n/**\n * A fenced code block: coloured, copyable, and a picture when it is mermaid.\n *\n * DESIGN PATTERNS:\n * - The fence's own word picks the grammar, and an unknown word means plain\n * text rather than a guess at the wrong language.\n * - Colour and the diagram both arrive asynchronously, so the block always has\n * the source on screen from the first frame of a streaming reply.\n *\n * AVOID:\n * - Reading the language anywhere but the fence. A block in a message has no\n * path, and guessing from the body colours prose as code.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The `language-*` class react-markdown puts on the inner <code>. */\n className?: string | undefined;\n}\n\nexport function CodeBlock({ text, className }: CodeBlockProps) {\n const language = fenceLanguageOf(className);\n const body =\n language === MERMAID_LANGUAGE ? (\n <MermaidDiagram code={text} />\n ) : (\n <SyntaxText\n text={text}\n grammar={fenceGrammarOf(language)}\n className=\"overflow-x-auto text-sm leading-relaxed text-doom-text\"\n />\n );\n return (\n <div\n data-slot=\"code-block\"\n data-language={language ?? ''}\n className=\"relative rounded border border-doom-border bg-doom-deep p-2.5\"\n >\n {body}\n <CopyButton text={text} className=\"absolute top-1.5 right-1.5\" />\n </div>\n );\n}\n"],"mappings":"4KA0BA,SAAgB,EAAU,CAAE,OAAM,aAA6B,CAC7D,IAAM,EAAWA,EAAAA,gBAAgB,CAAS,EACpC,EACJ,IAAA,UACE,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,eAAD,CAAgB,KAAM,CAAO,CAAA,EAE7B,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,WAAD,CACQ,OACN,QAASC,EAAAA,eAAe,CAAQ,EAChC,UAAU,wDACX,CAAA,EAEL,MACE,iBAAA,EAAA,EAAA,KAAA,CAAC,MAAD,CACE,YAAU,aACV,gBAAe,GAAY,GAC3B,UAAU,gEAHZ,SAAA,CAKG,EACD,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,WAAD,CAAkB,OAAM,UAAU,4BAA8B,CAAA,CAC7D,GAET"}
@@ -1,2 +1,2 @@
1
- import{SyntaxText as e}from"./SyntaxText.mjs";import{fenceGrammarOf as t,fenceLanguageOf as n}from"../lib/fenceGrammar.mjs";import{CopyButton as r}from"./CopyButton.mjs";import{MermaidDiagram as i}from"./MermaidDiagram.mjs";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s({text:s,className:c}){let l=n(c),u=l===`mermaid`?a(i,{code:s}):a(e,{text:s,grammar:t(l),className:`overflow-x-auto text-sm leading-relaxed text-doom-text`});return o(`div`,{"data-slot":`code-block`,"data-language":l??``,className:`relative rounded border border-doom-border bg-doom-deep p-2.5`,children:[u,a(r,{text:s,className:`absolute top-1.5 right-1.5`})]})}export{s as CodeBlock};
1
+ import{SyntaxText as e}from"./SyntaxText.mjs";import{fenceGrammarOf as t,fenceLanguageOf as n}from"../lib/fenceGrammar.mjs";import{CopyButton as r}from"./CopyButton.mjs";import{MermaidDiagram as i}from"./MermaidDiagram.mjs";import{jsx as a,jsxs as o}from"react/jsx-runtime";function s({text:s,className:c}){let l=n(c),u=l===`mermaid`?/* @__PURE__ */ a(i,{code:s}):/* @__PURE__ */ a(e,{text:s,grammar:t(l),className:`overflow-x-auto text-sm leading-relaxed text-doom-text`});return/* @__PURE__ */ o(`div`,{"data-slot":`code-block`,"data-language":l??``,className:`relative rounded border border-doom-border bg-doom-deep p-2.5`,children:[u,/* @__PURE__ */ a(r,{text:s,className:`absolute top-1.5 right-1.5`})]})}export{s as CodeBlock};
2
2
  //# sourceMappingURL=CodeBlock.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.mjs","names":[],"sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["import { fenceGrammarOf, fenceLanguageOf, MERMAID_LANGUAGE } from '../lib/fenceGrammar';\nimport { CopyButton } from './CopyButton';\nimport { MermaidDiagram } from './MermaidDiagram';\nimport { SyntaxText } from './SyntaxText';\n\n/**\n * A fenced code block: coloured, copyable, and a picture when it is mermaid.\n *\n * DESIGN PATTERNS:\n * - The fence's own word picks the grammar, and an unknown word means plain\n * text rather than a guess at the wrong language.\n * - Colour and the diagram both arrive asynchronously, so the block always has\n * the source on screen from the first frame of a streaming reply.\n *\n * AVOID:\n * - Reading the language anywhere but the fence. A block in a message has no\n * path, and guessing from the body colours prose as code.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The `language-*` class react-markdown puts on the inner <code>. */\n className?: string | undefined;\n}\n\nexport function CodeBlock({ text, className }: CodeBlockProps) {\n const language = fenceLanguageOf(className);\n const body =\n language === MERMAID_LANGUAGE ? (\n <MermaidDiagram code={text} />\n ) : (\n <SyntaxText\n text={text}\n grammar={fenceGrammarOf(language)}\n className=\"overflow-x-auto text-sm leading-relaxed text-doom-text\"\n />\n );\n return (\n <div\n data-slot=\"code-block\"\n data-language={language ?? ''}\n className=\"relative rounded border border-doom-border bg-doom-deep p-2.5\"\n >\n {body}\n <CopyButton text={text} className=\"absolute top-1.5 right-1.5\" />\n </div>\n );\n}\n"],"mappings":"kRA0BA,SAAgB,EAAU,CAAE,OAAM,aAA6B,CAC7D,IAAM,EAAW,EAAgB,CAAS,EACpC,EACJ,IAAA,UACE,EAAC,EAAD,CAAgB,KAAM,CAAO,CAAA,EAE7B,EAAC,EAAD,CACQ,OACN,QAAS,EAAe,CAAQ,EAChC,UAAU,wDACX,CAAA,EAEL,OACE,EAAC,MAAD,CACE,YAAU,aACV,gBAAe,GAAY,GAC3B,UAAU,gEAHZ,SAAA,CAKG,EACD,EAAC,EAAD,CAAkB,OAAM,UAAU,4BAA8B,CAAA,CAC7D,GAET"}
1
+ {"version":3,"file":"CodeBlock.mjs","names":[],"sources":["../../../src/components/CodeBlock.tsx"],"sourcesContent":["import { fenceGrammarOf, fenceLanguageOf, MERMAID_LANGUAGE } from '../lib/fenceGrammar';\nimport { CopyButton } from './CopyButton';\nimport { MermaidDiagram } from './MermaidDiagram';\nimport { SyntaxText } from './SyntaxText';\n\n/**\n * A fenced code block: coloured, copyable, and a picture when it is mermaid.\n *\n * DESIGN PATTERNS:\n * - The fence's own word picks the grammar, and an unknown word means plain\n * text rather than a guess at the wrong language.\n * - Colour and the diagram both arrive asynchronously, so the block always has\n * the source on screen from the first frame of a streaming reply.\n *\n * AVOID:\n * - Reading the language anywhere but the fence. A block in a message has no\n * path, and guessing from the body colours prose as code.\n */\n\nexport interface CodeBlockProps {\n /** The block's source, without the fence lines. */\n text: string;\n /** The `language-*` class react-markdown puts on the inner <code>. */\n className?: string | undefined;\n}\n\nexport function CodeBlock({ text, className }: CodeBlockProps) {\n const language = fenceLanguageOf(className);\n const body =\n language === MERMAID_LANGUAGE ? (\n <MermaidDiagram code={text} />\n ) : (\n <SyntaxText\n text={text}\n grammar={fenceGrammarOf(language)}\n className=\"overflow-x-auto text-sm leading-relaxed text-doom-text\"\n />\n );\n return (\n <div\n data-slot=\"code-block\"\n data-language={language ?? ''}\n className=\"relative rounded border border-doom-border bg-doom-deep p-2.5\"\n >\n {body}\n <CopyButton text={text} className=\"absolute top-1.5 right-1.5\" />\n </div>\n );\n}\n"],"mappings":"kRA0BA,SAAgB,EAAU,CAAE,OAAM,aAA6B,CAC7D,IAAM,EAAW,EAAgB,CAAS,EACpC,EACJ,IAAA,UACE,kBAAC,EAAD,CAAgB,KAAM,CAAO,CAAA,EAE7B,kBAAC,EAAD,CACQ,OACN,QAAS,EAAe,CAAQ,EAChC,UAAU,wDACX,CAAA,EAEL,MACE,kBAAC,MAAD,CACE,YAAU,aACV,gBAAe,GAAY,GAC3B,UAAU,gEAHZ,SAAA,CAKG,EACD,kBAAC,EAAD,CAAkB,OAAM,UAAU,4BAA8B,CAAA,CAC7D,GAET"}
@@ -1,2 +1,2 @@
1
- const e=require("../lib/cn.cjs"),t=require("./Skeleton.cjs");let n=require("react/jsx-runtime"),r=require("react");const i=(0,r.lazy)(async()=>({default:(await Promise.resolve().then(()=>require("./CodeEditorView.cjs"))).CodeEditorView}));function a({className:a,...o}){return(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)(t.Skeleton,{className:e.cn(`min-h-0`,a)}),children:(0,n.jsx)(i,{className:a,...o})})}exports.CodeEditor=a;
1
+ const e=require("../lib/cn.cjs"),t=require("./Skeleton.cjs");let n=require("react/jsx-runtime"),r=require("react");const i=(0,r.lazy)(async()=>({default:(await Promise.resolve().then(()=>require("./CodeEditorView.cjs"))).CodeEditorView}));function a({className:a,...o}){return/* @__PURE__ */ (0,n.jsx)(r.Suspense,{fallback:/* @__PURE__ */ (0,n.jsx)(t.Skeleton,{className:e.cn(`min-h-0`,a)}),children:/* @__PURE__ */ (0,n.jsx)(i,{className:a,...o})})}exports.CodeEditor=a;
2
2
  //# sourceMappingURL=CodeEditor.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.cjs","names":["lazy","Suspense","Skeleton","cn"],"sources":["../../../src/components/CodeEditor.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\n\nimport { cn } from '../lib/cn';\nimport type { CodeEditorProps } from '../types/editor';\nimport { Skeleton } from './Skeleton';\n\n/**\n * A code editor: line numbers, syntax colour, folding, undo, and a search\n * panel on the usual keys.\n *\n * The editor arrives as its own chunk. The cockpit is one bundle that every\n * session downloads, most of them without ever opening a file, and it is read\n * over a tunnel as often as over localhost; an editor nobody opened has no\n * business in that first load. What this module holds is the boundary, so the\n * cost is paid on the first render that asks for an editor and never again.\n */\nconst CodeEditorView = lazy(async () => ({ default: (await import('./CodeEditorView')).CodeEditorView }));\n\nexport function CodeEditor({ className, ...props }: CodeEditorProps) {\n return (\n <Suspense fallback={<Skeleton className={cn('min-h-0', className)} />}>\n <CodeEditorView className={className} {...props} />\n </Suspense>\n );\n}\n"],"mappings":"mHAgBA,MAAM,GAAA,EAAiBA,EAAAA,KAAAA,CAAK,UAAa,CAAE,SAAU,MAAA,QAAA,QAAA,CAAA,CAAA,SAAA,QAAM,sBAAA,CAAA,EAAA,CAA4B,cAAe,EAAE,EAExG,SAAgB,EAAW,CAAE,YAAW,GAAG,GAA0B,CACnE,OACE,EAAA,EAAA,IAAA,CAACC,EAAAA,SAAD,CAAU,UAAU,EAAA,EAAA,IAAA,CAACC,EAAAA,SAAD,CAAU,UAAWC,EAAAA,GAAG,UAAW,CAAS,CAAI,CAAA,EAClE,UAAA,EAAA,EAAA,IAAA,CAAC,EAAD,CAA2B,YAAW,GAAI,CAAQ,CAAA,CAC1C,CAAA,CAEd"}
1
+ {"version":3,"file":"CodeEditor.cjs","names":["lazy","Suspense","Skeleton","cn"],"sources":["../../../src/components/CodeEditor.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\n\nimport { cn } from '../lib/cn';\nimport type { CodeEditorProps } from '../types/editor';\nimport { Skeleton } from './Skeleton';\n\n/**\n * A code editor: line numbers, syntax colour, folding, undo, and a search\n * panel on the usual keys.\n *\n * The editor arrives as its own chunk. The cockpit is one bundle that every\n * session downloads, most of them without ever opening a file, and it is read\n * over a tunnel as often as over localhost; an editor nobody opened has no\n * business in that first load. What this module holds is the boundary, so the\n * cost is paid on the first render that asks for an editor and never again.\n */\nconst CodeEditorView = lazy(async () => ({ default: (await import('./CodeEditorView')).CodeEditorView }));\n\nexport function CodeEditor({ className, ...props }: CodeEditorProps) {\n return (\n <Suspense fallback={<Skeleton className={cn('min-h-0', className)} />}>\n <CodeEditorView className={className} {...props} />\n </Suspense>\n );\n}\n"],"mappings":"mHAgBA,MAAM,GAAA,EAAiBA,EAAAA,KAAAA,CAAK,UAAa,CAAE,SAAU,MAAA,QAAA,QAAA,CAAA,CAAA,SAAA,QAAM,sBAAA,CAAA,EAAA,CAA4B,cAAe,EAAE,EAExG,SAAgB,EAAW,CAAE,YAAW,GAAG,GAA0B,CACnE,MACE,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,SAAD,CAAU,SAAU,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,SAAD,CAAU,UAAWC,EAAAA,GAAG,UAAW,CAAS,CAAI,CAAA,EAClE,SAAA,iBAAA,EAAA,EAAA,IAAA,CAAC,EAAD,CAA2B,YAAW,GAAI,CAAQ,CAAA,CAC1C,CAAA,CAEd"}
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../lib/cn.mjs";import{Skeleton as t}from"./Skeleton.mjs";import{jsx as n}from"react/jsx-runtime";import{Suspense as r,lazy as i}from"react";const a=i(async()=>({default:(await import(`./CodeEditorView.mjs`)).CodeEditorView}));function o({className:i,...o}){return n(r,{fallback:n(t,{className:e(`min-h-0`,i)}),children:n(a,{className:i,...o})})}export{o as CodeEditor};
1
+ import{cn as e}from"../lib/cn.mjs";import{Skeleton as t}from"./Skeleton.mjs";import{jsx as n}from"react/jsx-runtime";import{Suspense as r,lazy as i}from"react";const a=i(async()=>({default:(await import(`./CodeEditorView.mjs`)).CodeEditorView}));function o({className:i,...o}){return/* @__PURE__ */ n(r,{fallback:/* @__PURE__ */ n(t,{className:e(`min-h-0`,i)}),children:/* @__PURE__ */ n(a,{className:i,...o})})}export{o as CodeEditor};
2
2
  //# sourceMappingURL=CodeEditor.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.mjs","names":[],"sources":["../../../src/components/CodeEditor.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\n\nimport { cn } from '../lib/cn';\nimport type { CodeEditorProps } from '../types/editor';\nimport { Skeleton } from './Skeleton';\n\n/**\n * A code editor: line numbers, syntax colour, folding, undo, and a search\n * panel on the usual keys.\n *\n * The editor arrives as its own chunk. The cockpit is one bundle that every\n * session downloads, most of them without ever opening a file, and it is read\n * over a tunnel as often as over localhost; an editor nobody opened has no\n * business in that first load. What this module holds is the boundary, so the\n * cost is paid on the first render that asks for an editor and never again.\n */\nconst CodeEditorView = lazy(async () => ({ default: (await import('./CodeEditorView')).CodeEditorView }));\n\nexport function CodeEditor({ className, ...props }: CodeEditorProps) {\n return (\n <Suspense fallback={<Skeleton className={cn('min-h-0', className)} />}>\n <CodeEditorView className={className} {...props} />\n </Suspense>\n );\n}\n"],"mappings":"gKAgBA,MAAM,EAAiB,EAAK,UAAa,CAAE,SAAU,MAAM,OAAO,wBAAA,CAAqB,cAAe,EAAE,EAExG,SAAgB,EAAW,CAAE,YAAW,GAAG,GAA0B,CACnE,OACE,EAAC,EAAD,CAAU,SAAU,EAAC,EAAD,CAAU,UAAW,EAAG,UAAW,CAAS,CAAI,CAAA,EAClE,SAAA,EAAC,EAAD,CAA2B,YAAW,GAAI,CAAQ,CAAA,CAC1C,CAAA,CAEd"}
1
+ {"version":3,"file":"CodeEditor.mjs","names":[],"sources":["../../../src/components/CodeEditor.tsx"],"sourcesContent":["import { lazy, Suspense } from 'react';\n\nimport { cn } from '../lib/cn';\nimport type { CodeEditorProps } from '../types/editor';\nimport { Skeleton } from './Skeleton';\n\n/**\n * A code editor: line numbers, syntax colour, folding, undo, and a search\n * panel on the usual keys.\n *\n * The editor arrives as its own chunk. The cockpit is one bundle that every\n * session downloads, most of them without ever opening a file, and it is read\n * over a tunnel as often as over localhost; an editor nobody opened has no\n * business in that first load. What this module holds is the boundary, so the\n * cost is paid on the first render that asks for an editor and never again.\n */\nconst CodeEditorView = lazy(async () => ({ default: (await import('./CodeEditorView')).CodeEditorView }));\n\nexport function CodeEditor({ className, ...props }: CodeEditorProps) {\n return (\n <Suspense fallback={<Skeleton className={cn('min-h-0', className)} />}>\n <CodeEditorView className={className} {...props} />\n </Suspense>\n );\n}\n"],"mappings":"gKAgBA,MAAM,EAAiB,EAAK,UAAa,CAAE,SAAU,MAAM,OAAO,wBAAA,CAAqB,cAAe,EAAE,EAExG,SAAgB,EAAW,CAAE,YAAW,GAAG,GAA0B,CACnE,MACE,kBAAC,EAAD,CAAU,SAAU,kBAAC,EAAD,CAAU,UAAW,EAAG,UAAW,CAAS,CAAI,CAAA,EAClE,SAAA,kBAAC,EAAD,CAA2B,YAAW,GAAI,CAAQ,CAAA,CAC1C,CAAA,CAEd"}
@@ -1,2 +1,2 @@
1
- const e=require("../lib/cn.cjs"),t=require("../lib/editorLanguage.cjs"),n=require("../lib/editorTheme.cjs"),r=require("../lib/editorController.cjs");let i=require("react/jsx-runtime"),a=require("react"),o=require("@codemirror/commands"),s=require("@codemirror/language"),c=require("@codemirror/search"),l=require("@codemirror/state"),u=require("@codemirror/view"),d=require("@lezer/highlight");function f(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return{text:e.state.sliceDoc(r,i),from:r,to:i,startLine:e.state.doc.lineAt(r).number,endLine:e.state.doc.lineAt(i).number}}function p(e,t){let n=e.posAtCoords({x:t.left,y:t.top}),r=e.posAtCoords({x:t.right,y:t.bottom});return n===null||r===null?null:f(e,n,r)}const m=u.EditorView.theme(n.DOOM_EDITOR_STYLES),h=s.HighlightStyle.define([{tag:d.tags.comment,...n.DOOM_SYNTAX_STYLES.comment},{tag:d.tags.keyword,...n.DOOM_SYNTAX_STYLES.keyword},{tag:[d.tags.atom,d.tags.bool,d.tags.null,d.tags.self],...n.DOOM_SYNTAX_STYLES.constant},{tag:d.tags.number,...n.DOOM_SYNTAX_STYLES.literal},{tag:[d.tags.string,d.tags.special(d.tags.string),d.tags.character],...n.DOOM_SYNTAX_STYLES.string},{tag:d.tags.regexp,...n.DOOM_SYNTAX_STYLES.regexp},{tag:d.tags.operator,...n.DOOM_SYNTAX_STYLES.operator},{tag:d.tags.punctuation,...n.DOOM_SYNTAX_STYLES.punctuation},{tag:d.tags.variableName,...n.DOOM_SYNTAX_STYLES.variable},{tag:d.tags.propertyName,...n.DOOM_SYNTAX_STYLES.property},{tag:[d.tags.function(d.tags.variableName),d.tags.function(d.tags.propertyName)],...n.DOOM_SYNTAX_STYLES.callable},{tag:[d.tags.typeName,d.tags.className,d.tags.namespace],...n.DOOM_SYNTAX_STYLES.type},{tag:d.tags.tagName,...n.DOOM_SYNTAX_STYLES.tag},{tag:d.tags.attributeName,...n.DOOM_SYNTAX_STYLES.attribute},{tag:[d.tags.meta,d.tags.processingInstruction],...n.DOOM_SYNTAX_STYLES.meta},{tag:d.tags.heading,...n.DOOM_SYNTAX_STYLES.heading},{tag:[d.tags.link,d.tags.url],...n.DOOM_SYNTAX_STYLES.link},{tag:d.tags.emphasis,...n.DOOM_SYNTAX_STYLES.emphasis},{tag:d.tags.strong,...n.DOOM_SYNTAX_STYLES.strong},{tag:d.tags.strikethrough,...n.DOOM_SYNTAX_STYLES.strikethrough},{tag:d.tags.invalid,...n.DOOM_SYNTAX_STYLES.invalid}]),g=l.StateEffect.define(),_=l.StateField.define({create:()=>u.Decoration.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(g)&&(n=e.value);return n},provide:e=>u.EditorView.decorations.from(e)}),v=l.StateEffect.define(),y=l.StateField.define({create:()=>u.Decoration.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(v)&&(n=e.value);return n},provide:e=>u.EditorView.decorations.from(e)});var b=class extends u.WidgetType{label;constructor(e){super(),this.label=e}eq(e){return e.label===this.label}toDOM(){let e=document.createElement(`span`);return e.className=`cm-marked-region-label`,e.dataset.authorRegionLabel=this.label,e.textContent=this.label,e}};const x=u.EditorView.baseTheme({".cm-marked-region":{backgroundColor:`var(--doom-tint-yellow)`,borderBottom:`1px solid var(--doom-edge-yellow)`},".cm-marked-region-label":{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:`16px`,height:`16px`,marginRight:`4px`,borderRadius:`999px`,backgroundColor:`var(--doom-yellow)`,color:`var(--doom-deep)`,fontSize:`9px`,fontWeight:`700`,lineHeight:`1`,verticalAlign:`text-bottom`}}),S=[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)(),(0,s.foldGutter)(),(0,u.highlightActiveLine)(),(0,u.drawSelection)(),(0,u.rectangularSelection)(),(0,s.indentOnInput)(),(0,s.bracketMatching)(),(0,o.history)(),(0,c.search)({top:!0}),(0,c.highlightSelectionMatches)(),u.keymap.of([...o.defaultKeymap,...o.historyKeymap,...c.searchKeymap,...s.foldKeymap,o.indentWithTab]),(0,s.syntaxHighlighting)(h),_,y,x,m];function C({value:n,path:o,readOnly:s=!1,lineWrapping:c=!0,className:d,onChange:m,onSelect:h,controllerRef:_,"data-testid":y}){let x=(0,a.useRef)(null),C=(0,a.useRef)(null),w=(0,a.useRef)({onChange:m,onSelect:h}),T=(0,a.useRef)(n),E=(0,a.useRef)({language:new l.Compartment,readOnly:new l.Compartment,wrapping:new l.Compartment});return(0,a.useEffect)(()=>{w.current={onChange:m,onSelect:h}}),(0,a.useLayoutEffect)(()=>{let e=x.current;if(e===null)return;let{language:t,readOnly:n,wrapping:r}=E.current,i=new u.EditorView({parent:e,state:l.EditorState.create({doc:T.current,extensions:[...S,t.of([]),n.of([]),r.of([]),u.EditorView.updateListener.of(e=>{if(e.docChanged&&w.current.onChange?.(e.state.doc.toString()),!e.selectionSet&&!e.docChanged)return;let t=w.current.onSelect;if(t===void 0)return;let n=e.state.selection.main;t(f(e.view,n.from,n.to))})]})});return C.current=i,()=>{i.destroy(),C.current=null}},[]),(0,a.useImperativeHandle)(_,()=>({focus:()=>C.current?.focus(),revealAndSelect:e=>{let t=C.current;if(t===null)return;let[n]=r.boundedEditorRanges(t.state.doc.length,[e]);n!==void 0&&t.dispatch({selection:{anchor:n.from,head:n.to},effects:u.EditorView.scrollIntoView(n.from,{y:`center`})})},applyEdits:e=>{let t=C.current;t!==null&&e.length!==0&&t.dispatch({changes:r.boundedEditorEdits(t.state.doc.length,e)})},setClosedRanges:e=>{let t=C.current;if(t===null)return;let n=r.boundedEditorRanges(t.state.doc.length,e).map(e=>e.from===e.to?u.Decoration.line({attributes:{class:`cm-closed-tone`,"data-tone":`closed`}}).range(t.state.doc.lineAt(e.from).from):u.Decoration.mark({class:`cm-closed-tone`,attributes:{"data-tone":`closed`}}).range(e.from,e.to));t.dispatch({effects:g.of(u.Decoration.set(n))})},setMarkedRanges:e=>{let t=C.current;if(t===null)return;let n=e.flatMap(e=>{let[n]=r.boundedEditorRanges(t.state.doc.length,[e]);return n===void 0||n.from===n.to?[]:[u.Decoration.widget({widget:new b(e.label),side:-1}).range(n.from),u.Decoration.mark({class:`cm-marked-region`,attributes:{"data-author-region":e.label}}).range(n.from,n.to)]});t.dispatch({effects:v.of(u.Decoration.set(n,!0))})},resolveViewportRegion:e=>{let t=C.current;return t===null?null:p(t,e)}}),[]),(0,a.useEffect)(()=>{let e=C.current;e!==null&&e.state.doc.toString()!==n&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:n}})},[n]),(0,a.useEffect)(()=>{C.current?.dispatch({effects:E.current.readOnly.reconfigure([l.EditorState.readOnly.of(s),u.EditorView.editable.of(!s)])})},[s]),(0,a.useEffect)(()=>{C.current?.dispatch({effects:E.current.wrapping.reconfigure(c?u.EditorView.lineWrapping:[])})},[c]),(0,a.useEffect)(()=>{let e=o===void 0?void 0:t.grammarKeyOf(o),{language:n}=E.current;if(e===void 0){C.current?.dispatch({effects:n.reconfigure([])});return}let r=!1;return t.loadGrammar(e).then(e=>{r||C.current?.dispatch({effects:n.reconfigure(e)})}).catch(()=>{r||C.current?.dispatch({effects:n.reconfigure([])})}),()=>{r=!0}},[o]),(0,i.jsx)(`div`,{ref:x,"data-testid":y,className:e.cn(`min-h-0 overflow-hidden`,d)})}exports.CodeEditorView=C,exports.resolveEditorViewportRegion=p;
1
+ const e=require("../lib/cn.cjs"),t=require("../lib/editorLanguage.cjs"),n=require("../lib/editorTheme.cjs"),r=require("../lib/editorController.cjs");let i=require("react/jsx-runtime"),a=require("react"),o=require("@codemirror/commands"),s=require("@codemirror/language"),c=require("@codemirror/search"),l=require("@codemirror/state"),u=require("@codemirror/view"),d=require("@lezer/highlight");function f(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return{text:e.state.sliceDoc(r,i),from:r,to:i,startLine:e.state.doc.lineAt(r).number,endLine:e.state.doc.lineAt(i).number}}function p(e,t){let n=e.posAtCoords({x:t.left,y:t.top}),r=e.posAtCoords({x:t.right,y:t.bottom});return n===null||r===null?null:f(e,n,r)}const m=u.EditorView.theme(n.DOOM_EDITOR_STYLES),h=s.HighlightStyle.define([{tag:d.tags.comment,...n.DOOM_SYNTAX_STYLES.comment},{tag:d.tags.keyword,...n.DOOM_SYNTAX_STYLES.keyword},{tag:[d.tags.atom,d.tags.bool,d.tags.null,d.tags.self],...n.DOOM_SYNTAX_STYLES.constant},{tag:d.tags.number,...n.DOOM_SYNTAX_STYLES.literal},{tag:[d.tags.string,d.tags.special(d.tags.string),d.tags.character],...n.DOOM_SYNTAX_STYLES.string},{tag:d.tags.regexp,...n.DOOM_SYNTAX_STYLES.regexp},{tag:d.tags.operator,...n.DOOM_SYNTAX_STYLES.operator},{tag:d.tags.punctuation,...n.DOOM_SYNTAX_STYLES.punctuation},{tag:d.tags.variableName,...n.DOOM_SYNTAX_STYLES.variable},{tag:d.tags.propertyName,...n.DOOM_SYNTAX_STYLES.property},{tag:[d.tags.function(d.tags.variableName),d.tags.function(d.tags.propertyName)],...n.DOOM_SYNTAX_STYLES.callable},{tag:[d.tags.typeName,d.tags.className,d.tags.namespace],...n.DOOM_SYNTAX_STYLES.type},{tag:d.tags.tagName,...n.DOOM_SYNTAX_STYLES.tag},{tag:d.tags.attributeName,...n.DOOM_SYNTAX_STYLES.attribute},{tag:[d.tags.meta,d.tags.processingInstruction],...n.DOOM_SYNTAX_STYLES.meta},{tag:d.tags.heading,...n.DOOM_SYNTAX_STYLES.heading},{tag:[d.tags.link,d.tags.url],...n.DOOM_SYNTAX_STYLES.link},{tag:d.tags.emphasis,...n.DOOM_SYNTAX_STYLES.emphasis},{tag:d.tags.strong,...n.DOOM_SYNTAX_STYLES.strong},{tag:d.tags.strikethrough,...n.DOOM_SYNTAX_STYLES.strikethrough},{tag:d.tags.invalid,...n.DOOM_SYNTAX_STYLES.invalid}]),g=l.StateEffect.define(),_=l.StateField.define({create:()=>u.Decoration.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(g)&&(n=e.value);return n},provide:e=>u.EditorView.decorations.from(e)}),v=l.StateEffect.define(),y=l.StateField.define({create:()=>u.Decoration.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(v)&&(n=e.value);return n},provide:e=>u.EditorView.decorations.from(e)});var b=class extends u.WidgetType{label;constructor(e){super(),this.label=e}eq(e){return e.label===this.label}toDOM(){let e=document.createElement(`span`);return e.className=`cm-marked-region-label`,e.dataset.authorRegionLabel=this.label,e.textContent=this.label,e}};const x=u.EditorView.baseTheme({".cm-marked-region":{backgroundColor:`var(--doom-tint-yellow)`,borderBottom:`1px solid var(--doom-edge-yellow)`},".cm-marked-region-label":{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:`16px`,height:`16px`,marginRight:`4px`,borderRadius:`999px`,backgroundColor:`var(--doom-yellow)`,color:`var(--doom-deep)`,fontSize:`9px`,fontWeight:`700`,lineHeight:`1`,verticalAlign:`text-bottom`}}),S=[(0,u.lineNumbers)(),(0,u.highlightActiveLineGutter)(),(0,s.foldGutter)(),(0,u.highlightActiveLine)(),(0,u.drawSelection)(),(0,u.rectangularSelection)(),(0,s.indentOnInput)(),(0,s.bracketMatching)(),(0,o.history)(),(0,c.search)({top:!0}),(0,c.highlightSelectionMatches)(),u.keymap.of([...o.defaultKeymap,...o.historyKeymap,...c.searchKeymap,...s.foldKeymap,o.indentWithTab]),(0,s.syntaxHighlighting)(h),_,y,x,m];function C({value:n,path:o,readOnly:s=!1,lineWrapping:c=!0,className:d,onChange:m,onSelect:h,controllerRef:_,"data-testid":y}){let x=(0,a.useRef)(null),C=(0,a.useRef)(null),w=(0,a.useRef)({onChange:m,onSelect:h}),T=(0,a.useRef)(n),E=(0,a.useRef)({language:new l.Compartment,readOnly:new l.Compartment,wrapping:new l.Compartment});return(0,a.useEffect)(()=>{w.current={onChange:m,onSelect:h}}),(0,a.useLayoutEffect)(()=>{let e=x.current;if(e===null)return;let{language:t,readOnly:n,wrapping:r}=E.current,i=new u.EditorView({parent:e,state:l.EditorState.create({doc:T.current,extensions:[...S,t.of([]),n.of([]),r.of([]),u.EditorView.updateListener.of(e=>{if(e.docChanged&&w.current.onChange?.(e.state.doc.toString()),!e.selectionSet&&!e.docChanged)return;let t=w.current.onSelect;if(t===void 0)return;let n=e.state.selection.main;t(f(e.view,n.from,n.to))})]})});return C.current=i,()=>{i.destroy(),C.current=null}},[]),(0,a.useImperativeHandle)(_,()=>({focus:()=>C.current?.focus(),revealAndSelect:e=>{let t=C.current;if(t===null)return;let[n]=r.boundedEditorRanges(t.state.doc.length,[e]);n!==void 0&&t.dispatch({selection:{anchor:n.from,head:n.to},effects:u.EditorView.scrollIntoView(n.from,{y:`center`})})},applyEdits:e=>{let t=C.current;t!==null&&e.length!==0&&t.dispatch({changes:r.boundedEditorEdits(t.state.doc.length,e)})},setClosedRanges:e=>{let t=C.current;if(t===null)return;let n=r.boundedEditorRanges(t.state.doc.length,e).map(e=>e.from===e.to?u.Decoration.line({attributes:{class:`cm-closed-tone`,"data-tone":`closed`}}).range(t.state.doc.lineAt(e.from).from):u.Decoration.mark({class:`cm-closed-tone`,attributes:{"data-tone":`closed`}}).range(e.from,e.to));t.dispatch({effects:g.of(u.Decoration.set(n))})},setMarkedRanges:e=>{let t=C.current;if(t===null)return;let n=e.flatMap(e=>{let[n]=r.boundedEditorRanges(t.state.doc.length,[e]);return n===void 0||n.from===n.to?[]:[u.Decoration.widget({widget:new b(e.label),side:-1}).range(n.from),u.Decoration.mark({class:`cm-marked-region`,attributes:{"data-author-region":e.label}}).range(n.from,n.to)]});t.dispatch({effects:v.of(u.Decoration.set(n,!0))})},resolveViewportRegion:e=>{let t=C.current;return t===null?null:p(t,e)}}),[]),(0,a.useEffect)(()=>{let e=C.current;e!==null&&e.state.doc.toString()!==n&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:n}})},[n]),(0,a.useEffect)(()=>{C.current?.dispatch({effects:E.current.readOnly.reconfigure([l.EditorState.readOnly.of(s),u.EditorView.editable.of(!s)])})},[s]),(0,a.useEffect)(()=>{C.current?.dispatch({effects:E.current.wrapping.reconfigure(c?u.EditorView.lineWrapping:[])})},[c]),(0,a.useEffect)(()=>{let e=o===void 0?void 0:t.grammarKeyOf(o),{language:n}=E.current;if(e===void 0){C.current?.dispatch({effects:n.reconfigure([])});return}let r=!1;return t.loadGrammar(e).then(e=>{r||C.current?.dispatch({effects:n.reconfigure(e)})}).catch(()=>{r||C.current?.dispatch({effects:n.reconfigure([])})}),()=>{r=!0}},[o]),/* @__PURE__ */ (0,i.jsx)(`div`,{ref:x,"data-testid":y,className:e.cn(`min-h-0 overflow-hidden`,d)})}exports.CodeEditorView=C,exports.resolveEditorViewportRegion=p;
2
2
  //# sourceMappingURL=CodeEditorView.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditorView.cjs","names":["EditorView","DOOM_EDITOR_STYLES","HighlightStyle","tags","DOOM_SYNTAX_STYLES","StateEffect","StateField","Decoration","WidgetType","lineNumbers","highlightActiveLineGutter","foldGutter","highlightActiveLine","drawSelection","rectangularSelection","indentOnInput","bracketMatching","history","search","highlightSelectionMatches","keymap","defaultKeymap","historyKeymap","searchKeymap","foldKeymap","indentWithTab","syntaxHighlighting","useRef","Compartment","EditorState","boundedEditorRanges","boundedEditorEdits","grammarKeyOf","loadGrammar","cn"],"sources":["../../../src/components/CodeEditorView.tsx"],"sourcesContent":["import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport {\n bracketMatching,\n foldGutter,\n foldKeymap,\n HighlightStyle,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { highlightSelectionMatches, search, searchKeymap } from '@codemirror/search';\nimport { Compartment, EditorState, StateEffect, StateField } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n drawSelection,\n EditorView,\n highlightActiveLine,\n highlightActiveLineGutter,\n keymap,\n lineNumbers,\n rectangularSelection,\n WidgetType,\n} from '@codemirror/view';\nimport { tags } from '@lezer/highlight';\nimport { useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { boundedEditorEdits, boundedEditorRanges } from '../lib/editorController';\nimport { grammarKeyOf, loadGrammar } from '../lib/editorLanguage';\nimport { DOOM_EDITOR_STYLES, DOOM_SYNTAX_STYLES } from '../lib/editorTheme';\nimport type { CodeEditorProps, EditorSelectionRange, EditorViewportRectangle } from '../types/editor';\n\nfunction selectionRange(editor: { readonly state: EditorState }, from: number, to: number): EditorSelectionRange {\n const start = Math.min(from, to);\n const end = Math.max(from, to);\n return {\n text: editor.state.sliceDoc(start, end),\n from: start,\n to: end,\n startLine: editor.state.doc.lineAt(start).number,\n endLine: editor.state.doc.lineAt(end).number,\n };\n}\n\nexport function resolveEditorViewportRegion(\n editor: {\n readonly state: EditorState;\n posAtCoords(coords: { x: number; y: number }): number | null;\n },\n rectangle: EditorViewportRectangle,\n): EditorSelectionRange | null {\n const start = editor.posAtCoords({ x: rectangle.left, y: rectangle.top });\n const end = editor.posAtCoords({ x: rectangle.right, y: rectangle.bottom });\n if (start === null || end === null) return null;\n return selectionRange(editor, start, end);\n}\n/**\n * The editor itself, mounted on a real CodeMirror view.\n *\n * Nothing imports this module directly: `CodeEditor` reaches it through a lazy\n * import so the whole editor, and every grammar under it, stays out of the\n * cockpit's first load. Behaviour lives here rather than in that wrapper so\n * the split costs one file and no indirection.\n *\n * The three things a caller can change after mount each sit in their own\n * compartment. Reconfiguring one is a transaction; rebuilding the editor would\n * throw away the undo history, the scroll position and the cursor, which is\n * what a reader loses if a parent re-render is allowed to remount this.\n */\n\n/** Not a colour or a layout choice: how CodeMirror is told to draw the doom palette. */\nconst DOOM_THEME = EditorView.theme(DOOM_EDITOR_STYLES);\n\nconst DOOM_HIGHLIGHT = HighlightStyle.define([\n { tag: tags.comment, ...DOOM_SYNTAX_STYLES.comment },\n { tag: tags.keyword, ...DOOM_SYNTAX_STYLES.keyword },\n { tag: [tags.atom, tags.bool, tags.null, tags.self], ...DOOM_SYNTAX_STYLES.constant },\n { tag: tags.number, ...DOOM_SYNTAX_STYLES.literal },\n { tag: [tags.string, tags.special(tags.string), tags.character], ...DOOM_SYNTAX_STYLES.string },\n { tag: tags.regexp, ...DOOM_SYNTAX_STYLES.regexp },\n { tag: tags.operator, ...DOOM_SYNTAX_STYLES.operator },\n { tag: tags.punctuation, ...DOOM_SYNTAX_STYLES.punctuation },\n { tag: tags.variableName, ...DOOM_SYNTAX_STYLES.variable },\n { tag: tags.propertyName, ...DOOM_SYNTAX_STYLES.property },\n { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], ...DOOM_SYNTAX_STYLES.callable },\n { tag: [tags.typeName, tags.className, tags.namespace], ...DOOM_SYNTAX_STYLES.type },\n { tag: tags.tagName, ...DOOM_SYNTAX_STYLES.tag },\n { tag: tags.attributeName, ...DOOM_SYNTAX_STYLES.attribute },\n { tag: [tags.meta, tags.processingInstruction], ...DOOM_SYNTAX_STYLES.meta },\n { tag: tags.heading, ...DOOM_SYNTAX_STYLES.heading },\n { tag: [tags.link, tags.url], ...DOOM_SYNTAX_STYLES.link },\n { tag: tags.emphasis, ...DOOM_SYNTAX_STYLES.emphasis },\n { tag: tags.strong, ...DOOM_SYNTAX_STYLES.strong },\n { tag: tags.strikethrough, ...DOOM_SYNTAX_STYLES.strikethrough },\n { tag: tags.invalid, ...DOOM_SYNTAX_STYLES.invalid },\n]);\n\nconst setClosedDecorations = StateEffect.define<DecorationSet>();\nconst closedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setClosedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nconst setMarkedDecorations = StateEffect.define<DecorationSet>();\nconst markedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setMarkedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nclass MarkedRangeLabel extends WidgetType {\n constructor(private readonly label: string) {\n super();\n }\n\n eq(other: MarkedRangeLabel): boolean {\n return other.label === this.label;\n }\n\n toDOM(): HTMLElement {\n const label = document.createElement('span');\n label.className = 'cm-marked-region-label';\n label.dataset.authorRegionLabel = this.label;\n label.textContent = this.label;\n return label;\n }\n}\n\nconst MARKED_REGION_THEME = EditorView.baseTheme({\n '.cm-marked-region': {\n backgroundColor: 'var(--doom-tint-yellow)',\n borderBottom: '1px solid var(--doom-edge-yellow)',\n },\n '.cm-marked-region-label': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '16px',\n height: '16px',\n marginRight: '4px',\n borderRadius: '999px',\n backgroundColor: 'var(--doom-yellow)',\n color: 'var(--doom-deep)',\n fontSize: '9px',\n fontWeight: '700',\n lineHeight: '1',\n verticalAlign: 'text-bottom',\n },\n});\n\n/** Everything that never changes for the life of an editor. */\nconst FIXED_EXTENSIONS = [\n lineNumbers(),\n highlightActiveLineGutter(),\n foldGutter(),\n highlightActiveLine(),\n drawSelection(),\n rectangularSelection(),\n indentOnInput(),\n bracketMatching(),\n history(),\n search({ top: true }),\n highlightSelectionMatches(),\n // Tab indents rather than leaving the editor. That trades a keyboard user's\n // escape route for the behaviour every other editor has, so it is last in\n // the keymap and Escape then Tab still moves focus out.\n keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap, ...foldKeymap, indentWithTab]),\n syntaxHighlighting(DOOM_HIGHLIGHT),\n closedDecorations,\n markedDecorations,\n MARKED_REGION_THEME,\n DOOM_THEME,\n];\n\nexport function CodeEditorView({\n value,\n path,\n readOnly = false,\n lineWrapping = true,\n className,\n onChange,\n onSelect,\n controllerRef,\n 'data-testid': testId,\n}: CodeEditorProps) {\n const host = useRef<HTMLDivElement>(null);\n const view = useRef<EditorView | null>(null);\n // The callbacks are new objects on every parent render. Reading them through\n // a ref is what lets the editor be built once and still call the current\n // pair, rather than being rebuilt whenever the parent re-renders.\n const handlers = useRef({ onChange, onSelect });\n // The document is seeded once from the value of the first render; the sync effect\n // below owns every later change.\n const initialValue = useRef(value);\n const compartments = useRef({\n language: new Compartment(),\n readOnly: new Compartment(),\n wrapping: new Compartment(),\n });\n\n useEffect(() => {\n handlers.current = { onChange, onSelect };\n });\n\n useLayoutEffect(() => {\n const parent = host.current;\n if (parent === null) return;\n const { language, readOnly: readOnlyPart, wrapping } = compartments.current;\n const editor = new EditorView({\n parent,\n state: EditorState.create({\n // The initial document only; every later change arrives as a\n // transaction from the effect below.\n doc: initialValue.current,\n extensions: [\n ...FIXED_EXTENSIONS,\n language.of([]),\n readOnlyPart.of([]),\n wrapping.of([]),\n EditorView.updateListener.of((update) => {\n if (update.docChanged) handlers.current.onChange?.(update.state.doc.toString());\n if (!update.selectionSet && !update.docChanged) return;\n const report = handlers.current.onSelect;\n if (report === undefined) return;\n const range = update.state.selection.main;\n report(selectionRange(update.view, range.from, range.to));\n }),\n ],\n }),\n });\n view.current = editor;\n return () => {\n editor.destroy();\n view.current = null;\n };\n // Built once.\n }, []);\n\n useImperativeHandle(\n controllerRef,\n () => ({\n focus: () => view.current?.focus(),\n revealAndSelect: (range) => {\n const editor = view.current;\n if (editor === null) return;\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined) return;\n editor.dispatch({\n selection: { anchor: bounded.from, head: bounded.to },\n effects: EditorView.scrollIntoView(bounded.from, { y: 'center' }),\n });\n },\n applyEdits: (edits) => {\n const editor = view.current;\n if (editor === null || edits.length === 0) return;\n editor.dispatch({ changes: boundedEditorEdits(editor.state.doc.length, edits) });\n },\n setClosedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const bounded = boundedEditorRanges(editor.state.doc.length, ranges);\n const decorations = bounded.map((range) =>\n range.from === range.to\n ? Decoration.line({ attributes: { class: 'cm-closed-tone', 'data-tone': 'closed' } }).range(\n editor.state.doc.lineAt(range.from).from,\n )\n : Decoration.mark({ class: 'cm-closed-tone', attributes: { 'data-tone': 'closed' } }).range(\n range.from,\n range.to,\n ),\n );\n editor.dispatch({ effects: setClosedDecorations.of(Decoration.set(decorations)) });\n },\n setMarkedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const decorations = ranges.flatMap((range) => {\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined || bounded.from === bounded.to) return [];\n return [\n Decoration.widget({ widget: new MarkedRangeLabel(range.label), side: -1 }).range(bounded.from),\n Decoration.mark({\n class: 'cm-marked-region',\n attributes: { 'data-author-region': range.label },\n }).range(bounded.from, bounded.to),\n ];\n });\n editor.dispatch({ effects: setMarkedDecorations.of(Decoration.set(decorations, true)) });\n },\n resolveViewportRegion: (rectangle) => {\n const editor = view.current;\n return editor === null ? null : resolveEditorViewportRegion(editor, rectangle);\n },\n }),\n [],\n );\n\n useEffect(() => {\n const editor = view.current;\n // A caller that echoes onChange back into `value` would otherwise replace\n // the document on every keystroke and drop the cursor to the end.\n if (editor === null || editor.state.doc.toString() === value) return;\n editor.dispatch({ changes: { from: 0, to: editor.state.doc.length, insert: value } });\n }, [value]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.readOnly.reconfigure([\n EditorState.readOnly.of(readOnly),\n EditorView.editable.of(!readOnly),\n ]),\n });\n }, [readOnly]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.wrapping.reconfigure(lineWrapping ? EditorView.lineWrapping : []),\n });\n }, [lineWrapping]);\n\n useEffect(() => {\n const key = path === undefined ? undefined : grammarKeyOf(path);\n const { language } = compartments.current;\n if (key === undefined) {\n view.current?.dispatch({ effects: language.reconfigure([]) });\n return;\n }\n let cancelled = false;\n void loadGrammar(key)\n .then((grammar) => {\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure(grammar) });\n })\n .catch(() => {\n // A grammar is a separate chunk over the network, and the cockpit is\n // often read through a tunnel. Losing it costs syntax colour, not the\n // file, so fall back to plain text rather than failing the pane.\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure([]) });\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return <div ref={host} data-testid={testId} className={cn('min-h-0 overflow-hidden', className)} />;\n}\n"],"mappings":"0YAgCA,SAAS,EAAe,EAAyC,EAAc,EAAkC,CAC/G,IAAM,EAAQ,KAAK,IAAI,EAAM,CAAE,EACzB,EAAM,KAAK,IAAI,EAAM,CAAE,EAC7B,MAAO,CACL,KAAM,EAAO,MAAM,SAAS,EAAO,CAAG,EACtC,KAAM,EACN,GAAI,EACJ,UAAW,EAAO,MAAM,IAAI,OAAO,CAAK,CAAC,CAAC,OAC1C,QAAS,EAAO,MAAM,IAAI,OAAO,CAAG,CAAC,CAAC,MACxC,CACF,CAEA,SAAgB,EACd,EAIA,EAC6B,CAC7B,IAAM,EAAQ,EAAO,YAAY,CAAE,EAAG,EAAU,KAAM,EAAG,EAAU,GAAI,CAAC,EAClE,EAAM,EAAO,YAAY,CAAE,EAAG,EAAU,MAAO,EAAG,EAAU,MAAO,CAAC,EAE1E,OADI,IAAU,MAAQ,IAAQ,KAAa,KACpC,EAAe,EAAQ,EAAO,CAAG,CAC1C,CAgBA,MAAM,EAAaA,EAAAA,WAAW,MAAMC,EAAAA,kBAAkB,EAEhD,EAAiBC,EAAAA,eAAe,OAAO,CAC3C,CAAE,IAAKC,EAAAA,KAAK,QAAS,GAAGC,EAAAA,mBAAmB,OAAQ,EACnD,C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EjB,EAAA,EAAA,UAAA,KAAgB,CACd,IAAM,EAAM,IAAS,IAAA,GAAY,IAAA,GAAYgC,EAAAA,aAAa,CAAI,EACxD,CAAE,YAAa,EAAa,QAClC,GAAI,IAAQ,IAAA,GAAW,CACrB,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,EAC5D,MACF,CACA,IAAI,EAAY,GAWhB,OAVA,EAAKC,YAAY,CAAG,CAAC,CAClB,KAAM,GAAY,CACZ,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAO,CAAE,CAAC,CACnF,CAAC,CAAC,CACD,UAAY,CAIN,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,CAC9E,CAAC,MACU,CACX,EAAY,EACd,CACF,EAAG,CAAC,CAAI,CAAC,GAEF,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,IAAK,EAAM,cAAa,EAAQ,UAAWC,EAAAA,GAAG,0BAA2B,CAAS,CAAI,CAAA,CACpG"}
1
+ {"version":3,"file":"CodeEditorView.cjs","names":["EditorView","DOOM_EDITOR_STYLES","HighlightStyle","tags","DOOM_SYNTAX_STYLES","StateEffect","StateField","Decoration","WidgetType","lineNumbers","highlightActiveLineGutter","foldGutter","highlightActiveLine","drawSelection","rectangularSelection","indentOnInput","bracketMatching","history","search","highlightSelectionMatches","keymap","defaultKeymap","historyKeymap","searchKeymap","foldKeymap","indentWithTab","syntaxHighlighting","useRef","Compartment","EditorState","boundedEditorRanges","boundedEditorEdits","grammarKeyOf","loadGrammar","cn"],"sources":["../../../src/components/CodeEditorView.tsx"],"sourcesContent":["import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport {\n bracketMatching,\n foldGutter,\n foldKeymap,\n HighlightStyle,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { highlightSelectionMatches, search, searchKeymap } from '@codemirror/search';\nimport { Compartment, EditorState, StateEffect, StateField } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n drawSelection,\n EditorView,\n highlightActiveLine,\n highlightActiveLineGutter,\n keymap,\n lineNumbers,\n rectangularSelection,\n WidgetType,\n} from '@codemirror/view';\nimport { tags } from '@lezer/highlight';\nimport { useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { boundedEditorEdits, boundedEditorRanges } from '../lib/editorController';\nimport { grammarKeyOf, loadGrammar } from '../lib/editorLanguage';\nimport { DOOM_EDITOR_STYLES, DOOM_SYNTAX_STYLES } from '../lib/editorTheme';\nimport type { CodeEditorProps, EditorSelectionRange, EditorViewportRectangle } from '../types/editor';\n\nfunction selectionRange(editor: { readonly state: EditorState }, from: number, to: number): EditorSelectionRange {\n const start = Math.min(from, to);\n const end = Math.max(from, to);\n return {\n text: editor.state.sliceDoc(start, end),\n from: start,\n to: end,\n startLine: editor.state.doc.lineAt(start).number,\n endLine: editor.state.doc.lineAt(end).number,\n };\n}\n\nexport function resolveEditorViewportRegion(\n editor: {\n readonly state: EditorState;\n posAtCoords(coords: { x: number; y: number }): number | null;\n },\n rectangle: EditorViewportRectangle,\n): EditorSelectionRange | null {\n const start = editor.posAtCoords({ x: rectangle.left, y: rectangle.top });\n const end = editor.posAtCoords({ x: rectangle.right, y: rectangle.bottom });\n if (start === null || end === null) return null;\n return selectionRange(editor, start, end);\n}\n/**\n * The editor itself, mounted on a real CodeMirror view.\n *\n * Nothing imports this module directly: `CodeEditor` reaches it through a lazy\n * import so the whole editor, and every grammar under it, stays out of the\n * cockpit's first load. Behaviour lives here rather than in that wrapper so\n * the split costs one file and no indirection.\n *\n * The three things a caller can change after mount each sit in their own\n * compartment. Reconfiguring one is a transaction; rebuilding the editor would\n * throw away the undo history, the scroll position and the cursor, which is\n * what a reader loses if a parent re-render is allowed to remount this.\n */\n\n/** Not a colour or a layout choice: how CodeMirror is told to draw the doom palette. */\nconst DOOM_THEME = EditorView.theme(DOOM_EDITOR_STYLES);\n\nconst DOOM_HIGHLIGHT = HighlightStyle.define([\n { tag: tags.comment, ...DOOM_SYNTAX_STYLES.comment },\n { tag: tags.keyword, ...DOOM_SYNTAX_STYLES.keyword },\n { tag: [tags.atom, tags.bool, tags.null, tags.self], ...DOOM_SYNTAX_STYLES.constant },\n { tag: tags.number, ...DOOM_SYNTAX_STYLES.literal },\n { tag: [tags.string, tags.special(tags.string), tags.character], ...DOOM_SYNTAX_STYLES.string },\n { tag: tags.regexp, ...DOOM_SYNTAX_STYLES.regexp },\n { tag: tags.operator, ...DOOM_SYNTAX_STYLES.operator },\n { tag: tags.punctuation, ...DOOM_SYNTAX_STYLES.punctuation },\n { tag: tags.variableName, ...DOOM_SYNTAX_STYLES.variable },\n { tag: tags.propertyName, ...DOOM_SYNTAX_STYLES.property },\n { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], ...DOOM_SYNTAX_STYLES.callable },\n { tag: [tags.typeName, tags.className, tags.namespace], ...DOOM_SYNTAX_STYLES.type },\n { tag: tags.tagName, ...DOOM_SYNTAX_STYLES.tag },\n { tag: tags.attributeName, ...DOOM_SYNTAX_STYLES.attribute },\n { tag: [tags.meta, tags.processingInstruction], ...DOOM_SYNTAX_STYLES.meta },\n { tag: tags.heading, ...DOOM_SYNTAX_STYLES.heading },\n { tag: [tags.link, tags.url], ...DOOM_SYNTAX_STYLES.link },\n { tag: tags.emphasis, ...DOOM_SYNTAX_STYLES.emphasis },\n { tag: tags.strong, ...DOOM_SYNTAX_STYLES.strong },\n { tag: tags.strikethrough, ...DOOM_SYNTAX_STYLES.strikethrough },\n { tag: tags.invalid, ...DOOM_SYNTAX_STYLES.invalid },\n]);\n\nconst setClosedDecorations = StateEffect.define<DecorationSet>();\nconst closedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setClosedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nconst setMarkedDecorations = StateEffect.define<DecorationSet>();\nconst markedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setMarkedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nclass MarkedRangeLabel extends WidgetType {\n constructor(private readonly label: string) {\n super();\n }\n\n eq(other: MarkedRangeLabel): boolean {\n return other.label === this.label;\n }\n\n toDOM(): HTMLElement {\n const label = document.createElement('span');\n label.className = 'cm-marked-region-label';\n label.dataset.authorRegionLabel = this.label;\n label.textContent = this.label;\n return label;\n }\n}\n\nconst MARKED_REGION_THEME = EditorView.baseTheme({\n '.cm-marked-region': {\n backgroundColor: 'var(--doom-tint-yellow)',\n borderBottom: '1px solid var(--doom-edge-yellow)',\n },\n '.cm-marked-region-label': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '16px',\n height: '16px',\n marginRight: '4px',\n borderRadius: '999px',\n backgroundColor: 'var(--doom-yellow)',\n color: 'var(--doom-deep)',\n fontSize: '9px',\n fontWeight: '700',\n lineHeight: '1',\n verticalAlign: 'text-bottom',\n },\n});\n\n/** Everything that never changes for the life of an editor. */\nconst FIXED_EXTENSIONS = [\n lineNumbers(),\n highlightActiveLineGutter(),\n foldGutter(),\n highlightActiveLine(),\n drawSelection(),\n rectangularSelection(),\n indentOnInput(),\n bracketMatching(),\n history(),\n search({ top: true }),\n highlightSelectionMatches(),\n // Tab indents rather than leaving the editor. That trades a keyboard user's\n // escape route for the behaviour every other editor has, so it is last in\n // the keymap and Escape then Tab still moves focus out.\n keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap, ...foldKeymap, indentWithTab]),\n syntaxHighlighting(DOOM_HIGHLIGHT),\n closedDecorations,\n markedDecorations,\n MARKED_REGION_THEME,\n DOOM_THEME,\n];\n\nexport function CodeEditorView({\n value,\n path,\n readOnly = false,\n lineWrapping = true,\n className,\n onChange,\n onSelect,\n controllerRef,\n 'data-testid': testId,\n}: CodeEditorProps) {\n const host = useRef<HTMLDivElement>(null);\n const view = useRef<EditorView | null>(null);\n // The callbacks are new objects on every parent render. Reading them through\n // a ref is what lets the editor be built once and still call the current\n // pair, rather than being rebuilt whenever the parent re-renders.\n const handlers = useRef({ onChange, onSelect });\n // The document is seeded once from the value of the first render; the sync effect\n // below owns every later change.\n const initialValue = useRef(value);\n const compartments = useRef({\n language: new Compartment(),\n readOnly: new Compartment(),\n wrapping: new Compartment(),\n });\n\n useEffect(() => {\n handlers.current = { onChange, onSelect };\n });\n\n useLayoutEffect(() => {\n const parent = host.current;\n if (parent === null) return;\n const { language, readOnly: readOnlyPart, wrapping } = compartments.current;\n const editor = new EditorView({\n parent,\n state: EditorState.create({\n // The initial document only; every later change arrives as a\n // transaction from the effect below.\n doc: initialValue.current,\n extensions: [\n ...FIXED_EXTENSIONS,\n language.of([]),\n readOnlyPart.of([]),\n wrapping.of([]),\n EditorView.updateListener.of((update) => {\n if (update.docChanged) handlers.current.onChange?.(update.state.doc.toString());\n if (!update.selectionSet && !update.docChanged) return;\n const report = handlers.current.onSelect;\n if (report === undefined) return;\n const range = update.state.selection.main;\n report(selectionRange(update.view, range.from, range.to));\n }),\n ],\n }),\n });\n view.current = editor;\n return () => {\n editor.destroy();\n view.current = null;\n };\n // Built once.\n }, []);\n\n useImperativeHandle(\n controllerRef,\n () => ({\n focus: () => view.current?.focus(),\n revealAndSelect: (range) => {\n const editor = view.current;\n if (editor === null) return;\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined) return;\n editor.dispatch({\n selection: { anchor: bounded.from, head: bounded.to },\n effects: EditorView.scrollIntoView(bounded.from, { y: 'center' }),\n });\n },\n applyEdits: (edits) => {\n const editor = view.current;\n if (editor === null || edits.length === 0) return;\n editor.dispatch({ changes: boundedEditorEdits(editor.state.doc.length, edits) });\n },\n setClosedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const bounded = boundedEditorRanges(editor.state.doc.length, ranges);\n const decorations = bounded.map((range) =>\n range.from === range.to\n ? Decoration.line({ attributes: { class: 'cm-closed-tone', 'data-tone': 'closed' } }).range(\n editor.state.doc.lineAt(range.from).from,\n )\n : Decoration.mark({ class: 'cm-closed-tone', attributes: { 'data-tone': 'closed' } }).range(\n range.from,\n range.to,\n ),\n );\n editor.dispatch({ effects: setClosedDecorations.of(Decoration.set(decorations)) });\n },\n setMarkedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const decorations = ranges.flatMap((range) => {\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined || bounded.from === bounded.to) return [];\n return [\n Decoration.widget({ widget: new MarkedRangeLabel(range.label), side: -1 }).range(bounded.from),\n Decoration.mark({\n class: 'cm-marked-region',\n attributes: { 'data-author-region': range.label },\n }).range(bounded.from, bounded.to),\n ];\n });\n editor.dispatch({ effects: setMarkedDecorations.of(Decoration.set(decorations, true)) });\n },\n resolveViewportRegion: (rectangle) => {\n const editor = view.current;\n return editor === null ? null : resolveEditorViewportRegion(editor, rectangle);\n },\n }),\n [],\n );\n\n useEffect(() => {\n const editor = view.current;\n // A caller that echoes onChange back into `value` would otherwise replace\n // the document on every keystroke and drop the cursor to the end.\n if (editor === null || editor.state.doc.toString() === value) return;\n editor.dispatch({ changes: { from: 0, to: editor.state.doc.length, insert: value } });\n }, [value]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.readOnly.reconfigure([\n EditorState.readOnly.of(readOnly),\n EditorView.editable.of(!readOnly),\n ]),\n });\n }, [readOnly]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.wrapping.reconfigure(lineWrapping ? EditorView.lineWrapping : []),\n });\n }, [lineWrapping]);\n\n useEffect(() => {\n const key = path === undefined ? undefined : grammarKeyOf(path);\n const { language } = compartments.current;\n if (key === undefined) {\n view.current?.dispatch({ effects: language.reconfigure([]) });\n return;\n }\n let cancelled = false;\n void loadGrammar(key)\n .then((grammar) => {\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure(grammar) });\n })\n .catch(() => {\n // A grammar is a separate chunk over the network, and the cockpit is\n // often read through a tunnel. Losing it costs syntax colour, not the\n // file, so fall back to plain text rather than failing the pane.\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure([]) });\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return <div ref={host} data-testid={testId} className={cn('min-h-0 overflow-hidden', className)} />;\n}\n"],"mappings":"0YAgCA,SAAS,EAAe,EAAyC,EAAc,EAAkC,CAC/G,IAAM,EAAQ,KAAK,IAAI,EAAM,CAAE,EACzB,EAAM,KAAK,IAAI,EAAM,CAAE,EAC7B,MAAO,CACL,KAAM,EAAO,MAAM,SAAS,EAAO,CAAG,EACtC,KAAM,EACN,GAAI,EACJ,UAAW,EAAO,MAAM,IAAI,OAAO,CAAK,CAAC,CAAC,OAC1C,QAAS,EAAO,MAAM,IAAI,OAAO,CAAG,CAAC,CAAC,MACxC,CACF,CAEA,SAAgB,EACd,EAIA,EAC6B,CAC7B,IAAM,EAAQ,EAAO,YAAY,CAAE,EAAG,EAAU,KAAM,EAAG,EAAU,GAAI,CAAC,EAClE,EAAM,EAAO,YAAY,CAAE,EAAG,EAAU,MAAO,EAAG,EAAU,MAAO,CAAC,EAE1E,OADI,IAAU,MAAQ,IAAQ,KAAa,KACpC,EAAe,EAAQ,EAAO,CAAG,CAC1C,CAgBA,MAAM,EAAaA,EAAAA,WAAW,MAAMC,EAAAA,kBAAkB,EAEhD,EAAiBC,EAAAA,eAAe,OAAO,CAC3C,CAAE,IAAKC,EAAAA,KAAK,QAAS,GAAGC,EAAAA,mBAAmB,OAAQ,EACnD,CAAE,IAAKD,EAAAA,KAAK,QAAS,GAAGC,EAAAA,mBAAmB,OAAQ,EACnD,CAAE,IAAK,CAACD,E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aAAa,CAAI,EACxD,CAAE,YAAa,EAAa,QAClC,GAAI,IAAQ,IAAA,GAAW,CACrB,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,EAC5D,MACF,CACA,IAAI,EAAY,GAWhB,OAVA,EAAKC,YAAY,CAAG,CAAC,CAClB,KAAM,GAAY,CACZ,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAO,CAAE,CAAC,CACnF,CAAC,CAAC,CACD,UAAY,CAIN,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,CAC9E,CAAC,MACU,CACX,EAAY,EACd,CACF,EAAG,CAAC,CAAI,CAAC,EAEF,iBAAA,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,IAAK,EAAM,cAAa,EAAQ,UAAWC,EAAAA,GAAG,0BAA2B,CAAS,CAAI,CAAA,CACpG"}
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../lib/cn.mjs";import{grammarKeyOf as t,loadGrammar as n}from"../lib/editorLanguage.mjs";import{DOOM_EDITOR_STYLES as r,DOOM_SYNTAX_STYLES as i}from"../lib/editorTheme.mjs";import{boundedEditorEdits as a,boundedEditorRanges as o}from"../lib/editorController.mjs";import{jsx as s}from"react/jsx-runtime";import{useEffect as c,useImperativeHandle as l,useLayoutEffect as u,useRef as d}from"react";import{defaultKeymap as f,history as p,historyKeymap as m,indentWithTab as h}from"@codemirror/commands";import{HighlightStyle as g,bracketMatching as _,foldGutter as v,foldKeymap as y,indentOnInput as b,syntaxHighlighting as x}from"@codemirror/language";import{highlightSelectionMatches as S,search as C,searchKeymap as w}from"@codemirror/search";import{Compartment as T,EditorState as E,StateEffect as D,StateField as O}from"@codemirror/state";import{Decoration as k,EditorView as A,WidgetType as j,drawSelection as M,highlightActiveLine as N,highlightActiveLineGutter as P,keymap as F,lineNumbers as I,rectangularSelection as L}from"@codemirror/view";import{tags as R}from"@lezer/highlight";function z(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return{text:e.state.sliceDoc(r,i),from:r,to:i,startLine:e.state.doc.lineAt(r).number,endLine:e.state.doc.lineAt(i).number}}function B(e,t){let n=e.posAtCoords({x:t.left,y:t.top}),r=e.posAtCoords({x:t.right,y:t.bottom});return n===null||r===null?null:z(e,n,r)}const V=A.theme(r),H=g.define([{tag:R.comment,...i.comment},{tag:R.keyword,...i.keyword},{tag:[R.atom,R.bool,R.null,R.self],...i.constant},{tag:R.number,...i.literal},{tag:[R.string,R.special(R.string),R.character],...i.string},{tag:R.regexp,...i.regexp},{tag:R.operator,...i.operator},{tag:R.punctuation,...i.punctuation},{tag:R.variableName,...i.variable},{tag:R.propertyName,...i.property},{tag:[R.function(R.variableName),R.function(R.propertyName)],...i.callable},{tag:[R.typeName,R.className,R.namespace],...i.type},{tag:R.tagName,...i.tag},{tag:R.attributeName,...i.attribute},{tag:[R.meta,R.processingInstruction],...i.meta},{tag:R.heading,...i.heading},{tag:[R.link,R.url],...i.link},{tag:R.emphasis,...i.emphasis},{tag:R.strong,...i.strong},{tag:R.strikethrough,...i.strikethrough},{tag:R.invalid,...i.invalid}]),U=D.define(),W=O.define({create:()=>k.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(U)&&(n=e.value);return n},provide:e=>A.decorations.from(e)}),G=D.define(),K=O.define({create:()=>k.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(G)&&(n=e.value);return n},provide:e=>A.decorations.from(e)});var q=class extends j{label;constructor(e){super(),this.label=e}eq(e){return e.label===this.label}toDOM(){let e=document.createElement(`span`);return e.className=`cm-marked-region-label`,e.dataset.authorRegionLabel=this.label,e.textContent=this.label,e}};const J=A.baseTheme({".cm-marked-region":{backgroundColor:`var(--doom-tint-yellow)`,borderBottom:`1px solid var(--doom-edge-yellow)`},".cm-marked-region-label":{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:`16px`,height:`16px`,marginRight:`4px`,borderRadius:`999px`,backgroundColor:`var(--doom-yellow)`,color:`var(--doom-deep)`,fontSize:`9px`,fontWeight:`700`,lineHeight:`1`,verticalAlign:`text-bottom`}}),Y=[I(),P(),v(),N(),M(),L(),b(),_(),p(),C({top:!0}),S(),F.of([...f,...m,...w,...y,h]),x(H),W,K,J,V];function X({value:r,path:i,readOnly:f=!1,lineWrapping:p=!0,className:m,onChange:h,onSelect:g,controllerRef:_,"data-testid":v}){let y=d(null),b=d(null),x=d({onChange:h,onSelect:g}),S=d(r),C=d({language:new T,readOnly:new T,wrapping:new T});return c(()=>{x.current={onChange:h,onSelect:g}}),u(()=>{let e=y.current;if(e===null)return;let{language:t,readOnly:n,wrapping:r}=C.current,i=new A({parent:e,state:E.create({doc:S.current,extensions:[...Y,t.of([]),n.of([]),r.of([]),A.updateListener.of(e=>{if(e.docChanged&&x.current.onChange?.(e.state.doc.toString()),!e.selectionSet&&!e.docChanged)return;let t=x.current.onSelect;if(t===void 0)return;let n=e.state.selection.main;t(z(e.view,n.from,n.to))})]})});return b.current=i,()=>{i.destroy(),b.current=null}},[]),l(_,()=>({focus:()=>b.current?.focus(),revealAndSelect:e=>{let t=b.current;if(t===null)return;let[n]=o(t.state.doc.length,[e]);n!==void 0&&t.dispatch({selection:{anchor:n.from,head:n.to},effects:A.scrollIntoView(n.from,{y:`center`})})},applyEdits:e=>{let t=b.current;t!==null&&e.length!==0&&t.dispatch({changes:a(t.state.doc.length,e)})},setClosedRanges:e=>{let t=b.current;if(t===null)return;let n=o(t.state.doc.length,e).map(e=>e.from===e.to?k.line({attributes:{class:`cm-closed-tone`,"data-tone":`closed`}}).range(t.state.doc.lineAt(e.from).from):k.mark({class:`cm-closed-tone`,attributes:{"data-tone":`closed`}}).range(e.from,e.to));t.dispatch({effects:U.of(k.set(n))})},setMarkedRanges:e=>{let t=b.current;if(t===null)return;let n=e.flatMap(e=>{let[n]=o(t.state.doc.length,[e]);return n===void 0||n.from===n.to?[]:[k.widget({widget:new q(e.label),side:-1}).range(n.from),k.mark({class:`cm-marked-region`,attributes:{"data-author-region":e.label}}).range(n.from,n.to)]});t.dispatch({effects:G.of(k.set(n,!0))})},resolveViewportRegion:e=>{let t=b.current;return t===null?null:B(t,e)}}),[]),c(()=>{let e=b.current;e!==null&&e.state.doc.toString()!==r&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:r}})},[r]),c(()=>{b.current?.dispatch({effects:C.current.readOnly.reconfigure([E.readOnly.of(f),A.editable.of(!f)])})},[f]),c(()=>{b.current?.dispatch({effects:C.current.wrapping.reconfigure(p?A.lineWrapping:[])})},[p]),c(()=>{let e=i===void 0?void 0:t(i),{language:r}=C.current;if(e===void 0){b.current?.dispatch({effects:r.reconfigure([])});return}let a=!1;return n(e).then(e=>{a||b.current?.dispatch({effects:r.reconfigure(e)})}).catch(()=>{a||b.current?.dispatch({effects:r.reconfigure([])})}),()=>{a=!0}},[i]),s(`div`,{ref:y,"data-testid":v,className:e(`min-h-0 overflow-hidden`,m)})}export{X as CodeEditorView,B as resolveEditorViewportRegion};
1
+ import{cn as e}from"../lib/cn.mjs";import{grammarKeyOf as t,loadGrammar as n}from"../lib/editorLanguage.mjs";import{DOOM_EDITOR_STYLES as r,DOOM_SYNTAX_STYLES as i}from"../lib/editorTheme.mjs";import{boundedEditorEdits as a,boundedEditorRanges as o}from"../lib/editorController.mjs";import{jsx as s}from"react/jsx-runtime";import{useEffect as c,useImperativeHandle as l,useLayoutEffect as u,useRef as d}from"react";import{defaultKeymap as f,history as p,historyKeymap as m,indentWithTab as h}from"@codemirror/commands";import{HighlightStyle as g,bracketMatching as _,foldGutter as v,foldKeymap as y,indentOnInput as b,syntaxHighlighting as x}from"@codemirror/language";import{highlightSelectionMatches as S,search as C,searchKeymap as w}from"@codemirror/search";import{Compartment as T,EditorState as E,StateEffect as D,StateField as O}from"@codemirror/state";import{Decoration as k,EditorView as A,WidgetType as j,drawSelection as M,highlightActiveLine as N,highlightActiveLineGutter as P,keymap as F,lineNumbers as I,rectangularSelection as L}from"@codemirror/view";import{tags as R}from"@lezer/highlight";function z(e,t,n){let r=Math.min(t,n),i=Math.max(t,n);return{text:e.state.sliceDoc(r,i),from:r,to:i,startLine:e.state.doc.lineAt(r).number,endLine:e.state.doc.lineAt(i).number}}function B(e,t){let n=e.posAtCoords({x:t.left,y:t.top}),r=e.posAtCoords({x:t.right,y:t.bottom});return n===null||r===null?null:z(e,n,r)}const V=A.theme(r),H=g.define([{tag:R.comment,...i.comment},{tag:R.keyword,...i.keyword},{tag:[R.atom,R.bool,R.null,R.self],...i.constant},{tag:R.number,...i.literal},{tag:[R.string,R.special(R.string),R.character],...i.string},{tag:R.regexp,...i.regexp},{tag:R.operator,...i.operator},{tag:R.punctuation,...i.punctuation},{tag:R.variableName,...i.variable},{tag:R.propertyName,...i.property},{tag:[R.function(R.variableName),R.function(R.propertyName)],...i.callable},{tag:[R.typeName,R.className,R.namespace],...i.type},{tag:R.tagName,...i.tag},{tag:R.attributeName,...i.attribute},{tag:[R.meta,R.processingInstruction],...i.meta},{tag:R.heading,...i.heading},{tag:[R.link,R.url],...i.link},{tag:R.emphasis,...i.emphasis},{tag:R.strong,...i.strong},{tag:R.strikethrough,...i.strikethrough},{tag:R.invalid,...i.invalid}]),U=D.define(),W=O.define({create:()=>k.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(U)&&(n=e.value);return n},provide:e=>A.decorations.from(e)}),G=D.define(),K=O.define({create:()=>k.none,update:(e,t)=>{let n=e.map(t.changes);for(let e of t.effects)e.is(G)&&(n=e.value);return n},provide:e=>A.decorations.from(e)});var q=class extends j{label;constructor(e){super(),this.label=e}eq(e){return e.label===this.label}toDOM(){let e=document.createElement(`span`);return e.className=`cm-marked-region-label`,e.dataset.authorRegionLabel=this.label,e.textContent=this.label,e}};const J=A.baseTheme({".cm-marked-region":{backgroundColor:`var(--doom-tint-yellow)`,borderBottom:`1px solid var(--doom-edge-yellow)`},".cm-marked-region-label":{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minWidth:`16px`,height:`16px`,marginRight:`4px`,borderRadius:`999px`,backgroundColor:`var(--doom-yellow)`,color:`var(--doom-deep)`,fontSize:`9px`,fontWeight:`700`,lineHeight:`1`,verticalAlign:`text-bottom`}}),Y=[I(),P(),v(),N(),M(),L(),b(),_(),p(),C({top:!0}),S(),F.of([...f,...m,...w,...y,h]),x(H),W,K,J,V];function X({value:r,path:i,readOnly:f=!1,lineWrapping:p=!0,className:m,onChange:h,onSelect:g,controllerRef:_,"data-testid":v}){let y=d(null),b=d(null),x=d({onChange:h,onSelect:g}),S=d(r),C=d({language:new T,readOnly:new T,wrapping:new T});return c(()=>{x.current={onChange:h,onSelect:g}}),u(()=>{let e=y.current;if(e===null)return;let{language:t,readOnly:n,wrapping:r}=C.current,i=new A({parent:e,state:E.create({doc:S.current,extensions:[...Y,t.of([]),n.of([]),r.of([]),A.updateListener.of(e=>{if(e.docChanged&&x.current.onChange?.(e.state.doc.toString()),!e.selectionSet&&!e.docChanged)return;let t=x.current.onSelect;if(t===void 0)return;let n=e.state.selection.main;t(z(e.view,n.from,n.to))})]})});return b.current=i,()=>{i.destroy(),b.current=null}},[]),l(_,()=>({focus:()=>b.current?.focus(),revealAndSelect:e=>{let t=b.current;if(t===null)return;let[n]=o(t.state.doc.length,[e]);n!==void 0&&t.dispatch({selection:{anchor:n.from,head:n.to},effects:A.scrollIntoView(n.from,{y:`center`})})},applyEdits:e=>{let t=b.current;t!==null&&e.length!==0&&t.dispatch({changes:a(t.state.doc.length,e)})},setClosedRanges:e=>{let t=b.current;if(t===null)return;let n=o(t.state.doc.length,e).map(e=>e.from===e.to?k.line({attributes:{class:`cm-closed-tone`,"data-tone":`closed`}}).range(t.state.doc.lineAt(e.from).from):k.mark({class:`cm-closed-tone`,attributes:{"data-tone":`closed`}}).range(e.from,e.to));t.dispatch({effects:U.of(k.set(n))})},setMarkedRanges:e=>{let t=b.current;if(t===null)return;let n=e.flatMap(e=>{let[n]=o(t.state.doc.length,[e]);return n===void 0||n.from===n.to?[]:[k.widget({widget:new q(e.label),side:-1}).range(n.from),k.mark({class:`cm-marked-region`,attributes:{"data-author-region":e.label}}).range(n.from,n.to)]});t.dispatch({effects:G.of(k.set(n,!0))})},resolveViewportRegion:e=>{let t=b.current;return t===null?null:B(t,e)}}),[]),c(()=>{let e=b.current;e!==null&&e.state.doc.toString()!==r&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:r}})},[r]),c(()=>{b.current?.dispatch({effects:C.current.readOnly.reconfigure([E.readOnly.of(f),A.editable.of(!f)])})},[f]),c(()=>{b.current?.dispatch({effects:C.current.wrapping.reconfigure(p?A.lineWrapping:[])})},[p]),c(()=>{let e=i===void 0?void 0:t(i),{language:r}=C.current;if(e===void 0){b.current?.dispatch({effects:r.reconfigure([])});return}let a=!1;return n(e).then(e=>{a||b.current?.dispatch({effects:r.reconfigure(e)})}).catch(()=>{a||b.current?.dispatch({effects:r.reconfigure([])})}),()=>{a=!0}},[i]),/* @__PURE__ */ s(`div`,{ref:y,"data-testid":v,className:e(`min-h-0 overflow-hidden`,m)})}export{X as CodeEditorView,B as resolveEditorViewportRegion};
2
2
  //# sourceMappingURL=CodeEditorView.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditorView.mjs","names":[],"sources":["../../../src/components/CodeEditorView.tsx"],"sourcesContent":["import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport {\n bracketMatching,\n foldGutter,\n foldKeymap,\n HighlightStyle,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { highlightSelectionMatches, search, searchKeymap } from '@codemirror/search';\nimport { Compartment, EditorState, StateEffect, StateField } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n drawSelection,\n EditorView,\n highlightActiveLine,\n highlightActiveLineGutter,\n keymap,\n lineNumbers,\n rectangularSelection,\n WidgetType,\n} from '@codemirror/view';\nimport { tags } from '@lezer/highlight';\nimport { useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { boundedEditorEdits, boundedEditorRanges } from '../lib/editorController';\nimport { grammarKeyOf, loadGrammar } from '../lib/editorLanguage';\nimport { DOOM_EDITOR_STYLES, DOOM_SYNTAX_STYLES } from '../lib/editorTheme';\nimport type { CodeEditorProps, EditorSelectionRange, EditorViewportRectangle } from '../types/editor';\n\nfunction selectionRange(editor: { readonly state: EditorState }, from: number, to: number): EditorSelectionRange {\n const start = Math.min(from, to);\n const end = Math.max(from, to);\n return {\n text: editor.state.sliceDoc(start, end),\n from: start,\n to: end,\n startLine: editor.state.doc.lineAt(start).number,\n endLine: editor.state.doc.lineAt(end).number,\n };\n}\n\nexport function resolveEditorViewportRegion(\n editor: {\n readonly state: EditorState;\n posAtCoords(coords: { x: number; y: number }): number | null;\n },\n rectangle: EditorViewportRectangle,\n): EditorSelectionRange | null {\n const start = editor.posAtCoords({ x: rectangle.left, y: rectangle.top });\n const end = editor.posAtCoords({ x: rectangle.right, y: rectangle.bottom });\n if (start === null || end === null) return null;\n return selectionRange(editor, start, end);\n}\n/**\n * The editor itself, mounted on a real CodeMirror view.\n *\n * Nothing imports this module directly: `CodeEditor` reaches it through a lazy\n * import so the whole editor, and every grammar under it, stays out of the\n * cockpit's first load. Behaviour lives here rather than in that wrapper so\n * the split costs one file and no indirection.\n *\n * The three things a caller can change after mount each sit in their own\n * compartment. Reconfiguring one is a transaction; rebuilding the editor would\n * throw away the undo history, the scroll position and the cursor, which is\n * what a reader loses if a parent re-render is allowed to remount this.\n */\n\n/** Not a colour or a layout choice: how CodeMirror is told to draw the doom palette. */\nconst DOOM_THEME = EditorView.theme(DOOM_EDITOR_STYLES);\n\nconst DOOM_HIGHLIGHT = HighlightStyle.define([\n { tag: tags.comment, ...DOOM_SYNTAX_STYLES.comment },\n { tag: tags.keyword, ...DOOM_SYNTAX_STYLES.keyword },\n { tag: [tags.atom, tags.bool, tags.null, tags.self], ...DOOM_SYNTAX_STYLES.constant },\n { tag: tags.number, ...DOOM_SYNTAX_STYLES.literal },\n { tag: [tags.string, tags.special(tags.string), tags.character], ...DOOM_SYNTAX_STYLES.string },\n { tag: tags.regexp, ...DOOM_SYNTAX_STYLES.regexp },\n { tag: tags.operator, ...DOOM_SYNTAX_STYLES.operator },\n { tag: tags.punctuation, ...DOOM_SYNTAX_STYLES.punctuation },\n { tag: tags.variableName, ...DOOM_SYNTAX_STYLES.variable },\n { tag: tags.propertyName, ...DOOM_SYNTAX_STYLES.property },\n { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], ...DOOM_SYNTAX_STYLES.callable },\n { tag: [tags.typeName, tags.className, tags.namespace], ...DOOM_SYNTAX_STYLES.type },\n { tag: tags.tagName, ...DOOM_SYNTAX_STYLES.tag },\n { tag: tags.attributeName, ...DOOM_SYNTAX_STYLES.attribute },\n { tag: [tags.meta, tags.processingInstruction], ...DOOM_SYNTAX_STYLES.meta },\n { tag: tags.heading, ...DOOM_SYNTAX_STYLES.heading },\n { tag: [tags.link, tags.url], ...DOOM_SYNTAX_STYLES.link },\n { tag: tags.emphasis, ...DOOM_SYNTAX_STYLES.emphasis },\n { tag: tags.strong, ...DOOM_SYNTAX_STYLES.strong },\n { tag: tags.strikethrough, ...DOOM_SYNTAX_STYLES.strikethrough },\n { tag: tags.invalid, ...DOOM_SYNTAX_STYLES.invalid },\n]);\n\nconst setClosedDecorations = StateEffect.define<DecorationSet>();\nconst closedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setClosedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nconst setMarkedDecorations = StateEffect.define<DecorationSet>();\nconst markedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setMarkedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nclass MarkedRangeLabel extends WidgetType {\n constructor(private readonly label: string) {\n super();\n }\n\n eq(other: MarkedRangeLabel): boolean {\n return other.label === this.label;\n }\n\n toDOM(): HTMLElement {\n const label = document.createElement('span');\n label.className = 'cm-marked-region-label';\n label.dataset.authorRegionLabel = this.label;\n label.textContent = this.label;\n return label;\n }\n}\n\nconst MARKED_REGION_THEME = EditorView.baseTheme({\n '.cm-marked-region': {\n backgroundColor: 'var(--doom-tint-yellow)',\n borderBottom: '1px solid var(--doom-edge-yellow)',\n },\n '.cm-marked-region-label': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '16px',\n height: '16px',\n marginRight: '4px',\n borderRadius: '999px',\n backgroundColor: 'var(--doom-yellow)',\n color: 'var(--doom-deep)',\n fontSize: '9px',\n fontWeight: '700',\n lineHeight: '1',\n verticalAlign: 'text-bottom',\n },\n});\n\n/** Everything that never changes for the life of an editor. */\nconst FIXED_EXTENSIONS = [\n lineNumbers(),\n highlightActiveLineGutter(),\n foldGutter(),\n highlightActiveLine(),\n drawSelection(),\n rectangularSelection(),\n indentOnInput(),\n bracketMatching(),\n history(),\n search({ top: true }),\n highlightSelectionMatches(),\n // Tab indents rather than leaving the editor. That trades a keyboard user's\n // escape route for the behaviour every other editor has, so it is last in\n // the keymap and Escape then Tab still moves focus out.\n keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap, ...foldKeymap, indentWithTab]),\n syntaxHighlighting(DOOM_HIGHLIGHT),\n closedDecorations,\n markedDecorations,\n MARKED_REGION_THEME,\n DOOM_THEME,\n];\n\nexport function CodeEditorView({\n value,\n path,\n readOnly = false,\n lineWrapping = true,\n className,\n onChange,\n onSelect,\n controllerRef,\n 'data-testid': testId,\n}: CodeEditorProps) {\n const host = useRef<HTMLDivElement>(null);\n const view = useRef<EditorView | null>(null);\n // The callbacks are new objects on every parent render. Reading them through\n // a ref is what lets the editor be built once and still call the current\n // pair, rather than being rebuilt whenever the parent re-renders.\n const handlers = useRef({ onChange, onSelect });\n // The document is seeded once from the value of the first render; the sync effect\n // below owns every later change.\n const initialValue = useRef(value);\n const compartments = useRef({\n language: new Compartment(),\n readOnly: new Compartment(),\n wrapping: new Compartment(),\n });\n\n useEffect(() => {\n handlers.current = { onChange, onSelect };\n });\n\n useLayoutEffect(() => {\n const parent = host.current;\n if (parent === null) return;\n const { language, readOnly: readOnlyPart, wrapping } = compartments.current;\n const editor = new EditorView({\n parent,\n state: EditorState.create({\n // The initial document only; every later change arrives as a\n // transaction from the effect below.\n doc: initialValue.current,\n extensions: [\n ...FIXED_EXTENSIONS,\n language.of([]),\n readOnlyPart.of([]),\n wrapping.of([]),\n EditorView.updateListener.of((update) => {\n if (update.docChanged) handlers.current.onChange?.(update.state.doc.toString());\n if (!update.selectionSet && !update.docChanged) return;\n const report = handlers.current.onSelect;\n if (report === undefined) return;\n const range = update.state.selection.main;\n report(selectionRange(update.view, range.from, range.to));\n }),\n ],\n }),\n });\n view.current = editor;\n return () => {\n editor.destroy();\n view.current = null;\n };\n // Built once.\n }, []);\n\n useImperativeHandle(\n controllerRef,\n () => ({\n focus: () => view.current?.focus(),\n revealAndSelect: (range) => {\n const editor = view.current;\n if (editor === null) return;\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined) return;\n editor.dispatch({\n selection: { anchor: bounded.from, head: bounded.to },\n effects: EditorView.scrollIntoView(bounded.from, { y: 'center' }),\n });\n },\n applyEdits: (edits) => {\n const editor = view.current;\n if (editor === null || edits.length === 0) return;\n editor.dispatch({ changes: boundedEditorEdits(editor.state.doc.length, edits) });\n },\n setClosedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const bounded = boundedEditorRanges(editor.state.doc.length, ranges);\n const decorations = bounded.map((range) =>\n range.from === range.to\n ? Decoration.line({ attributes: { class: 'cm-closed-tone', 'data-tone': 'closed' } }).range(\n editor.state.doc.lineAt(range.from).from,\n )\n : Decoration.mark({ class: 'cm-closed-tone', attributes: { 'data-tone': 'closed' } }).range(\n range.from,\n range.to,\n ),\n );\n editor.dispatch({ effects: setClosedDecorations.of(Decoration.set(decorations)) });\n },\n setMarkedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const decorations = ranges.flatMap((range) => {\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined || bounded.from === bounded.to) return [];\n return [\n Decoration.widget({ widget: new MarkedRangeLabel(range.label), side: -1 }).range(bounded.from),\n Decoration.mark({\n class: 'cm-marked-region',\n attributes: { 'data-author-region': range.label },\n }).range(bounded.from, bounded.to),\n ];\n });\n editor.dispatch({ effects: setMarkedDecorations.of(Decoration.set(decorations, true)) });\n },\n resolveViewportRegion: (rectangle) => {\n const editor = view.current;\n return editor === null ? null : resolveEditorViewportRegion(editor, rectangle);\n },\n }),\n [],\n );\n\n useEffect(() => {\n const editor = view.current;\n // A caller that echoes onChange back into `value` would otherwise replace\n // the document on every keystroke and drop the cursor to the end.\n if (editor === null || editor.state.doc.toString() === value) return;\n editor.dispatch({ changes: { from: 0, to: editor.state.doc.length, insert: value } });\n }, [value]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.readOnly.reconfigure([\n EditorState.readOnly.of(readOnly),\n EditorView.editable.of(!readOnly),\n ]),\n });\n }, [readOnly]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.wrapping.reconfigure(lineWrapping ? EditorView.lineWrapping : []),\n });\n }, [lineWrapping]);\n\n useEffect(() => {\n const key = path === undefined ? undefined : grammarKeyOf(path);\n const { language } = compartments.current;\n if (key === undefined) {\n view.current?.dispatch({ effects: language.reconfigure([]) });\n return;\n }\n let cancelled = false;\n void loadGrammar(key)\n .then((grammar) => {\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure(grammar) });\n })\n .catch(() => {\n // A grammar is a separate chunk over the network, and the cockpit is\n // often read through a tunnel. Losing it costs syntax colour, not the\n // file, so fall back to plain text rather than failing the pane.\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure([]) });\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return <div ref={host} data-testid={testId} className={cn('min-h-0 overflow-hidden', className)} />;\n}\n"],"mappings":"olCAgCA,SAAS,EAAe,EAAyC,EAAc,EAAkC,CAC/G,IAAM,EAAQ,KAAK,IAAI,EAAM,CAAE,EACzB,EAAM,KAAK,IAAI,EAAM,CAAE,EAC7B,MAAO,CACL,KAAM,EAAO,MAAM,SAAS,EAAO,CAAG,EACtC,KAAM,EACN,GAAI,EACJ,UAAW,EAAO,MAAM,IAAI,OAAO,CAAK,CAAC,CAAC,OAC1C,QAAS,EAAO,MAAM,IAAI,OAAO,CAAG,CAAC,CAAC,MACxC,CACF,CAEA,SAAgB,EACd,EAIA,EAC6B,CAC7B,IAAM,EAAQ,EAAO,YAAY,CAAE,EAAG,EAAU,KAAM,EAAG,EAAU,GAAI,CAAC,EAClE,EAAM,EAAO,YAAY,CAAE,EAAG,EAAU,MAAO,EAAG,EAAU,MAAO,CAAC,EAE1E,OADI,IAAU,MAAQ,IAAQ,KAAa,KACpC,EAAe,EAAQ,EAAO,CAAG,CAC1C,CAgBA,MAAM,EAAa,EAAW,MAAM,CAAkB,EAEhD,EAAiB,EAAe,OAAO,CAC3C,CAAE,IAAK,EAAK,QAAS,GAAG,EAAmB,OAAQ,EACnD,CAAE,IAAK,EAAK,QAAS,GAAG,EAAmB,OAAQ,EACnD,CAAE,IAAK,CAAC,EAAK,KAAM,EAAK,KAAM,EAAK,KAAM,EAAK,IAAI,EAAG,GAAG,EAAmB,QAAS,EACpF,CAAE,IAAK,EAAK,OAAQ,GAAG,EAAmB,OAAQ,EAClD,CAAE,IAAK,CAAC,EAAK,OAAQ,EAAK,QAAQ,EAAK,MAAM,EAAG,EAAK,SAAS,EAAG,GAAG,EAAmB,MAAO,EAC9F,CAAE,IAAK,EAAK,OAAQ,GAAG,EA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AW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,CAC9E,CAAC,MACU,CACX,EAAY,EACd,CACF,EAAG,CAAC,CAAI,CAAC,EAEF,EAAC,MAAD,CAAK,IAAK,EAAM,cAAa,EAAQ,UAAW,EAAG,0BAA2B,CAAS,CAAI,CAAA,CACpG"}
1
+ {"version":3,"file":"CodeEditorView.mjs","names":[],"sources":["../../../src/components/CodeEditorView.tsx"],"sourcesContent":["import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';\nimport {\n bracketMatching,\n foldGutter,\n foldKeymap,\n HighlightStyle,\n indentOnInput,\n syntaxHighlighting,\n} from '@codemirror/language';\nimport { highlightSelectionMatches, search, searchKeymap } from '@codemirror/search';\nimport { Compartment, EditorState, StateEffect, StateField } from '@codemirror/state';\nimport {\n Decoration,\n type DecorationSet,\n drawSelection,\n EditorView,\n highlightActiveLine,\n highlightActiveLineGutter,\n keymap,\n lineNumbers,\n rectangularSelection,\n WidgetType,\n} from '@codemirror/view';\nimport { tags } from '@lezer/highlight';\nimport { useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { boundedEditorEdits, boundedEditorRanges } from '../lib/editorController';\nimport { grammarKeyOf, loadGrammar } from '../lib/editorLanguage';\nimport { DOOM_EDITOR_STYLES, DOOM_SYNTAX_STYLES } from '../lib/editorTheme';\nimport type { CodeEditorProps, EditorSelectionRange, EditorViewportRectangle } from '../types/editor';\n\nfunction selectionRange(editor: { readonly state: EditorState }, from: number, to: number): EditorSelectionRange {\n const start = Math.min(from, to);\n const end = Math.max(from, to);\n return {\n text: editor.state.sliceDoc(start, end),\n from: start,\n to: end,\n startLine: editor.state.doc.lineAt(start).number,\n endLine: editor.state.doc.lineAt(end).number,\n };\n}\n\nexport function resolveEditorViewportRegion(\n editor: {\n readonly state: EditorState;\n posAtCoords(coords: { x: number; y: number }): number | null;\n },\n rectangle: EditorViewportRectangle,\n): EditorSelectionRange | null {\n const start = editor.posAtCoords({ x: rectangle.left, y: rectangle.top });\n const end = editor.posAtCoords({ x: rectangle.right, y: rectangle.bottom });\n if (start === null || end === null) return null;\n return selectionRange(editor, start, end);\n}\n/**\n * The editor itself, mounted on a real CodeMirror view.\n *\n * Nothing imports this module directly: `CodeEditor` reaches it through a lazy\n * import so the whole editor, and every grammar under it, stays out of the\n * cockpit's first load. Behaviour lives here rather than in that wrapper so\n * the split costs one file and no indirection.\n *\n * The three things a caller can change after mount each sit in their own\n * compartment. Reconfiguring one is a transaction; rebuilding the editor would\n * throw away the undo history, the scroll position and the cursor, which is\n * what a reader loses if a parent re-render is allowed to remount this.\n */\n\n/** Not a colour or a layout choice: how CodeMirror is told to draw the doom palette. */\nconst DOOM_THEME = EditorView.theme(DOOM_EDITOR_STYLES);\n\nconst DOOM_HIGHLIGHT = HighlightStyle.define([\n { tag: tags.comment, ...DOOM_SYNTAX_STYLES.comment },\n { tag: tags.keyword, ...DOOM_SYNTAX_STYLES.keyword },\n { tag: [tags.atom, tags.bool, tags.null, tags.self], ...DOOM_SYNTAX_STYLES.constant },\n { tag: tags.number, ...DOOM_SYNTAX_STYLES.literal },\n { tag: [tags.string, tags.special(tags.string), tags.character], ...DOOM_SYNTAX_STYLES.string },\n { tag: tags.regexp, ...DOOM_SYNTAX_STYLES.regexp },\n { tag: tags.operator, ...DOOM_SYNTAX_STYLES.operator },\n { tag: tags.punctuation, ...DOOM_SYNTAX_STYLES.punctuation },\n { tag: tags.variableName, ...DOOM_SYNTAX_STYLES.variable },\n { tag: tags.propertyName, ...DOOM_SYNTAX_STYLES.property },\n { tag: [tags.function(tags.variableName), tags.function(tags.propertyName)], ...DOOM_SYNTAX_STYLES.callable },\n { tag: [tags.typeName, tags.className, tags.namespace], ...DOOM_SYNTAX_STYLES.type },\n { tag: tags.tagName, ...DOOM_SYNTAX_STYLES.tag },\n { tag: tags.attributeName, ...DOOM_SYNTAX_STYLES.attribute },\n { tag: [tags.meta, tags.processingInstruction], ...DOOM_SYNTAX_STYLES.meta },\n { tag: tags.heading, ...DOOM_SYNTAX_STYLES.heading },\n { tag: [tags.link, tags.url], ...DOOM_SYNTAX_STYLES.link },\n { tag: tags.emphasis, ...DOOM_SYNTAX_STYLES.emphasis },\n { tag: tags.strong, ...DOOM_SYNTAX_STYLES.strong },\n { tag: tags.strikethrough, ...DOOM_SYNTAX_STYLES.strikethrough },\n { tag: tags.invalid, ...DOOM_SYNTAX_STYLES.invalid },\n]);\n\nconst setClosedDecorations = StateEffect.define<DecorationSet>();\nconst closedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setClosedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nconst setMarkedDecorations = StateEffect.define<DecorationSet>();\nconst markedDecorations = StateField.define<DecorationSet>({\n create: () => Decoration.none,\n update: (decorations, transaction) => {\n let next = decorations.map(transaction.changes);\n for (const effect of transaction.effects) {\n if (effect.is(setMarkedDecorations)) next = effect.value;\n }\n return next;\n },\n provide: (field) => EditorView.decorations.from(field),\n});\n\nclass MarkedRangeLabel extends WidgetType {\n constructor(private readonly label: string) {\n super();\n }\n\n eq(other: MarkedRangeLabel): boolean {\n return other.label === this.label;\n }\n\n toDOM(): HTMLElement {\n const label = document.createElement('span');\n label.className = 'cm-marked-region-label';\n label.dataset.authorRegionLabel = this.label;\n label.textContent = this.label;\n return label;\n }\n}\n\nconst MARKED_REGION_THEME = EditorView.baseTheme({\n '.cm-marked-region': {\n backgroundColor: 'var(--doom-tint-yellow)',\n borderBottom: '1px solid var(--doom-edge-yellow)',\n },\n '.cm-marked-region-label': {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '16px',\n height: '16px',\n marginRight: '4px',\n borderRadius: '999px',\n backgroundColor: 'var(--doom-yellow)',\n color: 'var(--doom-deep)',\n fontSize: '9px',\n fontWeight: '700',\n lineHeight: '1',\n verticalAlign: 'text-bottom',\n },\n});\n\n/** Everything that never changes for the life of an editor. */\nconst FIXED_EXTENSIONS = [\n lineNumbers(),\n highlightActiveLineGutter(),\n foldGutter(),\n highlightActiveLine(),\n drawSelection(),\n rectangularSelection(),\n indentOnInput(),\n bracketMatching(),\n history(),\n search({ top: true }),\n highlightSelectionMatches(),\n // Tab indents rather than leaving the editor. That trades a keyboard user's\n // escape route for the behaviour every other editor has, so it is last in\n // the keymap and Escape then Tab still moves focus out.\n keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap, ...foldKeymap, indentWithTab]),\n syntaxHighlighting(DOOM_HIGHLIGHT),\n closedDecorations,\n markedDecorations,\n MARKED_REGION_THEME,\n DOOM_THEME,\n];\n\nexport function CodeEditorView({\n value,\n path,\n readOnly = false,\n lineWrapping = true,\n className,\n onChange,\n onSelect,\n controllerRef,\n 'data-testid': testId,\n}: CodeEditorProps) {\n const host = useRef<HTMLDivElement>(null);\n const view = useRef<EditorView | null>(null);\n // The callbacks are new objects on every parent render. Reading them through\n // a ref is what lets the editor be built once and still call the current\n // pair, rather than being rebuilt whenever the parent re-renders.\n const handlers = useRef({ onChange, onSelect });\n // The document is seeded once from the value of the first render; the sync effect\n // below owns every later change.\n const initialValue = useRef(value);\n const compartments = useRef({\n language: new Compartment(),\n readOnly: new Compartment(),\n wrapping: new Compartment(),\n });\n\n useEffect(() => {\n handlers.current = { onChange, onSelect };\n });\n\n useLayoutEffect(() => {\n const parent = host.current;\n if (parent === null) return;\n const { language, readOnly: readOnlyPart, wrapping } = compartments.current;\n const editor = new EditorView({\n parent,\n state: EditorState.create({\n // The initial document only; every later change arrives as a\n // transaction from the effect below.\n doc: initialValue.current,\n extensions: [\n ...FIXED_EXTENSIONS,\n language.of([]),\n readOnlyPart.of([]),\n wrapping.of([]),\n EditorView.updateListener.of((update) => {\n if (update.docChanged) handlers.current.onChange?.(update.state.doc.toString());\n if (!update.selectionSet && !update.docChanged) return;\n const report = handlers.current.onSelect;\n if (report === undefined) return;\n const range = update.state.selection.main;\n report(selectionRange(update.view, range.from, range.to));\n }),\n ],\n }),\n });\n view.current = editor;\n return () => {\n editor.destroy();\n view.current = null;\n };\n // Built once.\n }, []);\n\n useImperativeHandle(\n controllerRef,\n () => ({\n focus: () => view.current?.focus(),\n revealAndSelect: (range) => {\n const editor = view.current;\n if (editor === null) return;\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined) return;\n editor.dispatch({\n selection: { anchor: bounded.from, head: bounded.to },\n effects: EditorView.scrollIntoView(bounded.from, { y: 'center' }),\n });\n },\n applyEdits: (edits) => {\n const editor = view.current;\n if (editor === null || edits.length === 0) return;\n editor.dispatch({ changes: boundedEditorEdits(editor.state.doc.length, edits) });\n },\n setClosedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const bounded = boundedEditorRanges(editor.state.doc.length, ranges);\n const decorations = bounded.map((range) =>\n range.from === range.to\n ? Decoration.line({ attributes: { class: 'cm-closed-tone', 'data-tone': 'closed' } }).range(\n editor.state.doc.lineAt(range.from).from,\n )\n : Decoration.mark({ class: 'cm-closed-tone', attributes: { 'data-tone': 'closed' } }).range(\n range.from,\n range.to,\n ),\n );\n editor.dispatch({ effects: setClosedDecorations.of(Decoration.set(decorations)) });\n },\n setMarkedRanges: (ranges) => {\n const editor = view.current;\n if (editor === null) return;\n const decorations = ranges.flatMap((range) => {\n const [bounded] = boundedEditorRanges(editor.state.doc.length, [range]);\n if (bounded === undefined || bounded.from === bounded.to) return [];\n return [\n Decoration.widget({ widget: new MarkedRangeLabel(range.label), side: -1 }).range(bounded.from),\n Decoration.mark({\n class: 'cm-marked-region',\n attributes: { 'data-author-region': range.label },\n }).range(bounded.from, bounded.to),\n ];\n });\n editor.dispatch({ effects: setMarkedDecorations.of(Decoration.set(decorations, true)) });\n },\n resolveViewportRegion: (rectangle) => {\n const editor = view.current;\n return editor === null ? null : resolveEditorViewportRegion(editor, rectangle);\n },\n }),\n [],\n );\n\n useEffect(() => {\n const editor = view.current;\n // A caller that echoes onChange back into `value` would otherwise replace\n // the document on every keystroke and drop the cursor to the end.\n if (editor === null || editor.state.doc.toString() === value) return;\n editor.dispatch({ changes: { from: 0, to: editor.state.doc.length, insert: value } });\n }, [value]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.readOnly.reconfigure([\n EditorState.readOnly.of(readOnly),\n EditorView.editable.of(!readOnly),\n ]),\n });\n }, [readOnly]);\n\n useEffect(() => {\n view.current?.dispatch({\n effects: compartments.current.wrapping.reconfigure(lineWrapping ? EditorView.lineWrapping : []),\n });\n }, [lineWrapping]);\n\n useEffect(() => {\n const key = path === undefined ? undefined : grammarKeyOf(path);\n const { language } = compartments.current;\n if (key === undefined) {\n view.current?.dispatch({ effects: language.reconfigure([]) });\n return;\n }\n let cancelled = false;\n void loadGrammar(key)\n .then((grammar) => {\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure(grammar) });\n })\n .catch(() => {\n // A grammar is a separate chunk over the network, and the cockpit is\n // often read through a tunnel. Losing it costs syntax colour, not the\n // file, so fall back to plain text rather than failing the pane.\n if (!cancelled) view.current?.dispatch({ effects: language.reconfigure([]) });\n });\n return () => {\n cancelled = true;\n };\n }, [path]);\n\n return <div ref={host} data-testid={testId} className={cn('min-h-0 overflow-hidden', className)} />;\n}\n"],"mappings":"olCAgCA,SAAS,EAAe,EAAyC,EAAc,EAAkC,CAC/G,IAAM,EAAQ,KAAK,IAAI,EAAM,CAAE,EACzB,EAAM,KAAK,IAAI,EAAM,CAAE,EAC7B,MAAO,CACL,KAAM,EAAO,MAAM,SAAS,EAAO,CAAG,EACtC,KAAM,EACN,GAAI,EACJ,UAAW,EAAO,MAAM,IAAI,OAAO,CAAK,CAAC,CAAC,OAC1C,QAAS,EAAO,MAAM,IAAI,OAAO,CAAG,CAAC,CAAC,MACxC,CACF,CAEA,SAAgB,EACd,EAIA,EAC6B,C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ACrB,QAAS,EAAa,QAAQ,SAAS,YAAY,CACjD,EAAY,SAAS,GAAG,CAAQ,EAChC,EAAW,SAAS,GAAG,CAAC,CAAQ,CAClC,CAAC,CACH,CAAC,CACH,EAAG,CAAC,CAAQ,CAAC,EAEb,MAAgB,CACd,EAAK,SAAS,SAAS,CACrB,QAAS,EAAa,QAAQ,SAAS,YAAY,EAAe,EAAW,aAAe,CAAC,CAAC,CAChG,CAAC,CACH,EAAG,CAAC,CAAY,CAAC,EAEjB,MAAgB,CACd,IAAM,EAAM,IAAS,IAAA,GAAY,IAAA,GAAY,EAAa,CAAI,EACxD,CAAE,YAAa,EAAa,QAClC,GAAI,IAAQ,IAAA,GAAW,CACrB,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,EAC5D,MACF,CACA,IAAI,EAAY,GAWhB,OAVA,EAAiB,CAAG,CAAC,CAClB,KAAM,GAAY,CACZ,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAO,CAAE,CAAC,CACnF,CAAC,CAAC,CACD,UAAY,CAIN,GAAW,EAAK,SAAS,SAAS,CAAE,QAAS,EAAS,YAAY,CAAC,CAAC,CAAE,CAAC,CAC9E,CAAC,MACU,CACX,EAAY,EACd,CACF,EAAG,CAAC,CAAI,CAAC,EAEF,kBAAC,MAAD,CAAK,IAAK,EAAM,cAAa,EAAQ,UAAW,EAAG,0BAA2B,CAAS,CAAI,CAAA,CACpG"}
@@ -1,2 +1,2 @@
1
- const e=require("../lib/cn.cjs");let t=require("radix-ui"),n=require("react/jsx-runtime");function r(e){return(0,n.jsx)(t.Collapsible.Root,{"data-slot":`collapsible`,...e})}function i(e){return(0,n.jsx)(t.Collapsible.CollapsibleTrigger,{"data-slot":`collapsible-trigger`,...e})}function a({className:r,...i}){return(0,n.jsx)(t.Collapsible.CollapsibleContent,{"data-slot":`collapsible-content`,className:e.cn(`overflow-hidden`,r),...i})}exports.Collapsible=r,exports.CollapsibleContent=a,exports.CollapsibleTrigger=i;
1
+ const e=require("../lib/cn.cjs");let t=require("radix-ui"),n=require("react/jsx-runtime");function r(e){return/* @__PURE__ */ (0,n.jsx)(t.Collapsible.Root,{"data-slot":`collapsible`,...e})}function i(e){return/* @__PURE__ */ (0,n.jsx)(t.Collapsible.CollapsibleTrigger,{"data-slot":`collapsible-trigger`,...e})}function a({className:r,...i}){return/* @__PURE__ */ (0,n.jsx)(t.Collapsible.CollapsibleContent,{"data-slot":`collapsible-content`,className:e.cn(`overflow-hidden`,r),...i})}exports.Collapsible=r,exports.CollapsibleContent=a,exports.CollapsibleTrigger=i;
2
2
  //# sourceMappingURL=Collapsible.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Collapsible.cjs","names":["CollapsiblePrimitive","cn"],"sources":["../../../src/components/Collapsible.tsx"],"sourcesContent":["import { Collapsible as CollapsiblePrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { cn } from '../lib/cn';\n\n/** A section that folds; Radix keeps the trigger's aria-expanded in step with the content. */\nexport function Collapsible(props: ComponentProps<typeof CollapsiblePrimitive.Root>) {\n return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />;\n}\n\nexport function CollapsibleTrigger(props: ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {\n return <CollapsiblePrimitive.CollapsibleTrigger data-slot=\"collapsible-trigger\" {...props} />;\n}\n\nexport function CollapsibleContent({\n className,\n ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {\n return (\n <CollapsiblePrimitive.CollapsibleContent\n data-slot=\"collapsible-content\"\n className={cn('overflow-hidden', className)}\n {...props}\n />\n );\n}\n"],"mappings":"0FAMA,SAAgB,EAAY,EAAyD,CACnF,OAAO,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,KAAtB,CAA2B,YAAU,cAAc,GAAI,CAAQ,CAAA,CACxE,CAEA,SAAgB,EAAmB,EAAuE,CACxG,OAAO,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,mBAAtB,CAAyC,YAAU,sBAAsB,GAAI,CAAQ,CAAA,CAC9F,CAEA,SAAgB,EAAmB,CACjC,YACA,GAAG,GAC8D,CACjE,OACE,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,mBAAtB,CACE,YAAU,sBACV,UAAWC,EAAAA,GAAG,kBAAmB,CAAS,EAC1C,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"Collapsible.cjs","names":["CollapsiblePrimitive","cn"],"sources":["../../../src/components/Collapsible.tsx"],"sourcesContent":["import { Collapsible as CollapsiblePrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { cn } from '../lib/cn';\n\n/** A section that folds; Radix keeps the trigger's aria-expanded in step with the content. */\nexport function Collapsible(props: ComponentProps<typeof CollapsiblePrimitive.Root>) {\n return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />;\n}\n\nexport function CollapsibleTrigger(props: ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {\n return <CollapsiblePrimitive.CollapsibleTrigger data-slot=\"collapsible-trigger\" {...props} />;\n}\n\nexport function CollapsibleContent({\n className,\n ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {\n return (\n <CollapsiblePrimitive.CollapsibleContent\n data-slot=\"collapsible-content\"\n className={cn('overflow-hidden', className)}\n {...props}\n />\n );\n}\n"],"mappings":"0FAMA,SAAgB,EAAY,EAAyD,CACnF,MAAO,iBAAA,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,KAAtB,CAA2B,YAAU,cAAc,GAAI,CAAQ,CAAA,CACxE,CAEA,SAAgB,EAAmB,EAAuE,CACxG,MAAO,iBAAA,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,mBAAtB,CAAyC,YAAU,sBAAsB,GAAI,CAAQ,CAAA,CAC9F,CAEA,SAAgB,EAAmB,CACjC,YACA,GAAG,GAC8D,CACjE,MACE,iBAAA,EAAA,EAAA,IAAA,CAACA,EAAAA,YAAqB,mBAAtB,CACE,YAAU,sBACV,UAAWC,EAAAA,GAAG,kBAAmB,CAAS,EAC1C,GAAI,CACL,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../lib/cn.mjs";import{Collapsible as t}from"radix-ui";import{jsx as n}from"react/jsx-runtime";function r(e){return n(t.Root,{"data-slot":`collapsible`,...e})}function i(e){return n(t.CollapsibleTrigger,{"data-slot":`collapsible-trigger`,...e})}function a({className:r,...i}){return n(t.CollapsibleContent,{"data-slot":`collapsible-content`,className:e(`overflow-hidden`,r),...i})}export{r as Collapsible,a as CollapsibleContent,i as CollapsibleTrigger};
1
+ import{cn as e}from"../lib/cn.mjs";import{Collapsible as t}from"radix-ui";import{jsx as n}from"react/jsx-runtime";function r(e){return/* @__PURE__ */ n(t.Root,{"data-slot":`collapsible`,...e})}function i(e){return/* @__PURE__ */ n(t.CollapsibleTrigger,{"data-slot":`collapsible-trigger`,...e})}function a({className:r,...i}){return/* @__PURE__ */ n(t.CollapsibleContent,{"data-slot":`collapsible-content`,className:e(`overflow-hidden`,r),...i})}export{r as Collapsible,a as CollapsibleContent,i as CollapsibleTrigger};
2
2
  //# sourceMappingURL=Collapsible.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Collapsible.mjs","names":["Collapsible","CollapsiblePrimitive"],"sources":["../../../src/components/Collapsible.tsx"],"sourcesContent":["import { Collapsible as CollapsiblePrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { cn } from '../lib/cn';\n\n/** A section that folds; Radix keeps the trigger's aria-expanded in step with the content. */\nexport function Collapsible(props: ComponentProps<typeof CollapsiblePrimitive.Root>) {\n return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />;\n}\n\nexport function CollapsibleTrigger(props: ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {\n return <CollapsiblePrimitive.CollapsibleTrigger data-slot=\"collapsible-trigger\" {...props} />;\n}\n\nexport function CollapsibleContent({\n className,\n ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {\n return (\n <CollapsiblePrimitive.CollapsibleContent\n data-slot=\"collapsible-content\"\n className={cn('overflow-hidden', className)}\n {...props}\n />\n );\n}\n"],"mappings":"kHAMA,SAAgBA,EAAY,EAAyD,CACnF,OAAO,EAACC,EAAqB,KAAtB,CAA2B,YAAU,cAAc,GAAI,CAAQ,CAAA,CACxE,CAEA,SAAgB,EAAmB,EAAuE,CACxG,OAAO,EAACA,EAAqB,mBAAtB,CAAyC,YAAU,sBAAsB,GAAI,CAAQ,CAAA,CAC9F,CAEA,SAAgB,EAAmB,CACjC,YACA,GAAG,GAC8D,CACjE,OACE,EAACA,EAAqB,mBAAtB,CACE,YAAU,sBACV,UAAW,EAAG,kBAAmB,CAAS,EAC1C,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"Collapsible.mjs","names":["Collapsible","CollapsiblePrimitive"],"sources":["../../../src/components/Collapsible.tsx"],"sourcesContent":["import { Collapsible as CollapsiblePrimitive } from 'radix-ui';\nimport type { ComponentProps } from 'react';\n\nimport { cn } from '../lib/cn';\n\n/** A section that folds; Radix keeps the trigger's aria-expanded in step with the content. */\nexport function Collapsible(props: ComponentProps<typeof CollapsiblePrimitive.Root>) {\n return <CollapsiblePrimitive.Root data-slot=\"collapsible\" {...props} />;\n}\n\nexport function CollapsibleTrigger(props: ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {\n return <CollapsiblePrimitive.CollapsibleTrigger data-slot=\"collapsible-trigger\" {...props} />;\n}\n\nexport function CollapsibleContent({\n className,\n ...props\n}: ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {\n return (\n <CollapsiblePrimitive.CollapsibleContent\n data-slot=\"collapsible-content\"\n className={cn('overflow-hidden', className)}\n {...props}\n />\n );\n}\n"],"mappings":"kHAMA,SAAgBA,EAAY,EAAyD,CACnF,MAAO,kBAACC,EAAqB,KAAtB,CAA2B,YAAU,cAAc,GAAI,CAAQ,CAAA,CACxE,CAEA,SAAgB,EAAmB,EAAuE,CACxG,MAAO,kBAACA,EAAqB,mBAAtB,CAAyC,YAAU,sBAAsB,GAAI,CAAQ,CAAA,CAC9F,CAEA,SAAgB,EAAmB,CACjC,YACA,GAAG,GAC8D,CACjE,MACE,kBAACA,EAAqB,mBAAtB,CACE,YAAU,sBACV,UAAW,EAAG,kBAAmB,CAAS,EAC1C,GAAI,CACL,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- const e=require("../lib/cn.cjs"),t=require("./Dialog.cjs"),n=require("./Input.cjs"),r=require("./OptionList.cjs");let i=require("react/jsx-runtime");function a({open:n,onOpenChange:r,title:a,titleVisible:o=!1,className:s,children:c,width:l=`lg`,...u}){return(0,i.jsx)(t.Dialog,{open:n,onOpenChange:r,children:(0,i.jsxs)(t.DialogContent,{"data-slot":`command-dialog`,width:l,className:e.cn(`max-h-[70vh]`,s),...u,children:[(0,i.jsx)(t.DialogTitle,{className:o?void 0:`sr-only`,children:a}),c]})})}function o({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`command-header`,className:e.cn(`flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5`,t),...n})}function s({className:t,...r}){return(0,i.jsx)(n.Input,{"data-slot":`command-input`,variant:`bare`,autoFocus:!0,autoComplete:`off`,className:e.cn(`flex-1`,t),...r})}function c({className:t,...n}){return(0,i.jsx)(`div`,{role:`listbox`,"data-slot":`command-list`,className:e.cn(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,t),...n})}function l({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`command-group`,className:e.cn(`flex flex-col gap-0.5`,t),...n})}function u({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`command-group-label`,className:e.cn(`px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase`,t),...n})}function d({density:e=`compact`,...t}){return(0,i.jsx)(r.OptionRow,{"data-slot":`command-item`,density:e,...t})}function f(e){return(0,i.jsx)(r.OptionLabel,{"data-slot":`command-item-label`,density:`compact`,...e})}function p({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`command-empty`,className:e.cn(`px-2 py-6 text-center text-sm text-doom-faint`,t),...n})}function m({className:t,...n}){return(0,i.jsx)(`div`,{"data-slot":`command-footer`,className:e.cn(`flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint`,t),...n})}exports.CommandDialog=a,exports.CommandEmpty=p,exports.CommandFooter=m,exports.CommandGroup=l,exports.CommandGroupLabel=u,exports.CommandHeader=o,exports.CommandInput=s,exports.CommandItem=d,exports.CommandItemLabel=f,exports.CommandList=c;
1
+ const e=require("../lib/cn.cjs"),t=require("./Dialog.cjs"),n=require("./Input.cjs"),r=require("./OptionList.cjs");let i=require("react/jsx-runtime");function a({open:n,onOpenChange:r,title:a,titleVisible:o=!1,className:s,children:c,width:l=`lg`,...u}){return/* @__PURE__ */ (0,i.jsx)(t.Dialog,{open:n,onOpenChange:r,children:/* @__PURE__ */ (0,i.jsxs)(t.DialogContent,{"data-slot":`command-dialog`,width:l,className:e.cn(`max-h-[70vh]`,s),...u,children:[/* @__PURE__ */ (0,i.jsx)(t.DialogTitle,{className:o?void 0:`sr-only`,children:a}),c]})})}function o({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{"data-slot":`command-header`,className:e.cn(`flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5`,t),...n})}function s({className:t,...r}){return/* @__PURE__ */ (0,i.jsx)(n.Input,{"data-slot":`command-input`,variant:`bare`,autoFocus:!0,autoComplete:`off`,className:e.cn(`flex-1`,t),...r})}function c({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{role:`listbox`,"data-slot":`command-list`,className:e.cn(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,t),...n})}function l({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{"data-slot":`command-group`,className:e.cn(`flex flex-col gap-0.5`,t),...n})}function u({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{"data-slot":`command-group-label`,className:e.cn(`px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase`,t),...n})}function d({density:e=`compact`,...t}){return/* @__PURE__ */ (0,i.jsx)(r.OptionRow,{"data-slot":`command-item`,density:e,...t})}function f(e){return/* @__PURE__ */ (0,i.jsx)(r.OptionLabel,{"data-slot":`command-item-label`,density:`compact`,...e})}function p({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{"data-slot":`command-empty`,className:e.cn(`px-2 py-6 text-center text-sm text-doom-faint`,t),...n})}function m({className:t,...n}){return/* @__PURE__ */ (0,i.jsx)(`div`,{"data-slot":`command-footer`,className:e.cn(`flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint`,t),...n})}exports.CommandDialog=a,exports.CommandEmpty=p,exports.CommandFooter=m,exports.CommandGroup=l,exports.CommandGroupLabel=u,exports.CommandHeader=o,exports.CommandInput=s,exports.CommandItem=d,exports.CommandItemLabel=f,exports.CommandList=c;
2
2
  //# sourceMappingURL=Command.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Command.cjs","names":["Dialog","DialogContent","cn","DialogTitle","Input","OptionRow","OptionLabel"],"sources":["../../../src/components/Command.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { Dialog, DialogContent, type DialogContentProps, DialogTitle } from './Dialog';\nimport { Input, type InputProps } from './Input';\nimport { OptionLabel, OptionRow, type OptionRowProps } from './OptionList';\n\n/**\n * The command palette's frame, its search strip, its rows, and its hint.\n *\n * It has no Radix counterpart and it deliberately does no filtering: the\n * surface that opens a palette already knows how to rank its own commands,\n * and a matcher baked in here would be a second, worse one. Built on Dialog,\n * Input, and the option row so a palette and a select popover cannot drift\n * apart, rather than on a new dependency.\n */\n\nexport interface CommandDialogProps extends Omit<DialogContentProps, 'title'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Names the dialog for assistive tech; visually hidden unless the palette draws its own heading. */\n title: ReactNode;\n titleVisible?: boolean;\n}\n\nexport function CommandDialog({\n open,\n onOpenChange,\n title,\n titleVisible = false,\n className,\n children,\n width = 'lg',\n ...props\n}: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-slot=\"command-dialog\" width={width} className={cn('max-h-[70vh]', className)} {...props}>\n <DialogTitle className={titleVisible ? undefined : 'sr-only'}>{title}</DialogTitle>\n {children}\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The strip the search field sits in. */\nexport function CommandHeader({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-header\"\n className={cn('flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5', className)}\n {...props}\n />\n );\n}\n\n/** The search field: bare, because the header already draws the surface. */\nexport function CommandInput({ className, ...props }: InputProps) {\n return (\n <Input\n data-slot=\"command-input\"\n variant=\"bare\"\n autoFocus\n autoComplete=\"off\"\n className={cn('flex-1', className)}\n {...props}\n />\n );\n}\n\n/** The scrolling body. It is the listbox, so its rows are the options. */\nexport function CommandList({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n role=\"listbox\"\n data-slot=\"command-list\"\n className={cn('flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5', className)}\n {...props}\n />\n );\n}\n\n/** A labelled run of rows. */\nexport function CommandGroup({ className, ...props }: ComponentProps<'div'>) {\n return <div data-slot=\"command-group\" className={cn('flex flex-col gap-0.5', className)} {...props} />;\n}\n\nexport function CommandGroupLabel({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-group-label\"\n className={cn('px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase', className)}\n {...props}\n />\n );\n}\n\n/** One command. Compact by default, since a palette shows many at once. */\nexport function CommandItem({ density = 'compact', ...props }: OptionRowProps) {\n return <OptionRow data-slot=\"command-item\" density={density} {...props} />;\n}\n\n/** A command's name, taking the width the row has left. */\nexport function CommandItemLabel(props: ComponentProps<'span'>) {\n return <OptionLabel data-slot=\"command-item-label\" density=\"compact\" {...props} />;\n}\n\n/** What the palette says when nothing matches. */\nexport function CommandEmpty({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-empty\"\n className={cn('px-2 py-6 text-center text-sm text-doom-faint', className)}\n {...props}\n />\n );\n}\n\n/** The hint strip along the bottom: what the keys do. */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-footer\"\n className={cn(\n 'flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint',\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":"qJAyBA,SAAgB,EAAc,CAC5B,OACA,eACA,QACA,eAAe,GACf,YACA,WACA,QAAQ,KACR,GAAG,GACkB,CACrB,OACE,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAc,OAAoB,eAChC,UAAA,EAAA,EAAA,KAAA,CAACC,EAAAA,cAAD,CAAe,YAAU,iBAAwB,QAAO,UAAWC,EAAAA,GAAG,eAAgB,CAAS,EAAG,GAAI,EAAtG,SAAA,EACE,EAAA,EAAA,IAAA,CAACC,EAAAA,YAAD,CAAa,UAAW,EAAe,IAAA,GAAY,UAAY,SAAA,CAAmB,CAAA,EACjF,CACY,GACT,CAAA,CAEZ,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,OACE,EAAA,EAAA,IAAA,CAAC,MAAD,CACE,YAAU,iBACV,UAAWD,EAAAA,GAAG,2EAA4E,CAAS,EACnG,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAqB,CAChE,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V,UAAWA,EAAAA,GACT,4IACA,CACF,EACA,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"Command.cjs","names":["Dialog","DialogContent","cn","DialogTitle","Input","OptionRow","OptionLabel"],"sources":["../../../src/components/Command.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { Dialog, DialogContent, type DialogContentProps, DialogTitle } from './Dialog';\nimport { Input, type InputProps } from './Input';\nimport { OptionLabel, OptionRow, type OptionRowProps } from './OptionList';\n\n/**\n * The command palette's frame, its search strip, its rows, and its hint.\n *\n * It has no Radix counterpart and it deliberately does no filtering: the\n * surface that opens a palette already knows how to rank its own commands,\n * and a matcher baked in here would be a second, worse one. Built on Dialog,\n * Input, and the option row so a palette and a select popover cannot drift\n * apart, rather than on a new dependency.\n */\n\nexport interface CommandDialogProps extends Omit<DialogContentProps, 'title'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Names the dialog for assistive tech; visually hidden unless the palette draws its own heading. */\n title: ReactNode;\n titleVisible?: boolean;\n}\n\nexport function CommandDialog({\n open,\n onOpenChange,\n title,\n titleVisible = false,\n className,\n children,\n width = 'lg',\n ...props\n}: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-slot=\"command-dialog\" width={width} className={cn('max-h-[70vh]', className)} {...props}>\n <DialogTitle className={titleVisible ? undefined : 'sr-only'}>{title}</DialogTitle>\n {children}\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The strip the search field sits in. */\nexport function CommandHeader({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-header\"\n className={cn('flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5', className)}\n {...props}\n />\n );\n}\n\n/** The search field: bare, because the header already draws the surface. */\nexport function CommandInput({ className, ...props }: InputProps) {\n return (\n <Input\n data-slot=\"command-input\"\n variant=\"bare\"\n autoFocus\n autoComplete=\"off\"\n className={cn('flex-1', className)}\n {...props}\n />\n );\n}\n\n/** The scrolling body. It is the listbox, so its rows are the options. */\nexport function CommandList({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n role=\"listbox\"\n data-slot=\"command-list\"\n className={cn('flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5', className)}\n {...props}\n />\n );\n}\n\n/** A labelled run of rows. */\nexport function CommandGroup({ className, ...props }: ComponentProps<'div'>) {\n return <div data-slot=\"command-group\" className={cn('flex flex-col gap-0.5', className)} {...props} />;\n}\n\nexport function CommandGroupLabel({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-group-label\"\n className={cn('px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase', className)}\n {...props}\n />\n );\n}\n\n/** One command. Compact by default, since a palette shows many at once. */\nexport function CommandItem({ density = 'compact', ...props }: OptionRowProps) {\n return <OptionRow data-slot=\"command-item\" density={density} {...props} />;\n}\n\n/** A command's name, taking the width the row has left. */\nexport function CommandItemLabel(props: ComponentProps<'span'>) {\n return <OptionLabel data-slot=\"command-item-label\" density=\"compact\" {...props} />;\n}\n\n/** What the palette says when nothing matches. */\nexport function CommandEmpty({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-empty\"\n className={cn('px-2 py-6 text-center text-sm text-doom-faint', className)}\n {...props}\n />\n );\n}\n\n/** The hint strip along the bottom: what the keys do. */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-footer\"\n className={cn(\n 'flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint',\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":"qJAyBA,SAAgB,EAAc,CAC5B,OACA,eACA,QACA,eAAe,GACf,YACA,WACA,QAAQ,KACR,GAAG,GACkB,CACrB,MACE,iBAAA,EAAA,EAAA,IAAA,CAACA,EAAAA,OAAD,CAAc,OA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UAAU,UAAW,GAAG,GAAyB,CAC7E,MAAO,iBAAA,EAAA,EAAA,IAAA,CAACG,EAAAA,UAAD,CAAW,YAAU,eAAwB,UAAS,GAAI,CAAQ,CAAA,CAC3E,CAGA,SAAgB,EAAiB,EAA+B,CAC9D,MAAO,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,YAAD,CAAa,YAAU,qBAAqB,QAAQ,UAAU,GAAI,CAAQ,CAAA,CACnF,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAgC,CAC3E,MACE,iBAAA,EAAA,EAAA,IAAA,CAAC,MAAD,CACE,YAAU,gBACV,UAAWJ,EAAAA,GAAG,gDAAiD,CAAS,EACxE,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,MACE,iBAAA,EAAA,EAAA,IAAA,CAAC,MAAD,CACE,YAAU,iBACV,UAAWA,EAAAA,GACT,4IACA,CACF,EACA,GAAI,CACL,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- import{cn as e}from"../lib/cn.mjs";import{Dialog as t,DialogContent as n,DialogTitle as r}from"./Dialog.mjs";import{Input as i}from"./Input.mjs";import{OptionLabel as a,OptionRow as o}from"./OptionList.mjs";import{jsx as s,jsxs as c}from"react/jsx-runtime";function l({open:i,onOpenChange:a,title:o,titleVisible:l=!1,className:u,children:d,width:f=`lg`,...p}){return s(t,{open:i,onOpenChange:a,children:c(n,{"data-slot":`command-dialog`,width:f,className:e(`max-h-[70vh]`,u),...p,children:[s(r,{className:l?void 0:`sr-only`,children:o}),d]})})}function u({className:t,...n}){return s(`div`,{"data-slot":`command-header`,className:e(`flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5`,t),...n})}function d({className:t,...n}){return s(i,{"data-slot":`command-input`,variant:`bare`,autoFocus:!0,autoComplete:`off`,className:e(`flex-1`,t),...n})}function f({className:t,...n}){return s(`div`,{role:`listbox`,"data-slot":`command-list`,className:e(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,t),...n})}function p({className:t,...n}){return s(`div`,{"data-slot":`command-group`,className:e(`flex flex-col gap-0.5`,t),...n})}function m({className:t,...n}){return s(`div`,{"data-slot":`command-group-label`,className:e(`px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase`,t),...n})}function h({density:e=`compact`,...t}){return s(o,{"data-slot":`command-item`,density:e,...t})}function g(e){return s(a,{"data-slot":`command-item-label`,density:`compact`,...e})}function _({className:t,...n}){return s(`div`,{"data-slot":`command-empty`,className:e(`px-2 py-6 text-center text-sm text-doom-faint`,t),...n})}function v({className:t,...n}){return s(`div`,{"data-slot":`command-footer`,className:e(`flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint`,t),...n})}export{l as CommandDialog,_ as CommandEmpty,v as CommandFooter,p as CommandGroup,m as CommandGroupLabel,u as CommandHeader,d as CommandInput,h as CommandItem,g as CommandItemLabel,f as CommandList};
1
+ import{cn as e}from"../lib/cn.mjs";import{Dialog as t,DialogContent as n,DialogTitle as r}from"./Dialog.mjs";import{Input as i}from"./Input.mjs";import{OptionLabel as a,OptionRow as o}from"./OptionList.mjs";import{jsx as s,jsxs as c}from"react/jsx-runtime";function l({open:i,onOpenChange:a,title:o,titleVisible:l=!1,className:u,children:d,width:f=`lg`,...p}){return/* @__PURE__ */ s(t,{open:i,onOpenChange:a,children:/* @__PURE__ */ c(n,{"data-slot":`command-dialog`,width:f,className:e(`max-h-[70vh]`,u),...p,children:[/* @__PURE__ */ s(r,{className:l?void 0:`sr-only`,children:o}),d]})})}function u({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`command-header`,className:e(`flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5`,t),...n})}function d({className:t,...n}){return/* @__PURE__ */ s(i,{"data-slot":`command-input`,variant:`bare`,autoFocus:!0,autoComplete:`off`,className:e(`flex-1`,t),...n})}function f({className:t,...n}){return/* @__PURE__ */ s(`div`,{role:`listbox`,"data-slot":`command-list`,className:e(`flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5`,t),...n})}function p({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`command-group`,className:e(`flex flex-col gap-0.5`,t),...n})}function m({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`command-group-label`,className:e(`px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase`,t),...n})}function h({density:e=`compact`,...t}){return/* @__PURE__ */ s(o,{"data-slot":`command-item`,density:e,...t})}function g(e){return/* @__PURE__ */ s(a,{"data-slot":`command-item-label`,density:`compact`,...e})}function _({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`command-empty`,className:e(`px-2 py-6 text-center text-sm text-doom-faint`,t),...n})}function v({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`command-footer`,className:e(`flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint`,t),...n})}export{l as CommandDialog,_ as CommandEmpty,v as CommandFooter,p as CommandGroup,m as CommandGroupLabel,u as CommandHeader,d as CommandInput,h as CommandItem,g as CommandItemLabel,f as CommandList};
2
2
  //# sourceMappingURL=Command.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Command.mjs","names":[],"sources":["../../../src/components/Command.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { Dialog, DialogContent, type DialogContentProps, DialogTitle } from './Dialog';\nimport { Input, type InputProps } from './Input';\nimport { OptionLabel, OptionRow, type OptionRowProps } from './OptionList';\n\n/**\n * The command palette's frame, its search strip, its rows, and its hint.\n *\n * It has no Radix counterpart and it deliberately does no filtering: the\n * surface that opens a palette already knows how to rank its own commands,\n * and a matcher baked in here would be a second, worse one. Built on Dialog,\n * Input, and the option row so a palette and a select popover cannot drift\n * apart, rather than on a new dependency.\n */\n\nexport interface CommandDialogProps extends Omit<DialogContentProps, 'title'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Names the dialog for assistive tech; visually hidden unless the palette draws its own heading. */\n title: ReactNode;\n titleVisible?: boolean;\n}\n\nexport function CommandDialog({\n open,\n onOpenChange,\n title,\n titleVisible = false,\n className,\n children,\n width = 'lg',\n ...props\n}: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-slot=\"command-dialog\" width={width} className={cn('max-h-[70vh]', className)} {...props}>\n <DialogTitle className={titleVisible ? undefined : 'sr-only'}>{title}</DialogTitle>\n {children}\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The strip the search field sits in. */\nexport function CommandHeader({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-header\"\n className={cn('flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5', className)}\n {...props}\n />\n );\n}\n\n/** The search field: bare, because the header already draws the surface. */\nexport function CommandInput({ className, ...props }: InputProps) {\n return (\n <Input\n data-slot=\"command-input\"\n variant=\"bare\"\n autoFocus\n autoComplete=\"off\"\n className={cn('flex-1', className)}\n {...props}\n />\n );\n}\n\n/** The scrolling body. It is the listbox, so its rows are the options. */\nexport function CommandList({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n role=\"listbox\"\n data-slot=\"command-list\"\n className={cn('flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5', className)}\n {...props}\n />\n );\n}\n\n/** A labelled run of rows. */\nexport function CommandGroup({ className, ...props }: ComponentProps<'div'>) {\n return <div data-slot=\"command-group\" className={cn('flex flex-col gap-0.5', className)} {...props} />;\n}\n\nexport function CommandGroupLabel({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-group-label\"\n className={cn('px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase', className)}\n {...props}\n />\n );\n}\n\n/** One command. Compact by default, since a palette shows many at once. */\nexport function CommandItem({ density = 'compact', ...props }: OptionRowProps) {\n return <OptionRow data-slot=\"command-item\" density={density} {...props} />;\n}\n\n/** A command's name, taking the width the row has left. */\nexport function CommandItemLabel(props: ComponentProps<'span'>) {\n return <OptionLabel data-slot=\"command-item-label\" density=\"compact\" {...props} />;\n}\n\n/** What the palette says when nothing matches. */\nexport function CommandEmpty({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-empty\"\n className={cn('px-2 py-6 text-center text-sm text-doom-faint', className)}\n {...props}\n />\n );\n}\n\n/** The hint strip along the bottom: what the keys do. */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-footer\"\n className={cn(\n 'flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint',\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":"iQAyBA,SAAgB,EAAc,CAC5B,OACA,eACA,QACA,eAAe,GACf,YACA,WACA,QAAQ,KACR,GAAG,GACkB,CACrB,OACE,EAAC,EAAD,CAAc,OAAoB,eAChC,SAAA,EAAC,EAAD,CAAe,YAAU,iBAAwB,QAAO,UAAW,EAAG,eAAgB,CAAS,EAAG,GAAI,EAAtG,SAAA,CACE,EAAC,EAAD,CAAa,UAAW,EAAe,IAAA,GAAY,UAAY,SAAA,CAAmB,CAAA,EACjF,CACY,GACT,CAAA,CAEZ,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,OACE,EAAC,MAAD,CACE,YAAU,iBACV,UAAW,EAAG,2EAA4E,CAAS,EACnG,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAqB,CAChE,OACE,EAAC,EAAD,CACE,YAAU,gBACV,QAAQ,OACR,UAAA,GACA,aAAa,MACb,UAAW,EAAG,SAAU,CAAS,EACjC,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAY,CAAE,YAAW,GAAG,GAAgC,CAC1E,OACE,EAAC,MAAD,CACE,KAAK,UACL,YAAU,eACV,UAAW,EAAG,6DAA8D,CAAS,EACrF,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAgC,CAC3E,OAAO,EAAC,MAAD,CAAK,YAAU,gBAAgB,UAAW,EAAG,wBAAyB,CAAS,EAAG,GAAI,CAAQ,CAAA,CACvG,CAEA,SAAgB,EAAkB,CAAE,YAAW,GAAG,GAAgC,CAChF,OACE,EAAC,MAAD,CACE,YAAU,sBACV,UAAW,EAAG,6EAA8E,CAAS,EACrG,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAY,CAAE,UAAU,UAAW,GAAG,GAAyB,CAC7E,OAAO,EAAC,EAAD,CAAW,YAAU,eAAwB,UAAS,GAAI,CAAQ,CAAA,CAC3E,CAGA,SAAgB,EAAiB,EAA+B,CAC9D,OAAO,EAAC,EAAD,CAAa,YAAU,qBAAqB,QAAQ,UAAU,GAAI,CAAQ,CAAA,CACnF,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAgC,CAC3E,OACE,EAAC,MAAD,CACE,YAAU,gBACV,UAAW,EAAG,gDAAiD,CAAS,EACxE,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,OACE,EAAC,MAAD,CACE,YAAU,iBACV,UAAW,EACT,4IACA,CACF,EACA,GAAI,CACL,CAAA,CAEL"}
1
+ {"version":3,"file":"Command.mjs","names":[],"sources":["../../../src/components/Command.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../lib/cn';\nimport { Dialog, DialogContent, type DialogContentProps, DialogTitle } from './Dialog';\nimport { Input, type InputProps } from './Input';\nimport { OptionLabel, OptionRow, type OptionRowProps } from './OptionList';\n\n/**\n * The command palette's frame, its search strip, its rows, and its hint.\n *\n * It has no Radix counterpart and it deliberately does no filtering: the\n * surface that opens a palette already knows how to rank its own commands,\n * and a matcher baked in here would be a second, worse one. Built on Dialog,\n * Input, and the option row so a palette and a select popover cannot drift\n * apart, rather than on a new dependency.\n */\n\nexport interface CommandDialogProps extends Omit<DialogContentProps, 'title'> {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Names the dialog for assistive tech; visually hidden unless the palette draws its own heading. */\n title: ReactNode;\n titleVisible?: boolean;\n}\n\nexport function CommandDialog({\n open,\n onOpenChange,\n title,\n titleVisible = false,\n className,\n children,\n width = 'lg',\n ...props\n}: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent data-slot=\"command-dialog\" width={width} className={cn('max-h-[70vh]', className)} {...props}>\n <DialogTitle className={titleVisible ? undefined : 'sr-only'}>{title}</DialogTitle>\n {children}\n </DialogContent>\n </Dialog>\n );\n}\n\n/** The strip the search field sits in. */\nexport function CommandHeader({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-header\"\n className={cn('flex shrink-0 items-center gap-2 border-b border-doom-border px-3 py-2.5', className)}\n {...props}\n />\n );\n}\n\n/** The search field: bare, because the header already draws the surface. */\nexport function CommandInput({ className, ...props }: InputProps) {\n return (\n <Input\n data-slot=\"command-input\"\n variant=\"bare\"\n autoFocus\n autoComplete=\"off\"\n className={cn('flex-1', className)}\n {...props}\n />\n );\n}\n\n/** The scrolling body. It is the listbox, so its rows are the options. */\nexport function CommandList({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n role=\"listbox\"\n data-slot=\"command-list\"\n className={cn('flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto p-1.5', className)}\n {...props}\n />\n );\n}\n\n/** A labelled run of rows. */\nexport function CommandGroup({ className, ...props }: ComponentProps<'div'>) {\n return <div data-slot=\"command-group\" className={cn('flex flex-col gap-0.5', className)} {...props} />;\n}\n\nexport function CommandGroupLabel({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-group-label\"\n className={cn('px-2 pt-2 pb-1 text-2xs font-bold tracking-wider text-doom-faint uppercase', className)}\n {...props}\n />\n );\n}\n\n/** One command. Compact by default, since a palette shows many at once. */\nexport function CommandItem({ density = 'compact', ...props }: OptionRowProps) {\n return <OptionRow data-slot=\"command-item\" density={density} {...props} />;\n}\n\n/** A command's name, taking the width the row has left. */\nexport function CommandItemLabel(props: ComponentProps<'span'>) {\n return <OptionLabel data-slot=\"command-item-label\" density=\"compact\" {...props} />;\n}\n\n/** What the palette says when nothing matches. */\nexport function CommandEmpty({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-empty\"\n className={cn('px-2 py-6 text-center text-sm text-doom-faint', className)}\n {...props}\n />\n );\n}\n\n/** The hint strip along the bottom: what the keys do. */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"command-footer\"\n className={cn(\n 'flex min-h-[30px] shrink-0 items-center justify-between gap-3 border-t border-doom-border-soft bg-doom-deep px-3 text-2xs text-doom-faint',\n className,\n )}\n {...props}\n />\n );\n}\n"],"mappings":"iQAyBA,SAAgB,EAAc,CAC5B,OACA,eACA,QACA,eAAe,GACf,YACA,WACA,QAAQ,KACR,GAAG,GACkB,CACrB,MACE,kBAAC,EAAD,CAAc,OAAoB,eAChC,SAAA,kBAAC,EAAD,CAAe,YAAU,iBAAwB,QAAO,UAAW,EAAG,eAAgB,CAAS,EAAG,GAAI,EAAtG,SAAA,CACE,kBAAC,EAAD,CAAa,UAAW,EAAe,IAAA,GAAY,UAAY,SAAA,CAAmB,CAAA,EACjF,CACY,GACT,CAAA,CAEZ,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,MACE,kBAAC,MAAD,CACE,YAAU,iBACV,UAAW,EAAG,2EAA4E,CAAS,EACnG,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAqB,CAChE,MACE,kBAAC,EAAD,CACE,YAAU,gBACV,QAAQ,OACR,UAAA,GACA,aAAa,MACb,UAAW,EAAG,SAAU,CAAS,EACjC,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAY,CAAE,YAAW,GAAG,GAAgC,CAC1E,MACE,kBAAC,MAAD,CACE,KAAK,UACL,YAAU,eACV,UAAW,EAAG,6DAA8D,CAAS,EACrF,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAgC,CAC3E,MAAO,kBAAC,MAAD,CAAK,YAAU,gBAAgB,UAAW,EAAG,wBAAyB,CAAS,EAAG,GAAI,CAAQ,CAAA,CACvG,CAEA,SAAgB,EAAkB,CAAE,YAAW,GAAG,GAAgC,CAChF,MACE,kBAAC,MAAD,CACE,YAAU,sBACV,UAAW,EAAG,6EAA8E,CAAS,EACrG,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAY,CAAE,UAAU,UAAW,GAAG,GAAyB,CAC7E,MAAO,kBAAC,EAAD,CAAW,YAAU,eAAwB,UAAS,GAAI,CAAQ,CAAA,CAC3E,CAGA,SAAgB,EAAiB,EAA+B,CAC9D,MAAO,kBAAC,EAAD,CAAa,YAAU,qBAAqB,QAAQ,UAAU,GAAI,CAAQ,CAAA,CACnF,CAGA,SAAgB,EAAa,CAAE,YAAW,GAAG,GAAgC,CAC3E,MACE,kBAAC,MAAD,CACE,YAAU,gBACV,UAAW,EAAG,gDAAiD,CAAS,EACxE,GAAI,CACL,CAAA,CAEL,CAGA,SAAgB,EAAc,CAAE,YAAW,GAAG,GAAgC,CAC5E,MACE,kBAAC,MAAD,CACE,YAAU,iBACV,UAAW,EACT,4IACA,CACF,EACA,GAAI,CACL,CAAA,CAEL"}
@@ -1,2 +1,2 @@
1
- require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./Button.cjs");let n=require("react/jsx-runtime"),r=require("react"),i=require("lucide-react");const a={idle:`copy`,copied:`copied`,failed:`copying was blocked by the browser`};function o({text:o,className:s}){let[c,l]=(0,r.useState)(`idle`);(0,r.useEffect)(()=>{if(c===`idle`)return;let e=setTimeout(()=>l(`idle`),1500);return()=>clearTimeout(e)},[c]);let u=(0,r.useCallback)(()=>{navigator.clipboard.writeText(o).then(()=>l(`copied`),()=>l(`failed`))},[o]),d=a[c];return(0,n.jsx)(t.Button,{type:`button`,variant:`ghost`,size:`icon`,"data-testid":`copy-button`,"data-state":c,title:d,"aria-label":d,onClick:u,className:e.cn(`opacity-60 hover:opacity-100`,s),children:c===`copied`?(0,n.jsx)(i.Check,{className:`size-3 text-doom-green`}):(0,n.jsx)(i.Copy,{className:`size-3`})})}exports.CopyButton=o;
1
+ require("../icons/icons.cjs");const e=require("../lib/cn.cjs"),t=require("./Button.cjs");let n=require("react/jsx-runtime"),r=require("react"),i=require("lucide-react");const a={idle:`copy`,copied:`copied`,failed:`copying was blocked by the browser`};function o({text:o,className:s}){let[c,l]=(0,r.useState)(`idle`);(0,r.useEffect)(()=>{if(c===`idle`)return;let e=setTimeout(()=>l(`idle`),1500);return()=>clearTimeout(e)},[c]);let u=(0,r.useCallback)(()=>{navigator.clipboard.writeText(o).then(()=>l(`copied`),()=>l(`failed`))},[o]),d=a[c];return/* @__PURE__ */ (0,n.jsx)(t.Button,{type:`button`,variant:`ghost`,size:`icon`,"data-testid":`copy-button`,"data-state":c,title:d,"aria-label":d,onClick:u,className:e.cn(`opacity-60 hover:opacity-100`,s),children:c===`copied`?/* @__PURE__ */ (0,n.jsx)(i.Check,{className:`size-3 text-doom-green`}):/* @__PURE__ */ (0,n.jsx)(i.Copy,{className:`size-3`})})}exports.CopyButton=o;
2
2
  //# sourceMappingURL=CopyButton.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyButton.cjs","names":["useState","useCallback","Button","cn","CheckIcon","CopyIcon"],"sources":["../../../src/components/CopyButton.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport { CheckIcon, CopyIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport { Button } from './Button';\n\n/**\n * Puts a piece of text on the clipboard and says so.\n *\n * DESIGN PATTERNS:\n * - Always visible, dimmed. Half the cockpit's surfaces are touched rather\n * than pointed at, and a control revealed by hover does not exist there.\n * - A refused clipboard is a state, not a crash: the label says the browser\n * blocked it and the text is still there to select by hand.\n */\n\n/** How long the control stays acknowledged before returning to its icon. */\nconst FEEDBACK_MS = 1500;\n\ntype CopyState = 'idle' | 'copied' | 'failed';\n\nconst LABELS: Readonly<Record<CopyState, string>> = {\n idle: 'copy',\n copied: 'copied',\n failed: 'copying was blocked by the browser',\n};\n\nexport interface CopyButtonProps {\n /** What lands on the clipboard. */\n text: string;\n className?: string | undefined;\n}\n\nexport function CopyButton({ text, className }: CopyButtonProps) {\n const [state, setState] = useState<CopyState>('idle');\n\n useEffect(() => {\n if (state === 'idle') return;\n const timer = setTimeout(() => setState('idle'), FEEDBACK_MS);\n return () => clearTimeout(timer);\n }, [state]);\n\n const copy = useCallback(() => {\n void navigator.clipboard.writeText(text).then(\n () => setState('copied'),\n () => setState('failed'),\n );\n }, [text]);\n\n const label = LABELS[state];\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n data-testid=\"copy-button\"\n data-state={state}\n title={label}\n aria-label={label}\n onClick={copy}\n className={cn('opacity-60 hover:opacity-100', className)}\n >\n {state === 'copied' ? <CheckIcon className=\"size-3 text-doom-green\" /> : <CopyIcon className=\"size-3\" />}\n </Button>\n );\n}\n"],"mappings":"yKAiBA,MAIM,EAA8C,CAClD,KAAM,OACN,OAAQ,SACR,OAAQ,oCACV,EAQA,SAAgB,EAAW,CAAE,OAAM,aAA8B,CAC/D,GAAM,CAAC,EAAO,IAAA,EAAYA,EAAAA,SAAAA,CAAoB,MAAM,GAEpD,EAAA,EAAA,UAAA,KAAgB,CACd,GAAI,IAAU,OAAQ,OACtB,IAAM,EAAQ,eAAiB,EAAS,MAAM,EAAG,IAAW,EAC5D,UAAa,aAAa,CAAK,CACjC,EAAG,CAAC,CAAK,CAAC,EAEV,IAAM,GAAA,EAAOC,EAAAA,YAAAA,KAAkB,CAC7B,UAAe,UAAU,UAAU,CAAI,CAAC,CAAC,SACjC,EAAS,QAAQ,MACjB,EAAS,QAAQ,CACzB,CACF,EAAG,CAAC,CAAI,CAAC,EAEH,EAAQ,EAAO,GACrB,OACE,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CACE,KAAK,SACL,QAAQ,QACR,KAAK,OACL,cAAY,cACZ,aAAY,EACZ,MAAO,EACP,aAAY,EACZ,QAAS,EACT,UAAWC,EAAAA,GAAG,+BAAgC,CAAS,EAEtD,SAAA,IAAU,UAAW,EAAA,EAAA,IAAA,CAACC,EAAAA,MAAD,CAAW,UAAU,wBAA0B,CAAA,GAAI,EAAA,EAAA,IAAA,CAACC,EAAAA,KAAD,CAAU,UAAU,QAAU,CAAA,CACjG,CAAA,CAEZ"}
1
+ {"version":3,"file":"CopyButton.cjs","names":["useState","useCallback","Button","cn","CheckIcon","CopyIcon"],"sources":["../../../src/components/CopyButton.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport { CheckIcon, CopyIcon } from '../icons/icons';\nimport { cn } from '../lib/cn';\nimport { Button } from './Button';\n\n/**\n * Puts a piece of text on the clipboard and says so.\n *\n * DESIGN PATTERNS:\n * - Always visible, dimmed. Half the cockpit's surfaces are touched rather\n * than pointed at, and a control revealed by hover does not exist there.\n * - A refused clipboard is a state, not a crash: the label says the browser\n * blocked it and the text is still there to select by hand.\n */\n\n/** How long the control stays acknowledged before returning to its icon. */\nconst FEEDBACK_MS = 1500;\n\ntype CopyState = 'idle' | 'copied' | 'failed';\n\nconst LABELS: Readonly<Record<CopyState, string>> = {\n idle: 'copy',\n copied: 'copied',\n failed: 'copying was blocked by the browser',\n};\n\nexport interface CopyButtonProps {\n /** What lands on the clipboard. */\n text: string;\n className?: string | undefined;\n}\n\nexport function CopyButton({ text, className }: CopyButtonProps) {\n const [state, setState] = useState<CopyState>('idle');\n\n useEffect(() => {\n if (state === 'idle') return;\n const timer = setTimeout(() => setState('idle'), FEEDBACK_MS);\n return () => clearTimeout(timer);\n }, [state]);\n\n const copy = useCallback(() => {\n void navigator.clipboard.writeText(text).then(\n () => setState('copied'),\n () => setState('failed'),\n );\n }, [text]);\n\n const label = LABELS[state];\n return (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n data-testid=\"copy-button\"\n data-state={state}\n title={label}\n aria-label={label}\n onClick={copy}\n className={cn('opacity-60 hover:opacity-100', className)}\n >\n {state === 'copied' ? <CheckIcon className=\"size-3 text-doom-green\" /> : <CopyIcon className=\"size-3\" />}\n </Button>\n );\n}\n"],"mappings":"yKAiBA,MAIM,EAA8C,CAClD,KAAM,OACN,OAAQ,SACR,OAAQ,oCACV,EAQA,SAAgB,EAAW,CAAE,OAAM,aAA8B,CAC/D,GAAM,CAAC,EAAO,IAAA,EAAYA,EAAAA,SAAAA,CAAoB,MAAM,GAEpD,EAAA,EAAA,UAAA,KAAgB,CACd,GAAI,IAAU,OAAQ,OACtB,IAAM,EAAQ,eAAiB,EAAS,MAAM,EAAG,IAAW,EAC5D,UAAa,aAAa,CAAK,CACjC,EAAG,CAAC,CAAK,CAAC,EAEV,IAAM,GAAA,EAAOC,EAAAA,YAAAA,KAAkB,CAC7B,UAAe,UAAU,UAAU,CAAI,CAAC,CAAC,SACjC,EAAS,QAAQ,MACjB,EAAS,QAAQ,CACzB,CACF,EAAG,CAAC,CAAI,CAAC,EAEH,EAAQ,EAAO,GACrB,MACE,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,OAAD,CACE,KAAK,SACL,QAAQ,QACR,KAAK,OACL,cAAY,cACZ,aAAY,EACZ,MAAO,EACP,aAAY,EACZ,QAAS,EACT,UAAWC,EAAAA,GAAG,+BAAgC,CAAS,EAEtD,SAAA,IAAU,SAAW,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,MAAD,CAAW,UAAU,wBAA0B,CAAA,EAAI,iBAAA,EAAA,EAAA,IAAA,CAACC,EAAAA,KAAD,CAAU,UAAU,QAAU,CAAA,CACjG,CAAA,CAEZ"}