@deepseek-ai/dsh-client-ui-primitives 0.2.2-rc.1 → 0.2.2-rc.2

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 (412) hide show
  1. package/README.i18n.yaml +16 -16
  2. package/README.md +21 -14
  3. package/README.zh.md +21 -14
  4. package/lib/HoverCard.module.css +8 -3
  5. package/lib/JsonTree.module.css +7 -17
  6. package/lib/Menu.module.css +157 -37
  7. package/lib/Modal.module.css +16 -0
  8. package/lib/QuotePreview.module.css +37 -0
  9. package/lib/RiskConfirmation.module.css +11 -37
  10. package/lib/Toast.module.css +2 -3
  11. package/lib/Tooltip.module.css +2 -1
  12. package/lib/index.js +1447 -776
  13. package/lib/index.js.map +1 -0
  14. package/lib/markdown/CodeBlock.module.css +64 -0
  15. package/lib/markdown/MarkdownText.module.css +20 -1
  16. package/lib/types/AnimatedRows.d.ts +3 -0
  17. package/lib/types/AnimatedRows.d.ts.map +1 -0
  18. package/lib/types/AnimatedRows.js.map +1 -0
  19. package/lib/types/BrandWordmark.d.ts.map +1 -0
  20. package/lib/types/BrandWordmark.js.map +1 -0
  21. package/lib/types/Button.d.ts.map +1 -0
  22. package/lib/types/Button.js.map +1 -0
  23. package/lib/types/Checkbox.d.ts +3 -1
  24. package/lib/types/Checkbox.d.ts.map +1 -0
  25. package/lib/types/Checkbox.js.map +1 -0
  26. package/lib/types/CodeFileIcon.d.ts.map +1 -0
  27. package/lib/types/CodeFileIcon.js.map +1 -0
  28. package/lib/types/CodeToolbar.d.ts.map +1 -0
  29. package/lib/types/CodeToolbar.js.map +1 -0
  30. package/lib/types/CommandText.d.ts.map +1 -0
  31. package/lib/types/CommandText.js.map +1 -0
  32. package/lib/types/ConfigField.d.ts.map +1 -0
  33. package/lib/types/ConfigField.js.map +1 -0
  34. package/lib/types/ConnectionIndicator.d.ts.map +1 -0
  35. package/lib/types/ConnectionIndicator.js.map +1 -0
  36. package/lib/types/DetailDocument.d.ts.map +1 -0
  37. package/lib/types/DetailDocument.js.map +1 -0
  38. package/lib/types/DiffBlock.d.ts.map +1 -0
  39. package/lib/types/DiffBlock.js.map +1 -0
  40. package/lib/types/DisclosureRow.d.ts.map +1 -0
  41. package/lib/types/DisclosureRow.js.map +1 -0
  42. package/lib/types/DraggableImage.d.ts.map +1 -0
  43. package/lib/types/DraggableImage.js.map +1 -0
  44. package/lib/types/FileTypeIcon.d.ts.map +1 -0
  45. package/lib/types/FileTypeIcon.js.map +1 -0
  46. package/lib/types/FishLogo.d.ts.map +1 -0
  47. package/lib/types/FishLogo.js.map +1 -0
  48. package/lib/types/FoldToggle.d.ts.map +1 -0
  49. package/lib/types/FoldToggle.js.map +1 -0
  50. package/lib/types/HoverCard.d.ts.map +1 -0
  51. package/lib/types/HoverCard.js.map +1 -0
  52. package/lib/types/HoverCardGroup.d.ts.map +1 -0
  53. package/lib/types/HoverCardGroup.js.map +1 -0
  54. package/lib/types/ImageLightbox.d.ts.map +1 -0
  55. package/lib/types/ImageLightbox.js.map +1 -0
  56. package/lib/types/ImagePreview.d.ts.map +1 -0
  57. package/lib/types/ImagePreview.js.map +1 -0
  58. package/lib/types/InlineEditor.d.ts.map +1 -0
  59. package/lib/types/InlineEditor.js.map +1 -0
  60. package/lib/types/Input.d.ts.map +1 -0
  61. package/lib/types/Input.js.map +1 -0
  62. package/lib/types/JsonTree.d.ts.map +1 -0
  63. package/lib/types/JsonTree.js.map +1 -0
  64. package/lib/types/LinkIcon.d.ts.map +1 -0
  65. package/lib/types/LinkIcon.js.map +1 -0
  66. package/lib/types/Menu.d.ts +26 -14
  67. package/lib/types/Menu.d.ts.map +1 -0
  68. package/lib/types/Menu.js.map +1 -0
  69. package/lib/types/MenuGroup.d.ts.map +1 -0
  70. package/lib/types/MenuGroup.js.map +1 -0
  71. package/lib/types/MenuRow.d.ts +37 -0
  72. package/lib/types/MenuRow.d.ts.map +1 -0
  73. package/lib/types/MenuRow.js.map +1 -0
  74. package/lib/types/MenuSurface.d.ts.map +1 -0
  75. package/lib/types/MenuSurface.js.map +1 -0
  76. package/lib/types/Modal.d.ts +3 -1
  77. package/lib/types/Modal.d.ts.map +1 -0
  78. package/lib/types/Modal.js.map +1 -0
  79. package/lib/types/PathLabel.d.ts.map +1 -0
  80. package/lib/types/PathLabel.js.map +1 -0
  81. package/lib/types/PermissionIcon.d.ts.map +1 -0
  82. package/lib/types/PermissionIcon.js.map +1 -0
  83. package/lib/types/Pill.d.ts.map +1 -0
  84. package/lib/types/Pill.js.map +1 -0
  85. package/lib/types/QuotePreview.d.ts +17 -4
  86. package/lib/types/QuotePreview.d.ts.map +1 -0
  87. package/lib/types/QuotePreview.js.map +1 -0
  88. package/lib/types/ReadBlock.d.ts.map +1 -0
  89. package/lib/types/ReadBlock.js.map +1 -0
  90. package/lib/types/ReferenceIcon.d.ts.map +1 -0
  91. package/lib/types/ReferenceIcon.js.map +1 -0
  92. package/lib/types/RiskConfirmation.d.ts.map +1 -0
  93. package/lib/types/RiskConfirmation.js.map +1 -0
  94. package/lib/types/SearchBlock.d.ts.map +1 -0
  95. package/lib/types/SearchBlock.js.map +1 -0
  96. package/lib/types/SegmentedControl.d.ts.map +1 -0
  97. package/lib/types/SegmentedControl.js.map +1 -0
  98. package/lib/types/SegmentedTabs.d.ts.map +1 -0
  99. package/lib/types/SegmentedTabs.js.map +1 -0
  100. package/lib/types/ShortcutKeys.d.ts.map +1 -0
  101. package/lib/types/ShortcutKeys.js.map +1 -0
  102. package/lib/types/SiteGlyph.d.ts.map +1 -0
  103. package/lib/types/SiteGlyph.js.map +1 -0
  104. package/lib/types/StateDot.d.ts.map +1 -0
  105. package/lib/types/StateDot.js.map +1 -0
  106. package/lib/types/SubmenuPanel.d.ts +19 -0
  107. package/lib/types/SubmenuPanel.d.ts.map +1 -0
  108. package/lib/types/SubmenuPanel.js.map +1 -0
  109. package/lib/types/Switch.d.ts.map +1 -0
  110. package/lib/types/Switch.js.map +1 -0
  111. package/lib/types/Tag.d.ts.map +1 -0
  112. package/lib/types/Tag.js.map +1 -0
  113. package/lib/types/TerminalBlock.d.ts.map +1 -0
  114. package/lib/types/TerminalBlock.js.map +1 -0
  115. package/lib/types/TextShimmer.d.ts.map +1 -0
  116. package/lib/types/TextShimmer.js.map +1 -0
  117. package/lib/types/Toast.d.ts.map +1 -0
  118. package/lib/types/Toast.js.map +1 -0
  119. package/lib/types/Tooltip.d.ts.map +1 -0
  120. package/lib/types/Tooltip.js.map +1 -0
  121. package/lib/types/UserMessageBubble.d.ts.map +1 -0
  122. package/lib/types/UserMessageBubble.js.map +1 -0
  123. package/lib/types/WebBlock.d.ts.map +1 -0
  124. package/lib/types/WebBlock.js.map +1 -0
  125. package/lib/types/ZoomControls.d.ts.map +1 -0
  126. package/lib/types/ZoomControls.js.map +1 -0
  127. package/lib/types/ansi.d.ts.map +1 -0
  128. package/lib/types/ansi.js.map +1 -0
  129. package/lib/types/clipboard.d.ts.map +1 -0
  130. package/lib/types/clipboard.js.map +1 -0
  131. package/lib/types/code-file-icon-artwork.d.ts.map +1 -0
  132. package/lib/types/code-file-icon-artwork.js.map +1 -0
  133. package/lib/types/code-file-types.d.ts.map +1 -0
  134. package/lib/types/code-file-types.js.map +1 -0
  135. package/lib/types/code-highlighting.d.ts.map +1 -0
  136. package/lib/types/code-highlighting.js.map +1 -0
  137. package/lib/types/darwin-desktop.d.ts.map +1 -0
  138. package/lib/types/darwin-desktop.js.map +1 -0
  139. package/lib/types/document-zoom.d.ts.map +1 -0
  140. package/lib/types/document-zoom.js.map +1 -0
  141. package/lib/types/file-drag-actions.d.ts.map +1 -0
  142. package/lib/types/file-drag-actions.js.map +1 -0
  143. package/lib/types/file-size.d.ts.map +1 -0
  144. package/lib/types/file-size.js.map +1 -0
  145. package/lib/types/focus.d.ts.map +1 -0
  146. package/lib/types/focus.js.map +1 -0
  147. package/lib/types/guide-artwork.d.ts.map +1 -0
  148. package/lib/types/guide-artwork.js.map +1 -0
  149. package/lib/types/head-tail-cap.d.ts.map +1 -0
  150. package/lib/types/head-tail-cap.js.map +1 -0
  151. package/lib/types/icons/artwork.d.ts +12 -0
  152. package/lib/types/icons/artwork.d.ts.map +1 -0
  153. package/lib/types/icons/artwork.js.map +1 -0
  154. package/lib/types/icons/index.d.ts +12 -0
  155. package/lib/types/icons/index.d.ts.map +1 -0
  156. package/lib/types/icons/index.js.map +1 -0
  157. package/lib/types/icons/props.d.ts.map +1 -0
  158. package/lib/types/icons/props.js.map +1 -0
  159. package/lib/types/icons/shared-artwork.d.ts.map +1 -0
  160. package/lib/types/icons/shared-artwork.js.map +1 -0
  161. package/lib/types/image-drag.d.ts.map +1 -0
  162. package/lib/types/image-drag.js.map +1 -0
  163. package/lib/types/index.d.ts +5 -4
  164. package/lib/types/index.d.ts.map +1 -0
  165. package/lib/types/index.js.map +1 -0
  166. package/lib/types/input-modality.d.ts.map +1 -0
  167. package/lib/types/input-modality.js.map +1 -0
  168. package/lib/types/keyboard-composition.d.ts.map +1 -0
  169. package/lib/types/keyboard-composition.js.map +1 -0
  170. package/lib/types/markdown/CodeBlock.d.ts +8 -1
  171. package/lib/types/markdown/CodeBlock.d.ts.map +1 -0
  172. package/lib/types/markdown/CodeBlock.js.map +1 -0
  173. package/lib/types/markdown/FenceBlocks.d.ts +31 -0
  174. package/lib/types/markdown/FenceBlocks.d.ts.map +1 -0
  175. package/lib/types/markdown/FenceBlocks.js.map +1 -0
  176. package/lib/types/markdown/JsonBlock.d.ts.map +1 -0
  177. package/lib/types/markdown/JsonBlock.js.map +1 -0
  178. package/lib/types/markdown/MarkdownDelegate.d.ts +23 -1
  179. package/lib/types/markdown/MarkdownDelegate.d.ts.map +1 -0
  180. package/lib/types/markdown/MarkdownDelegate.js.map +1 -0
  181. package/lib/types/markdown/MarkdownText.d.ts +2 -0
  182. package/lib/types/markdown/MarkdownText.d.ts.map +1 -0
  183. package/lib/types/markdown/MarkdownText.js.map +1 -0
  184. package/lib/types/markdown/cjkFriendlyStrong.d.ts.map +1 -0
  185. package/lib/types/markdown/cjkFriendlyStrong.js.map +1 -0
  186. package/lib/types/markdown/copy-tex.d.ts +14 -0
  187. package/lib/types/markdown/copy-tex.d.ts.map +1 -0
  188. package/lib/types/markdown/copy-tex.js.map +1 -0
  189. package/lib/types/markdown/diff-fence.d.ts +58 -0
  190. package/lib/types/markdown/diff-fence.d.ts.map +1 -0
  191. package/lib/types/markdown/diff-fence.js.map +1 -0
  192. package/lib/types/markdown/file-link.d.ts.map +1 -0
  193. package/lib/types/markdown/file-link.js.map +1 -0
  194. package/lib/types/markdown/highlight.d.ts +18 -0
  195. package/lib/types/markdown/highlight.d.ts.map +1 -0
  196. package/lib/types/markdown/highlight.js.map +1 -0
  197. package/lib/types/markdown/incremental.d.ts.map +1 -0
  198. package/lib/types/markdown/incremental.js.map +1 -0
  199. package/lib/types/markdown/katex.d.ts.map +1 -0
  200. package/lib/types/markdown/katex.js.map +1 -0
  201. package/lib/types/markdown/local-image-syntax.d.ts.map +1 -0
  202. package/lib/types/markdown/local-image-syntax.js.map +1 -0
  203. package/lib/types/markdown/mathCompatibility.d.ts.map +1 -0
  204. package/lib/types/markdown/mathCompatibility.js.map +1 -0
  205. package/lib/types/markdown/parse.d.ts.map +1 -0
  206. package/lib/types/markdown/parse.js.map +1 -0
  207. package/lib/types/markdown/plain-text.d.ts.map +1 -0
  208. package/lib/types/markdown/plain-text.js.map +1 -0
  209. package/lib/types/markdown/quote-text.d.ts.map +1 -0
  210. package/lib/types/markdown/quote-text.js.map +1 -0
  211. package/lib/types/markdown/render.d.ts.map +1 -0
  212. package/lib/types/markdown/render.js.map +1 -0
  213. package/lib/types/markdown/useViewportHighlighting.d.ts.map +1 -0
  214. package/lib/types/markdown/useViewportHighlighting.js.map +1 -0
  215. package/lib/types/markdown/windows-path-destinations.d.ts.map +1 -0
  216. package/lib/types/markdown/windows-path-destinations.js.map +1 -0
  217. package/lib/types/menu-submenu-position.d.ts +15 -0
  218. package/lib/types/menu-submenu-position.d.ts.map +1 -0
  219. package/lib/types/menu-submenu-position.js.map +1 -0
  220. package/lib/types/overlay-top-margin.d.ts.map +1 -0
  221. package/lib/types/overlay-top-margin.js.map +1 -0
  222. package/lib/types/plugin-artwork.d.ts.map +1 -0
  223. package/lib/types/plugin-artwork.js.map +1 -0
  224. package/lib/types/pointer-grace.d.ts.map +1 -0
  225. package/lib/types/pointer-grace.js.map +1 -0
  226. package/lib/types/rank-by-name.d.ts.map +1 -0
  227. package/lib/types/rank-by-name.js.map +1 -0
  228. package/lib/types/relative-time.d.ts.map +1 -0
  229. package/lib/types/relative-time.js.map +1 -0
  230. package/lib/types/settings-form/SettingsForm.d.ts.map +1 -0
  231. package/lib/types/settings-form/SettingsForm.js.map +1 -0
  232. package/lib/types/settings-form/fields.d.ts.map +1 -0
  233. package/lib/types/settings-form/fields.js.map +1 -0
  234. package/lib/types/settings-form/form-model.d.ts.map +1 -0
  235. package/lib/types/settings-form/form-model.js.map +1 -0
  236. package/lib/types/tooltip-placement.d.ts.map +1 -0
  237. package/lib/types/tooltip-placement.js.map +1 -0
  238. package/lib/types/use-clipboard-copy.d.ts.map +1 -0
  239. package/lib/types/use-clipboard-copy.js.map +1 -0
  240. package/lib/types/useAnchoredMaxHeight.d.ts.map +1 -0
  241. package/lib/types/useAnchoredMaxHeight.js.map +1 -0
  242. package/lib/types/useDismissOnOutsidePointer.d.ts.map +1 -0
  243. package/lib/types/useDismissOnOutsidePointer.js.map +1 -0
  244. package/lib/types/useMenuSubmenu.d.ts +43 -0
  245. package/lib/types/useMenuSubmenu.d.ts.map +1 -0
  246. package/lib/types/useMenuSubmenu.js.map +1 -0
  247. package/lib/types/useModalLayer.d.ts.map +1 -0
  248. package/lib/types/useModalLayer.js.map +1 -0
  249. package/lib/types/useRowDragPreview.d.ts.map +1 -0
  250. package/lib/types/useRowDragPreview.js.map +1 -0
  251. package/lib/types/user-text.d.ts.map +1 -0
  252. package/lib/types/user-text.js.map +1 -0
  253. package/package.json +9 -6
  254. package/src/AnimatedRows.module.css +7 -0
  255. package/src/AnimatedRows.tsx +195 -0
  256. package/src/BrandWordmark.tsx +59 -0
  257. package/src/Button.module.css +84 -0
  258. package/src/Button.tsx +36 -0
  259. package/src/Checkbox.module.css +28 -0
  260. package/src/Checkbox.tsx +34 -0
  261. package/src/CodeCard.module.css +85 -0
  262. package/src/CodeFileIcon.tsx +28 -0
  263. package/src/CodeToolbar.tsx +62 -0
  264. package/src/CommandText.module.css +12 -0
  265. package/src/CommandText.tsx +46 -0
  266. package/src/ConfigField.module.css +12 -0
  267. package/src/ConfigField.tsx +53 -0
  268. package/src/ConnectionIndicator.module.css +120 -0
  269. package/src/ConnectionIndicator.tsx +103 -0
  270. package/src/DetailDocument.module.css +67 -0
  271. package/src/DetailDocument.tsx +120 -0
  272. package/src/DiffBlock.module.css +82 -0
  273. package/src/DiffBlock.tsx +221 -0
  274. package/src/DisclosureRow.module.css +115 -0
  275. package/src/DisclosureRow.tsx +124 -0
  276. package/src/DraggableImage.tsx +26 -0
  277. package/src/FileTypeIcon.module.css +50 -0
  278. package/src/FileTypeIcon.tsx +285 -0
  279. package/src/FishLogo.tsx +28 -0
  280. package/src/FoldToggle.tsx +33 -0
  281. package/src/HoverCard.module.css +108 -0
  282. package/src/HoverCard.tsx +356 -0
  283. package/src/HoverCardGroup.tsx +77 -0
  284. package/src/ImageLightbox.module.css +54 -0
  285. package/src/ImageLightbox.tsx +72 -0
  286. package/src/ImagePreview.module.css +24 -0
  287. package/src/ImagePreview.tsx +36 -0
  288. package/src/InlineEditor.module.css +23 -0
  289. package/src/InlineEditor.tsx +69 -0
  290. package/src/Input.module.css +38 -0
  291. package/src/Input.tsx +24 -0
  292. package/src/JsonTree.module.css +371 -0
  293. package/src/JsonTree.tsx +850 -0
  294. package/src/LinkIcon.tsx +118 -0
  295. package/src/Menu.module.css +443 -0
  296. package/src/Menu.tsx +553 -0
  297. package/src/MenuGroup.module.css +37 -0
  298. package/src/MenuGroup.tsx +103 -0
  299. package/src/MenuRow.tsx +89 -0
  300. package/src/MenuSurface.module.css +65 -0
  301. package/src/MenuSurface.tsx +54 -0
  302. package/src/Modal.module.css +147 -0
  303. package/src/Modal.tsx +96 -0
  304. package/src/PathLabel.module.css +28 -0
  305. package/src/PathLabel.tsx +41 -0
  306. package/src/PermissionIcon.tsx +119 -0
  307. package/src/Pill.module.css +30 -0
  308. package/src/Pill.tsx +36 -0
  309. package/src/QuotePreview.module.css +138 -0
  310. package/src/QuotePreview.tsx +133 -0
  311. package/src/ReadBlock.module.css +45 -0
  312. package/src/ReadBlock.tsx +151 -0
  313. package/src/ReferenceIcon.tsx +49 -0
  314. package/src/RiskConfirmation.module.css +47 -0
  315. package/src/RiskConfirmation.tsx +79 -0
  316. package/src/RowDragPreview.module.css +12 -0
  317. package/src/SearchBlock.module.css +114 -0
  318. package/src/SearchBlock.tsx +281 -0
  319. package/src/SegmentedControl.module.css +81 -0
  320. package/src/SegmentedControl.tsx +140 -0
  321. package/src/SegmentedTabs.module.css +77 -0
  322. package/src/SegmentedTabs.tsx +84 -0
  323. package/src/ShortcutKeys.module.css +33 -0
  324. package/src/ShortcutKeys.tsx +12 -0
  325. package/src/SiteGlyph.tsx +149 -0
  326. package/src/StateDot.module.css +100 -0
  327. package/src/StateDot.tsx +77 -0
  328. package/src/SubmenuPanel.tsx +51 -0
  329. package/src/Switch.module.css +49 -0
  330. package/src/Switch.tsx +42 -0
  331. package/src/Tag.module.css +57 -0
  332. package/src/Tag.tsx +42 -0
  333. package/src/TerminalBlock.module.css +207 -0
  334. package/src/TerminalBlock.tsx +294 -0
  335. package/src/TextShimmer.module.css +88 -0
  336. package/src/TextShimmer.tsx +58 -0
  337. package/src/Toast.module.css +102 -0
  338. package/src/Toast.tsx +101 -0
  339. package/src/Tooltip.module.css +68 -0
  340. package/src/Tooltip.tsx +273 -0
  341. package/src/UserMessageBubble.module.css +11 -0
  342. package/src/UserMessageBubble.tsx +16 -0
  343. package/src/WebBlock.module.css +153 -0
  344. package/src/WebBlock.tsx +196 -0
  345. package/src/ZoomControls.module.css +54 -0
  346. package/src/ZoomControls.tsx +92 -0
  347. package/src/ansi.ts +447 -0
  348. package/src/clipboard.ts +47 -0
  349. package/src/code-file-icon-artwork.manifest.json +71 -0
  350. package/src/code-file-icon-artwork.ts +60 -0
  351. package/src/code-file-types.ts +340 -0
  352. package/src/code-highlighting.ts +25 -0
  353. package/src/css-modules.d.ts +6 -0
  354. package/src/darwin-desktop.ts +11 -0
  355. package/src/document-zoom.ts +12 -0
  356. package/src/file-drag-actions.ts +29 -0
  357. package/src/file-size.ts +16 -0
  358. package/src/focus.ts +44 -0
  359. package/src/guide-artwork.tsx +32 -0
  360. package/src/head-tail-cap.ts +27 -0
  361. package/src/icons/artwork.ts +156 -0
  362. package/src/icons/index.tsx +634 -0
  363. package/src/icons/props.ts +8 -0
  364. package/src/icons/shared-artwork.tsx +71 -0
  365. package/src/image-drag.ts +84 -0
  366. package/src/index.ts +142 -0
  367. package/src/input-modality.ts +59 -0
  368. package/src/keyboard-composition.ts +36 -0
  369. package/src/markdown/CodeBlock.module.css +209 -0
  370. package/src/markdown/CodeBlock.tsx +268 -0
  371. package/src/markdown/FenceBlocks.tsx +51 -0
  372. package/src/markdown/JsonBlock.module.css +34 -0
  373. package/src/markdown/JsonBlock.tsx +36 -0
  374. package/src/markdown/MarkdownDelegate.tsx +102 -0
  375. package/src/markdown/MarkdownText.module.css +511 -0
  376. package/src/markdown/MarkdownText.tsx +218 -0
  377. package/src/markdown/cjkFriendlyStrong.ts +83 -0
  378. package/src/markdown/copy-tex.ts +53 -0
  379. package/src/markdown/diff-fence.ts +212 -0
  380. package/src/markdown/file-link.ts +45 -0
  381. package/src/markdown/highlight.ts +689 -0
  382. package/src/markdown/incremental.ts +360 -0
  383. package/src/markdown/katex.tsx +90 -0
  384. package/src/markdown/local-image-syntax.ts +29 -0
  385. package/src/markdown/mathCompatibility.ts +349 -0
  386. package/src/markdown/parse.ts +49 -0
  387. package/src/markdown/plain-text.ts +121 -0
  388. package/src/markdown/quote-text.ts +10 -0
  389. package/src/markdown/render.tsx +834 -0
  390. package/src/markdown/useViewportHighlighting.ts +72 -0
  391. package/src/markdown/windows-path-destinations.ts +34 -0
  392. package/src/menu-submenu-position.ts +20 -0
  393. package/src/overlay-top-margin.ts +18 -0
  394. package/src/plugin-artwork.tsx +110 -0
  395. package/src/pointer-grace.ts +47 -0
  396. package/src/rank-by-name.ts +93 -0
  397. package/src/relative-time.ts +36 -0
  398. package/src/settings-form/SettingsForm.module.css +53 -0
  399. package/src/settings-form/SettingsForm.tsx +74 -0
  400. package/src/settings-form/fields.module.css +153 -0
  401. package/src/settings-form/fields.tsx +151 -0
  402. package/src/settings-form/form-model.ts +393 -0
  403. package/src/tooltip-placement.ts +60 -0
  404. package/src/use-clipboard-copy.ts +44 -0
  405. package/src/useAnchoredMaxHeight.ts +45 -0
  406. package/src/useDismissOnOutsidePointer.ts +34 -0
  407. package/src/useMenuSubmenu.ts +182 -0
  408. package/src/useModalLayer.ts +108 -0
  409. package/src/useRowDragPreview.ts +76 -0
  410. package/src/user-text.module.css +46 -0
  411. package/src/user-text.tsx +67 -0
  412. package/lib/types/useAnchoredPosition.d.ts +0 -36
