@deepseek-ai/dsh-client-ui-primitives 0.2.2-alpha.3 → 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 +11 -8
  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,108 @@
1
+ /* Block, not inline-flex: consumers wrap full-width list rows and an
2
+ * inline wrapper would shrink them; the card still measures this rect. */
3
+ .root {
4
+ position: relative;
5
+ display: block;
6
+ }
7
+
8
+ /* The preview remains hit-testable so pointer entry cancels the grace close. */
9
+ .card {
10
+ position: fixed;
11
+ z-index: 100;
12
+ box-sizing: border-box;
13
+ width: 244px;
14
+ padding: 12px 16px;
15
+ border-radius: var(--dsw-radius-lg);
16
+ background: var(--dsw-alias-hovercard-bg);
17
+ box-shadow: var(--dsw-shadow-lv3);
18
+ }
19
+
20
+ .copyable {
21
+ cursor: pointer;
22
+ }
23
+
24
+ .copyable:focus-visible {
25
+ outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
26
+ outline-offset: 2px;
27
+ }
28
+
29
+ .feedback {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ }
34
+
35
+ .copied {
36
+ color: var(--dsw-alias-hovercard-label-primary);
37
+ font-size: 14px;
38
+ line-height: 20px;
39
+ text-align: center;
40
+ }
41
+
42
+ .status {
43
+ position: absolute;
44
+ width: 1px;
45
+ height: 1px;
46
+ overflow: hidden;
47
+ clip: rect(0 0 0 0);
48
+ white-space: nowrap;
49
+ }
50
+
51
+ .preview {
52
+ display: flex;
53
+ flex-direction: column;
54
+ padding: 0;
55
+ overflow: hidden;
56
+ border: 0;
57
+ border-radius: var(--dsw-radius-lg);
58
+ background: var(--dsw-alias-bg-layer-1);
59
+ color: var(--dsw-alias-label-primary);
60
+ box-shadow: var(--dsw-elevation-panel);
61
+ opacity: 1;
62
+ transition: opacity var(--dsh-hover-preview-fade) linear;
63
+ }
64
+
65
+ @starting-style {
66
+ .preview { opacity: 0; }
67
+ }
68
+
69
+ .preview[data-closing] {
70
+ opacity: 0;
71
+ pointer-events: none;
72
+ }
73
+
74
+ @media (prefers-reduced-motion: reduce) {
75
+ .preview { transition: none; }
76
+ }
77
+
78
+ .inline { display: inline; }
79
+ .media {
80
+ --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
81
+ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
82
+ overflow: auto;
83
+ padding: 8px;
84
+ border: 0;
85
+ color: var(--dsw-alias-label-primary);
86
+ background: var(--dsw-specific-menu);
87
+ backdrop-filter: var(--dsw-menu-backdrop-filter);
88
+ box-shadow: var(--dsw-elevation-panel);
89
+ }
90
+
91
+ .fitContent {
92
+ width: max-content;
93
+ }
94
+
95
+ .portal {
96
+ display: contents;
97
+ }
98
+
99
+ .bridge {
100
+ position: fixed;
101
+ z-index: 100;
102
+ }
103
+
104
+ /* The display:contents portal has no box to subtract from native drag regions. */
105
+ :global(:where(html[data-platform='darwin'])) .card,
106
+ :global(:where(html[data-platform='darwin'])) .bridge {
107
+ -webkit-app-region: no-drag;
108
+ }
@@ -0,0 +1,356 @@
1
+ import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react'
2
+ import type { CSSProperties, ReactNode, RefObject, SyntheticEvent } from 'react'
3
+ import clsx from 'clsx'
4
+ import { createPortal } from 'react-dom'
5
+ import { writeClipboard } from './clipboard.ts'
6
+ import { usePointerGrace } from './pointer-grace.ts'
7
+ import { overlayTopMargin } from './overlay-top-margin.ts'
8
+ import { HoverCardGroupContext } from './HoverCardGroup.tsx'
9
+ import css from './HoverCard.module.css'
10
+
11
+ /** Preview opacity transition and retained lifetime during dismissal. */
12
+ const PREVIEW_FADE_MS = 100
13
+ const PREVIEW_MAX_HEIGHT = 420
14
+ const PREVIEW_INSET = 24
15
+ const INLINE_PREVIEW_WIDTH = 300
16
+ const ANCHOR_GAP = 8
17
+ const VIEWPORT_MARGIN = 8
18
+
19
+ interface CardPosition {
20
+ left: number
21
+ top: number
22
+ width?: number
23
+ maxWidth?: number
24
+ maxHeight?: number
25
+ bridge?: { left: number; top: number; width: number; height: number }
26
+ }
27
+
28
+ /**
29
+ * Render an anchor with a hover-triggered preview card independently of nested tooltips.
30
+ * Touch entry does not open a preview or intercept the anchor's action.
31
+ * @param props.anchor - the hover target (rendered in place inside a wrapper span).
32
+ * @param props.content - card content; the pointer may rest on it, so it is
33
+ * readable and selectable, but it carries no dismissal affordance of its own.
34
+ * @param props.openDelayMs - hover dwell before the card shows (default 500).
35
+ * @param props.variant - compact card beside the anchor, or a preview above/below it
36
+ * with 24px side insets, a 420px height cap, the frame-top clearance (capped below an anchor inside the top strip),
37
+ * and 100ms opacity transitions.
38
+ * @param props.widthAnchorRef - optional element whose width and horizontal position size the preview.
39
+ * @param props.inline - keep the anchor in prose; show a contained preview on hover or keyboard focus.
40
+ * Its hover region connects the anchor and preview across the visual gap.
41
+ * @param props.fitContent - size an inline card to its content within the usual width cap.
42
+ * @param props.disabled - suppress opening; turning true dismisses an open card.
43
+ * @param props.grouped - share first-display dwell across the surrounding list and active portal.
44
+ * Group replacement removes the previous card immediately, including a fading preview.
45
+ * @param props.copyText - optional primary value copied by activation and
46
+ * included in the card's accessible name.
47
+ * @param props.copyLabel - localized accessible activation-label prefix.
48
+ * @param props.copiedLabel - localized visible success label.
49
+ * @returns anchor wrapper with the conditional portaled card.
50
+ */
51
+ export function HoverCard({
52
+ anchor, content, openDelayMs = 500, disabled = false, grouped = false,
53
+ copyText, copyLabel, copiedLabel, variant = 'compact', widthAnchorRef, inline = false, fitContent = false,
54
+ }: {
55
+ anchor: ReactNode
56
+ /** Inline media preview using the shared menu material and keyboard focus. */
57
+ inline?: boolean
58
+ fitContent?: boolean
59
+ content: ReactNode
60
+ openDelayMs?: number
61
+ disabled?: boolean
62
+ grouped?: boolean
63
+ variant?: 'compact' | 'preview'
64
+ widthAnchorRef?: RefObject<HTMLElement | null>
65
+ } & ({ copyText?: string | undefined; copyLabel: string; copiedLabel: string } | {
66
+ copyText?: undefined
67
+ copyLabel?: string
68
+ copiedLabel?: string
69
+ })) {
70
+ const rootRef = useRef<HTMLSpanElement>(null)
71
+ const cardRef = useRef<HTMLDivElement>(null)
72
+ const portalRef = useRef<HTMLSpanElement>(null)
73
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
74
+ const copyTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
75
+ const copyHeightRef = useRef<number | null>(null)
76
+ const copyEpochRef = useRef(0)
77
+ const copyingRef = useRef(false)
78
+ const mountedRef = useRef(true)
79
+ const [phase, setPhase] = useState<'closed' | 'open' | 'closing'>('closed')
80
+ const open = phase !== 'closed'
81
+ const closing = phase === 'closing'
82
+ const [pos, setPos] = useState<CardPosition | null>(null)
83
+ const positioned = pos !== null
84
+ const [copied, setCopied] = useState(false)
85
+ const parentGroup = useContext(HoverCardGroupContext)
86
+ const group = grouped ? parentGroup : null
87
+ const [groupOwner] = useState(() => Symbol('hover-card'))
88
+
89
+ const clearCopied = useCallback(() => {
90
+ if (copyTimerRef.current !== null) {
91
+ clearTimeout(copyTimerRef.current)
92
+ copyTimerRef.current = null
93
+ }
94
+ copyHeightRef.current = null
95
+ setCopied(false)
96
+ }, [])
97
+
98
+ const close = useCallback(() => {
99
+ copyEpochRef.current += 1
100
+ clearCopied()
101
+ setPhase(current => variant === 'preview' && current !== 'closed' ? 'closing' : 'closed')
102
+ }, [clearCopied, variant])
103
+
104
+ const { arm: armClose, cancel: cancelClose } = usePointerGrace(close)
105
+
106
+ const clearTimer = useCallback(() => {
107
+ if (timerRef.current !== null) {
108
+ clearTimeout(timerRef.current)
109
+ timerRef.current = null
110
+ }
111
+ }, [])
112
+
113
+ const dismissImmediately = useCallback(() => {
114
+ clearTimer()
115
+ cancelClose()
116
+ copyEpochRef.current += 1
117
+ clearCopied()
118
+ setPhase('closed')
119
+ }, [clearTimer, cancelClose, clearCopied])
120
+ // A fading preview still owns the group's visible card until it unmounts or another card replaces it.
121
+ const groupVisible = open && positioned
122
+ useLayoutEffect(() => {
123
+ if (!groupVisible || group === null) return
124
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- The visible portal's ref is attached before layout effects.
125
+ group.shown(groupOwner, dismissImmediately, portalRef.current!)
126
+ return () => { group.release(groupOwner) }
127
+ }, [group, groupOwner, groupVisible, dismissImmediately])
128
+
129
+ useEffect(() => {
130
+ if (!closing) return
131
+ const timer = setTimeout(() => { setPhase('closed') }, PREVIEW_FADE_MS)
132
+ return () => { clearTimeout(timer) }
133
+ }, [closing])
134
+
135
+ // Owner disabling mid-hover (menu opened, drag started) starts dismissal.
136
+ useEffect(() => {
137
+ if (!disabled) return
138
+ clearTimer()
139
+ cancelClose()
140
+ close()
141
+ }, [disabled, cancelClose, close])
142
+
143
+ useEffect(() => {
144
+ mountedRef.current = true
145
+ return () => {
146
+ mountedRef.current = false
147
+ copyEpochRef.current += 1
148
+ clearTimer()
149
+ if (copyTimerRef.current !== null) {
150
+ clearTimeout(copyTimerRef.current)
151
+ copyTimerRef.current = null
152
+ }
153
+ }
154
+ }, [])
155
+
156
+ useEffect(() => {
157
+ if (!open || (variant !== 'preview' && !inline)) return
158
+ const dismiss = (event: KeyboardEvent): void => {
159
+ if (event.key !== 'Escape') return
160
+ if (inline) event.stopPropagation()
161
+ clearTimer()
162
+ cancelClose()
163
+ close()
164
+ }
165
+ window.addEventListener('keydown', dismiss, inline)
166
+ return () => { window.removeEventListener('keydown', dismiss, inline) }
167
+ }, [open, variant, inline, cancelClose, close])
168
+
169
+ // Fixed-position from the anchor rect before paint; track the anchor while
170
+ // open (capture-phase scroll catches nested panes), as in Menu portal mode.
171
+ useLayoutEffect(() => {
172
+ if (!open) { setPos(null); return }
173
+ const place = () => {
174
+ const wrapper = rootRef.current
175
+ /* v8 ignore next -- the ref is attached before the layout effect runs and the listeners die with it. */
176
+ if (wrapper === null) return
177
+ if (wrapper.closest('[inert], [hidden]') !== null) {
178
+ dismissImmediately()
179
+ return
180
+ }
181
+ const r = wrapper.getBoundingClientRect()
182
+ const h = cardRef.current?.offsetHeight ?? 0
183
+ if (variant === 'preview') {
184
+ const bounds = widthAnchorRef?.current?.getBoundingClientRect() ?? r
185
+ const width = Math.max(0, Math.min(bounds.width - PREVIEW_INSET * 2, window.innerWidth - VIEWPORT_MARGIN * 2))
186
+ const topMargin = overlayTopMargin(VIEWPORT_MARGIN, r, ANCHOR_GAP)
187
+ const belowTop = Math.max(topMargin, r.bottom + ANCHOR_GAP)
188
+ const above = Math.max(0, r.top - ANCHOR_GAP - topMargin)
189
+ const below = Math.max(0, window.innerHeight - belowTop - VIEWPORT_MARGIN)
190
+ const onTop = above >= Math.min(PREVIEW_MAX_HEIGHT, below)
191
+ const maxHeight = Math.min(PREVIEW_MAX_HEIGHT, onTop ? above : below)
192
+ setPos({
193
+ left: Math.max(VIEWPORT_MARGIN, Math.min(bounds.left + PREVIEW_INSET, window.innerWidth - width - VIEWPORT_MARGIN)),
194
+ top: onTop ? Math.max(topMargin, r.top - Math.min(h, maxHeight) - ANCHOR_GAP) : belowTop,
195
+ width, maxHeight,
196
+ })
197
+ return
198
+ }
199
+ if (inline) {
200
+ const height = Math.max(h, cardRef.current?.scrollHeight ?? 0)
201
+ const maxWidth = Math.max(0, Math.min(INLINE_PREVIEW_WIDTH, window.innerWidth - VIEWPORT_MARGIN * 2))
202
+ const width = fitContent ? Math.min(cardRef.current?.offsetWidth ?? maxWidth, maxWidth) : maxWidth
203
+ const topMargin = overlayTopMargin(VIEWPORT_MARGIN, r, ANCHOR_GAP)
204
+ const belowTop = Math.max(topMargin, r.bottom + ANCHOR_GAP)
205
+ const above = Math.max(0, r.top - ANCHOR_GAP - topMargin)
206
+ const below = Math.max(0, window.innerHeight - belowTop - VIEWPORT_MARGIN)
207
+ const onTop = height > below && above > below
208
+ const maxHeight = onTop ? above : below
209
+ const left = Math.max(VIEWPORT_MARGIN, Math.min(r.left, window.innerWidth - width - VIEWPORT_MARGIN))
210
+ const top = onTop ? r.top - ANCHOR_GAP - Math.min(height, maxHeight) : belowTop
211
+ const bridgeTop = onTop ? top + Math.min(height, maxHeight) : r.bottom
212
+ const bridgeLeft = Math.min(r.left, left)
213
+ setPos({
214
+ left, top, ...fitContent ? {} : { width }, maxWidth, maxHeight,
215
+ bridge: {
216
+ left: bridgeLeft, top: bridgeTop,
217
+ width: Math.max(r.right, left + width) - bridgeLeft,
218
+ height: Math.max(0, (onTop ? r.top : top) - bridgeTop),
219
+ },
220
+ })
221
+ return
222
+ }
223
+ const top = r.top + h > window.innerHeight - VIEWPORT_MARGIN ? window.innerHeight - h - VIEWPORT_MARGIN : r.top
224
+ setPos({ left: r.right + ANCHOR_GAP, top })
225
+ }
226
+ place()
227
+ // Observe only the anchor's ancestors: an offscreen drawer can hide without resizing its retained row.
228
+ const visibility = new MutationObserver(place)
229
+ for (let ancestor = rootRef.current?.parentElement; ancestor != null; ancestor = ancestor.parentElement) {
230
+ visibility.observe(ancestor, { attributes: true, attributeFilter: ['inert', 'hidden'] })
231
+ }
232
+ const observer = (variant === 'preview' || inline) && typeof ResizeObserver !== 'undefined' ? new ResizeObserver(place) : null
233
+ for (const element of [cardRef.current, rootRef.current, widthAnchorRef?.current]) {
234
+ if (element !== null && element !== undefined) observer?.observe(element)
235
+ }
236
+ window.addEventListener('scroll', place, true)
237
+ window.addEventListener('resize', place)
238
+ return () => {
239
+ observer?.disconnect()
240
+ visibility.disconnect()
241
+ window.removeEventListener('scroll', place, true)
242
+ window.removeEventListener('resize', place)
243
+ }
244
+ }, [open, variant, widthAnchorRef, positioned, inline, fitContent, dismissImmediately])
245
+
246
+ // The first placement ran before the card mounted (height read 0): once the
247
+ // card's real height is measurable, correct the bottom-edge clamp. The
248
+ // correction converges — a clamped top satisfies the guard, so it runs once.
249
+ useLayoutEffect(() => {
250
+ if (!open || pos === null || variant === 'preview' || inline) return
251
+ /* v8 ignore next -- the card is mounted whenever pos is set, so the ref is attached here. */
252
+ const h = cardRef.current?.offsetHeight ?? 0
253
+ if (pos.top + h > window.innerHeight - VIEWPORT_MARGIN) {
254
+ setPos({ left: pos.left, top: window.innerHeight - h - VIEWPORT_MARGIN })
255
+ }
256
+ }, [open, pos, variant, inline])
257
+
258
+ const copy = async (text: string): Promise<void> => {
259
+ if (copied || copyingRef.current) return
260
+ copyingRef.current = true
261
+ const copyEpoch = copyEpochRef.current
262
+ const accepted = await writeClipboard(text)
263
+ copyingRef.current = false
264
+ const card = cardRef.current
265
+ if (!accepted || !mountedRef.current || copyEpoch !== copyEpochRef.current || card === null) return
266
+ const height = card.offsetHeight
267
+ copyHeightRef.current = height > 0 ? height : null
268
+ setCopied(true)
269
+ copyTimerRef.current = setTimeout(clearCopied, 1000)
270
+ }
271
+
272
+ const copyable = copyText !== undefined
273
+ const dismissFromAnchor = (event: SyntheticEvent<HTMLSpanElement>): void => {
274
+ // Portal content is a React child, but its clicks and text selection do not activate the anchor.
275
+ if (portalRef.current?.contains(event.target as Node)) return
276
+ clearTimer()
277
+ cancelClose()
278
+ close()
279
+ }
280
+ const card = open && pos !== null && (
281
+ <div
282
+ ref={cardRef}
283
+ className={clsx(css.card, variant === 'preview' && css.preview, inline && css.media, inline && fitContent && css.fitContent, copyable && css.copyable, copied && css.feedback)}
284
+ data-closing={closing || undefined}
285
+ style={{
286
+ left: pos.left, top: pos.top, width: pos.width, maxWidth: pos.maxWidth, maxHeight: pos.maxHeight,
287
+ minHeight: copied && copyHeightRef.current !== null ? copyHeightRef.current : undefined,
288
+ '--dsh-hover-preview-fade': `${PREVIEW_FADE_MS}ms`,
289
+ } as CSSProperties}
290
+ role={copyable ? 'button' : undefined}
291
+ tabIndex={copyable ? 0 : undefined}
292
+ aria-label={copyable ? `${copyLabel}: ${copyText}` : undefined}
293
+ onClick={copyable
294
+ ? (e) => {
295
+ const selection = window.getSelection()
296
+ if (selection !== null && !selection.isCollapsed) {
297
+ for (let i = 0; i < selection.rangeCount; i += 1) {
298
+ if (selection.getRangeAt(i).intersectsNode(e.currentTarget)) return
299
+ }
300
+ }
301
+ void copy(copyText)
302
+ }
303
+ : undefined}
304
+ onKeyDown={copyable
305
+ ? (e) => {
306
+ if (e.key !== 'Enter' && e.key !== ' ') return
307
+ e.preventDefault()
308
+ void copy(copyText)
309
+ }
310
+ : undefined}
311
+ >
312
+ {copied ? <span className={css.copied} aria-hidden="true">{copiedLabel}</span> : content}
313
+ </div>
314
+ )
315
+
316
+ return (
317
+ <span
318
+ ref={rootRef}
319
+ className={clsx(css.root, inline && css.inline)}
320
+ onFocus={inline ? (event) => {
321
+ if (!disabled && event.target.matches(':focus-visible')) { cancelClose(); setPhase('open') }
322
+ } : undefined}
323
+ onBlur={inline ? (event) => {
324
+ if (!event.currentTarget.contains(event.relatedTarget)) { clearTimer(); cancelClose(); close() }
325
+ } : undefined}
326
+ onPointerEnter={(event) => {
327
+ if (disabled || event.pointerType === 'touch') return
328
+ if (event.pointerType === 'mouse' && !window.matchMedia('(any-hover: hover)').matches) return
329
+ // Coming back inside during the grace (the gap, or the card itself)
330
+ // keeps the current card rather than restarting the dwell.
331
+ cancelClose()
332
+ if (open) { setPhase('open'); return }
333
+ clearTimer()
334
+ if (group?.isWarm()) setPhase('open')
335
+ else timerRef.current = setTimeout(() => { setPhase('open') }, openDelayMs)
336
+ }}
337
+ onPointerLeave={() => {
338
+ clearTimer()
339
+ // Leaving a closed card schedules a no-op close; only arm while
340
+ // open, matching Menu's shape.
341
+ if (open) armClose()
342
+ }}
343
+ onPointerDownCapture={dismissFromAnchor}
344
+ onClickCapture={dismissFromAnchor}
345
+ >
346
+ {anchor}
347
+ {open && copyable && <span className={css.status} role="status">{copied ? copiedLabel : ''}</span>}
348
+ {card !== false && createPortal(
349
+ <span ref={portalRef} className={css.portal}>
350
+ {pos.bridge !== undefined && <span className={css.bridge} style={pos.bridge} data-hovercard-bridge="" aria-hidden />}
351
+ {card}
352
+ </span>, document.body,
353
+ )}
354
+ </span>
355
+ )
356
+ }
@@ -0,0 +1,77 @@
1
+ import { createContext, useState, type ReactNode } from 'react'
2
+
3
+ interface GroupState {
4
+ isWarm: () => boolean
5
+ enter: (overCard: boolean) => void
6
+ leave: () => void
7
+ containsCard: (target: EventTarget | null) => boolean
8
+ shown: (owner: symbol, dismiss: () => void, element: HTMLElement) => void
9
+ release: (owner: symbol) => void
10
+ }
11
+
12
+ /** Private coordination shared only by opted-in HoverCards inside one mounted group. */
13
+ export const HoverCardGroupContext = createContext<GroupState | null>(null)
14
+
15
+ /**
16
+ * Share first-display dwell across a list and its active portal, including the card's existing pointer grace.
17
+ * @param props.children - list contents, including opted-in HoverCards.
18
+ * @param props.className - classes for the physical list container.
19
+ * @param props.as - physical container tag; use span to preserve inline text layout.
20
+ * @returns the list container and its private hover coordinator.
21
+ */
22
+ export function HoverCardGroup({ children, className, as: Container = 'div' }: {
23
+ children: ReactNode
24
+ className?: string | undefined
25
+ as?: 'div' | 'span'
26
+ }) {
27
+ const [group] = useState<GroupState>(() => {
28
+ let pointer: 'outside' | 'list' | 'card' = 'outside'
29
+ let warm = false
30
+ let active: { owner: symbol; dismiss: () => void; element: HTMLElement } | null = null
31
+ return {
32
+ isWarm: () => warm,
33
+ enter: (overCard) => {
34
+ pointer = overCard ? 'card' : 'list'
35
+ if (overCard) warm = true
36
+ },
37
+ leave: () => {
38
+ pointer = 'outside'
39
+ // A displayed card owns the grace across the gap; its release ends an outside visit.
40
+ if (active === null) warm = false
41
+ },
42
+ containsCard: target => target instanceof Node && active !== null && active.element.contains(target),
43
+ shown: (owner, dismiss, element) => {
44
+ // Keyboard focus can replace the portal under the pointer without a pointer-out event.
45
+ if (pointer === 'card') { pointer = 'outside'; warm = false }
46
+ if (pointer === 'list') warm = true
47
+ const previous = active
48
+ active = { owner, dismiss, element }
49
+ if (previous !== null && previous.owner !== owner) previous.dismiss()
50
+ },
51
+ release: (owner) => {
52
+ if (active?.owner !== owner) return
53
+ active = null
54
+ if (pointer !== 'list') { pointer = 'outside'; warm = false }
55
+ },
56
+ }
57
+ })
58
+ return (
59
+ <HoverCardGroupContext.Provider value={group}>
60
+ <Container
61
+ className={className}
62
+ onPointerOverCapture={(event) => {
63
+ const overCard = group.containsCard(event.target)
64
+ if (event.currentTarget.contains(event.target as Node) || overCard) group.enter(overCard)
65
+ }}
66
+ onPointerOutCapture={(event) => {
67
+ const fromGroup = event.currentTarget.contains(event.target as Node) || group.containsCard(event.target)
68
+ const intoGroup = (event.relatedTarget instanceof Node && event.currentTarget.contains(event.relatedTarget))
69
+ || group.containsCard(event.relatedTarget)
70
+ if (fromGroup && !intoGroup) group.leave()
71
+ }}
72
+ >
73
+ {children}
74
+ </Container>
75
+ </HoverCardGroupContext.Provider>
76
+ )
77
+ }
@@ -0,0 +1,54 @@
1
+ /* Full-viewport layer that blocks background clicks, including on the Windows caption. */
2
+ .backdrop {
3
+ position: fixed;
4
+ inset: 0;
5
+ z-index: 1000;
6
+ }
7
+
8
+ /* Painted area below the Windows caption; like Modal, the caption stays unpainted. */
9
+ .stage {
10
+ position: absolute;
11
+ inset: var(--dsh-frame-chrome-top, 0px) 0 0;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ padding: 40px;
16
+ }
17
+
18
+ /* Shared dimming mask below the preview and its controls. */
19
+ .mask {
20
+ position: absolute;
21
+ inset: 0;
22
+ background: var(--dsw-alias-bg-mask-1);
23
+ backdrop-filter: var(--dsw-mask-blur);
24
+ }
25
+
26
+ .image {
27
+ position: relative;
28
+ max-width: min(100%, 1600px);
29
+ max-height: 100%;
30
+ object-fit: contain;
31
+ border-radius: var(--dsw-radius-lg);
32
+ background: var(--dsw-specific-input-major);
33
+ border: 0;
34
+ box-shadow: var(--dsw-elevation-prominent);
35
+ }
36
+
37
+ .close {
38
+ position: absolute;
39
+ top: 20px;
40
+ right: 20px;
41
+ z-index: 1;
42
+ display: grid;
43
+ place-items: center;
44
+ width: 36px;
45
+ height: 36px;
46
+ border: 0.5px solid var(--dsw-alias-border-l2-darkmode-thin);
47
+ border-radius: 999px;
48
+ corner-shape: round;
49
+ background: var(--dsw-specific-input-major);
50
+ color: var(--dsw-alias-label-primary);
51
+ cursor: pointer;
52
+ }
53
+
54
+ .close:focus-visible { outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 3px; }
@@ -0,0 +1,72 @@
1
+ import type { HTMLAttributes } from 'react'
2
+ import { useEffect, useRef } from 'react'
3
+ import { createPortal } from 'react-dom'
4
+ import { IconCloseOutlineRegular } from './icons/index.tsx'
5
+ import css from './ImageLightbox.module.css'
6
+
7
+ /** Lightbox strings the owner resolves from its own locale namespace. */
8
+ export interface ImageLightboxLabels {
9
+ /** Accessible name of the preview dialog. */
10
+ dialog: string
11
+ /** Accessible label of the close control. */
12
+ close: string
13
+ }
14
+
15
+ /**
16
+ * Document-level original-image preview opened by clicking a thumbnail.
17
+ * Closes on Escape, backdrop press, or the close control, and restores focus
18
+ * to the opener on unmount. Rendered through a body portal: an opener inside
19
+ * a transformed or filtered ancestor would otherwise trap the fixed backdrop
20
+ * in that ancestor's box instead of covering the viewport.
21
+ *
22
+ * @param props.src - the original image URL.
23
+ * @param props.alt - the image's alt text.
24
+ * @param props.labels - dialog and close-control strings.
25
+ * @param props.contextMenuProps - optional original-image gesture bindings.
26
+ * @param props.onClose - dismiss callback owned by the opener.
27
+ * @returns the modal preview dialog.
28
+ */
29
+ export function ImageLightbox({ src, alt, labels, onClose, contextMenuProps }: {
30
+ src: string
31
+ alt: string
32
+ labels: ImageLightboxLabels
33
+ onClose: () => void
34
+ contextMenuProps?: Pick<HTMLAttributes<HTMLElement>, 'onContextMenu' | 'onKeyDown' | 'tabIndex'> | undefined
35
+ }) {
36
+ const closeRef = useRef<HTMLButtonElement | null>(null)
37
+ const restoreRef = useRef<HTMLElement | null>(null)
38
+
39
+ useEffect(() => {
40
+ restoreRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null
41
+ closeRef.current?.focus()
42
+ const onKeyDown = (event: globalThis.KeyboardEvent): void => {
43
+ // A portaled image menu owns Escape and Tab until it returns focus.
44
+ if (event.defaultPrevented || document.activeElement?.closest('[role="menu"]')) return
45
+ if (event.key === 'Escape') { event.stopPropagation(); onClose() }
46
+ if (event.key === 'Tab') { event.preventDefault(); closeRef.current?.focus() }
47
+ }
48
+ window.addEventListener('keydown', onKeyDown, true)
49
+ return () => {
50
+ window.removeEventListener('keydown', onKeyDown, true)
51
+ restoreRef.current?.focus()
52
+ }
53
+ }, [onClose])
54
+
55
+ return createPortal(
56
+ <div
57
+ className={css.backdrop}
58
+ role="dialog"
59
+ aria-modal="true"
60
+ aria-label={labels.dialog}
61
+ >
62
+ <div className={css.stage}>
63
+ <div className={css.mask} aria-hidden="true" onMouseDown={onClose} />
64
+ <img className={css.image} src={src} alt={alt} {...contextMenuProps} />
65
+ <button ref={closeRef} type="button" className={css.close} aria-label={labels.close} onClick={onClose}>
66
+ <IconCloseOutlineRegular size={16} />
67
+ </button>
68
+ </div>
69
+ </div>,
70
+ document.body,
71
+ )
72
+ }
@@ -0,0 +1,24 @@
1
+ .frame {
2
+ position: relative;
3
+ display: grid;
4
+ place-items: center;
5
+ width: 100%;
6
+ height: 180px;
7
+ overflow: hidden;
8
+ border-radius: var(--dsw-radius-sm);
9
+ background: var(--dsw-alias-bg-base);
10
+ }
11
+ .image { width: 100%; height: 100%; min-height: 0; object-fit: contain; opacity: 0; }
12
+ .image[data-ready] { opacity: 1; }
13
+ .status {
14
+ position: absolute;
15
+ inset: 0;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ gap: 8px;
20
+ padding: 12px;
21
+ color: var(--dsw-alias-label-tertiary);
22
+ font-size: 12px;
23
+ line-height: 18px;
24
+ }