@zonsh/ui 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (562) hide show
  1. package/CHANGELOG.md +639 -0
  2. package/README.md +49 -21
  3. package/dist/brand.d.ts +3 -0
  4. package/dist/brand.js +7 -0
  5. package/dist/components/_breadcrumb-more.d.ts +6 -0
  6. package/dist/components/_breadcrumb-more.js +5 -0
  7. package/dist/components/_drawing-svg.d.ts +11 -0
  8. package/dist/components/_drawing-svg.js +30 -0
  9. package/dist/components/_media.d.ts +159 -0
  10. package/dist/components/_media.js +266 -0
  11. package/dist/components/_overlay.d.ts +8 -5
  12. package/dist/components/_overlay.js +11 -6
  13. package/dist/components/_scheduler-calendar.d.ts +71 -0
  14. package/dist/components/_scheduler-calendar.js +940 -0
  15. package/dist/components/_scheduler-editor.d.ts +29 -0
  16. package/dist/components/_scheduler-editor.js +111 -0
  17. package/dist/components/_scheduler-menu.d.ts +16 -0
  18. package/dist/components/_scheduler-menu.js +18 -0
  19. package/dist/components/_scheduler-parts.d.ts +164 -0
  20. package/dist/components/_scheduler-parts.js +327 -0
  21. package/dist/components/_suggest-list.d.ts +142 -0
  22. package/dist/components/_suggest-list.js +159 -0
  23. package/dist/components/_toolbar-more.d.ts +24 -0
  24. package/dist/components/_toolbar-more.js +25 -0
  25. package/dist/components/accordion.d.ts +1 -1
  26. package/dist/components/accordion.js +7 -7
  27. package/dist/components/action-sheet.d.ts +88 -0
  28. package/dist/components/action-sheet.js +124 -0
  29. package/dist/components/alert-dialog.js +3 -1
  30. package/dist/components/alert.d.ts +11 -18
  31. package/dist/components/alert.js +9 -6
  32. package/dist/components/app-bar.d.ts +93 -0
  33. package/dist/components/app-bar.js +175 -0
  34. package/dist/components/ascii-field.js +2 -1
  35. package/dist/components/audio-player.d.ts +134 -0
  36. package/dist/components/audio-player.js +618 -0
  37. package/dist/components/avatar.d.ts +6 -6
  38. package/dist/components/avatar.js +13 -11
  39. package/dist/components/badge.d.ts +12 -12
  40. package/dist/components/badge.js +7 -5
  41. package/dist/components/bottom-nav.d.ts +53 -11
  42. package/dist/components/bottom-nav.js +389 -24
  43. package/dist/components/breadcrumb.d.ts +11 -2
  44. package/dist/components/breadcrumb.js +60 -6
  45. package/dist/components/button-group.js +5 -1
  46. package/dist/components/button.d.ts +23 -6
  47. package/dist/components/button.js +64 -8
  48. package/dist/components/calendar.js +8 -6
  49. package/dist/components/card.d.ts +10 -8
  50. package/dist/components/card.js +15 -14
  51. package/dist/components/carousel.d.ts +2 -2
  52. package/dist/components/carousel.js +21 -8
  53. package/dist/components/chart.d.ts +38 -1
  54. package/dist/components/chart.js +27 -5
  55. package/dist/components/checkbox.js +2 -2
  56. package/dist/components/code-block.d.ts +9 -2
  57. package/dist/components/code-block.js +26 -7
  58. package/dist/components/collapsible.js +4 -4
  59. package/dist/components/color-picker.d.ts +2 -2
  60. package/dist/components/color-picker.js +5 -5
  61. package/dist/components/combobox.d.ts +26 -7
  62. package/dist/components/combobox.js +32 -13
  63. package/dist/components/command.d.ts +29 -5
  64. package/dist/components/command.js +37 -12
  65. package/dist/components/context-menu.d.ts +5 -2
  66. package/dist/components/context-menu.js +24 -3
  67. package/dist/components/conversation.d.ts +1 -1
  68. package/dist/components/conversation.js +77 -16
  69. package/dist/components/copy-button.d.ts +1 -1
  70. package/dist/components/copy-button.js +8 -6
  71. package/dist/components/data-table.d.ts +6 -6
  72. package/dist/components/data-table.js +41 -15
  73. package/dist/components/date-picker.d.ts +31 -9
  74. package/dist/components/date-picker.js +100 -18
  75. package/dist/components/dialog.d.ts +17 -10
  76. package/dist/components/dialog.js +20 -13
  77. package/dist/components/drawer.d.ts +26 -8
  78. package/dist/components/drawer.js +75 -16
  79. package/dist/components/drawing.d.ts +25 -0
  80. package/dist/components/drawing.js +32 -0
  81. package/dist/components/empty.js +2 -2
  82. package/dist/components/feature-list.d.ts +65 -13
  83. package/dist/components/feature-list.js +116 -15
  84. package/dist/components/field.js +2 -2
  85. package/dist/components/file-drop.d.ts +9 -7
  86. package/dist/components/file-drop.js +8 -43
  87. package/dist/components/filter-bar.d.ts +10 -9
  88. package/dist/components/filter-bar.js +42 -25
  89. package/dist/components/graph.d.ts +19 -3
  90. package/dist/components/graph.js +190 -28
  91. package/dist/components/illustration.js +53 -31
  92. package/dist/components/input-group.d.ts +6 -11
  93. package/dist/components/input-group.js +21 -19
  94. package/dist/components/input.d.ts +2 -2
  95. package/dist/components/input.js +3 -3
  96. package/dist/components/item.d.ts +9 -6
  97. package/dist/components/item.js +13 -8
  98. package/dist/components/kbd.d.ts +1 -1
  99. package/dist/components/kbd.js +1 -1
  100. package/dist/components/layout.d.ts +2 -1
  101. package/dist/components/layout.js +55 -11
  102. package/dist/components/lightbox.d.ts +76 -9
  103. package/dist/components/lightbox.js +354 -48
  104. package/dist/components/locale.d.ts +6 -6
  105. package/dist/components/logo.d.ts +21 -1
  106. package/dist/components/logo.js +32 -2
  107. package/dist/components/markdown-editor.d.ts +275 -0
  108. package/dist/components/markdown-editor.js +831 -0
  109. package/dist/components/mentions.d.ts +153 -0
  110. package/dist/components/mentions.js +507 -0
  111. package/dist/components/menu.d.ts +2 -1
  112. package/dist/components/menu.js +5 -4
  113. package/dist/components/menubar.d.ts +23 -5
  114. package/dist/components/menubar.js +153 -31
  115. package/dist/components/message.d.ts +62 -11
  116. package/dist/components/message.js +51 -14
  117. package/dist/components/meter.js +1 -1
  118. package/dist/components/money-input.d.ts +1 -1
  119. package/dist/components/money-input.js +1 -1
  120. package/dist/components/native-select.d.ts +2 -2
  121. package/dist/components/native-select.js +4 -4
  122. package/dist/components/navigation-menu.d.ts +3 -1
  123. package/dist/components/navigation-menu.js +23 -10
  124. package/dist/components/number-field.d.ts +2 -9
  125. package/dist/components/number-field.js +90 -26
  126. package/dist/components/number-roll.d.ts +26 -0
  127. package/dist/components/number-roll.js +81 -0
  128. package/dist/components/otp-field.d.ts +1 -1
  129. package/dist/components/otp-field.js +24 -3
  130. package/dist/components/pagination.d.ts +11 -3
  131. package/dist/components/pagination.js +59 -13
  132. package/dist/components/pdf-viewer.d.ts +1 -1
  133. package/dist/components/pdf-viewer.js +8 -8
  134. package/dist/components/phone-input.d.ts +1 -1
  135. package/dist/components/phone-input.js +2 -2
  136. package/dist/components/popover.js +5 -3
  137. package/dist/components/preview-card.d.ts +37 -2
  138. package/dist/components/preview-card.js +226 -2
  139. package/dist/components/progress.js +1 -1
  140. package/dist/components/prompt-input.d.ts +1 -1
  141. package/dist/components/prompt-input.js +35 -17
  142. package/dist/components/pull-to-refresh.d.ts +50 -0
  143. package/dist/components/pull-to-refresh.js +189 -0
  144. package/dist/components/quote.d.ts +6 -1
  145. package/dist/components/quote.js +3 -2
  146. package/dist/components/radio-group.js +8 -3
  147. package/dist/components/rating.d.ts +4 -1
  148. package/dist/components/rating.js +131 -10
  149. package/dist/components/reasoning.d.ts +1 -1
  150. package/dist/components/reasoning.js +7 -3
  151. package/dist/components/resizable.d.ts +1 -1
  152. package/dist/components/resizable.js +2 -2
  153. package/dist/components/response.d.ts +4 -3
  154. package/dist/components/response.js +39 -15
  155. package/dist/components/scheduler.d.ts +352 -0
  156. package/dist/components/scheduler.js +1717 -0
  157. package/dist/components/scroll-area.js +1 -1
  158. package/dist/components/select.d.ts +17 -4
  159. package/dist/components/select.js +140 -9
  160. package/dist/components/separator.d.ts +1 -1
  161. package/dist/components/separator.js +3 -3
  162. package/dist/components/sidebar.d.ts +44 -3
  163. package/dist/components/sidebar.js +90 -31
  164. package/dist/components/site-header.d.ts +18 -13
  165. package/dist/components/site-header.js +26 -9
  166. package/dist/components/skeleton.d.ts +18 -8
  167. package/dist/components/skeleton.js +23 -8
  168. package/dist/components/slider.js +2 -2
  169. package/dist/components/sortable.d.ts +55 -4
  170. package/dist/components/sortable.js +187 -94
  171. package/dist/components/sources.d.ts +1 -1
  172. package/dist/components/sources.js +2 -2
  173. package/dist/components/spinner.d.ts +4 -4
  174. package/dist/components/spinner.js +4 -4
  175. package/dist/components/stat.d.ts +21 -4
  176. package/dist/components/stat.js +17 -8
  177. package/dist/components/stepper.d.ts +1 -1
  178. package/dist/components/stepper.js +8 -7
  179. package/dist/components/suggestions.d.ts +11 -3
  180. package/dist/components/suggestions.js +10 -4
  181. package/dist/components/swipe-actions.d.ts +66 -0
  182. package/dist/components/swipe-actions.js +292 -0
  183. package/dist/components/switch.js +1 -1
  184. package/dist/components/table.d.ts +13 -7
  185. package/dist/components/table.js +124 -23
  186. package/dist/components/tabs.js +15 -8
  187. package/dist/components/tag.d.ts +19 -20
  188. package/dist/components/tag.js +9 -5
  189. package/dist/components/tags-input.d.ts +2 -7
  190. package/dist/components/tags-input.js +11 -8
  191. package/dist/components/textarea.d.ts +3 -2
  192. package/dist/components/textarea.js +4 -3
  193. package/dist/components/theme.d.ts +50 -7
  194. package/dist/components/theme.js +168 -12
  195. package/dist/components/time-field.d.ts +6 -10
  196. package/dist/components/time-field.js +19 -9
  197. package/dist/components/timeline.d.ts +19 -3
  198. package/dist/components/timeline.js +21 -9
  199. package/dist/components/tippy.d.ts +17 -1
  200. package/dist/components/tippy.js +95 -15
  201. package/dist/components/toast.d.ts +2 -7
  202. package/dist/components/toast.js +12 -8
  203. package/dist/components/toggle-group.d.ts +7 -1
  204. package/dist/components/toggle-group.js +17 -5
  205. package/dist/components/toggle.d.ts +2 -2
  206. package/dist/components/toggle.js +3 -2
  207. package/dist/components/tool-call.d.ts +1 -1
  208. package/dist/components/tool-call.js +8 -3
  209. package/dist/components/toolbar.d.ts +57 -4
  210. package/dist/components/toolbar.js +219 -16
  211. package/dist/components/tooltip.d.ts +5 -3
  212. package/dist/components/tooltip.js +14 -6
  213. package/dist/components/tour.d.ts +1 -1
  214. package/dist/components/tour.js +70 -24
  215. package/dist/components/tree.js +33 -10
  216. package/dist/components/typography.d.ts +31 -8
  217. package/dist/components/typography.js +21 -10
  218. package/dist/components/video-player.d.ts +7 -2
  219. package/dist/components/video-player.js +182 -225
  220. package/dist/index.d.ts +99 -92
  221. package/dist/index.js +99 -92
  222. package/dist/lib/calendar.d.ts +153 -0
  223. package/dist/lib/calendar.js +312 -0
  224. package/dist/lib/cn.d.ts +3 -1
  225. package/dist/lib/cn.js +5 -0
  226. package/dist/lib/code-highlight.d.ts +14 -0
  227. package/dist/lib/code-highlight.js +81 -18
  228. package/dist/lib/drag.d.ts +39 -0
  229. package/dist/lib/drag.js +96 -0
  230. package/dist/lib/editorial-assets.js +16 -8
  231. package/dist/lib/figure/figures/automation.js +25 -6
  232. package/dist/lib/figure/figures/bar-chart.js +6 -1
  233. package/dist/lib/figure/figures/brackets-classic.js +4 -1
  234. package/dist/lib/figure/figures/city.js +12 -2
  235. package/dist/lib/figure/figures/conveyor.js +17 -4
  236. package/dist/lib/figure/figures/database.js +5 -2
  237. package/dist/lib/figure/figures/documents.js +11 -3
  238. package/dist/lib/figure/figures/inbox.js +5 -2
  239. package/dist/lib/figure/figures/laptop.js +3 -1
  240. package/dist/lib/figure/figures/pipeline.js +45 -10
  241. package/dist/lib/figure/figures/platform.js +62 -7
  242. package/dist/lib/figure/figures/server.js +21 -5
  243. package/dist/lib/figure/figures/spreadsheet.js +29 -5
  244. package/dist/lib/figure/kernel.d.ts +4 -2
  245. package/dist/lib/figure/kernel.js +10 -5
  246. package/dist/lib/figure/parts.js +6 -2
  247. package/dist/lib/files.d.ts +31 -0
  248. package/dist/lib/files.js +60 -0
  249. package/dist/lib/gesture.d.ts +70 -0
  250. package/dist/lib/gesture.js +141 -0
  251. package/dist/lib/glide.d.ts +10 -4
  252. package/dist/lib/glide.js +14 -5
  253. package/dist/lib/icons.d.ts +1 -0
  254. package/dist/lib/icons.js +6 -0
  255. package/dist/lib/illustration-library.js +1 -6
  256. package/dist/lib/markdown-edit.d.ts +112 -0
  257. package/dist/lib/markdown-edit.js +557 -0
  258. package/dist/lib/markdown-rich-editor.d.ts +188 -0
  259. package/dist/lib/markdown-rich-editor.js +1153 -0
  260. package/dist/lib/markdown-rich.d.ts +63 -0
  261. package/dist/lib/markdown-rich.js +534 -0
  262. package/dist/lib/mentions.d.ts +100 -0
  263. package/dist/lib/mentions.js +246 -0
  264. package/dist/lib/motion.d.ts +18 -0
  265. package/dist/lib/motion.js +43 -5
  266. package/dist/lib/number-roll.d.ts +89 -0
  267. package/dist/lib/number-roll.js +391 -0
  268. package/dist/lib/platform.d.ts +6 -0
  269. package/dist/lib/platform.js +14 -0
  270. package/dist/lib/portal-container.d.ts +9 -0
  271. package/dist/lib/portal-container.js +10 -0
  272. package/dist/lib/press.d.ts +5 -0
  273. package/dist/lib/press.js +186 -0
  274. package/dist/lib/scheduler.d.ts +128 -0
  275. package/dist/lib/scheduler.js +272 -0
  276. package/dist/lib/scroll-edges.d.ts +9 -0
  277. package/dist/lib/scroll-edges.js +50 -0
  278. package/dist/lib/table-fit.d.ts +4 -3
  279. package/dist/lib/table-fit.js +92 -25
  280. package/dist/lib/theme-preset.d.ts +267 -0
  281. package/dist/lib/theme-preset.js +1046 -0
  282. package/dist/lib/theme-script.d.ts +23 -3
  283. package/dist/lib/theme-script.js +17 -5
  284. package/dist/lib/tippy/sprite.d.ts +36 -4
  285. package/dist/lib/tippy/sprite.js +188 -15
  286. package/dist/lib/tone.d.ts +4 -0
  287. package/dist/lib/tone.js +1 -0
  288. package/dist/messages/de.d.ts +3 -3
  289. package/dist/messages/de.js +274 -3
  290. package/dist/skills/zon-ui/SKILL.md +279 -0
  291. package/dist/skills/zon-ui/references/authoring.md +265 -0
  292. package/dist/skills/zon-ui/references/brand.md +416 -0
  293. package/dist/skills/zon-ui/references/components/accordion.md +199 -0
  294. package/dist/skills/zon-ui/references/components/action-sheet.md +268 -0
  295. package/dist/skills/zon-ui/references/components/alert-dialog.md +276 -0
  296. package/dist/skills/zon-ui/references/components/alert.md +167 -0
  297. package/dist/skills/zon-ui/references/components/app-bar.md +307 -0
  298. package/dist/skills/zon-ui/references/components/ascii-field.md +121 -0
  299. package/dist/skills/zon-ui/references/components/aspect-ratio.md +112 -0
  300. package/dist/skills/zon-ui/references/components/audio-player.md +231 -0
  301. package/dist/skills/zon-ui/references/components/avatar.md +98 -0
  302. package/dist/skills/zon-ui/references/components/badge.md +227 -0
  303. package/dist/skills/zon-ui/references/components/bottom-nav.md +709 -0
  304. package/dist/skills/zon-ui/references/components/breadcrumb.md +143 -0
  305. package/dist/skills/zon-ui/references/components/button-group.md +216 -0
  306. package/dist/skills/zon-ui/references/components/button.md +309 -0
  307. package/dist/skills/zon-ui/references/components/calendar.md +296 -0
  308. package/dist/skills/zon-ui/references/components/card.md +158 -0
  309. package/dist/skills/zon-ui/references/components/carousel.md +297 -0
  310. package/dist/skills/zon-ui/references/components/chart.md +739 -0
  311. package/dist/skills/zon-ui/references/components/chat.md +417 -0
  312. package/dist/skills/zon-ui/references/components/checkbox.md +219 -0
  313. package/dist/skills/zon-ui/references/components/code-block.md +143 -0
  314. package/dist/skills/zon-ui/references/components/code-highlight.md +118 -0
  315. package/dist/skills/zon-ui/references/components/collapsible.md +146 -0
  316. package/dist/skills/zon-ui/references/components/color-picker.md +200 -0
  317. package/dist/skills/zon-ui/references/components/combobox.md +455 -0
  318. package/dist/skills/zon-ui/references/components/command.md +326 -0
  319. package/dist/skills/zon-ui/references/components/contact-form.md +562 -0
  320. package/dist/skills/zon-ui/references/components/context-menu.md +159 -0
  321. package/dist/skills/zon-ui/references/components/conversation.md +146 -0
  322. package/dist/skills/zon-ui/references/components/copy-button.md +162 -0
  323. package/dist/skills/zon-ui/references/components/crm.md +1022 -0
  324. package/dist/skills/zon-ui/references/components/dashboard.md +612 -0
  325. package/dist/skills/zon-ui/references/components/data-table.md +776 -0
  326. package/dist/skills/zon-ui/references/components/date-picker.md +444 -0
  327. package/dist/skills/zon-ui/references/components/dialog.md +335 -0
  328. package/dist/skills/zon-ui/references/components/direction.md +165 -0
  329. package/dist/skills/zon-ui/references/components/drawer.md +276 -0
  330. package/dist/skills/zon-ui/references/components/drawing.md +94 -0
  331. package/dist/skills/zon-ui/references/components/empty.md +225 -0
  332. package/dist/skills/zon-ui/references/components/feature-list.md +412 -0
  333. package/dist/skills/zon-ui/references/components/field.md +209 -0
  334. package/dist/skills/zon-ui/references/components/file-drop.md +234 -0
  335. package/dist/skills/zon-ui/references/components/filter-bar.md +485 -0
  336. package/dist/skills/zon-ui/references/components/form.md +970 -0
  337. package/dist/skills/zon-ui/references/components/graph.md +339 -0
  338. package/dist/skills/zon-ui/references/components/illustration.md +497 -0
  339. package/dist/skills/zon-ui/references/components/inbox.md +263 -0
  340. package/dist/skills/zon-ui/references/components/input-group.md +339 -0
  341. package/dist/skills/zon-ui/references/components/input.md +189 -0
  342. package/dist/skills/zon-ui/references/components/item.md +277 -0
  343. package/dist/skills/zon-ui/references/components/kanban.md +626 -0
  344. package/dist/skills/zon-ui/references/components/kbd.md +116 -0
  345. package/dist/skills/zon-ui/references/components/label.md +104 -0
  346. package/dist/skills/zon-ui/references/components/layout.md +291 -0
  347. package/dist/skills/zon-ui/references/components/lightbox.md +235 -0
  348. package/dist/skills/zon-ui/references/components/locale.md +279 -0
  349. package/dist/skills/zon-ui/references/components/logo.md +257 -0
  350. package/dist/skills/zon-ui/references/components/markdown-editor.md +558 -0
  351. package/dist/skills/zon-ui/references/components/mentions.md +512 -0
  352. package/dist/skills/zon-ui/references/components/menu.md +218 -0
  353. package/dist/skills/zon-ui/references/components/menubar.md +292 -0
  354. package/dist/skills/zon-ui/references/components/message.md +243 -0
  355. package/dist/skills/zon-ui/references/components/meter.md +105 -0
  356. package/dist/skills/zon-ui/references/components/money-input.md +333 -0
  357. package/dist/skills/zon-ui/references/components/native-select.md +197 -0
  358. package/dist/skills/zon-ui/references/components/navigation-menu.md +253 -0
  359. package/dist/skills/zon-ui/references/components/number-field.md +210 -0
  360. package/dist/skills/zon-ui/references/components/number-roll.md +175 -0
  361. package/dist/skills/zon-ui/references/components/onboarding.md +896 -0
  362. package/dist/skills/zon-ui/references/components/otp-field.md +166 -0
  363. package/dist/skills/zon-ui/references/components/pagination.md +109 -0
  364. package/dist/skills/zon-ui/references/components/pdf-viewer.md +177 -0
  365. package/dist/skills/zon-ui/references/components/phone-input.md +252 -0
  366. package/dist/skills/zon-ui/references/components/popover.md +176 -0
  367. package/dist/skills/zon-ui/references/components/preview-card.md +193 -0
  368. package/dist/skills/zon-ui/references/components/pricing.md +724 -0
  369. package/dist/skills/zon-ui/references/components/progress.md +92 -0
  370. package/dist/skills/zon-ui/references/components/prompt-input.md +307 -0
  371. package/dist/skills/zon-ui/references/components/pull-to-refresh.md +188 -0
  372. package/dist/skills/zon-ui/references/components/quote.md +115 -0
  373. package/dist/skills/zon-ui/references/components/radio-group.md +215 -0
  374. package/dist/skills/zon-ui/references/components/rating.md +260 -0
  375. package/dist/skills/zon-ui/references/components/reasoning.md +102 -0
  376. package/dist/skills/zon-ui/references/components/resizable.md +213 -0
  377. package/dist/skills/zon-ui/references/components/response.md +170 -0
  378. package/dist/skills/zon-ui/references/components/scheduler.md +732 -0
  379. package/dist/skills/zon-ui/references/components/scroll-area.md +122 -0
  380. package/dist/skills/zon-ui/references/components/select.md +351 -0
  381. package/dist/skills/zon-ui/references/components/separator.md +103 -0
  382. package/dist/skills/zon-ui/references/components/settings.md +793 -0
  383. package/dist/skills/zon-ui/references/components/shop.md +1715 -0
  384. package/dist/skills/zon-ui/references/components/sidebar.md +813 -0
  385. package/dist/skills/zon-ui/references/components/sign-in.md +1639 -0
  386. package/dist/skills/zon-ui/references/components/site-header.md +303 -0
  387. package/dist/skills/zon-ui/references/components/skeleton.md +256 -0
  388. package/dist/skills/zon-ui/references/components/slider.md +172 -0
  389. package/dist/skills/zon-ui/references/components/sortable.md +405 -0
  390. package/dist/skills/zon-ui/references/components/sources.md +106 -0
  391. package/dist/skills/zon-ui/references/components/spinner.md +222 -0
  392. package/dist/skills/zon-ui/references/components/stat.md +267 -0
  393. package/dist/skills/zon-ui/references/components/stepper.md +285 -0
  394. package/dist/skills/zon-ui/references/components/suggestions.md +146 -0
  395. package/dist/skills/zon-ui/references/components/swipe-actions.md +344 -0
  396. package/dist/skills/zon-ui/references/components/switch.md +160 -0
  397. package/dist/skills/zon-ui/references/components/table.md +999 -0
  398. package/dist/skills/zon-ui/references/components/tabs.md +258 -0
  399. package/dist/skills/zon-ui/references/components/tag.md +115 -0
  400. package/dist/skills/zon-ui/references/components/tags-input.md +216 -0
  401. package/dist/skills/zon-ui/references/components/textarea.md +95 -0
  402. package/dist/skills/zon-ui/references/components/theme-editor.md +3940 -0
  403. package/dist/skills/zon-ui/references/components/theme.md +362 -0
  404. package/dist/skills/zon-ui/references/components/time-field.md +222 -0
  405. package/dist/skills/zon-ui/references/components/timeline.md +285 -0
  406. package/dist/skills/zon-ui/references/components/tippy.md +243 -0
  407. package/dist/skills/zon-ui/references/components/toast.md +220 -0
  408. package/dist/skills/zon-ui/references/components/toggle-group.md +261 -0
  409. package/dist/skills/zon-ui/references/components/toggle.md +167 -0
  410. package/dist/skills/zon-ui/references/components/tool-call.md +146 -0
  411. package/dist/skills/zon-ui/references/components/toolbar.md +260 -0
  412. package/dist/skills/zon-ui/references/components/tooltip.md +172 -0
  413. package/dist/skills/zon-ui/references/components/tour.md +423 -0
  414. package/dist/skills/zon-ui/references/components/tree.md +481 -0
  415. package/dist/skills/zon-ui/references/components/typography.md +347 -0
  416. package/dist/skills/zon-ui/references/components/video-player.md +386 -0
  417. package/dist/skills/zon-ui/references/marketing.md +467 -0
  418. package/dist/skills/zon-ui/references/motion.md +455 -0
  419. package/dist/skills/zon-ui/references/recipes.md +1232 -0
  420. package/dist/skills/zon-ui/references/tokens.md +866 -0
  421. package/dist/sources/accordion.css +4 -0
  422. package/dist/sources/action-sheet.css +11 -0
  423. package/dist/sources/alert-dialog.css +6 -0
  424. package/dist/sources/alert.css +3 -0
  425. package/dist/sources/app-bar.css +14 -0
  426. package/dist/sources/ascii-field.css +3 -0
  427. package/dist/sources/aspect-ratio.css +3 -0
  428. package/dist/sources/audio-player.css +20 -0
  429. package/dist/sources/avatar.css +3 -0
  430. package/dist/sources/badge.css +3 -0
  431. package/dist/sources/bottom-nav.css +9 -0
  432. package/dist/sources/breadcrumb.css +14 -0
  433. package/dist/sources/button-group.css +3 -0
  434. package/dist/sources/button.css +9 -0
  435. package/dist/sources/calendar.css +13 -0
  436. package/dist/sources/card.css +3 -0
  437. package/dist/sources/carousel.css +11 -0
  438. package/dist/sources/chart.css +5 -0
  439. package/dist/sources/checkbox.css +6 -0
  440. package/dist/sources/code-block.css +13 -0
  441. package/dist/sources/collapsible.css +4 -0
  442. package/dist/sources/color-picker.css +13 -0
  443. package/dist/sources/combobox.css +13 -0
  444. package/dist/sources/command.css +13 -0
  445. package/dist/sources/context-menu.css +12 -0
  446. package/dist/sources/conversation.css +10 -0
  447. package/dist/sources/copy-button.css +10 -0
  448. package/dist/sources/data-table.css +27 -0
  449. package/dist/sources/date-picker.css +20 -0
  450. package/dist/sources/dialog.css +9 -0
  451. package/dist/sources/direction.css +2 -0
  452. package/dist/sources/drawer.css +9 -0
  453. package/dist/sources/drawing.css +5 -0
  454. package/dist/sources/empty.css +3 -0
  455. package/dist/sources/feature-list.css +4 -0
  456. package/dist/sources/field.css +4 -0
  457. package/dist/sources/file-drop.css +15 -0
  458. package/dist/sources/filter-bar.css +30 -0
  459. package/dist/sources/form.css +4 -0
  460. package/dist/sources/graph.css +19 -0
  461. package/dist/sources/illustration.css +28 -0
  462. package/dist/sources/input-group.css +7 -0
  463. package/dist/sources/input.css +3 -0
  464. package/dist/sources/item.css +4 -0
  465. package/dist/sources/kbd.css +5 -0
  466. package/dist/sources/label.css +3 -0
  467. package/dist/sources/layout.css +3 -0
  468. package/dist/sources/lightbox.css +33 -0
  469. package/dist/sources/locale.css +2 -0
  470. package/dist/sources/logo.css +4 -0
  471. package/dist/sources/markdown-editor.css +41 -0
  472. package/dist/sources/mentions.css +13 -0
  473. package/dist/sources/menu.css +11 -0
  474. package/dist/sources/menubar.css +14 -0
  475. package/dist/sources/message.css +16 -0
  476. package/dist/sources/meter.css +4 -0
  477. package/dist/sources/money-input.css +10 -0
  478. package/dist/sources/native-select.css +4 -0
  479. package/dist/sources/navigation-menu.css +8 -0
  480. package/dist/sources/number-field.css +8 -0
  481. package/dist/sources/number-roll.css +6 -0
  482. package/dist/sources/otp-field.css +5 -0
  483. package/dist/sources/pagination.css +11 -0
  484. package/dist/sources/pdf-viewer.css +30 -0
  485. package/dist/sources/phone-input.css +20 -0
  486. package/dist/sources/popover.css +7 -0
  487. package/dist/sources/preview-card.css +7 -0
  488. package/dist/sources/progress.css +4 -0
  489. package/dist/sources/prompt-input.css +15 -0
  490. package/dist/sources/pull-to-refresh.css +14 -0
  491. package/dist/sources/quote.css +3 -0
  492. package/dist/sources/radio-group.css +5 -0
  493. package/dist/sources/rating.css +6 -0
  494. package/dist/sources/reasoning.css +6 -0
  495. package/dist/sources/resizable.css +4 -0
  496. package/dist/sources/response.css +16 -0
  497. package/dist/sources/scheduler.css +44 -0
  498. package/dist/sources/scroll-area.css +3 -0
  499. package/dist/sources/select.css +12 -0
  500. package/dist/sources/separator.css +3 -0
  501. package/dist/sources/sidebar.css +19 -0
  502. package/dist/sources/site-header.css +15 -0
  503. package/dist/sources/skeleton.css +3 -0
  504. package/dist/sources/slider.css +6 -0
  505. package/dist/sources/sortable.css +12 -0
  506. package/dist/sources/sources.css +6 -0
  507. package/dist/sources/spinner.css +6 -0
  508. package/dist/sources/stat.css +9 -0
  509. package/dist/sources/stepper.css +6 -0
  510. package/dist/sources/suggestions.css +10 -0
  511. package/dist/sources/swipe-actions.css +20 -0
  512. package/dist/sources/switch.css +5 -0
  513. package/dist/sources/table.css +7 -0
  514. package/dist/sources/tabs.css +5 -0
  515. package/dist/sources/tag.css +3 -0
  516. package/dist/sources/tags-input.css +6 -0
  517. package/dist/sources/textarea.css +3 -0
  518. package/dist/sources/theme.css +13 -0
  519. package/dist/sources/time-field.css +7 -0
  520. package/dist/sources/timeline.css +7 -0
  521. package/dist/sources/tippy.css +6 -0
  522. package/dist/sources/toast.css +6 -0
  523. package/dist/sources/toggle-group.css +5 -0
  524. package/dist/sources/toggle.css +3 -0
  525. package/dist/sources/tool-call.css +16 -0
  526. package/dist/sources/toolbar.css +14 -0
  527. package/dist/sources/tooltip.css +6 -0
  528. package/dist/sources/tour.css +14 -0
  529. package/dist/sources/tree.css +6 -0
  530. package/dist/sources/typography.css +4 -0
  531. package/dist/sources/video-player.css +21 -0
  532. package/dist/styles/ai.css +3 -0
  533. package/dist/styles/brand.css +98 -0
  534. package/dist/styles/core.css +266 -0
  535. package/dist/styles/editor.css +3 -0
  536. package/dist/styles/expressive.css +75 -77
  537. package/dist/styles/fonts.css +61 -117
  538. package/dist/styles/graph.css +4 -0
  539. package/dist/styles/illustration.css +4 -0
  540. package/dist/styles/index.css +11 -193
  541. package/dist/styles/material.css +177 -31
  542. package/dist/styles/parts/ai.css +20 -14
  543. package/dist/styles/parts/brand.css +2 -2
  544. package/dist/styles/parts/controls.css +51 -38
  545. package/dist/styles/parts/data.css +43 -11
  546. package/dist/styles/parts/editor.css +372 -0
  547. package/dist/styles/parts/feedback.css +75 -15
  548. package/dist/styles/parts/foundations.css +12 -7
  549. package/dist/styles/parts/graph.css +25 -9
  550. package/dist/styles/parts/inputs.css +172 -9
  551. package/dist/styles/parts/isometric.css +6 -5
  552. package/dist/styles/parts/navigation.css +237 -25
  553. package/dist/styles/parts/overlays.css +110 -8
  554. package/dist/styles/parts/pdf.css +15 -9
  555. package/dist/styles/pdf.css +3 -0
  556. package/dist/styles/prose.css +3 -0
  557. package/dist/styles/tokens.css +105 -15
  558. package/dist/theme.d.ts +1 -0
  559. package/dist/theme.js +5 -0
  560. package/dist/vite.d.ts +48 -59
  561. package/dist/vite.js +54 -21
  562. package/package.json +69 -2
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
3
+ import { ChevronLeftIcon, ChevronRightIcon } from "../lib/icons.js";
4
4
  import * as React from "react";