@@ -0,0 +1,60 @@
1
+ /** Deterministic tooltip placement using measured border boxes and viewport coordinates. */
2
+ /** Bubble placement relative to the anchor. */
3
+ export type TooltipSide = 'right' | 'left' | 'bottom' | 'top'
4
+
5
+ interface PlacementInput {
6
+ anchor: { left: number; right: number; top: number; bottom: number }
7
+ width: number
8
+ height: number
9
+ viewportWidth: number
10
+ viewportHeight: number
11
+ side: TooltipSide
12
+ align: 'center' | 'end'
13
+ gap: number
14
+ }
15
+
16
+ interface TooltipPlacement {
17
+ left: number
18
+ top: number
19
+ width: number
20
+ height: number
21
+ side: TooltipSide
22
+ /** No complete side fits, so placement is bounded by the viewport instead. */
23
+ overflow: boolean
24
+ }
25
+
26
+ const opposite: Record<TooltipSide, TooltipSide> = { right: 'left', left: 'right', top: 'bottom', bottom: 'top' }
27
+
28
+ /**
29
+ * Prefer the requested side, its opposite, then perpendicular sides without covering the anchor.
30
+ * @param input - Observed dimensions, anchor edges, viewport and requested placement; horizontal gaps remain 10px.
31
+ * @returns Border-box coordinates and the selected side; if no side fits, a viewport-bounded fallback.
32
+ */
33
+ export function placeTooltip(input: PlacementInput): TooltipPlacement {
34
+ const { anchor, viewportWidth, viewportHeight, side, align, gap } = input
35
+ let { width, height } = input
36
+ const margin = 12
37
+ const maxWidth = Math.max(0, viewportWidth - margin * 2)
38
+ const maxHeight = Math.max(0, viewportHeight - margin * 2)
39
+ width = Math.min(width, maxWidth)
40
+ height = Math.min(height, maxHeight)
41
+ const clampX = (x: number) => Math.max(margin, Math.min(x, viewportWidth - margin - width))
42
+ const clampY = (y: number) => Math.max(margin, Math.min(y, viewportHeight - margin - height))
43
+ const horizontal = side === 'right' || side === 'left'
44
+ const candidates: TooltipSide[] = [side, opposite[side], ...horizontal ? ['bottom', 'top'] as const : ['right', 'left'] as const]
45
+ const positions = {
46
+ right: { left: anchor.right + 10, top: clampY((anchor.top + anchor.bottom - height) / 2) },
47
+ left: { left: anchor.left - 10 - width, top: clampY((anchor.top + anchor.bottom - height) / 2) },
48
+ bottom: { left: clampX(align === 'end' ? anchor.right - width : (anchor.left + anchor.right - width) / 2), top: anchor.bottom + gap },
49
+ top: { left: clampX(align === 'end' ? anchor.right - width : (anchor.left + anchor.right - width) / 2), top: anchor.top - gap - height },
50
+ }
51
+ for (const candidate of candidates) {
52
+ const position = positions[candidate]
53
+ if (position.left >= margin && position.top >= margin
54
+ && position.left + width <= viewportWidth - margin && position.top + height <= viewportHeight - margin) {
55
+ return { ...position, side: candidate, width, height, overflow: false }
56
+ }
57
+ }
58
+ const position = positions[side]
59
+ return { left: clampX(position.left), top: clampY(position.top), side, width, height, overflow: true }
60
+ }
@@ -0,0 +1,44 @@
1
+ /** Clipboard writes with component-owned success feedback and cleanup. */
2
+ import { useCallback, useEffect, useRef, useState } from 'react'
3
+ import { writeClipboard } from './clipboard.ts'
4
+
5
+ /** Clipboard action and its temporary success state. */
6
+ export interface ClipboardCopyState {
7
+ /** True for one second after an accepted clipboard write. */
8
+ readonly copied: boolean
9
+ /** Write the current text unless a write or success indication is already active. */
10
+ readonly onCopy: () => void
11
+ }
12
+
13
+ /**
14
+ * Keep clipboard feedback local to the mounted control and release its reset timer on unmount.
15
+ * @param text - Exact text to copy when the action is invoked.
16
+ * @returns Success feedback and a callback stable while text and feedback are unchanged.
17
+ */
18
+ export function useClipboardCopy(text: string): ClipboardCopyState {
19
+ const [copied, setCopied] = useState(false)
20
+ const copyPending = useRef(false)
21
+ const copyTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
22
+ const copyEpoch = useRef(0)
23
+ useEffect(() => () => {
24
+ copyEpoch.current += 1
25
+ copyPending.current = false
26
+ if (copyTimer.current !== null) clearTimeout(copyTimer.current)
27
+ }, [])
28
+ const onCopy = useCallback(() => {
29
+ if (copied || copyPending.current) return
30
+ const epoch = copyEpoch.current
31
+ copyPending.current = true
32
+ void writeClipboard(text).then((ok) => {
33
+ if (epoch !== copyEpoch.current) return
34
+ copyPending.current = false
35
+ if (!ok) return
36
+ setCopied(true)
37
+ copyTimer.current = window.setTimeout(() => {
38
+ copyTimer.current = null
39
+ setCopied(false)
40
+ }, 1000)
41
+ })
42
+ }, [copied, text])
43
+ return { copied, onCopy }
44
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Viewport-fit hook for bottom-anchored overlays (slash menu, popupSelect):
3
+ * the element's bottom edge is laid out independent of its height, so it
4
+ * grows upward and only the top edge can collide with the viewport — clamp
5
+ * the design cap to the space between that edge and the viewport top.
6
+ */
7
+ import { useLayoutEffect, useState } from 'react'
8
+ import type { RefObject } from 'react'
9
+ import { overlayTopMargin } from './overlay-top-margin.ts'
10
+
11
+ /**
12
+ * Safe distance kept between the overlay and the viewport top edge (mirrors
13
+ * the Menu portal margin); the frame's overlay inset widens it.
14
+ */
15
+ const MARGIN = 12
16
+
17
+ /**
18
+ * Clamp a bottom-anchored overlay's max-height to the viewport.
19
+ * @param ref - the overlay element; a null current (overlay closed) skips measuring.
20
+ * @param cap - design max-height in px (the clamp never exceeds it).
21
+ * @param signal - re-measure trigger: pass the overlay's render state so anchor
22
+ * moves (composer growth) re-fit; resize/scroll re-fit while mounted.
23
+ * @param margin - viewport top margin floor in px; the frame's overlay
24
+ * inset widens it. Callers under fixed chrome (the conversation header)
25
+ * raise it past their chrome's height.
26
+ * @returns the max-height to apply inline, in px.
27
+ */
28
+ export function useAnchoredMaxHeight(ref: RefObject<HTMLElement>, cap: number, signal: unknown, margin: number = MARGIN): number {
29
+ const [maxHeight, setMaxHeight] = useState(cap)
30
+ useLayoutEffect(() => {
31
+ const el = ref.current
32
+ if (el === null) return
33
+ const fit = () => {
34
+ setMaxHeight(Math.min(cap, Math.max(0, el.getBoundingClientRect().bottom - overlayTopMargin(margin))))
35
+ }
36
+ fit()
37
+ window.addEventListener('resize', fit)
38
+ window.addEventListener('scroll', fit, true)
39
+ return () => {
40
+ window.removeEventListener('resize', fit)
41
+ window.removeEventListener('scroll', fit, true)
42
+ }
43
+ }, [ref, cap, signal, margin])
44
+ return maxHeight
45
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Outside-pointer dismissal for trigger-owned popovers (jobs list, Cordis
3
+ * panel): while the surface is open, a pointerdown outside the root closes it.
4
+ */
5
+ import { useEffect } from 'react'
6
+ import type { RefObject } from 'react'
7
+
8
+ /**
9
+ * Close an open popover when a pointerdown lands outside its root element.
10
+ * @param root - element containing both the trigger and the open surface.
11
+ * @param open - whether the surface is showing; false detaches the listener.
12
+ * @param setOpen - state setter invoked with false on an outside pointerdown.
13
+ * @param portal - surface portaled outside the root (a `document.body` dialog)
14
+ * that also counts as inside; omit when the root contains the whole popover.
15
+ */
16
+ export function useDismissOnOutsidePointer(
17
+ root: RefObject<HTMLElement | null>,
18
+ open: boolean,
19
+ setOpen: (open: boolean) => void,
20
+ portal?: RefObject<HTMLElement | null>,
21
+ ): void {
22
+ useEffect(() => {
23
+ if (!open) return
24
+ const closeOutside = (event: PointerEvent): void => {
25
+ if (event.target instanceof Node
26
+ && root.current?.contains(event.target) !== true
27
+ && portal?.current?.contains(event.target) !== true) {
28
+ setOpen(false)
29
+ }
30
+ }
31
+ document.addEventListener('pointerdown', closeOutside)
32
+ return () => { document.removeEventListener('pointerdown', closeOutside) }
33
+ }, [root, open, setOpen, portal])
34
+ }
@@ -0,0 +1,182 @@
1
+ /** Owns one menu's child layout mode, pointer grace, and focus transitions. */
2
+ import { useId, useLayoutEffect, useRef, useState } from 'react'
3
+ import type { RefObject, SyntheticEvent } from 'react'
4
+ import type { MenuEntry, MenuItem } from './Menu.tsx'
5
+ import { submenuNeedsPage } from './menu-submenu-position.ts'
6
+ import { usePointerGrace } from './pointer-grace.ts'
7
+
8
+ /** Whether a pointer event can request hover interactions.
9
+ * @param event - current pointer, including mixed-input touch events.
10
+ * @returns true for non-touch input with an available hover device.
11
+ */
12
+ export function menuHoverAllowed(event: { pointerType: string }): boolean {
13
+ return event.pointerType !== 'touch' && window.matchMedia('(any-hover: hover)').matches
14
+ }
15
+
16
+ interface MenuSubmenu {
17
+ entry: (MenuItem & { submenu: readonly MenuEntry[] }) | undefined
18
+ panelRef: RefObject<HTMLDivElement>
19
+ /** CSS anchor name of the root card's anchor box; the child card is placed against it. */
20
+ parentAnchor: string
21
+ /** Whether the layout mode for the current child is known; the card stays hidden until it is. */
22
+ measured: boolean
23
+ page: boolean
24
+ hidden: boolean
25
+ contains: (node: Node | null) => boolean
26
+ activeList: (focused: Node | null) => HTMLDivElement | null
27
+ /** Returns false when no visible child can handle the navigation. */
28
+ returnToParent: () => boolean
29
+ openChild: (id: string, target: HTMLButtonElement, enter?: boolean) => void
30
+ focusParent: (id: string, target: HTMLButtonElement) => void
31
+ leave: () => void
32
+ cancelClose: () => void
33
+ collapseFrom: (event: SyntheticEvent<HTMLDivElement>) => void
34
+ }
35
+
36
+ /** Manage a single child card without owning the root menu's document listeners.
37
+ * @param options - current entries, root lifetime, and fallback focus destination.
38
+ * @returns child rendering data and narrow interaction operations.
39
+ */
40
+ export function useMenuSubmenu(options: {
41
+ open: boolean
42
+ items: readonly MenuEntry[]
43
+ footer: readonly MenuEntry[] | undefined
44
+ listRef: RefObject<HTMLDivElement>
45
+ refocusAnchor: () => void
46
+ }): MenuSubmenu {
47
+ const { open, items, footer, listRef, refocusAnchor } = options
48
+ const [expanded, setExpanded] = useState<{ id: string; trigger: HTMLButtonElement; activated: boolean } | null>(null)
49
+ const panelRef = useRef<HTMLDivElement>(null)
50
+ // A DOM target suppresses its focus-open handler until focus restoration completes.
51
+ const pendingFocus = useRef<'child' | HTMLButtonElement | null>(null)
52
+ const entry = [...items, ...(footer ?? [])].find((item): item is MenuItem & { submenu: readonly MenuEntry[] } =>
53
+ !('type' in item) && item.id === expanded?.id && item.disabled !== true
54
+ && item.submenu !== undefined && item.submenu.length > 0)
55
+ const trigger = expanded?.trigger ?? null
56
+ const anchorId = useId().replaceAll(':', '')
57
+ const parentAnchor = `--dsh-submenu-parent-${anchorId}`
58
+ // Null until the active child has been measured against the layout viewport.
59
+ const [needsPage, setNeedsPage] = useState<boolean | null>(null)
60
+ const contains = (node: Node | null): boolean => panelRef.current?.contains(node) === true
61
+ const invalidated = expanded !== null && entry === undefined
62
+ // These reads precede React removing an invalidated panel or a page's return row.
63
+ const active = document.activeElement
64
+ const restoreInvalidatedFocus = open && invalidated && (contains(active) || trigger === active)
65
+ const backWasFocused = contains(active) && active?.hasAttribute('data-menu-back') === true
66
+ const measured = needsPage !== null
67
+ const page = entry !== undefined && expanded?.activated === true && needsPage === true
68
+ const hidden = !measured || (needsPage && !page)
69
+ // CSS anchors place the card against the parent card. JavaScript selects the layout and
70
+ // supplies two lengths: the card's natural height and the active row's offset from the
71
+ // parent card's top. Both are relative sizes, so page zoom and panning leave them valid.
72
+ const visible = open && entry !== undefined
73
+ useLayoutEffect(() => {
74
+ const panel = panelRef.current
75
+ const parent = listRef.current
76
+ if (!visible || panel === null || parent === null || trigger === null) { setNeedsPage(null); return }
77
+ const measureRow = (): void => {
78
+ panel.style.setProperty('--dsh-submenu-row-offset', `${trigger.getBoundingClientRect().top - parent.getBoundingClientRect().top}px`)
79
+ }
80
+ // The layout uses the side card's natural size, not the size a page layout gives it.
81
+ const measure = (): void => {
82
+ const layout = panel.getAttribute('data-submenu-layout')
83
+ panel.removeAttribute('data-submenu-layout')
84
+ const width = panel.offsetWidth
85
+ panel.style.setProperty('--dsh-submenu-height', `${panel.offsetHeight}px`)
86
+ if (layout !== null) panel.setAttribute('data-submenu-layout', layout)
87
+ measureRow()
88
+ const viewport = document.documentElement.clientWidth || window.innerWidth
89
+ setNeedsPage(submenuNeedsPage(parent.getBoundingClientRect(), width, viewport))
90
+ }
91
+ measure()
92
+ window.addEventListener('resize', measure)
93
+ parent.addEventListener('scroll', measureRow, true)
94
+ const observer = new ResizeObserver(measure)
95
+ for (const element of [parent, trigger, panel]) observer.observe(element)
96
+ return () => {
97
+ window.removeEventListener('resize', measure)
98
+ parent.removeEventListener('scroll', measureRow, true)
99
+ observer.disconnect()
100
+ }
101
+ }, [visible, entry, trigger, listRef])
102
+ const focusFirstChild = (): void => {
103
+ const panel = panelRef.current
104
+ const first = panel?.querySelector<HTMLButtonElement>('button[role="menuitem"]:not(:disabled):not([data-menu-back])')
105
+ ?? panel?.querySelector<HTMLButtonElement>('button:not(:disabled)')
106
+ first?.focus()
107
+ }
108
+ const returnToParent = (): void => {
109
+ cancelClose()
110
+ pendingFocus.current = trigger
111
+ setExpanded(null)
112
+ }
113
+ const collapse = (): void => {
114
+ cancelClose()
115
+ if (contains(document.activeElement)) returnToParent()
116
+ else setExpanded(null)
117
+ }
118
+ const { arm: armClose, cancel: cancelClose } = usePointerGrace(() => { if (!page) collapse() })
119
+ const openChild = (id: string, target: HTMLButtonElement, enter = false): void => {
120
+ cancelClose()
121
+ if (trigger !== target && contains(document.activeElement)) {
122
+ pendingFocus.current = target
123
+ target.focus()
124
+ pendingFocus.current = null
125
+ }
126
+ pendingFocus.current = enter ? 'child' : null
127
+ setExpanded(current => current?.id === id
128
+ ? enter && !current.activated ? { ...current, activated: true } : current
129
+ : { id, trigger: target, activated: enter })
130
+ if (enter) focusFirstChild()
131
+ }
132
+ useLayoutEffect(() => {
133
+ if (!open || invalidated) {
134
+ cancelClose()
135
+ pendingFocus.current = null
136
+ setExpanded(null)
137
+ if (restoreInvalidatedFocus && (document.activeElement === document.body || document.activeElement === trigger)) {
138
+ const target = trigger?.isConnected === true && !trigger.disabled ? trigger
139
+ : listRef.current?.querySelector<HTMLButtonElement>('button:not(:disabled)')
140
+ pendingFocus.current = target ?? null
141
+ if (target != null) target.focus()
142
+ else refocusAnchor()
143
+ pendingFocus.current = null
144
+ }
145
+ return
146
+ }
147
+ if (entry === undefined && pendingFocus.current instanceof HTMLButtonElement) {
148
+ pendingFocus.current.focus()
149
+ pendingFocus.current = null
150
+ }
151
+ if (entry === undefined || hidden) return
152
+ if (pendingFocus.current === 'child' || (page && listRef.current?.contains(document.activeElement))
153
+ || (!page && backWasFocused)) {
154
+ focusFirstChild()
155
+ pendingFocus.current = null
156
+ }
157
+ }, [open, entry, needsPage, page, hidden, invalidated, restoreInvalidatedFocus, backWasFocused, cancelClose])
158
+
159
+ const collapseFrom = (event: SyntheticEvent<HTMLDivElement>): void => {
160
+ // React DOM normalizes text-node event targets to their parent element.
161
+ const row = (event.target as Element).closest('button[role="menuitem"]')
162
+ if (row === null || row.getAttribute('aria-haspopup') === 'menu') return
163
+ if (row.closest('[role="menu"]') === event.currentTarget) collapse()
164
+ }
165
+ return {
166
+ entry, panelRef, parentAnchor, measured, page, hidden,
167
+ contains,
168
+ activeList: (focused: Node | null) => page || contains(focused) ? panelRef.current : listRef.current,
169
+ returnToParent: (): boolean => {
170
+ if (entry === undefined || hidden) return false
171
+ returnToParent()
172
+ return true
173
+ },
174
+ openChild,
175
+ focusParent: (id: string, target: HTMLButtonElement): void => {
176
+ if (pendingFocus.current !== target) openChild(id, target)
177
+ },
178
+ leave: (): void => { if (!page) armClose() },
179
+ cancelClose,
180
+ collapseFrom,
181
+ }
182
+ }
@@ -0,0 +1,108 @@
1
+ /** Shared modal keyboard ownership and focus lifetime. */
2
+ import { useLayoutEffect, useRef } from 'react'
3
+ import type { RefObject } from 'react'
4
+ import { observeComposition } from './keyboard-composition.ts'
5
+ import { focusWithoutRing } from './focus.ts'
6
+
7
+ /** Dialog and menu elements whose document order determines foreground shortcut ownership. */
8
+ export const modalSelector = '[role="dialog"][aria-modal="true"], [role="menu"]'
9
+
10
+ const layers = new WeakMap<Document, { element: HTMLElement; close: () => void }[]>()
11
+
12
+ /**
13
+ * Request closure of the foreground registered modal using its current onClose callback.
14
+ * A newer menu or unregistered dialog blocks dismissal of the modal behind it.
15
+ * @param document - product document whose modal owns the close command.
16
+ */
17
+ export function closeTopModal(document: Document): void {
18
+ const top = layers.get(document)?.at(-1)
19
+ if (top === undefined) return
20
+ const foreground = [...document.querySelectorAll(modalSelector)].at(-1)
21
+ if (foreground === top.element) top.close()
22
+ }
23
+ /**
24
+ * Whether an anchor belongs behind the current modal and must yield keyboard input.
25
+ * @param anchor - local control owning the input handler.
26
+ * @returns true when another modal owns the foreground.
27
+ */
28
+ export function isBehindModal(anchor: HTMLElement | null): boolean {
29
+ if (anchor === null) return false
30
+ const top = layers.get(anchor.ownerDocument)?.at(-1)
31
+ return top !== undefined && !top.element.contains(anchor)
32
+ }
33
+
34
+ const focusable = 'button:not(:disabled), input:not(:disabled), textarea:not(:disabled), select:not(:disabled), a[href], [tabindex="0"]'
35
+
36
+ /**
37
+ * Give only the top modal Escape and Tab ownership, then restore its previous focus.
38
+ * Automatic entry and return focus omit outlines; keyboard traversal retains its indicators.
39
+ * Controls mounted with the dialog use data-modal-autofocus for initial focus;
40
+ * React autoFocus runs before this layer can capture the invoking control.
41
+ * Local menus handle their Escape during capture before this bubble listener.
42
+ * @param dialog - mounted dialog element.
43
+ * @param open - whether this layer is active.
44
+ * @param onClose - top-layer Escape or application close action.
45
+ */
46
+ export function useModalLayer(dialog: RefObject<HTMLElement | null>, open: boolean, onClose: () => void): void {
47
+ const close = useRef(onClose)
48
+ const pendingRestore = useRef<HTMLElement | undefined>(undefined)
49
+ close.current = onClose
50
+ useLayoutEffect(() => {
51
+ const target = pendingRestore.current
52
+ pendingRestore.current = undefined
53
+ const element = dialog.current
54
+ // Restore only focus left inside the retained dialog, preserving the owner's chosen target.
55
+ if (!open && element?.contains(element.ownerDocument.activeElement)
56
+ && target?.isConnected && !target.closest('[inert], [hidden]') && !isBehindModal(target)) {
57
+ focusWithoutRing(target, { preventScroll: true })
58
+ }
59
+ if (!open || element === null) return
60
+ const document = element.ownerDocument
61
+ const composition = observeComposition(document)
62
+ const previous = document.activeElement
63
+ const stack = layers.get(document) ?? []
64
+ layers.set(document, stack)
65
+ const layer = { element, close: () => { close.current() } }
66
+ stack.push(layer)
67
+ const initial = element.querySelector<HTMLElement>('[data-modal-autofocus]')
68
+ ?? element.querySelector<HTMLElement>(focusable) ?? element
69
+ if (!element.contains(document.activeElement)) focusWithoutRing(initial)
70
+ const keydown = (event: KeyboardEvent): void => {
71
+ const composing = composition.guards(event)
72
+ if (stack.at(-1) !== layer || event.defaultPrevented || composing
73
+ || event.ctrlKey || event.altKey || event.metaKey) return
74
+ if (event.key === 'Escape' && !event.shiftKey) {
75
+ event.preventDefault()
76
+ if (!event.repeat) close.current()
77
+ }
78
+ if (event.key !== 'Tab') return
79
+ // Portaled menus own their traversal while they contain focus.
80
+ if (document.activeElement?.closest('[role="menu"]')) return
81
+ const items = [...element.querySelectorAll<HTMLElement>(focusable)]
82
+ .filter(item => !item.closest('[inert], [hidden]'))
83
+ const first = items[0] ?? element
84
+ const last = items.at(-1) ?? element
85
+ const atEdge = event.shiftKey ? document.activeElement === first : document.activeElement === last
86
+ if (document.activeElement === element || !element.contains(document.activeElement) || atEdge) {
87
+ event.preventDefault()
88
+ const target = event.shiftKey ? last : first
89
+ target.focus()
90
+ }
91
+ }
92
+ document.addEventListener('keydown', keydown)
93
+ return () => {
94
+ composition.dispose()
95
+ const wasTop = stack.at(-1) === layer
96
+ stack.splice(stack.indexOf(layer), 1)
97
+ document.removeEventListener('keydown', keydown)
98
+ if (stack.length === 0) layers.delete(document)
99
+ if (wasTop) {
100
+ const target = previous instanceof HTMLElement && previous.isConnected ? previous : stack.at(-1)?.element
101
+ if (target !== undefined) {
102
+ pendingRestore.current = target
103
+ focusWithoutRing(target)
104
+ }
105
+ }
106
+ }
107
+ }, [dialog, open])
108
+ }
@@ -0,0 +1,76 @@
1
+ /** Offscreen row snapshots for native browser dragging. */
2
+ import { useEffect, useMemo, useRef } from 'react'
3
+ import type { DragEvent } from 'react'
4
+ import clsx from 'clsx'
5
+ import css from './RowDragPreview.module.css'
6
+
7
+ /**
8
+ * Own a row's inert drag preview until drag end, replacement, or unmount.
9
+ * The offscreen copy keeps WebKit snapshots separate from overlapping panels.
10
+ * The wrapper copies only explicitly requested computed custom properties.
11
+ * Its cloned slot DOM remains in document.body for that lifetime; query live rows
12
+ * within their list to exclude duplicate text and element IDs.
13
+ * @param className - preview background matching the row's surface; WebKit fills
14
+ * transparent snapshot pixels white, including rounded corners.
15
+ * @param inheritedProperties - custom-property names whose computed values the preview needs.
16
+ * Omit to copy none. Keep the list reference stable; replacing it clears the active preview.
17
+ * @returns preview callbacks; cleanup reports whether this row started a drag,
18
+ * even when its preview failed or the row became non-draggable before drag end.
19
+ * Start accepts the source row when a child handle owns the drag event.
20
+ */
21
+ export function useRowDragPreview(className: string, inheritedProperties?: readonly `--${string}`[]): {
22
+ start: (event: DragEvent<HTMLElement>, row?: HTMLElement) => void
23
+ clear: () => boolean
24
+ } {
25
+ const current = useRef<HTMLDivElement | null>(null)
26
+ const dragging = useRef(false)
27
+ const preview = useMemo(() => {
28
+ const clear = (): boolean => {
29
+ const wasDragging = dragging.current
30
+ dragging.current = false
31
+ current.current?.remove()
32
+ current.current = null
33
+ return wasDragging
34
+ }
35
+ return {
36
+ clear,
37
+ start: (event: DragEvent<HTMLElement>, row = event.currentTarget): void => {
38
+ clear()
39
+ dragging.current = true
40
+ const rect = row.getBoundingClientRect()
41
+ const style = getComputedStyle(row)
42
+ const copy = row.cloneNode(true) as HTMLElement
43
+ copy.removeAttribute('data-row-key')
44
+ copy.tabIndex = -1
45
+ for (const control of copy.querySelectorAll<HTMLElement>(
46
+ 'button, a[href], input, select, textarea, [tabindex], [contenteditable]',
47
+ )) control.tabIndex = -1
48
+ copy.style.color = style.color
49
+ copy.style.paddingInlineStart = style.paddingInlineStart
50
+ const image = row.ownerDocument.createElement('div')
51
+ image.className = clsx(css.preview, className)
52
+ image.inert = true
53
+ image.setAttribute('aria-hidden', 'true')
54
+ inheritedProperties?.forEach((property) => {
55
+ image.style.setProperty(property, style.getPropertyValue(property))
56
+ })
57
+ Object.assign(image.style, {
58
+ left: `${String(-rect.width)}px`, width: `${String(rect.width)}px`,
59
+ height: `${String(rect.height)}px`, font: style.font,
60
+ })
61
+ image.append(copy)
62
+ row.ownerDocument.body.append(image)
63
+ current.current = image
64
+ try {
65
+ event.dataTransfer.setDragImage(image, event.clientX - rect.left, event.clientY - rect.top)
66
+ } catch (_error) {
67
+ // Browsers may reject a custom image; retain native dragging without the copy.
68
+ image.remove()
69
+ current.current = null
70
+ }
71
+ },
72
+ }
73
+ }, [className, inheritedProperties])
74
+ useEffect(() => () => { preview.clear() }, [preview])
75
+ return preview
76
+ }
@@ -0,0 +1,46 @@
1
+ /* Inline projection of sent user text: plain runs and reference chips flow in
2
+ the consumer's own line box (bubble or queue row); nothing here is block.
3
+ White-space policy stays with the consumer: the bubble wraps with pre-wrap,
4
+ the queue preview keeps its single nowrap/ellipsis line. */
5
+
6
+ .plainRun {
7
+ font-size: inherit;
8
+ line-height: inherit;
9
+ }
10
+
11
+ .refChip {
12
+ /* Plain inline, NOT inline-flex: a flex container takes its baseline from
13
+ its first flex item — the icon svg, which has no text baseline — so the
14
+ chip's label rode ~3px above the surrounding text in both surfaces. An
15
+ inline chip shares the consumer's baseline by construction. */
16
+ display: inline;
17
+ max-width: 100%;
18
+ margin: 0 2px;
19
+ color: var(--dsw-alias-state-business-primary);
20
+ font-weight: 500;
21
+ white-space: inherit;
22
+ overflow-wrap: anywhere;
23
+ text-align: inherit;
24
+ }
25
+
26
+ /* Skill and command tokens read as code: the theme's code family at the
27
+ consumer's own size and line height, so the chip sits on the bubble line
28
+ like the plain runs around it. `@` chips keep the body face — a file or
29
+ session name is a label, not code. */
30
+ .slashChip {
31
+ font-family: var(--dsw-font-markdown-code-font-family);
32
+ }
33
+
34
+ /* Inline reference glyphs (always ReferenceIcon svgs) ride the consumer's own
35
+ font: 1em keeps the glyph at the text's size in the bubble (14px + user
36
+ setting), the queue preview's fixed 13px line, and any future consumer — a
37
+ px+delta size followed only the bubble axis and left the glyph oversized in
38
+ the queue row. */
39
+ .refIcon {
40
+ width: 1em;
41
+ height: 1em;
42
+ margin-right: 4px;
43
+ /* Optical centering against the text: drops the glyph below the baseline by
44
+ a font-relative amount, so it holds across the font axis. */
45
+ vertical-align: -0.125em;
46
+ }
@@ -0,0 +1,67 @@
1
+ /** Inline text and reference presentation; business rules supply resolved JSON data and actions. */
2
+ import type { HTMLAttributes } from 'react'
3
+ import type { ReactNode } from 'react'
4
+ import clsx from 'clsx'
5
+ import { ReferenceIconRegular, type ReferenceIconKind } from './ReferenceIcon.tsx'
6
+ import css from './user-text.module.css'
7
+ import markdownCss from './markdown/MarkdownText.module.css'
8
+
9
+ /** Plain text follows the wrapping and typography of its host. */
10
+ export interface UserTextRunProps {
11
+ readonly text: string
12
+ }
13
+
14
+ /**
15
+ * Render an uninterpreted inline text run.
16
+ * @param props - text retained verbatim from the caller's document.
17
+ * @returns one inline run without Markdown or reference recognition.
18
+ */
19
+ export function UserTextRun({ text }: UserTextRunProps): ReactNode {
20
+ return <span className={css.plainRun}>{text}</span>
21
+ }
22
+
23
+ /** Presentation selected by a reference renderer, independent of its matching grammar. */
24
+ export interface ReferenceChipProps {
25
+ readonly appearance: ReferenceIconKind | 'skill' | 'command'
26
+ /** Explicit object-menu gesture bindings; absent for display-only references. */
27
+ readonly contextMenuProps?: Pick<HTMLAttributes<HTMLElement>, 'onContextMenu' | 'onKeyDown' | 'tabIndex'>
28
+ readonly label: string
29
+ readonly title: string
30
+ /** Absent for display-only references and previews. */
31
+ readonly onActivate?: () => void
32
+ }
33
+
34
+ /**
35
+ * Render a reference label or its explicitly supplied activation action.
36
+ * Text selection and repeated pointer clicks do not activate the reference.
37
+ * @param props - resolved visual fields and optional action from the owning renderer.
38
+ * @returns an inline label, or a keyboard-accessible button when activation is supplied.
39
+ */
40
+ export function ReferenceChip({
41
+ appearance, label, title, onActivate, contextMenuProps,
42
+ }: ReferenceChipProps): ReactNode {
43
+ const slash = appearance === 'skill' || appearance === 'command'
44
+ const contents = <>
45
+ {!slash && <ReferenceIconRegular kind={appearance} size={16} className={css.refIcon} />}
46
+ {label}
47
+ </>
48
+ const className = clsx(css.refChip, slash && css.slashChip)
49
+ return onActivate === undefined
50
+ ? <span
51
+ {...contextMenuProps}
52
+ className={className}
53
+ data-ref-chip={appearance}
54
+ title={title}
55
+ >{contents}</span>
56
+ : <button
57
+ type="button"
58
+ {...contextMenuProps}
59
+ className={clsx(className, markdownCss.fileMention)}
60
+ data-ref-chip={appearance}
61
+ title={title}
62
+ onClick={(event) => {
63
+ if (event.detail > 1 || (event.detail !== 0 && event.currentTarget.ownerDocument.getSelection()?.isCollapsed === false)) return
64
+ onActivate()
65
+ }}
66
+ >{contents}</button>
67
+ }