5
5
  import { cn } from "../lib/cn.js";
6
6
  import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
@@ -11,6 +11,7 @@ const defaultMessages = {
11
11
  previous: "Previous page",
12
12
  next: "Next page",
13
13
  page: (page) => `Page ${page}`,
14
+ status: (page, count) => `Page ${page} of ${count}`,
14
15
  };
15
16
  const PAGE = '[data-slot="pagination-page"]';
16
17
  const findCurrent = (nav) => nav.querySelector(`${PAGE}[aria-current="page"]`);
@@ -38,7 +39,7 @@ function getPages(page, count, siblings) {
38
39
  * something short. Under ~50 rows, show them all; a table with `dense` rows is easier to scan
39
40
  * than a page switcher.
40
41
  */
41
- export function Pagination({ page, pageCount, onPageChange, getHref, siblingCount = 1, size = "default", labels, className, ref, ...props }) {
42
+ export function Pagination({ page, pageCount, onPageChange, getHref, siblingCount = 1, compact = "auto", size = "default", labels, className, ref, ...props }) {
42
43
  const [navRef, setNavRef] = useMergedRef(ref);
43
44
  const glide = useGlide(navRef, findCurrent, { attributes: ["aria-current"], items: PAGE });
44
45
  // A count straight from a division (95 rows / 10) rounds up; one that is not a number yet, or
@@ -50,7 +51,49 @@ export function Pagination({ page, pageCount, onPageChange, getHref, siblingCoun
50
51
  // the nearest one, so a page still reads as current and Previous and Next still lead somewhere.
51
52
  // Choosing a page reports it whenever it differs from `page` itself.
52
53
  const current = Number.isNaN(page) ? 1 : Math.min(Math.max(Math.floor(page), 1), Math.max(count, 1));
53
- const siblings = siblingCount >= 0 ? Math.floor(siblingCount) : 1;
54
+ const wanted = siblingCount >= 0 ? Math.floor(siblingCount) : 1;
55
+ // Where the row of pages would not fit on one line (a phone), the current page goes without
56
+ // neighbours — 1 … 4 … 12 — rather than wrapping the pager onto a second line; where even that
57
+ // would not fit, the pager turns compact (with `compact="auto"`).
58
+ const [fit, setFit] = React.useState("full");
59
+ React.useLayoutEffect(() => {
60
+ const nav = navRef.current;
61
+ const box = nav?.parentElement;
62
+ if (!nav || !box || typeof ResizeObserver === "undefined" || compact === true)
63
+ return;
64
+ if (wanted === 0 && compact === false)
65
+ return;
66
+ const measure = () => {
67
+ const list = nav.querySelector("ul");
68
+ const arrow = list?.firstElementChild;
69
+ if (!list || !arrow)
70
+ return;
71
+ const style = getComputedStyle(box);
72
+ const room = box.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
73
+ // Every slot is about an arrow's width: the arrows, first, last, the current page, its
74
+ // neighbours and two ellipses.
75
+ const width = (siblings, gapRem) => {
76
+ const slots = Math.min(count, siblings * 2 + 5) + 2;
77
+ // Measured in the root font size, as the gaps are rem (gap-1.5, gap-1).
78
+ const gap = parseFloat(getComputedStyle(document.documentElement).fontSize) * gapRem;
79
+ return slots * arrow.offsetWidth + (slots - 1) * gap;
80
+ };
81
+ // Not laid out (no width to measure): as it is.
82
+ const over = (w) => w > room + 0.5;
83
+ setFit(!over(width(wanted, 0.375))
84
+ ? "full"
85
+ : compact === "auto" && over(width(0, 0.25))
86
+ ? "compact"
87
+ : "tight");
88
+ };
89
+ measure();
90
+ const observer = new ResizeObserver(measure);
91
+ observer.observe(box);
92
+ return () => observer.disconnect();
93
+ }, [navRef, count, wanted, compact]);
94
+ const tight = fit !== "full";
95
+ const isCompact = compact === true || (compact === "auto" && fit === "compact");
96
+ const siblings = tight ? 0 : wanted;
54
97
  const pages = getPages(current, count, siblings);
55
98
  const square = size === "sm" ? "min-w-(--control-h-sm) px-2" : "min-w-(--control-h) px-2.5";
56
99
  // Previous and Next are exactly square at any control height, not as wide as chevron + padding.
@@ -62,19 +105,22 @@ export function Pagination({ page, pageCount, onPageChange, getHref, siblingCoun
62
105
  return (_jsx(Button, { variant: "secondary", size: size, disabled: disabled,
63
106
  // Previous and Next stay focusable when they run out, so pressing Next onto the last
64
107
  // page leaves keyboard focus on it instead of dropping it to the page.
65
- focusableWhenDisabled: true, nativeButton: !asLink, render: asLink ? _jsx("a", { href: getHref(target) }) : undefined, onClick: () => !disabled && target !== page && onPageChange?.(target), className: cn(square, "font-mono text-[13px] leading-none font-normal tabular-nums"), ...extra, children: content }));
108
+ focusableWhenDisabled: true, nativeButton: !asLink, render: asLink ? _jsx("a", { href: getHref(target) }) : undefined, onClick: () => !disabled && target !== page && onPageChange?.(target), ...extra,
109
+ // On a touch screen each takes a 44px tap (touch-target), also at 38px.
110
+ className: cn("touch-target", extra.className ?? square), children: content }));
66
111
  };
67
- return (_jsxs("nav", { "aria-label": text.nav, "data-slot": "pagination", "data-size": size, "data-glide": glide.visible ? "" : undefined, ref: setNavRef, className: cn("group/pagination relative flex", className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "pagination-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(glideMotion, "z-10 rounded-button ring-1 ring-control-focus duration-[calc(var(--duration)*1.3)]"), style: glideStyle(glide) }), _jsxs("ul", { className: "m-0 flex list-none flex-wrap items-center gap-1.5 p-0 [&>li]:flex", children: [_jsx("li", { children: control(current - 1, _jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }), {
112
+ return (_jsxs("nav", { "aria-label": text.nav, "data-slot": "pagination", "data-size": size, "data-compact": isCompact ? "" : undefined, "data-glide": glide.visible ? "" : undefined, ref: setNavRef, className: cn("group/pagination relative flex", className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "pagination-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(glideMotion, "z-10 rounded-button ring-1 ring-control-focus"), style: glideStyle(glide) }), _jsxs("ul", { className: cn("m-0 flex list-none flex-wrap items-center p-0 [&>li]:flex", tight ? "gap-1" : "gap-1.5"), children: [_jsx("li", { children: control(current - 1, _jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }), {
68
113
  "aria-label": text.previous,
69
114
  className: arrow,
70
- }) }), pages.map((p) => typeof p === "number" ? (_jsx("li", { children: control(p, p, {
71
- "aria-label": text.page(p),
72
- "aria-current": p === current ? "page" : undefined,
73
- "data-slot": "pagination-page",
74
- className: cn(square, "font-mono text-[13px] leading-none font-normal tabular-nums", "aria-[current=page]:bg-control-hover aria-[current=page]:shadow-raised-current",
75
- // The gliding indicator carries the focus edge once it is placed.
76
- "group-data-glide/pagination:aria-[current=page]:shadow-raised"),
77
- }) }, p)) : (_jsx("li", { "aria-hidden": true, "data-slot": "pagination-ellipsis", className: cn("inline-flex items-center justify-center font-mono text-[13px] text-muted-foreground", square), children: "\u2026" }, p))), _jsx("li", { children: control(current + 1, _jsx(ChevronRightIcon, { className: "rtl:-scale-x-100" }), {
115
+ }) }), isCompact && (_jsxs("li", { "data-slot": "pagination-status", className: "items-center justify-center px-2", children: [_jsxs("span", { "aria-hidden": true, className: "font-mono text-13 leading-none whitespace-nowrap text-foreground-soft tabular-nums", children: [Math.min(current, Math.max(count, 1)), _jsxs("span", { className: "text-muted-foreground", children: [" / ", count] })] }), _jsx("span", { className: "sr-only", children: text.status(current, count) })] })), !isCompact &&
116
+ pages.map((p) => typeof p === "number" ? (_jsx("li", { children: control(p, p, {
117
+ "aria-label": text.page(p),
118
+ "aria-current": p === current ? "page" : undefined,
119
+ "data-slot": "pagination-page",
120
+ className: cn(square, "font-mono text-13 leading-none font-normal tabular-nums", "aria-[current=page]:bg-control-hover aria-[current=page]:shadow-raised-current",
121
+ // The gliding indicator carries the focus edge once it is placed.
122
+ "group-data-glide/pagination:aria-[current=page]:shadow-raised"),
123
+ }) }, p)) : (_jsx("li", { "aria-hidden": true, "data-slot": "pagination-ellipsis", className: cn("inline-flex items-center justify-center font-mono text-13 text-muted-foreground", square), children: "\u2026" }, p))), _jsx("li", { children: control(current + 1, _jsx(ChevronRightIcon, { className: "rtl:-scale-x-100" }), {
78
124
  "aria-label": text.next,
79
125
  className: arrow,
80
126
  }) })] })] }));
@@ -62,7 +62,7 @@ export interface PdfViewerMessages {
62
62
  close: string;
63
63
  }
64
64
  declare module "./locale" {
65
- interface Messages {
65
+ interface LocaleMessages {
66
66
  pdfViewer: PdfViewerMessages;
67
67
  }
68
68
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
4
- import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, DownloadIcon, FileTextIcon, FileWarningIcon, LayoutGridIcon, ListTreeIcon, MaximizeIcon, MinimizeIcon, MinusIcon, PanelLeftIcon, PlusIcon, PrinterIcon, RotateCwIcon, SearchIcon, XIcon, } from "lucide-react";
4
+ import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, DownloadIcon, FileTextIcon, FileWarningIcon, LayoutGridIcon, ListTreeIcon, MaximizeIcon, MinimizeIcon, MinusIcon, PanelLeftIcon, PlusIcon, PrinterIcon, RotateCwIcon, SearchIcon, XIcon, } from "../lib/icons.js";
5
5
  import * as React from "react";
6
6
  import { cn } from "../lib/cn.js";
7
7
  import { CSS_UNITS, loadPdfjs, openPdf, pdfFileName, } from "../lib/pdf.js";
@@ -512,7 +512,7 @@ function OutlineRow({ entry, current, onSelect, }) {
512
512
  const text = React.useContext(TextContext);
513
513
  const [open, setOpen] = React.useState(true);
514
514
  const nested = entry.children.length > 0;
515
- return (_jsxs("li", { className: "flex flex-col gap-0.5", children: [_jsxs("div", { className: "flex items-center", children: [nested ? (_jsx("button", { type: "button", "aria-label": open ? text.collapse(entry.title) : text.expand(entry.title), "aria-expanded": open, onClick: () => setOpen((o) => !o), className: "flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-checkbox text-muted-foreground focus-ring transition-colors duration-(--duration) ease-(--ease) hover:text-foreground", children: _jsx(ChevronRightIcon, { "aria-hidden": true, className: cn("size-3.5 transition-transform duration-(--duration) ease-(--ease) motion-reduce:transition-none rtl:-scale-x-100", open && "rotate-90 rtl:-rotate-90") }) })) : (_jsx("span", { "aria-hidden": true, className: "w-6 shrink-0" })), _jsxs("button", { type: "button", disabled: !entry.target && !entry.url, "aria-current": entry === current ? "true" : undefined, onClick: () => onSelect(entry), className: "flex min-h-(--control-h-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-item material-row px-2 text-start text-[13px] leading-tight focus-ring disabled:cursor-default disabled:opacity-60", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: entry.title }), entry.target && (_jsx("span", { className: "font-mono text-[11px] text-muted-foreground tabular-nums", children: String(entry.target.page).padStart(2, "0") }))] })] }), nested && open && (_jsx("div", { className: "ps-4", children: _jsx(OutlineList, { entries: entry.children, current: current, onSelect: onSelect }) }))] }));
515
+ return (_jsxs("li", { className: "flex flex-col gap-0.5", children: [_jsxs("div", { className: "flex items-center", children: [nested ? (_jsx("button", { type: "button", "aria-label": open ? text.collapse(entry.title) : text.expand(entry.title), "aria-expanded": open, onClick: () => setOpen((o) => !o), className: "flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-checkbox text-muted-foreground focus-ring transition-colors duration-(--duration-fade) ease-(--ease) hover:text-foreground", children: _jsx(ChevronRightIcon, { "aria-hidden": true, className: cn("size-3.5 transition-transform duration-(--duration) ease-(--ease) motion-reduce:transition-none rtl:-scale-x-100", open && "rotate-90 rtl:-rotate-90") }) })) : (_jsx("span", { "aria-hidden": true, className: "w-6 shrink-0" })), _jsxs("button", { type: "button", disabled: !entry.target && !entry.url, "aria-current": entry === current ? "true" : undefined, onClick: () => onSelect(entry), className: "flex min-h-(--control-h-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-item material-row px-2 text-start text-13 leading-tight focus-ring disabled:cursor-default disabled:opacity-60", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: entry.title }), entry.target && (_jsx("span", { className: "font-mono text-11 text-muted-foreground tabular-nums", children: String(entry.target.page).padStart(2, "0") }))] })] }), nested && open && (_jsx("div", { className: "ps-4", children: _jsx(OutlineList, { entries: entry.children, current: current, onSelect: onSelect }) }))] }));
516
516
  }
517
517
  /* ── Viewer ─────────────────────────────────────────────────────────────────── */
518
518
  const ZOOM_STEPS = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4];
@@ -900,7 +900,7 @@ function Reader({ src, fileName, variant = "region", defaultZoom = "auto", defau
900
900
  sizes?.map((size, i) => (_jsx(Thumbnail, { doc: doc, n: i + 1, size: size, rotation: rotation, current: page === i + 1, onSelect: goTo }, i))), [doc, sizes, rotation, page, goTo]);
901
901
  return (_jsxs("div", { ref: root, "data-slot": "pdf-viewer", "data-variant": variant, "data-fullscreen": isFullscreen ? "" : undefined, "aria-busy": state.status === "idle" || state.status === "loading", onKeyDown: handleKeyDown, className: cn("@container/pdf relative flex h-[min(80svh,46rem)] min-h-0 w-full min-w-0 flex-col font-body", viewerVariants[variant], className,
902
902
  // Last, so filling the window beats a height given in `className`.
903
- isFullscreen && "fixed inset-0 z-50 h-svh w-screen rounded-none border-0 bg-background"), ...props, children: [_jsx("div", { "data-slot": "pdf-viewer-header", className: "flex shrink-0 items-center border-b border-border/60 p-1.5", children: state.status === "error" ? (_jsxs(Toolbar, { "data-slot": "pdf-viewer-toolbar", "aria-label": text.toolbar, className: "w-full min-w-0", children: [_jsxs("span", { className: "flex min-h-(--control-h-sm) min-w-0 flex-1 items-center gap-2 px-2 font-mono text-xs text-muted-foreground", children: [_jsx(FileWarningIcon, { "aria-hidden": true, className: "size-4 shrink-0" }), _jsx("span", { className: "truncate", children: name })] }), toolbarEnd && _jsx(ToolbarGroup, { className: "ms-auto", children: toolbarEnd })] })) : (_jsxs(Toolbar, { "data-slot": "pdf-viewer-toolbar", "aria-label": text.toolbar, className: "w-full min-w-0 flex-wrap", children: [thumbnails && (_jsxs(_Fragment, { children: [_jsx(Tool, { label: railOpen ? text.hideSidebar : text.showSidebar, "aria-pressed": railOpen, disabled: !ready, onClick: () => setRailOpen((o) => !o), className: "hidden @3xl/pdf:inline-flex", children: _jsx(PanelLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }), _jsx(ToolbarSeparator, { className: "hidden @3xl/pdf:block" })] })), _jsxs(ToolbarGroup, { children: [_jsx(Tool, { label: text.previousPage, disabled: !ready || page <= 1, onClick: () => goTo(page - 1), className: "hidden @min-[25rem]/pdf:inline-flex", children: _jsx(ChevronLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }), _jsxs("span", { className: "flex items-center gap-1.5 px-1 font-mono text-xs text-muted-foreground tabular-nums", children: [_jsx(BaseToolbar.Input, { "aria-label": text.pageField, disabled: !ready, inputMode: "numeric", value: pageDraft ?? String(page), onChange: (e) => setPageDraft(e.currentTarget.value.replace(/\D/g, "")), onFocus: (e) => e.currentTarget.select(), onBlur: commitPage, onKeyDown: (e) => {
903
+ isFullscreen && "fixed inset-0 z-50 h-svh w-screen rounded-none border-0 bg-background"), ...props, children: [_jsx("div", { "data-slot": "pdf-viewer-header", className: "flex shrink-0 items-center border-b border-border/(--hairline-opacity) p-1.5", children: state.status === "error" ? (_jsxs(Toolbar, { "data-slot": "pdf-viewer-toolbar", "aria-label": text.toolbar, className: "w-full min-w-0", children: [_jsxs("span", { className: "flex min-h-(--control-h-sm) min-w-0 flex-1 items-center gap-2 px-2 font-mono text-xs text-muted-foreground", children: [_jsx(FileWarningIcon, { "aria-hidden": true, className: "size-4 shrink-0" }), _jsx("span", { className: "truncate", children: name })] }), toolbarEnd && _jsx(ToolbarGroup, { className: "ms-auto", children: toolbarEnd })] })) : (_jsxs(Toolbar, { "data-slot": "pdf-viewer-toolbar", "aria-label": text.toolbar, className: "w-full min-w-0 flex-wrap", children: [thumbnails && (_jsxs(_Fragment, { children: [_jsx(Tool, { label: railOpen ? text.hideSidebar : text.showSidebar, "aria-pressed": railOpen, disabled: !ready, onClick: () => setRailOpen((o) => !o), className: "hidden @3xl/pdf:inline-flex", children: _jsx(PanelLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }), _jsx(ToolbarSeparator, { className: "hidden @3xl/pdf:block" })] })), _jsxs(ToolbarGroup, { children: [_jsx(Tool, { label: text.previousPage, disabled: !ready || page <= 1, onClick: () => goTo(page - 1), className: "hidden @min-[25rem]/pdf:inline-flex", children: _jsx(ChevronLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }), _jsxs("span", { className: "flex items-center gap-1.5 px-1 font-mono text-xs text-muted-foreground tabular-nums", children: [_jsx(BaseToolbar.Input, { "aria-label": text.pageField, disabled: !ready, inputMode: "numeric", value: pageDraft ?? String(page), onChange: (e) => setPageDraft(e.currentTarget.value.replace(/\D/g, "")), onFocus: (e) => e.currentTarget.select(), onBlur: commitPage, onKeyDown: (e) => {
904
904
  if (e.key === "Enter") {
905
905
  // Not a submit of a form the viewer sits in.
906
906
  e.preventDefault();
@@ -911,10 +911,10 @@ function Reader({ src, fileName, variant = "region", defaultZoom = "auto", defau
911
911
  e.stopPropagation();
912
912
  setPageDraft(null);
913
913
  }
914
- }, render: _jsx(Input, { size: "sm", className: "w-11 px-1 text-center font-mono tabular-nums" }) }), _jsx("span", { "aria-hidden": true, children: "/" }), _jsx("span", { "aria-label": text.ofPages(count), children: count || "–" })] }), _jsx(Tool, { label: text.nextPage, disabled: !ready || page >= count, onClick: () => goTo(page + 1), className: "hidden @min-[25rem]/pdf:inline-flex", children: _jsx(ChevronRightIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) })] }), _jsx(ToolbarSeparator, {}), _jsxs(ToolbarGroup, { children: [_jsx(Tool, { label: text.zoomOut, disabled: !ready || scale <= 0.26, onClick: () => zoomBy(-1), className: "hidden @md/pdf:inline-flex", children: _jsx(MinusIcon, { "aria-hidden": true }) }), _jsxs(Menu, { children: [_jsxs(ToolbarButton, { disabled: !ready, "aria-label": text.zoom(Math.round(scale * 100)), render: _jsx(MenuTrigger, {}), className: "w-16 gap-1 px-1.5 font-mono text-xs tabular-nums", children: [Math.round(scale * 100), "%", _jsx(ChevronDownIcon, { "aria-hidden": true, className: "size-3!" })] }), _jsx(MenuContent, { align: "center", children: _jsxs(MenuRadioGroup, { value: zoomValue, onValueChange: (v) => zoomTo(v === "auto" || v === "fit-width" || v === "fit-page" ? v : Number(v)), children: [_jsx(MenuRadioItem, { value: "auto", closeOnClick: true, children: text.zoomAuto }), _jsx(MenuRadioItem, { value: "fit-width", closeOnClick: true, children: text.zoomFitWidth }), _jsx(MenuRadioItem, { value: "fit-page", closeOnClick: true, children: text.zoomFitPage }), _jsx(MenuSeparator, {}), ZOOM_STEPS.map((z) => (_jsxs(MenuRadioItem, { value: String(z), closeOnClick: true, className: "font-mono tabular-nums", children: [Math.round(z * 100), "%"] }, z)))] }) })] }), _jsx(Tool, { label: text.zoomIn, disabled: !ready || scale >= 4.99, onClick: () => zoomBy(1), className: "hidden @md/pdf:inline-flex", children: _jsx(PlusIcon, { "aria-hidden": true }) })] }), _jsx(ToolbarSeparator, { className: "hidden @lg/pdf:block" }), _jsx(Tool, { label: text.rotate, disabled: !ready, onClick: rotate, className: "hidden @lg/pdf:inline-flex", children: _jsx(RotateCwIcon, { "aria-hidden": true }) }), _jsx("span", { className: "hidden min-w-0 flex-1 truncate px-2 text-center font-mono text-xs text-muted-foreground @2xl/pdf:block", children: name }), _jsxs(ToolbarGroup, { className: "ms-auto @2xl/pdf:ms-0", children: [search && (_jsx(Tool, { label: text.search, "aria-pressed": searchOpen, disabled: !ready, onClick: () => (searchOpen ? closeSearch() : openSearch()), children: _jsx(SearchIcon, { "aria-hidden": true }) })), download && (_jsx(Tool, { label: text.download, disabled: !ready, onClick: () => doc && void savePdf(doc, name), children: _jsx(DownloadIcon, { "aria-hidden": true }) })), print && (_jsx(Tool, { label: text.print, disabled: !ready, onClick: () => doc && void printPdf(doc), className: "hidden @lg/pdf:inline-flex", children: _jsx(PrinterIcon, { "aria-hidden": true }) })), allowFullscreen && (_jsx(Tool, { label: isFullscreen ? text.exitFullScreen : text.fullScreen, onClick: toggleFullscreen, children: isFullscreen ? _jsx(MinimizeIcon, { "aria-hidden": true }) : _jsx(MaximizeIcon, { "aria-hidden": true }) })), toolbarEnd] })] })) }), _jsxs("div", { className: "flex min-h-0 flex-1", children: [thumbnails && railOpen && doc && sizes && (_jsxs("div", { "data-slot": "pdf-viewer-rail", className: cn("hidden shrink-0 flex-col border-e border-border/60 @3xl/pdf:flex", showOutline ? "w-60" : "w-[136px]"), children: [outline && (_jsx(Tabs, { value: railTab, onValueChange: (v) => setRailTab(v), className: "w-auto shrink-0 gap-0 border-b border-border/60 p-1.5", children: _jsx(TabsList, { "aria-label": text.sidebar, className: "w-full", children: [
914
+ }, render: _jsx(Input, { size: "sm", className: "w-11 px-1 text-center font-mono tabular-nums" }) }), _jsx("span", { "aria-hidden": true, children: "/" }), _jsx("span", { "aria-label": text.ofPages(count), children: count || "–" })] }), _jsx(Tool, { label: text.nextPage, disabled: !ready || page >= count, onClick: () => goTo(page + 1), className: "hidden @min-[25rem]/pdf:inline-flex", children: _jsx(ChevronRightIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) })] }), _jsx(ToolbarSeparator, {}), _jsxs(ToolbarGroup, { children: [_jsx(Tool, { label: text.zoomOut, disabled: !ready || scale <= 0.26, onClick: () => zoomBy(-1), className: "hidden @md/pdf:inline-flex", children: _jsx(MinusIcon, { "aria-hidden": true }) }), _jsxs(Menu, { children: [_jsxs(ToolbarButton, { disabled: !ready, "aria-label": text.zoom(Math.round(scale * 100)), render: _jsx(MenuTrigger, {}), className: "w-16 gap-1 px-1.5 font-mono text-xs tabular-nums", children: [Math.round(scale * 100), "%", _jsx(ChevronDownIcon, { "aria-hidden": true, className: "size-3!" })] }), _jsx(MenuContent, { align: "center", children: _jsxs(MenuRadioGroup, { value: zoomValue, onValueChange: (v) => zoomTo(v === "auto" || v === "fit-width" || v === "fit-page" ? v : Number(v)), children: [_jsx(MenuRadioItem, { value: "auto", closeOnClick: true, children: text.zoomAuto }), _jsx(MenuRadioItem, { value: "fit-width", closeOnClick: true, children: text.zoomFitWidth }), _jsx(MenuRadioItem, { value: "fit-page", closeOnClick: true, children: text.zoomFitPage }), _jsx(MenuSeparator, {}), ZOOM_STEPS.map((z) => (_jsxs(MenuRadioItem, { value: String(z), closeOnClick: true, className: "font-mono tabular-nums", children: [Math.round(z * 100), "%"] }, z)))] }) })] }), _jsx(Tool, { label: text.zoomIn, disabled: !ready || scale >= 4.99, onClick: () => zoomBy(1), className: "hidden @md/pdf:inline-flex", children: _jsx(PlusIcon, { "aria-hidden": true }) })] }), _jsx(ToolbarSeparator, { className: "hidden @lg/pdf:block" }), _jsx(Tool, { label: text.rotate, disabled: !ready, onClick: rotate, className: "hidden @lg/pdf:inline-flex", children: _jsx(RotateCwIcon, { "aria-hidden": true }) }), _jsx("span", { className: "hidden min-w-0 flex-1 truncate px-2 text-center font-mono text-xs text-muted-foreground @2xl/pdf:block", children: name }), _jsxs(ToolbarGroup, { className: "ms-auto @2xl/pdf:ms-0", children: [search && (_jsx(Tool, { label: text.search, "aria-pressed": searchOpen, disabled: !ready, onClick: () => (searchOpen ? closeSearch() : openSearch()), children: _jsx(SearchIcon, { "aria-hidden": true }) })), download && (_jsx(Tool, { label: text.download, disabled: !ready, onClick: () => doc && void savePdf(doc, name), children: _jsx(DownloadIcon, { "aria-hidden": true }) })), print && (_jsx(Tool, { label: text.print, disabled: !ready, onClick: () => doc && void printPdf(doc), className: "hidden @lg/pdf:inline-flex", children: _jsx(PrinterIcon, { "aria-hidden": true }) })), allowFullscreen && (_jsx(Tool, { label: isFullscreen ? text.exitFullScreen : text.fullScreen, onClick: toggleFullscreen, children: isFullscreen ? _jsx(MinimizeIcon, { "aria-hidden": true }) : _jsx(MaximizeIcon, { "aria-hidden": true }) })), toolbarEnd] })] })) }), _jsxs("div", { className: "flex min-h-0 flex-1", children: [thumbnails && railOpen && doc && sizes && (_jsxs("div", { "data-slot": "pdf-viewer-rail", className: cn("hidden shrink-0 flex-col border-e border-border/(--hairline-opacity) @3xl/pdf:flex", showOutline ? "w-60" : "w-[136px]"), children: [outline && (_jsx(Tabs, { value: railTab, onValueChange: (v) => setRailTab(v), className: "w-auto shrink-0 gap-0 border-b border-border/(--hairline-opacity) p-1.5", children: _jsx(TabsList, { "aria-label": text.sidebar, className: "w-full", children: [
915
915
  ["pages", text.pages, LayoutGridIcon],
916
916
  ["outline", text.outline, ListTreeIcon],
917
- ].map(([value, label, Icon]) => (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(TabsTab, { value: value, "aria-label": label, className: "flex-1 px-0" }), children: _jsx(Icon, { "aria-hidden": true }) }), _jsx(TooltipContent, { children: label })] }, value))) }) })), showOutline ? (_jsx(ScrollArea, { "data-slot": "pdf-viewer-outline", scrollbar: false, className: "min-h-0 flex-1", contentClassName: "p-1.5", children: _jsx("nav", { "aria-label": text.outline, children: _jsx(OutlineList, { entries: outline, current: reading, onSelect: openEntry }) }) })) : (_jsx(ScrollArea, { "data-slot": "pdf-viewer-thumbnails", scrollbar: false, "aria-label": text.pages, className: "min-h-0 flex-1", contentClassName: "flex flex-col items-center gap-1.5 py-3", children: thumbnailViews }))] })), _jsxs("div", { className: "relative min-w-0 flex-1", children: [_jsx("div", { ref: viewport, "data-slot": "pdf-viewer-pages", tabIndex: 0, role: "region", "aria-label": count ? text.document(name, page, count) : name, onScroll: onScroll, className: "absolute inset-0 [scrollbar-gutter:stable] overflow-auto overscroll-contain bg-(--field-surface) focus-ring", children: doc && sizes ? (_jsx("div", { className: "mx-auto flex w-max min-w-full flex-col items-center", style: { padding: pad, gap: pad }, children: pageViews })) : state.status === "error" ? (_jsxs(Empty, { className: "h-full justify-center", children: [_jsx(EmptyMedia, { children: _jsx(FileWarningIcon, { "aria-hidden": true }) }), _jsx(EmptyTitle, { children: text.cantOpen }), _jsx(EmptyDescription, { children: text.error(state.reason) }), (typeof src === "string" || src instanceof URL) && (_jsx(EmptyActions, { children: _jsxs(Button, { variant: "secondary", render: _jsx("a", { href: String(src), download: name }), nativeButton: false, children: [_jsx(DownloadIcon, { "aria-hidden": true }), text.downloadFile] }) }))] })) : (_jsxs("div", { className: "flex h-full items-center justify-center gap-2.5 font-mono text-xs text-muted-foreground", children: [_jsx(Spinner, { size: "sm" }), "Opening ", name] })) }), searchOpen && (_jsxs("div", { "data-slot": "pdf-viewer-search", role: "search", className: "absolute end-5 top-3 z-20 flex w-[min(24rem,calc(100%-2.5rem))] items-center gap-1 rounded-button material-menu p-1 transition-[opacity,translate] duration-(--duration) ease-(--ease) motion-reduce:transition-none starting:-translate-y-1 starting:opacity-0", children: [_jsxs(InputGroup, { size: "sm", className: "min-w-0 flex-1", children: [_jsx(InputGroupAddon, { className: "ps-2.5", children: _jsx(SearchIcon, { "aria-hidden": true }) }), _jsx(InputGroupInput, { ref: searchInput, "aria-label": text.searchField, placeholder: text.searchField, value: query, onChange: (e) => setQuery(e.currentTarget.value), onKeyDown: (e) => {
917
+ ].map(([value, label, Icon]) => (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(TabsTab, { value: value, "aria-label": label, className: "flex-1 px-0" }), children: _jsx(Icon, { "aria-hidden": true }) }), _jsx(TooltipContent, { children: label })] }, value))) }) })), showOutline ? (_jsx(ScrollArea, { "data-slot": "pdf-viewer-outline", scrollbar: false, className: "min-h-0 flex-1", contentClassName: "p-1.5", children: _jsx("nav", { "aria-label": text.outline, children: _jsx(OutlineList, { entries: outline, current: reading, onSelect: openEntry }) }) })) : (_jsx(ScrollArea, { "data-slot": "pdf-viewer-thumbnails", scrollbar: false, "aria-label": text.pages, className: "min-h-0 flex-1", contentClassName: "flex flex-col items-center gap-1.5 py-3", children: thumbnailViews }))] })), _jsxs("div", { className: "relative min-w-0 flex-1", children: [_jsx("div", { ref: viewport, "data-slot": "pdf-viewer-pages", tabIndex: 0, role: "region", "aria-label": count ? text.document(name, page, count) : name, onScroll: onScroll, className: "absolute inset-0 [scrollbar-gutter:stable] overflow-auto overscroll-contain bg-(--field-surface) focus-ring", children: doc && sizes ? (_jsx("div", { className: "mx-auto flex w-max min-w-full flex-col items-center", style: { padding: pad, gap: pad }, children: pageViews })) : state.status === "error" ? (_jsxs(Empty, { className: "h-full justify-center", children: [_jsx(EmptyMedia, { children: _jsx(FileWarningIcon, { "aria-hidden": true }) }), _jsx(EmptyTitle, { children: text.cantOpen }), _jsx(EmptyDescription, { children: text.error(state.reason) }), (typeof src === "string" || src instanceof URL) && (_jsx(EmptyActions, { children: _jsxs(Button, { variant: "secondary", render: _jsx("a", { href: String(src), download: name }), nativeButton: false, children: [_jsx(DownloadIcon, { "aria-hidden": true }), text.downloadFile] }) }))] })) : (_jsxs("div", { className: "flex h-full items-center justify-center gap-2.5 font-mono text-xs text-muted-foreground", children: [_jsx(Spinner, { size: "sm" }), "Opening ", name] })) }), searchOpen && (_jsxs("div", { "data-slot": "pdf-viewer-search", role: "search", className: "absolute end-5 top-3 z-20 flex w-[min(24rem,calc(100%-2.5rem))] items-center gap-1 rounded-button material-menu p-1 transition-[opacity,translate] [transition-duration:var(--duration-fade),var(--duration)] ease-(--ease) starting:-translate-y-1 starting:opacity-0", children: [_jsxs(InputGroup, { size: "sm", className: "min-w-0 flex-1", children: [_jsx(InputGroupAddon, { className: "ps-2.5", children: _jsx(SearchIcon, { "aria-hidden": true }) }), _jsx(InputGroupInput, { ref: searchInput, "aria-label": text.searchField, placeholder: text.searchField, value: query, onChange: (e) => setQuery(e.currentTarget.value), onKeyDown: (e) => {
918
918
  if (e.key === "Enter") {
919
919
  e.preventDefault();
920
920
  step(e.shiftKey ? -1 : 1);
@@ -928,7 +928,7 @@ function Reader({ src, fileName, variant = "region", defaultZoom = "auto", defau
928
928
  ? ""
929
929
  : hits.length
930
930
  ? text.matches(hitIndex + 1, hits.length)
931
- : text.noMatches }), _jsx(InputGroupButton, { variant: "ghost", size: "icon-sm", "aria-label": text.previousMatch, disabled: !hits?.length, onClick: () => step(-1), children: _jsx(ChevronUpIcon, { "aria-hidden": true }) }), _jsx(InputGroupButton, { variant: "ghost", size: "icon-sm", "aria-label": text.nextMatch, disabled: !hits?.length, onClick: () => step(1), children: _jsx(ChevronDownIcon, { "aria-hidden": true }) })] })] }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": text.closeSearch, onClick: closeSearch, children: _jsx(XIcon, { "aria-hidden": true }) })] })), count > 1 && (_jsxs("span", { "aria-hidden": true, "data-slot": "pdf-viewer-page-chip", className: cn("pointer-events-none absolute bottom-4 left-1/2 z-10 -translate-x-1/2 rounded-item material-menu px-2.5 py-1.5 font-mono text-xs leading-none tabular-nums transition-opacity duration-(--duration) ease-(--ease)", chip ? "opacity-100" : "opacity-0"), children: [String(page).padStart(2, "0"), " / ", String(count).padStart(2, "0")] }))] })] })] }));
931
+ : text.noMatches }), _jsx(InputGroupButton, { variant: "ghost", size: "icon-sm", "aria-label": text.previousMatch, disabled: !hits?.length, onClick: () => step(-1), children: _jsx(ChevronUpIcon, { "aria-hidden": true }) }), _jsx(InputGroupButton, { variant: "ghost", size: "icon-sm", "aria-label": text.nextMatch, disabled: !hits?.length, onClick: () => step(1), children: _jsx(ChevronDownIcon, { "aria-hidden": true }) })] })] }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": text.closeSearch, onClick: closeSearch, children: _jsx(XIcon, { "aria-hidden": true }) })] })), count > 1 && (_jsxs("span", { "aria-hidden": true, "data-slot": "pdf-viewer-page-chip", className: cn("pointer-events-none absolute bottom-4 left-1/2 z-10 -translate-x-1/2 rounded-item material-menu px-2.5 py-1.5 font-mono text-xs leading-none tabular-nums transition-opacity duration-(--duration-fade) ease-(--ease)", chip ? "opacity-100" : "opacity-0"), children: [String(page).padStart(2, "0"), " / ", String(count).padStart(2, "0")] }))] })] })] }));
932
932
  }
933
933
  /**
934
934
  * PdfPreview — a compact card with a document's first page, its name and its length. Clicking it
@@ -987,10 +987,10 @@ export function PdfPreview({ src, fileName, title, description, viewer, labels,
987
987
  return () => ac.abort();
988
988
  }, [state]);
989
989
  const count = state.status === "ready" ? state.sizes.length : undefined;
990
- return (_jsxs(Dialog, { children: [_jsxs(DialogTrigger, { render: _jsx("button", { ref: ref, type: "button", "data-slot": "pdf-preview", "aria-busy": !drawn && state.status !== "error", className: cn("group/preview flex w-full max-w-xs cursor-pointer flex-col overflow-hidden surface-card text-start focus-ring [--card-padding:0]", className), ...props }), children: [_jsxs("span", { "data-slot": "pdf-preview-page", className: "relative block aspect-[4/3] overflow-hidden border-b border-border/60 px-6 pt-6", children: [_jsx("span", { ref: art, "aria-hidden": true, className: "relative block w-full bg-white shadow-card transition-transform duration-(--duration) ease-(--ease) group-hover/preview:-translate-y-1", style: { aspectRatio: first ? `${first.w} / ${first.h}` : "1 / 1.414" } }), state.status === "error" && (_jsx("span", { className: "absolute inset-0 flex items-center justify-center text-muted-foreground", children: _jsx(FileWarningIcon, { "aria-hidden": true, className: "size-6" }) }))] }), _jsxs("span", { className: "flex items-start gap-3 p-4", children: [_jsx(FileTextIcon, { "aria-hidden": true, className: "mt-0.5 size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? name }), _jsx("span", { className: "font-mono text-[11px] tracking-[0.12em] text-muted-foreground uppercase", children: description ??
990
+ return (_jsxs(Dialog, { children: [_jsxs(DialogTrigger, { render: _jsx("button", { ref: ref, type: "button", "data-slot": "pdf-preview", "aria-busy": !drawn && state.status !== "error", className: cn("group/preview flex w-full max-w-xs cursor-pointer flex-col overflow-hidden surface-card text-start focus-ring [--card-padding:0]", className), ...props }), children: [_jsxs("span", { "data-slot": "pdf-preview-page", className: "relative block aspect-[4/3] overflow-hidden border-b border-border/(--hairline-opacity) px-6 pt-6", children: [_jsx("span", { ref: art, "aria-hidden": true, className: "relative block w-full bg-white shadow-card transition-transform duration-(--duration) ease-(--ease) group-hover/preview:-translate-y-1", style: { aspectRatio: first ? `${first.w} / ${first.h}` : "1 / 1.414" } }), state.status === "error" && (_jsx("span", { className: "absolute inset-0 flex items-center justify-center text-muted-foreground", children: _jsx(FileWarningIcon, { "aria-hidden": true, className: "size-6" }) }))] }), _jsxs("span", { className: "flex items-start gap-3 p-4", children: [_jsx(FileTextIcon, { "aria-hidden": true, className: "mt-0.5 size-4 shrink-0 text-muted-foreground" }), _jsxs("span", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("span", { className: "truncate text-sm font-medium text-foreground", children: title ?? name }), _jsx("span", { className: "font-mono text-11 tracking-[0.12em] text-muted-foreground uppercase", children: description ??
991
991
  (state.status === "error"
992
992
  ? text.previewError
993
993
  : count
994
994
  ? text.previewPages(count)
995
- : text.previewPdf) })] })] })] }), _jsxs(DialogContent, { size: "xl", showCloseButton: false, className: "h-[min(90svh,60rem)] max-w-[min(72rem,100%)] gap-0 p-0 sm:p-0", children: [_jsx(DialogTitle, { className: "sr-only", children: typeof title === "string" ? title : name }), _jsx(PdfViewer, { labels: labels, ...viewer, src: src, fileName: name, variant: "plain", className: cn("h-full", viewer?.className), toolbarEnd: _jsxs(_Fragment, { children: [_jsx(ToolbarSeparator, {}), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(ToolbarButton, { "aria-label": text.close, render: _jsx(DialogClose, {}) }), children: _jsx(XIcon, { "aria-hidden": true }) }), _jsx(TooltipContent, { children: text.close })] })] }) })] })] }));
995
+ : text.previewPdf) })] })] })] }), _jsxs(DialogContent, { size: "full", showCloseButton: false, className: "gap-0 p-0 sm:p-0", children: [_jsx(DialogTitle, { className: "sr-only", children: typeof title === "string" ? title : name }), _jsx(PdfViewer, { labels: labels, ...viewer, src: src, fileName: name, variant: "plain", className: cn("h-full", viewer?.className), toolbarEnd: _jsxs(_Fragment, { children: [_jsx(ToolbarSeparator, {}), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(ToolbarButton, { "aria-label": text.close, render: _jsx(DialogClose, {}) }), children: _jsx(XIcon, { "aria-hidden": true }) }), _jsx(TooltipContent, { children: text.close })] })] }) })] })] }));
996
996
  }
@@ -16,7 +16,7 @@ export interface PhoneInputMessages {
16
16
  unknownCode: string;
17
17
  }
18
18
  declare module "./locale" {
19
- interface Messages {
19
+ interface LocaleMessages {
20
20
  phoneInput: PhoneInputMessages;
21
21
  }
22
22
  }
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
4
4
  import { Field as BaseField } from "@base-ui/react/field";
5
- import { ChevronDownIcon } from "lucide-react";
5
+ import { ChevronDownIcon } from "../lib/icons.js";
6
6
  import * as React from "react";
7
7
  import { cn } from "../lib/cn.js";
8
8
  import { FieldValueInput, useFormatLocale, useFormResetEffect } from "../lib/field-value.js";
@@ -233,7 +233,7 @@ export function PhoneInput({ value: valueProp, defaultValue, onValueChange, coun
233
233
  // It stays an input-group-button, so the field rounds and insets it like any.
234
234
  , { "data-phone-input-country": "", "aria-label": `${text.country}: ${countryName}, +${country.dial}`, render: _jsx(InputGroupButton, { variant: "ghost", size: sizing.button, ...(size === "lg" ? { "data-size": "lg" } : {}), className: cn(
235
235
  // The field already dims when disabled: not the button twice.
236
- "gap-1.5 font-mono tabular-nums data-disabled:opacity-100", size === "lg" && "min-h-[calc(var(--control-h-lg)-8px)] px-3 text-sm", size === "sm" ? "text-xs" : "text-[13px]",
236
+ "gap-1.5 font-mono tabular-nums data-disabled:opacity-100", size === "lg" && "min-h-[calc(var(--control-h-lg)-8px)] px-3 text-sm", size === "sm" ? "text-xs" : "text-13",
237
237
  // After the text size, which would reset it: one line as tall as the type.
238
238
  "leading-none") }), children: [_jsx("span", { className: "text-muted-foreground", children: country.iso }), _jsxs("span", { className: "text-foreground", children: ["+", country.dial] }), _jsx(ChevronDownIcon, { "aria-hidden": true, className: "size-3.5 text-muted-foreground transition-transform duration-(--duration) ease-(--ease) in-data-popup-open:rotate-180" })] }), _jsxs(ComboboxContent, { "aria-label": text.country, positioner: { anchor: groupRef, align: "start" }, className: "min-w-[min(18rem,var(--available-width))]", children: [_jsx("div", { className: "pb-1", children: _jsx(ComboboxInput, { size: "sm", showTrigger: false, placeholder: text.search, "aria-label": text.search }) }), _jsx(ComboboxEmpty, { children: text.empty }), _jsx(ComboboxList, { children: (option) => (_jsx(ComboboxItem, { value: option, "data-country": option.iso, children: _jsxs("span", { className: "flex min-w-0 items-baseline gap-3", children: [_jsx("span", { className: "w-6 shrink-0 font-mono text-xs text-muted-foreground", children: option.iso }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: option.name }), _jsxs("span", { className: "shrink-0 font-mono text-xs text-muted-foreground tabular-nums", children: ["+", option.dial] })] }) }, option.iso)) })] })] }) }) }), _jsx("input", { ...props, ref: visibleRefs, id: controlId, "data-slot": "input-group-control", type: "tel", inputMode: "tel", autoComplete: props.autoComplete ?? "tel", value: shown, placeholder: placeholder, disabled: off, readOnly: readOnly, required: required, "aria-labelledby": labelledBy ?? props["aria-labelledby"], "aria-describedby": [describedBy, props["aria-describedby"]].filter(Boolean).join(" ") || undefined, "aria-invalid": invalid, onChange: (event) => take(event.currentTarget.value, event.currentTarget.selectionStart), onPaste: (event) => {
239
239
  onPaste?.(event);
@@ -6,6 +6,7 @@ import { sx, triggerSlot } from "../lib/cn.js";
6
6
  import { mergeRefs } from "../lib/merge-refs.js";
7
7
  import { roomBounds, TriggerRoomContext, useTriggerRoom } from "../lib/room.js";
8
8
  import { overlayArrow, overlayPopup, usePopupDir } from "./_overlay.js";
9
+ import { usePortalContainer } from "../lib/portal-container.js";
9
10
  /**
10
11
  * Popover — a small panel anchored to a control: a hint with a link, a short form, a few
11
12
  * settings. Menu material at 12px.
@@ -29,18 +30,19 @@ export function PopoverTrigger({ ref, ...props }) {
29
30
  }
30
31
  /** Portal + Positioner + Popup. Fades and scales from the trigger (`popup-motion`). */
31
32
  export function PopoverContent({ side = "bottom", align = "center", sideOffset = 8, alignOffset = 0, positioner, portal, arrow = false, className, children, dir, ...props }) {
33
+ const portalContainer = usePortalContainer();
32
34
  // Across, keep inside the trigger's room (a narrow panel), not only the window. Found once per
33
35
  // trigger, not on every render of a closed popover.
34
36
  const trigger = React.useContext(TriggerRoomContext)?.trigger ?? null;
35
37
  const bounds = React.useMemo(() => roomBounds(trigger), [trigger]);
36
38
  const popupDir = usePopupDir(dir);
37
- return (_jsx(BasePopover.Portal, { ...portal, children: _jsx(BasePopover.Positioner, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, arrowPadding: 14, collisionPadding: 16, collisionBoundary: bounds, dir: popupDir, ...positioner, className: "z-50 outline-none", children: _jsxs(BasePopover.Popup, { "data-slot": "popover-content", className: sx(["relative flex w-72 max-w-(--available-width) flex-col gap-1.5 p-4 text-sm", overlayPopup], className), ...props, children: [arrow && _jsx(BasePopover.Arrow, { "data-slot": "popover-arrow", className: overlayArrow }), children] }) }) }));
39
+ return (_jsx(BasePopover.Portal, { container: portalContainer, ...portal, children: _jsx(BasePopover.Positioner, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, arrowPadding: 14, collisionPadding: 16, collisionBoundary: bounds, dir: popupDir, ...positioner, className: "z-50 outline-none", children: _jsxs(BasePopover.Popup, { "data-slot": "popover-content", className: sx(["relative flex w-72 max-w-(--available-width) flex-col gap-1.5 p-4 text-sm", overlayPopup], className), ...props, children: [arrow && _jsx(BasePopover.Arrow, { "data-slot": "popover-arrow", className: overlayArrow }), children] }) }) }));
38
40
  }
39
41
  export function PopoverTitle({ className, ...props }) {
40
- return (_jsx(BasePopover.Title, { "data-slot": "popover-title", className: sx("font-body text-[15px] leading-snug font-medium tracking-normal text-foreground", className), ...props }));
42
+ return (_jsx(BasePopover.Title, { "data-slot": "popover-title", className: sx("font-body text-15 leading-snug font-medium tracking-normal text-foreground", className), ...props }));
41
43
  }
42
44
  export function PopoverDescription({ className, ...props }) {
43
- return (_jsx(BasePopover.Description, { "data-slot": "popover-description", className: sx("text-[13px] leading-normal text-muted-foreground", className), ...props }));
45
+ return (_jsx(BasePopover.Description, { "data-slot": "popover-description", className: sx("text-13 leading-normal text-muted-foreground", className), ...props }));
44
46
  }
45
47
  /** Closes the popover. Compose with a button: `render={<Button variant="ghost" size="sm" />}`. */
46
48
  export function PopoverClose(props) {
@@ -1,4 +1,5 @@
1
1
  import { PreviewCard as BasePreviewCard } from "@base-ui/react/preview-card";
2
+ import * as React from "react";
2
3
  /**
3
4
  * PreviewCard — a hover card that previews what a link points to (a person, an article, a
4
5
  * doc page) before the reader commits to the click.
@@ -8,7 +9,7 @@ import { PreviewCard as BasePreviewCard } from "@base-ui/react/preview-card";
8
9
  */
9
10
  export declare const PreviewCard: <Payload>(props: BasePreviewCard.Root.Props<Payload>) => React.JSX.Element;
10
11
  /** The link that opens the card. Renders an `<a>`; style it with the `link` utility. */
11
- export declare function PreviewCardTrigger(props: BasePreviewCard.Trigger.Props): import("react").JSX.Element;
12
+ export declare function PreviewCardTrigger(props: BasePreviewCard.Trigger.Props): React.JSX.Element;
12
13
  export interface PreviewCardContentProps extends BasePreviewCard.Popup.Props {
13
14
  side?: BasePreviewCard.Positioner.Props["side"];
14
15
  align?: BasePreviewCard.Positioner.Props["align"];
@@ -22,4 +23,38 @@ export interface PreviewCardContentProps extends BasePreviewCard.Popup.Props {
22
23
  arrow?: boolean;
23
24
  }
24
25
  /** Portal + Positioner + Popup. Menu material at 12px, 320px wide, `popup-motion`. */
25
- export declare function PreviewCardContent({ side, align, sideOffset, alignOffset, positioner, portal, arrow, className, children, dir, ...props }: PreviewCardContentProps): import("react").JSX.Element;
26
+ export declare function PreviewCardContent({ side, align, sideOffset, alignOffset, positioner, portal, arrow, className, children, dir, ref, ...props }: PreviewCardContentProps): React.JSX.Element;
27
+ export interface PreviewCardDelegateProps {
28
+ /** A CSS selector for the elements that open the card: `"[data-ref]"`, `"a.mention"` … */
29
+ selector: string;
30
+ /**
31
+ * Renders the card for the element that opened it — read what to show from its attributes
32
+ * (`element.dataset`). Return a `PreviewCardContent`; it positions against that element.
33
+ */
34
+ children: (element: HTMLElement) => React.ReactNode;
35
+ /** Where to listen for hover and focus. The whole document by default. */
36
+ container?: React.RefObject<HTMLElement | null>;
37
+ /** How long to wait before the card opens, in ms. Moving to another match while it is open switches at once. */
38
+ delay?: number;
39
+ /** How long the card lingers after the pointer leaves the element and the card, in ms. */
40
+ closeDelay?: number;
41
+ /** Called when the card opens, moves to another element, or closes (with `null`). */
42
+ onOpenChange?: (open: boolean, element: HTMLElement | null) => void;
43
+ /** Stop listening, and close the card if it is open. */
44
+ disabled?: boolean;
45
+ }
46
+ /**
47
+ * PreviewCardDelegate — one preview card for every element on the page that matches a selector:
48
+ * reference chips, mentions, links in a long thread. It listens once, on the document or a
49
+ * container, instead of mounting a trigger per element, so a page with hundreds of references
50
+ * stays cheap.
51
+ *
52
+ * It keeps a normal PreviewCard's behaviour: opens on hover or keyboard focus after the delay,
53
+ * lingers so the pointer can move into the card, moves to the next match at once while it is
54
+ * open, and closes on Escape, a press outside, scrolling or leaving the window.
55
+ *
56
+ * The rule people break: the matching elements must make sense on their own. Make them real
57
+ * links (`<a href>`) or focusable (`tabIndex={0}`), since the card adds a glance, never the only
58
+ * way to what they point to.
59
+ */
60
+ export declare function PreviewCardDelegate({ selector, children, container, delay, closeDelay, onOpenChange, disabled, }: PreviewCardDelegateProps): React.JSX.Element;
@@ -1,8 +1,12 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { PreviewCard as BasePreviewCard } from "@base-ui/react/preview-card";
4
+ import * as React from "react";
4
5
  import { sx, triggerSlot } from "../lib/cn.js";
6
+ import { mergeRefs } from "../lib/merge-refs.js";
5
7
  import { overlayArrow, overlayPopup, usePopupDir } from "./_overlay.js";
8
+ import { usePortalContainer } from "../lib/portal-container.js";
9
+ const DelegateContext = React.createContext(null);
6
10
  /**
7
11
  * PreviewCard — a hover card that previews what a link points to (a person, an article, a
8
12
  * doc page) before the reader commits to the click.
@@ -16,7 +20,227 @@ export function PreviewCardTrigger(props) {
16
20
  return _jsx(BasePreviewCard.Trigger, { ...triggerSlot("preview-card-trigger", props.render), ...props });
17
21
  }
18
22
  /** Portal + Positioner + Popup. Menu material at 12px, 320px wide, `popup-motion`. */
19
- export function PreviewCardContent({ side = "bottom", align = "center", sideOffset = 8, alignOffset = 0, positioner, portal, arrow = false, className, children, dir, ...props }) {
23
+ export function PreviewCardContent({ side = "bottom", align = "center", sideOffset = 8, alignOffset = 0, positioner, portal, arrow = false, className, children, dir, ref, ...props }) {
24
+ const portalContainer = usePortalContainer();
20
25
  const popupDir = usePopupDir(dir);
21
- return (_jsx(BasePreviewCard.Portal, { ...portal, children: _jsx(BasePreviewCard.Positioner, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, arrowPadding: 14, collisionPadding: 16, dir: popupDir, ...positioner, className: "z-50 outline-none", children: _jsxs(BasePreviewCard.Popup, { "data-slot": "preview-card-content", className: sx(["relative flex w-80 max-w-(--available-width) flex-col gap-3 p-4 text-sm", overlayPopup], className), ...props, children: [arrow && _jsx(BasePreviewCard.Arrow, { "data-slot": "preview-card-arrow", className: overlayArrow }), children] }) }) }));
26
+ const delegate = React.useContext(DelegateContext);
27
+ const popupRef = delegate?.popupRef;
28
+ const refs = React.useMemo(() => (popupRef ? mergeRefs(popupRef, ref) : ref), [popupRef, ref]);
29
+ return (_jsx(BasePreviewCard.Portal, { container: portalContainer, ...portal, children: _jsx(BasePreviewCard.Positioner, { side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, arrowPadding: 14, collisionPadding: 16, dir: popupDir, ...(delegate && { anchor: delegate.anchor }), ...positioner, className: "z-50 outline-none", children: _jsxs(BasePreviewCard.Popup, { "data-slot": "preview-card-content", ref: refs, className: sx(["relative flex w-80 max-w-(--available-width) flex-col gap-3 p-4 text-sm", overlayPopup], className), ...props, children: [arrow && _jsx(BasePreviewCard.Arrow, { "data-slot": "preview-card-arrow", className: overlayArrow }), children] }) }) }));
30
+ }
31
+ /**
32
+ * PreviewCardDelegate — one preview card for every element on the page that matches a selector:
33
+ * reference chips, mentions, links in a long thread. It listens once, on the document or a
34
+ * container, instead of mounting a trigger per element, so a page with hundreds of references
35
+ * stays cheap.
36
+ *
37
+ * It keeps a normal PreviewCard's behaviour: opens on hover or keyboard focus after the delay,
38
+ * lingers so the pointer can move into the card, moves to the next match at once while it is
39
+ * open, and closes on Escape, a press outside, scrolling or leaving the window.
40
+ *
41
+ * The rule people break: the matching elements must make sense on their own. Make them real
42
+ * links (`<a href>`) or focusable (`tabIndex={0}`), since the card adds a glance, never the only
43
+ * way to what they point to.
44
+ */
45
+ export function PreviewCardDelegate({ selector, children, container,
46
+ // Base UI's own trigger delays, so a delegated card keeps the timing of a normal one.
47
+ delay = 600, closeDelay = 300, onOpenChange, disabled = false, }) {
48
+ // The element the card sits against. It stays set while the card leaves, so the exit animates
49
+ // in place; `open` is what says whether it is showing.
50
+ const [anchor, setAnchor] = React.useState(null);
51
+ const [open, setOpenState] = React.useState(false);
52
+ const popupRef = React.useRef(null);
53
+ // The listeners below are registered once per selector and container; they read and write
54
+ // the live state through these refs.
55
+ const live = React.useRef({ open: false, anchor: null });
56
+ const options = React.useRef({ delay, closeDelay, onOpenChange });
57
+ options.current = { delay, closeDelay, onOpenChange };
58
+ const closeRef = React.useRef(() => { });
59
+ React.useEffect(() => {
60
+ if (disabled)
61
+ return;
62
+ const doc = container?.current?.ownerDocument ?? document;
63
+ const win = doc.defaultView ?? window;
64
+ const root = container?.current ?? doc;
65
+ let showTimer;
66
+ let hideTimer;
67
+ // The element waiting out the open delay, or the one shown.
68
+ let pending = null;
69
+ let hovering = false;
70
+ let focused = null;
71
+ const clear = () => {
72
+ clearTimeout(showTimer);
73
+ clearTimeout(hideTimer);
74
+ showTimer = hideTimer = undefined;
75
+ };
76
+ const inPopup = (node) => node instanceof win.Node && !!popupRef.current?.contains(node);
77
+ const match = (node) => {
78
+ if (!(node instanceof win.Element))
79
+ return null;
80
+ const el = node.closest(selector);
81
+ return el instanceof win.HTMLElement && root.contains(el) ? el : null;
82
+ };
83
+ const show = (el) => {
84
+ clear();
85
+ pending = el;
86
+ if (live.current.open && live.current.anchor === el)
87
+ return;
88
+ live.current = { open: true, anchor: el };
89
+ setAnchor(el);
90
+ setOpenState(true);
91
+ options.current.onOpenChange?.(true, el);
92
+ };
93
+ const close = () => {
94
+ clear();
95
+ pending = null;
96
+ hovering = false;
97
+ if (!live.current.open)
98
+ return;
99
+ live.current = { ...live.current, open: false };
100
+ setOpenState(false);
101
+ options.current.onOpenChange?.(false, null);
102
+ };
103
+ closeRef.current = close;
104
+ /** Open after the delay, or move there at once if the card is already showing. */
105
+ const request = (el) => {
106
+ if (live.current.open)
107
+ return show(el);
108
+ clear();
109
+ pending = el;
110
+ showTimer = setTimeout(() => show(el), options.current.delay);
111
+ };
112
+ const scheduleClose = () => {
113
+ clearTimeout(showTimer);
114
+ clearTimeout(hideTimer);
115
+ if (!live.current.open) {
116
+ pending = null;
117
+ return;
118
+ }
119
+ hideTimer = setTimeout(close, options.current.closeDelay);
120
+ };
121
+ const onPointerOver = (event) => {
122
+ // Like the trigger: hover is for a mouse or a pen. A tap is a click on the link.
123
+ if (event.pointerType === "touch")
124
+ return;
125
+ if (inPopup(event.target)) {
126
+ hovering = true;
127
+ clearTimeout(hideTimer);
128
+ return;
129
+ }
130
+ const el = match(event.target);
131
+ if (!el)
132
+ return;
133
+ hovering = true;
134
+ if (el === pending) {
135
+ clearTimeout(hideTimer);
136
+ return;
137
+ }
138
+ request(el);
139
+ };
140
+ const onPointerOut = (event) => {
141
+ if (event.pointerType === "touch" || !pending)
142
+ return;
143
+ const from = event.target;
144
+ if (!pending.contains(from) && !inPopup(from))
145
+ return;
146
+ const to = event.relatedTarget;
147
+ if (to instanceof win.Node && (pending.contains(to) || inPopup(to)))
148
+ return;
149
+ hovering = false;
150
+ if (focused === pending)
151
+ return;
152
+ // Onto another match: its pointerover, next, moves the card there.
153
+ scheduleClose();
154
+ };
155
+ const onFocusIn = (event) => {
156
+ if (inPopup(event.target))
157
+ return;
158
+ const el = match(event.target);
159
+ if (!el)
160
+ return;
161
+ // Like the trigger: a click that focuses the link does not open the card, the keyboard does.
162
+ let visible = true;
163
+ try {
164
+ visible = event.target.matches(":focus-visible");
165
+ }
166
+ catch {
167
+ // An engine without :focus-visible: treat every focus as visible.
168
+ }
169
+ if (!visible)
170
+ return;
171
+ focused = el;
172
+ request(el);
173
+ };
174
+ const onFocusOut = (event) => {
175
+ if (!focused || !focused.contains(event.target))
176
+ return;
177
+ const to = event.relatedTarget;
178
+ if (to instanceof win.Node && (focused.contains(to) || inPopup(to)))
179
+ return;
180
+ const was = focused;
181
+ focused = null;
182
+ // Focus moving to another match is handled by its focusin.
183
+ if (match(to))
184
+ return;
185
+ if (hovering && was === pending)
186
+ return;
187
+ close();
188
+ };
189
+ const onKeyDown = (event) => {
190
+ // Esc on an open card is Base UI's (onOpenChange below); this cancels one still waiting.
191
+ if (event.key === "Escape" && !live.current.open && pending) {
192
+ clear();
193
+ pending = null;
194
+ }
195
+ };
196
+ const onScroll = (event) => {
197
+ if (inPopup(event.target))
198
+ return;
199
+ if (live.current.open)
200
+ return close();
201
+ // Focusing an element scrolls it into view: that scroll keeps a keyboard open waiting.
202
+ if (pending && pending !== focused) {
203
+ clear();
204
+ pending = null;
205
+ }
206
+ };
207
+ root.addEventListener("pointerover", onPointerOver);
208
+ root.addEventListener("pointerout", onPointerOut);
209
+ root.addEventListener("focusin", onFocusIn);
210
+ root.addEventListener("focusout", onFocusOut);
211
+ // The card is portalled outside a container: hovering it is heard on the document.
212
+ if (root !== doc) {
213
+ doc.addEventListener("pointerover", onPointerOver);
214
+ doc.addEventListener("pointerout", onPointerOut);
215
+ }
216
+ doc.addEventListener("keydown", onKeyDown);
217
+ win.addEventListener("scroll", onScroll, true);
218
+ win.addEventListener("blur", close);
219
+ return () => {
220
+ clear();
221
+ root.removeEventListener("pointerover", onPointerOver);
222
+ root.removeEventListener("pointerout", onPointerOut);
223
+ root.removeEventListener("focusin", onFocusIn);
224
+ root.removeEventListener("focusout", onFocusOut);
225
+ if (root !== doc) {
226
+ doc.removeEventListener("pointerover", onPointerOver);
227
+ doc.removeEventListener("pointerout", onPointerOut);
228
+ }
229
+ doc.removeEventListener("keydown", onKeyDown);
230
+ win.removeEventListener("scroll", onScroll, true);
231
+ win.removeEventListener("blur", close);
232
+ close();
233
+ closeRef.current = () => { };
234
+ };
235
+ }, [selector, container, disabled]);
236
+ const context = React.useMemo(() => ({ anchor, popupRef }), [anchor]);
237
+ return (_jsx(BasePreviewCard.Root, { open: open, onOpenChange: (next, details) => {
238
+ // Hover and focus are this component's; Esc, a press outside and the rest close it.
239
+ if (!next && details.reason !== "trigger-hover" && details.reason !== "trigger-focus") {
240
+ closeRef.current();
241
+ }
242
+ }, onOpenChangeComplete: (isOpen) => {
243
+ if (!isOpen && !live.current.open)
244
+ setAnchor(null);
245
+ }, children: _jsx(DelegateContext.Provider, { value: context, children: anchor && children(anchor) }) }));
22
246
  }