@zyncat/ui 0.13.0 → 0.15.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 (440) hide show
  1. package/README.md +72 -13
  2. package/dist/alert.css +26 -33
  3. package/dist/alert.js +18 -17
  4. package/dist/alert.js.map +1 -1
  5. package/dist/avatar-group.js +2 -2
  6. package/dist/avatar-group.js.map +1 -1
  7. package/dist/avatar.css +51 -50
  8. package/dist/avatar.js +29 -7
  9. package/dist/avatar.js.map +1 -1
  10. package/dist/badge.css +30 -36
  11. package/dist/badge.js +1 -1
  12. package/dist/button.css +80 -96
  13. package/dist/button.js +1 -1
  14. package/dist/checkbox.css +27 -32
  15. package/dist/checkbox.js +2 -2
  16. package/dist/{chunk-RJFGWJ4W.js → chunk-3XRVPCIM.js} +6 -6
  17. package/dist/chunk-3XRVPCIM.js.map +1 -0
  18. package/dist/{chunk-M43IOM5C.js → chunk-5GBV45YD.js} +3 -3
  19. package/dist/{chunk-M43IOM5C.js.map → chunk-5GBV45YD.js.map} +1 -1
  20. package/dist/{chunk-45R4Z5XN.js → chunk-5VC3TUZ2.js} +4 -4
  21. package/dist/{chunk-45R4Z5XN.js.map → chunk-5VC3TUZ2.js.map} +1 -1
  22. package/dist/{chunk-A5WTZACK.js → chunk-5W5TKANX.js} +3 -3
  23. package/dist/{chunk-A5WTZACK.js.map → chunk-5W5TKANX.js.map} +1 -1
  24. package/dist/{chunk-AADAJL7D.js → chunk-5X3MJRIM.js} +8 -9
  25. package/dist/chunk-5X3MJRIM.js.map +1 -0
  26. package/dist/{chunk-TCUCYFT7.js → chunk-6SUHSSOK.js} +3 -3
  27. package/dist/{chunk-TCUCYFT7.js.map → chunk-6SUHSSOK.js.map} +1 -1
  28. package/dist/{chunk-DDRSMHN4.js → chunk-6X3G4GIM.js} +3 -3
  29. package/dist/{chunk-DDRSMHN4.js.map → chunk-6X3G4GIM.js.map} +1 -1
  30. package/dist/{chunk-TYHR4VNM.js → chunk-AREEMG47.js} +10 -8
  31. package/dist/chunk-AREEMG47.js.map +1 -0
  32. package/dist/{chunk-EF6RPXU7.js → chunk-BH4JFWXQ.js} +36 -31
  33. package/dist/chunk-BH4JFWXQ.js.map +1 -0
  34. package/dist/{chunk-TVYH4AN7.js → chunk-BTF6DAE3.js} +13 -13
  35. package/dist/chunk-BTF6DAE3.js.map +1 -0
  36. package/dist/{chunk-CF4QHO4N.js → chunk-CAXQJSIE.js} +10 -10
  37. package/dist/{chunk-CF4QHO4N.js.map → chunk-CAXQJSIE.js.map} +1 -1
  38. package/dist/{chunk-4C5RZXBT.js → chunk-CFRGQJ23.js} +8 -8
  39. package/dist/chunk-CFRGQJ23.js.map +1 -0
  40. package/dist/{chunk-IJS7TPGV.js → chunk-FEXUS4SV.js} +6 -5
  41. package/dist/chunk-FEXUS4SV.js.map +1 -0
  42. package/dist/{chunk-227ZW4V7.js → chunk-FLQVOSFC.js} +11 -11
  43. package/dist/chunk-FLQVOSFC.js.map +1 -0
  44. package/dist/{chunk-FONOS5RN.js → chunk-FVPNICF4.js} +11 -10
  45. package/dist/chunk-FVPNICF4.js.map +1 -0
  46. package/dist/{chunk-I45AU6KH.js → chunk-GGDAMIBH.js} +13 -7
  47. package/dist/chunk-GGDAMIBH.js.map +1 -0
  48. package/dist/{chunk-4BSHB7R3.js → chunk-GJTHWB6O.js} +9 -9
  49. package/dist/chunk-GJTHWB6O.js.map +1 -0
  50. package/dist/{chunk-EAI4POPB.js → chunk-GOLSYGRA.js} +45 -75
  51. package/dist/chunk-GOLSYGRA.js.map +1 -0
  52. package/dist/chunk-H3X2263Y.js +17 -0
  53. package/dist/chunk-H3X2263Y.js.map +1 -0
  54. package/dist/chunk-K45CWVHS.js +53 -0
  55. package/dist/chunk-K45CWVHS.js.map +1 -0
  56. package/dist/{chunk-JY6A2ZJZ.js → chunk-LNAV5E7S.js} +2 -2
  57. package/dist/{chunk-JY6A2ZJZ.js.map → chunk-LNAV5E7S.js.map} +1 -1
  58. package/dist/{chunk-TUTXXC3W.js → chunk-MDSRZ4QR.js} +3 -3
  59. package/dist/{chunk-TUTXXC3W.js.map → chunk-MDSRZ4QR.js.map} +1 -1
  60. package/dist/chunk-N2GJEO5Z.js +101 -0
  61. package/dist/chunk-N2GJEO5Z.js.map +1 -0
  62. package/dist/chunk-PU3QWBEL.js +39 -0
  63. package/dist/chunk-PU3QWBEL.js.map +1 -0
  64. package/dist/{chunk-43M6GQ4Q.js → chunk-PWQVSVXR.js} +51 -32
  65. package/dist/chunk-PWQVSVXR.js.map +1 -0
  66. package/dist/chunk-QGVFFT2B.js +14 -0
  67. package/dist/chunk-QGVFFT2B.js.map +1 -0
  68. package/dist/{chunk-5PZ43DCG.js → chunk-RBSHRRNO.js} +12 -13
  69. package/dist/chunk-RBSHRRNO.js.map +1 -0
  70. package/dist/{chunk-XNIYSAMJ.js → chunk-RW2A4M2Q.js} +14 -9
  71. package/dist/chunk-RW2A4M2Q.js.map +1 -0
  72. package/dist/{chunk-HY5MPISE.js → chunk-UYSXJ7MH.js} +9 -9
  73. package/dist/chunk-UYSXJ7MH.js.map +1 -0
  74. package/dist/chunk-VDOBLABP.js +38 -0
  75. package/dist/chunk-VDOBLABP.js.map +1 -0
  76. package/dist/chunk-VNVVG47J.js +12 -0
  77. package/dist/chunk-VNVVG47J.js.map +1 -0
  78. package/dist/{chunk-3MPF7FZV.js → chunk-WCWV5IX6.js} +3 -3
  79. package/dist/{chunk-3MPF7FZV.js.map → chunk-WCWV5IX6.js.map} +1 -1
  80. package/dist/{chunk-VAXCXZ53.js → chunk-WZUTBJC4.js} +5 -4
  81. package/dist/chunk-WZUTBJC4.js.map +1 -0
  82. package/dist/cli.js +137 -25
  83. package/dist/collapse.css +15 -30
  84. package/dist/collapse.js +1 -1
  85. package/dist/confetti.css +19 -12
  86. package/dist/confetti.js +7 -6
  87. package/dist/confetti.js.map +1 -1
  88. package/dist/count-badge.js +2 -2
  89. package/dist/date-field.js +20 -19
  90. package/dist/date-field.js.map +1 -1
  91. package/dist/date-picker.css +131 -154
  92. package/dist/date-range-field.js +55 -54
  93. package/dist/date-range-field.js.map +1 -1
  94. package/dist/datetime-field.js +24 -23
  95. package/dist/datetime-field.js.map +1 -1
  96. package/dist/dialog.css +31 -41
  97. package/dist/dialog.js +23 -22
  98. package/dist/dialog.js.map +1 -1
  99. package/dist/digit-strip.css +16 -16
  100. package/dist/dropdown.css +36 -27
  101. package/dist/dropdown.js +77 -40
  102. package/dist/dropdown.js.map +1 -1
  103. package/dist/emoji-picker.js +44 -45
  104. package/dist/emoji-picker.js.map +1 -1
  105. package/dist/facebook-feed.css +145 -148
  106. package/dist/facebook-feed.js +106 -102
  107. package/dist/facebook-feed.js.map +1 -1
  108. package/dist/flow-field.css +8 -4
  109. package/dist/flow-field.js +7 -6
  110. package/dist/flow-field.js.map +1 -1
  111. package/dist/glide.js +4 -3
  112. package/dist/icon.css +7 -10
  113. package/dist/input.css +76 -84
  114. package/dist/instagram-feed.css +65 -66
  115. package/dist/instagram-feed.js +61 -44
  116. package/dist/instagram-feed.js.map +1 -1
  117. package/dist/lens.css +42 -38
  118. package/dist/lens.js +17 -16
  119. package/dist/lens.js.map +1 -1
  120. package/dist/mcp.js +3 -2
  121. package/dist/menu-surface.css +54 -34
  122. package/dist/modal.css +2 -4
  123. package/dist/modal.js +12 -11
  124. package/dist/modal.js.map +1 -1
  125. package/dist/morphing-text.css +26 -16
  126. package/dist/morphing-text.js +14 -13
  127. package/dist/morphing-text.js.map +1 -1
  128. package/dist/motion-devtools.css +42 -68
  129. package/dist/motion-devtools.js +47 -39
  130. package/dist/motion-devtools.js.map +1 -1
  131. package/dist/motion-tokens.js +1 -1
  132. package/dist/multi-select.js +21 -16
  133. package/dist/multi-select.js.map +1 -1
  134. package/dist/number-field.js +14 -14
  135. package/dist/number-field.js.map +1 -1
  136. package/dist/odometer.css +22 -16
  137. package/dist/odometer.js +12 -11
  138. package/dist/odometer.js.map +1 -1
  139. package/dist/otp-field.js +3 -3
  140. package/dist/otp-field.js.map +1 -1
  141. package/dist/overlay.css +4 -9
  142. package/dist/pagination.css +10 -15
  143. package/dist/pagination.js +11 -10
  144. package/dist/pagination.js.map +1 -1
  145. package/dist/popover.css +13 -15
  146. package/dist/popover.js +10 -9
  147. package/dist/radio-group.css +60 -73
  148. package/dist/radio-group.js +30 -29
  149. package/dist/radio-group.js.map +1 -1
  150. package/dist/select.css +66 -75
  151. package/dist/select.js +19 -14
  152. package/dist/select.js.map +1 -1
  153. package/dist/sheet.css +12 -14
  154. package/dist/sheet.js +11 -10
  155. package/dist/status-badge.js +9 -9
  156. package/dist/status-badge.js.map +1 -1
  157. package/dist/styles.css +34 -34
  158. package/dist/support-rail.css +116 -100
  159. package/dist/support-rail.js +41 -40
  160. package/dist/support-rail.js.map +1 -1
  161. package/dist/table.css +76 -84
  162. package/dist/table.js +42 -41
  163. package/dist/table.js.map +1 -1
  164. package/dist/tabs.css +82 -90
  165. package/dist/tabs.js +23 -20
  166. package/dist/tabs.js.map +1 -1
  167. package/dist/tag.css +48 -53
  168. package/dist/tag.js +13 -12
  169. package/dist/tag.js.map +1 -1
  170. package/dist/text-field.js +5 -5
  171. package/dist/textarea.css +46 -49
  172. package/dist/textarea.js +16 -16
  173. package/dist/textarea.js.map +1 -1
  174. package/dist/theme.js +31 -15
  175. package/dist/theme.js.map +1 -1
  176. package/dist/tiktok.css +113 -117
  177. package/dist/tiktok.js +53 -52
  178. package/dist/tiktok.js.map +1 -1
  179. package/dist/time-field.js +26 -20
  180. package/dist/time-field.js.map +1 -1
  181. package/dist/toast-store.js +2 -1
  182. package/dist/toast.css +49 -65
  183. package/dist/toast.js +32 -26
  184. package/dist/toast.js.map +1 -1
  185. package/dist/toggle-tag.js +22 -13
  186. package/dist/toggle-tag.js.map +1 -1
  187. package/dist/toggle.css +26 -31
  188. package/dist/toggle.js +7 -7
  189. package/dist/toggle.js.map +1 -1
  190. package/dist/tooltip.css +16 -23
  191. package/dist/tooltip.js +117 -95
  192. package/dist/tooltip.js.map +1 -1
  193. package/dist/trigger.css +3 -3
  194. package/dist/types/components/composites/alert/Alert.d.ts +1 -2
  195. package/dist/types/components/composites/date-picker/TimeField.d.ts +1 -2
  196. package/dist/types/components/composites/date-picker/field-shell.d.ts +1 -1
  197. package/dist/types/components/composites/date-picker/time-core.d.ts +1 -2
  198. package/dist/types/components/composites/dropdown/Dropdown.d.ts +9 -1
  199. package/dist/types/components/composites/dropdown/types.d.ts +14 -0
  200. package/dist/types/components/composites/emoji-picker/EmojiPickerPanel.d.ts +1 -1
  201. package/dist/types/components/composites/emoji-picker/data.d.ts +2 -5
  202. package/dist/types/components/composites/emoji-picker/react/useEmojiPicker.d.ts +0 -11
  203. package/dist/types/components/composites/emoji-picker/types.d.ts +3 -8
  204. package/dist/types/components/composites/select/MultiSelect.d.ts +6 -1
  205. package/dist/types/components/composites/select/Select.d.ts +6 -1
  206. package/dist/types/components/composites/select/core/index.d.ts +1 -1
  207. package/dist/types/components/composites/select/core/menu.d.ts +3 -3
  208. package/dist/types/components/composites/select/core/panel.d.ts +3 -3
  209. package/dist/types/components/composites/tabs/Tabs.d.ts +7 -10
  210. package/dist/types/components/composites/toast/Toast.d.ts +1 -1
  211. package/dist/types/components/composites/tooltip/Tooltip.d.ts +9 -1
  212. package/dist/types/components/composites/tooltip/tooltip-store.d.ts +5 -6
  213. package/dist/types/components/dev/MotionDevtools.d.ts +3 -1
  214. package/dist/types/components/internal/hooks/use-host-election.d.ts +8 -0
  215. package/dist/types/components/internal/icon/Icon.d.ts +1 -3
  216. package/dist/types/components/internal/menu/highlight.d.ts +7 -0
  217. package/dist/types/components/internal/utils/activation.d.ts +0 -4
  218. package/dist/types/components/primitives/avatar/Avatar.d.ts +1 -1
  219. package/dist/types/components/primitives/button/Button.d.ts +1 -1
  220. package/dist/types/components/primitives/input/TextField.d.ts +1 -2
  221. package/dist/types/components/primitives/textarea/Textarea.d.ts +0 -1
  222. package/dist/types/shared-slot.d.ts +1 -0
  223. package/dist/types/tokens/component-styles.generated.d.ts +79 -151
  224. package/dist/types/tokens/motion-defaults.generated.d.ts +34 -0
  225. package/dist/types/tokens/motion-scale.d.ts +2 -2
  226. package/dist/types/tokens/motion-tokens.d.ts +7 -0
  227. package/dist/types/tokens/theme-sync.d.ts +3 -0
  228. package/dist/types/tokens/theme-tokens.generated.d.ts +669 -1105
  229. package/dist/typing-lines.css +17 -10
  230. package/dist/typing-lines.js +9 -8
  231. package/dist/typing-lines.js.map +1 -1
  232. package/dist/weight-field.css +31 -17
  233. package/dist/weight-field.js +4 -4
  234. package/dist/weight-field.js.map +1 -1
  235. package/dist/youtube.css +90 -96
  236. package/dist/youtube.js +87 -86
  237. package/dist/youtube.js.map +1 -1
  238. package/package.json +3 -1
  239. package/skills/zyncat-ui/SKILL.md +5 -3
  240. package/skills/zyncat-ui/references/components.md +4 -4
  241. package/skills/zyncat-ui/references/theming.md +105 -34
  242. package/src/components/composites/alert/Alert.tsx +9 -10
  243. package/src/components/composites/alert/alert.css +26 -33
  244. package/src/components/composites/date-picker/DateField.tsx +1 -1
  245. package/src/components/composites/date-picker/DateRangeField.tsx +1 -1
  246. package/src/components/composites/date-picker/DateTimeField.tsx +4 -4
  247. package/src/components/composites/date-picker/TimeField.tsx +8 -5
  248. package/src/components/composites/date-picker/calendar-panel.tsx +25 -20
  249. package/src/components/composites/date-picker/date-picker.css +131 -154
  250. package/src/components/composites/date-picker/field-shell.tsx +7 -7
  251. package/src/components/composites/date-picker/range-panel.tsx +34 -34
  252. package/src/components/composites/date-picker/time-core.tsx +4 -6
  253. package/src/components/composites/date-picker/use-day-focus.ts +1 -1
  254. package/src/components/composites/dialog/Dialog.tsx +11 -11
  255. package/src/components/composites/dialog/dialog.css +31 -41
  256. package/src/components/composites/dropdown/Dropdown.tsx +15 -2
  257. package/src/components/composites/dropdown/Dropdown.usage.md +7 -4
  258. package/src/components/composites/dropdown/dropdown.css +36 -27
  259. package/src/components/composites/dropdown/menu-panel.tsx +56 -27
  260. package/src/components/composites/dropdown/types.ts +28 -6
  261. package/src/components/composites/emoji-picker/EmojiPickerPanel.tsx +5 -4
  262. package/src/components/composites/emoji-picker/EmojiPickerPanel.usage.md +4 -4
  263. package/src/components/composites/emoji-picker/data.ts +2 -5
  264. package/src/components/composites/emoji-picker/dom.ts +6 -6
  265. package/src/components/composites/emoji-picker/react/category-bar.tsx +6 -6
  266. package/src/components/composites/emoji-picker/react/useEmojiPicker.ts +0 -11
  267. package/src/components/composites/emoji-picker/scaffold.ts +7 -7
  268. package/src/components/composites/emoji-picker/search.ts +0 -7
  269. package/src/components/composites/emoji-picker/styles.css +34 -34
  270. package/src/components/composites/emoji-picker/types.ts +3 -8
  271. package/src/components/composites/modal/Modal.tsx +2 -2
  272. package/src/components/composites/modal/modal.css +2 -4
  273. package/src/components/composites/pagination/Pagination.tsx +7 -7
  274. package/src/components/composites/pagination/pagination.css +10 -15
  275. package/src/components/composites/popover/Popover.tsx +2 -2
  276. package/src/components/composites/popover/popover.css +13 -15
  277. package/src/components/composites/select/MultiSelect.tsx +11 -2
  278. package/src/components/composites/select/MultiSelect.usage.md +2 -1
  279. package/src/components/composites/select/Select.tsx +10 -1
  280. package/src/components/composites/select/Select.usage.md +2 -1
  281. package/src/components/composites/select/core/index.ts +1 -1
  282. package/src/components/composites/select/core/menu.tsx +19 -4
  283. package/src/components/composites/select/core/panel.tsx +19 -15
  284. package/src/components/composites/select/core/trigger.tsx +5 -5
  285. package/src/components/composites/select/select.css +66 -75
  286. package/src/components/composites/sheet/Sheet.tsx +2 -2
  287. package/src/components/composites/sheet/sheet.css +12 -14
  288. package/src/components/composites/sheet/use-sheet-drag.ts +1 -1
  289. package/src/components/composites/table/Table.tsx +35 -35
  290. package/src/components/composites/table/table.css +76 -84
  291. package/src/components/composites/tabs/Tabs.tsx +20 -21
  292. package/src/components/composites/tabs/Tabs.usage.md +3 -2
  293. package/src/components/composites/tabs/tabs.css +82 -90
  294. package/src/components/composites/toast/Toast.tsx +23 -18
  295. package/src/components/composites/toast/toast-store.ts +8 -6
  296. package/src/components/composites/toast/toast.css +49 -65
  297. package/src/components/composites/tooltip/Tooltip.tsx +40 -19
  298. package/src/components/composites/tooltip/Tooltip.usage.md +9 -1
  299. package/src/components/composites/tooltip/tooltip-host.tsx +55 -23
  300. package/src/components/composites/tooltip/tooltip-store.ts +36 -53
  301. package/src/components/composites/tooltip/tooltip.css +16 -23
  302. package/src/components/compound/support-rail/SupportRail.tsx +33 -33
  303. package/src/components/compound/support-rail/support-rail.css +116 -100
  304. package/src/components/dev/MotionDevtools.tsx +28 -17
  305. package/src/components/dev/MotionDevtools.usage.md +2 -2
  306. package/src/components/dev/motion-devtools.css +42 -68
  307. package/src/components/dev/slowmo-engine.ts +16 -15
  308. package/src/components/expressive/confetti/Confetti.tsx +4 -4
  309. package/src/components/expressive/confetti/confetti.css +19 -12
  310. package/src/components/expressive/facebook-feed/chrome.tsx +2 -2
  311. package/src/components/expressive/facebook-feed/facebook-feed.css +145 -148
  312. package/src/components/expressive/facebook-feed/post.tsx +39 -39
  313. package/src/components/expressive/facebook-feed/reel.tsx +41 -37
  314. package/src/components/expressive/facebook-feed/story.tsx +27 -27
  315. package/src/components/expressive/flow-field/FlowField.tsx +4 -4
  316. package/src/components/expressive/flow-field/flow-field.css +8 -4
  317. package/src/components/expressive/instagram-feed/InstagramFeed.tsx +52 -44
  318. package/src/components/expressive/instagram-feed/instagram-feed.css +65 -66
  319. package/src/components/expressive/lens/Lens.tsx +14 -14
  320. package/src/components/expressive/lens/lens.css +42 -38
  321. package/src/components/expressive/morphing-text/MorphingText.tsx +12 -13
  322. package/src/components/expressive/morphing-text/morphing-text.css +26 -16
  323. package/src/components/expressive/odometer/Odometer.tsx +9 -9
  324. package/src/components/expressive/odometer/odometer.css +22 -16
  325. package/src/components/expressive/tiktok/TikTok.tsx +54 -54
  326. package/src/components/expressive/tiktok/tiktok.css +113 -117
  327. package/src/components/expressive/typing-lines/TypingLines.tsx +0 -0
  328. package/src/components/expressive/typing-lines/typing-lines.css +17 -10
  329. package/src/components/expressive/weight-field/WeightField.tsx +4 -4
  330. package/src/components/expressive/weight-field/weight-field.css +31 -17
  331. package/src/components/expressive/youtube/YouTube.tsx +4 -4
  332. package/src/components/expressive/youtube/glyphs.tsx +16 -16
  333. package/src/components/expressive/youtube/media.tsx +3 -3
  334. package/src/components/expressive/youtube/post.tsx +28 -28
  335. package/src/components/expressive/youtube/short.tsx +25 -25
  336. package/src/components/expressive/youtube/video.tsx +13 -13
  337. package/src/components/expressive/youtube/youtube.css +90 -96
  338. package/src/components/internal/glass/glass.css +19 -22
  339. package/src/components/internal/glass/glint.ts +3 -3
  340. package/src/components/internal/hooks/use-host-election.ts +46 -0
  341. package/src/components/internal/icon/Icon.tsx +1 -5
  342. package/src/components/internal/icon/IconSlot.tsx +1 -1
  343. package/src/components/internal/icon/icon.css +7 -10
  344. package/src/components/internal/menu/highlight.ts +12 -0
  345. package/src/components/internal/menu/menu-row.tsx +5 -5
  346. package/src/components/internal/menu/menu-surface.css +54 -34
  347. package/src/components/internal/overlay/layer.tsx +2 -1
  348. package/src/components/internal/overlay/modal.tsx +5 -4
  349. package/src/components/internal/overlay/overlay.css +4 -9
  350. package/src/components/internal/overlay/trigger.css +3 -3
  351. package/src/components/internal/utils/activation.ts +0 -4
  352. package/src/components/primitives/avatar/Avatar.tsx +24 -8
  353. package/src/components/primitives/avatar/AvatarGroup.tsx +4 -4
  354. package/src/components/primitives/avatar/avatar.css +51 -50
  355. package/src/components/primitives/badge/Badge.tsx +9 -9
  356. package/src/components/primitives/badge/StatusBadge.tsx +7 -7
  357. package/src/components/primitives/badge/badge.css +30 -36
  358. package/src/components/primitives/badge/digit-strip.css +16 -16
  359. package/src/components/primitives/badge/digit-strip.tsx +4 -4
  360. package/src/components/primitives/button/Button.tsx +8 -8
  361. package/src/components/primitives/button/button.css +80 -96
  362. package/src/components/primitives/checkbox/Checkbox.tsx +10 -4
  363. package/src/components/primitives/checkbox/check-glyph.tsx +5 -5
  364. package/src/components/primitives/checkbox/checkbox.css +27 -32
  365. package/src/components/primitives/collapse/Collapse.tsx +2 -2
  366. package/src/components/primitives/collapse/collapse.css +15 -30
  367. package/src/components/primitives/collapse/collapse.typecheck.tsx +1 -1
  368. package/src/components/primitives/input/NumberField.tsx +11 -11
  369. package/src/components/primitives/input/OtpField.tsx +3 -3
  370. package/src/components/primitives/input/TextField.tsx +9 -10
  371. package/src/components/primitives/input/field-chrome.tsx +6 -6
  372. package/src/components/primitives/input/input.css +76 -84
  373. package/src/components/primitives/radio-group/RadioGroup.tsx +23 -23
  374. package/src/components/primitives/radio-group/radio-group.css +60 -73
  375. package/src/components/primitives/tag/Tag.tsx +5 -5
  376. package/src/components/primitives/tag/ToggleTag.tsx +11 -6
  377. package/src/components/primitives/tag/tag.css +48 -53
  378. package/src/components/primitives/textarea/Textarea.tsx +13 -14
  379. package/src/components/primitives/textarea/textarea.css +46 -49
  380. package/src/components/primitives/toggle/Toggle.tsx +7 -7
  381. package/src/components/primitives/toggle/toggle.css +26 -31
  382. package/src/engine/animate.ts +2 -1
  383. package/src/engine/flip.ts +2 -1
  384. package/src/mcp/server.ts +3 -1
  385. package/src/motion/flip.ts +7 -8
  386. package/src/motion/glide.tsx +41 -26
  387. package/src/shared-slot.ts +10 -0
  388. package/src/styles.css +7 -15
  389. package/src/tokens/base.css +15 -0
  390. package/src/tokens/color.css +19 -59
  391. package/src/tokens/component-styles.generated.ts +79 -151
  392. package/src/tokens/dark.css +63 -0
  393. package/src/tokens/decisions.css +26 -0
  394. package/src/tokens/elevation.css +71 -21
  395. package/src/tokens/fonts.css +0 -2
  396. package/src/tokens/glass.css +15 -9
  397. package/src/tokens/motion-defaults.generated.ts +21 -0
  398. package/src/tokens/motion-scale.ts +2 -2
  399. package/src/tokens/motion-tokens.ts +65 -40
  400. package/src/tokens/motion-tokens.usage.md +5 -2
  401. package/src/tokens/motion.css +12 -22
  402. package/src/tokens/radius.css +10 -9
  403. package/src/tokens/semantic.css +57 -37
  404. package/src/tokens/spacing.css +5 -6
  405. package/src/tokens/theme-sync.tsx +15 -0
  406. package/src/tokens/theme-tokens.generated.ts +682 -1109
  407. package/src/tokens/theme.tsx +22 -16
  408. package/src/tokens/theme.usage.md +19 -13
  409. package/src/tokens/typography.css +16 -19
  410. package/tailwind.css +193 -0
  411. package/dist/chunk-227ZW4V7.js.map +0 -1
  412. package/dist/chunk-43M6GQ4Q.js.map +0 -1
  413. package/dist/chunk-4BSHB7R3.js.map +0 -1
  414. package/dist/chunk-4C5RZXBT.js.map +0 -1
  415. package/dist/chunk-5PZ43DCG.js.map +0 -1
  416. package/dist/chunk-7IZJERGA.js +0 -80
  417. package/dist/chunk-7IZJERGA.js.map +0 -1
  418. package/dist/chunk-AADAJL7D.js.map +0 -1
  419. package/dist/chunk-CNWTIMIP.js +0 -39
  420. package/dist/chunk-CNWTIMIP.js.map +0 -1
  421. package/dist/chunk-EAI4POPB.js.map +0 -1
  422. package/dist/chunk-EF6RPXU7.js.map +0 -1
  423. package/dist/chunk-FONOS5RN.js.map +0 -1
  424. package/dist/chunk-FQEHSKEI.js +0 -38
  425. package/dist/chunk-FQEHSKEI.js.map +0 -1
  426. package/dist/chunk-HY5MPISE.js.map +0 -1
  427. package/dist/chunk-I45AU6KH.js.map +0 -1
  428. package/dist/chunk-IJS7TPGV.js.map +0 -1
  429. package/dist/chunk-OWNMRMPN.js +0 -14
  430. package/dist/chunk-OWNMRMPN.js.map +0 -1
  431. package/dist/chunk-RJFGWJ4W.js.map +0 -1
  432. package/dist/chunk-TVYH4AN7.js.map +0 -1
  433. package/dist/chunk-TYHR4VNM.js.map +0 -1
  434. package/dist/chunk-VAXCXZ53.js.map +0 -1
  435. package/dist/chunk-XNIYSAMJ.js.map +0 -1
  436. package/dist/chunk-Y2YA7QRF.js +0 -17
  437. package/dist/chunk-Y2YA7QRF.js.map +0 -1
  438. package/src/tokens/avatar.css +0 -24
  439. package/src/tokens/icons.css +0 -11
  440. package/src/tokens/layers.css +0 -11
@@ -1,39 +1,34 @@
1
1
  @layer zyncat.tokens, zyncat.components;
2
2
 
3
3
  @layer zyncat.components {
4
- /* toast.css - the glass notification card, tinted per tone (a draining timer ring). */
5
-
6
- .toast-viewport {
4
+ .zc-toast-viewport {
7
5
  position: fixed;
8
6
  width: min(22.5rem, calc(100vw - 2 * var(--toast-offset, var(--space-6))));
9
7
  z-index: var(--layer-toast);
10
8
  margin: 0;
11
9
  padding: 0;
12
10
  list-style: none;
13
- pointer-events: none; /* only the cards themselves are live */
11
+ pointer-events: none;
14
12
  }
15
13
 
16
- /* Anchored by [data-position]; --toast-offset (set by <Toaster offset>) overrides the edge inset. */
17
- .toast-viewport[data-position^='top'] {
14
+ .zc-toast-viewport[data-position^='top'] {
18
15
  top: var(--toast-offset, var(--space-6));
19
16
  }
20
- .toast-viewport[data-position^='bottom'] {
17
+ .zc-toast-viewport[data-position^='bottom'] {
21
18
  bottom: var(--toast-offset, var(--space-6));
22
19
  }
23
- .toast-viewport[data-position$='right'] {
20
+ .zc-toast-viewport[data-position$='right'] {
24
21
  right: var(--toast-offset, var(--space-6));
25
22
  }
26
- .toast-viewport[data-position$='left'] {
23
+ .zc-toast-viewport[data-position$='left'] {
27
24
  left: var(--toast-offset, var(--space-6));
28
25
  }
29
- .toast-viewport[data-position$='center'] {
26
+ .zc-toast-viewport[data-position$='center'] {
30
27
  left: 50%;
31
28
  transform: translateX(-50%);
32
29
  }
33
30
 
34
- /* The card - a glass consumer (.glass is set in JSX). */
35
- .toast {
36
- /* tone hooks - set by [data-tone] below */
31
+ .zc-toast {
37
32
  --toast-hue: var(--text-subtle);
38
33
  --glass-fg: var(--text-strong);
39
34
  --glass-tint: color-mix(in oklab, var(--glass-tint-neutral) 75%, transparent);
@@ -43,59 +38,55 @@
43
38
  left: 0;
44
39
  width: 100%;
45
40
  box-sizing: border-box;
46
- overflow: hidden; /* custom content stays in the pane */
41
+ overflow: hidden;
47
42
  pointer-events: auto;
48
43
  border-radius: var(--radius-lg);
49
44
 
50
- /* Motion owns transform - keep only the color/shadow transitions (never smooth Motion's writes) */
51
45
  transition:
52
46
  background-color var(--duration-base) var(--ease-standard),
53
47
  box-shadow var(--duration-base) var(--ease-standard);
54
48
  }
55
49
 
56
- /* Cards pin to the stack's edge; Motion offsets each one away from it (up from bottom, down from top). */
57
- .toast-viewport[data-position^='bottom'] .toast {
50
+ .zc-toast-viewport[data-position^='bottom'] .zc-toast {
58
51
  bottom: 0;
59
52
  transform-origin: center bottom;
60
53
  }
61
- .toast-viewport[data-position^='top'] .toast {
54
+ .zc-toast-viewport[data-position^='top'] .zc-toast {
62
55
  top: 0;
63
56
  transform-origin: center top;
64
57
  }
65
58
 
66
- /* rich panes for genuine status, diluted to stay glass; neutral otherwise */
67
- .toast[data-tone='success'] {
59
+ .zc-toast[data-tone='success'] {
68
60
  --toast-hue: var(--success);
69
61
  --glass-fg: var(--success-text);
70
62
  --glass-tint: color-mix(in oklab, var(--glass-tint-success) 70%, transparent);
71
63
  }
72
- .toast[data-tone='danger'] {
64
+ .zc-toast[data-tone='danger'] {
73
65
  --toast-hue: var(--danger);
74
66
  --glass-fg: var(--danger-text);
75
67
  --glass-tint: color-mix(in oklab, var(--glass-tint-danger) 70%, transparent);
76
68
  }
77
- .toast[data-tone='warning'] {
69
+ .zc-toast[data-tone='warning'] {
78
70
  --toast-hue: var(--warning);
79
71
  --glass-fg: var(--warning-text);
80
72
  --glass-tint: color-mix(in oklab, var(--glass-tint-warning) 70%, transparent);
81
73
  }
82
- .toast[data-tone='info'] {
74
+ .zc-toast[data-tone='info'] {
83
75
  --toast-hue: var(--info);
84
76
  --glass-fg: var(--info-text);
85
77
  --glass-tint: color-mix(in oklab, var(--glass-tint-info) 70%, transparent);
86
78
  }
87
79
 
88
- /* receding cards fall quiet: tone drains out, sheen dims, content fades */
89
- .toast[data-behind] {
80
+ .zc-toast[data-behind] {
90
81
  --glass-tint: color-mix(in oklab, var(--glass-tint-neutral) 75%, transparent);
91
82
  --glass-sheen-rest: 0.3;
92
83
  }
93
- .toast[data-behind] .toast__inner,
94
- .toast[data-behind] .toast__custom {
84
+ .zc-toast[data-behind] .zc-toast__inner,
85
+ .zc-toast[data-behind] .zc-toast__custom {
95
86
  opacity: 0;
96
87
  }
97
88
 
98
- .toast__inner {
89
+ .zc-toast__inner {
99
90
  display: flex;
100
91
  align-items: center;
101
92
  gap: var(--space-3);
@@ -103,8 +94,7 @@
103
94
  transition: var(--transition-opacity);
104
95
  }
105
96
 
106
- /* the dial - glyph centered in the timer ring; one instrument, not two */
107
- .toast__icon {
97
+ .zc-toast__icon {
108
98
  position: relative;
109
99
  flex: none;
110
100
  display: grid;
@@ -113,36 +103,35 @@
113
103
  height: calc(var(--icon-md) + 2 * var(--space-2));
114
104
  color: var(--toast-hue);
115
105
  }
116
- .toast__icon-glyph {
106
+ .zc-toast__icon-glyph {
117
107
  display: grid;
118
108
  place-items: center;
119
109
  }
120
110
 
121
- /* the ring - a draining arc; linear by design, animation-duration set at runtime to the toast's lifetime */
122
- .toast__ring {
111
+ .zc-toast__ring {
123
112
  position: absolute;
124
113
  inset: 0;
125
114
  width: 100%;
126
115
  height: 100%;
127
- transform: rotate(-90deg); /* arc starts at 12 o'clock */
116
+ transform: rotate(-90deg);
128
117
  pointer-events: none;
129
118
  }
130
- .toast__ring circle {
119
+ .zc-toast__ring circle {
131
120
  fill: none;
132
121
  stroke-width: var(--border-emphasis);
133
122
  }
134
- .toast__ring-track {
123
+ .zc-toast__ring-track {
135
124
  stroke: color-mix(in oklab, var(--toast-hue) 16%, transparent);
136
125
  }
137
- .toast__ring-arc {
126
+ .zc-toast__ring-arc {
138
127
  stroke: var(--toast-hue);
139
128
  stroke-linecap: round;
140
- stroke-dasharray: 1; /* pathLength=1 - offset is a fraction */
141
- animation-name: toast-ring;
129
+ stroke-dasharray: 1; /* the circle sets pathLength=1 */
130
+ animation-name: toast-ring; /* the duration is inline, set to the toast's lifetime */
142
131
  animation-timing-function: linear;
143
132
  animation-fill-mode: both;
144
133
  }
145
- .toast-viewport.is-paused .toast__ring-arc {
134
+ .zc-toast-viewport.zc-is-paused .zc-toast__ring-arc {
146
135
  animation-play-state: paused;
147
136
  }
148
137
  @keyframes toast-ring {
@@ -154,27 +143,26 @@
154
143
  }
155
144
  }
156
145
 
157
- .toast__text {
146
+ .zc-toast__text {
158
147
  flex: 1 1 auto;
159
148
  min-width: 0;
160
149
  }
161
- .toast__message {
150
+ .zc-toast__message {
162
151
  margin: 0;
163
152
  font: var(--type-label);
164
153
  color: var(--glass-fg);
165
154
  text-wrap: pretty;
166
155
  }
167
- .toast__desc {
156
+ .zc-toast__desc {
168
157
  margin: var(--space-1) 0 0;
169
158
  font: var(--type-caption);
170
159
  color: color-mix(in oklab, var(--glass-fg) 76%, transparent);
171
160
  text-wrap: pretty;
172
161
  }
173
162
 
174
- /* coalesce counter - same toast refired becomes a xN counter (mono) */
175
- .toast__count {
163
+ .zc-toast__count {
176
164
  flex: none;
177
- font-family: var(--font-mono);
165
+ font-family: var(--font-code);
178
166
  font-size: var(--size-micro);
179
167
  line-height: var(--leading-micro);
180
168
  font-variant-numeric: tabular-nums;
@@ -184,12 +172,11 @@
184
172
  padding: 0 var(--space-1);
185
173
  }
186
174
 
187
- .toast__action {
175
+ .zc-toast__action {
188
176
  flex: none;
189
177
  }
190
178
 
191
- /* dismiss - appears only while the card is hovered or holds focus */
192
- .toast__close {
179
+ .zc-toast__close {
193
180
  flex: none;
194
181
  appearance: none;
195
182
  display: grid;
@@ -208,25 +195,23 @@
208
195
  var(--transition-control),
209
196
  opacity var(--duration-fast) var(--ease-standard);
210
197
  }
211
- .toast:hover .toast__close,
212
- .toast:focus-within .toast__close {
198
+ .zc-toast:hover .zc-toast__close,
199
+ .zc-toast:focus-within .zc-toast__close {
213
200
  opacity: 1;
214
201
  }
215
- .toast__close:hover {
202
+ .zc-toast__close:hover {
216
203
  background: color-mix(in oklab, var(--glass-fg) 9%, transparent);
217
204
  color: var(--glass-fg);
218
205
  }
219
- .toast__close:active {
206
+ .zc-toast__close:active {
220
207
  background: color-mix(in oklab, var(--glass-fg) 14%, transparent);
221
208
  }
222
- .toast__close:focus-visible {
223
- outline: none;
224
- box-shadow: var(--focus-ring);
209
+ .zc-toast__close:focus-visible {
210
+ outline: var(--focus-ring);
225
211
  opacity: 1;
226
212
  }
227
213
 
228
- /* Loading spinner - continuous --duration-spin (linear is allowed for loops; reduced motion slows, never freezes) */
229
- .toast__spinner {
214
+ .zc-toast__spinner {
230
215
  display: block;
231
216
  box-sizing: border-box;
232
217
  width: var(--icon-sm);
@@ -243,18 +228,17 @@
243
228
  }
244
229
  }
245
230
 
246
- /* Custom slot - bare neutral glass; the consumer owns the interior. */
247
- .toast__custom {
231
+ .zc-toast__custom {
248
232
  padding: var(--space-3) var(--space-4);
249
233
  transition: var(--transition-opacity);
250
234
  }
251
235
 
252
236
  @media (prefers-reduced-motion: reduce) {
253
- /* travel/gestures collapse via the tokens; the ring is data, so it keeps running */
254
- .toast,
255
- .toast__close,
256
- .toast__inner,
257
- .toast__custom {
237
+ /* the ring keeps running: it is a clock, not decoration */
238
+ .zc-toast,
239
+ .zc-toast__close,
240
+ .zc-toast__inner,
241
+ .zc-toast__custom {
258
242
  transition: none;
259
243
  }
260
244
  }
@@ -15,6 +15,8 @@ import {
15
15
  } from 'react';
16
16
 
17
17
  import type { DataAttributes } from '../../../dom-props';
18
+ import { usePresence } from '../../../motion/presence-context';
19
+ import { useControllable } from '../../internal/hooks/use-controllable';
18
20
  import { cx } from '../../internal/utils/cx';
19
21
  import { TooltipHost } from './tooltip-host';
20
22
  import { CLOSE_GRACE, OPEN_DELAY, store, useHostElection, type Placement } from './tooltip-store';
@@ -26,6 +28,14 @@ export interface TooltipProps {
26
28
  shortcut?: string | null;
27
29
  /** Preferred side; flips automatically when out of viewport room. */
28
30
  placement?: Placement;
31
+ /** Controlled visibility - shows with no hover or focus, and stays until you clear it.
32
+ * Omit to stay uncontrolled. One bubble shows at a time: the newest wins, and the ones
33
+ * under it come back when it leaves. */
34
+ open?: boolean;
35
+ /** Initial state when uncontrolled. Default false. */
36
+ defaultOpen?: boolean;
37
+ /** Fires whenever hover, focus, or Escape asks for a new state. Pair with `open` for controlled use. */
38
+ onOpenChange?: (open: boolean) => void;
29
39
  /** Suppress the tooltip entirely (trigger renders untouched). */
30
40
  disabled?: boolean;
31
41
  /** ms before a cold hover shows; warm hovers + focus are instant. Default 350. */
@@ -45,6 +55,9 @@ export function Tooltip({
45
55
  content,
46
56
  shortcut = null,
47
57
  placement = 'top',
58
+ open: controlledOpen,
59
+ defaultOpen = false,
60
+ onOpenChange,
48
61
  disabled = false,
49
62
  openDelay = OPEN_DELAY,
50
63
  closeDelay = CLOSE_GRACE,
@@ -54,38 +67,46 @@ export function Tooltip({
54
67
  }: TooltipProps) {
55
68
  const wrapRef = useRef<HTMLSpanElement | null>(null);
56
69
  const openTimer = useRef<ReturnType<typeof setTimeout> | 0>(0);
57
- const myId = id || 'tip-' + useId();
70
+ const autoId = useId();
71
+ const myId = id || 'tip-' + autoId;
58
72
  const isHost = useHostElection();
73
+ const { isPresent } = usePresence();
74
+ const [open, setOpen] = useControllable(controlledOpen, defaultOpen, onOpenChange);
59
75
 
60
- const anchorEl = (): HTMLElement | null => (wrapRef.current?.firstElementChild as HTMLElement) ?? null;
76
+ useEffect(() => {
77
+ if (!open || disabled || !isPresent) return undefined;
78
+ store.open({
79
+ id: myId,
80
+ content,
81
+ shortcut,
82
+ placement,
83
+ anchor: () => (wrapRef.current?.firstElementChild as HTMLElement) ?? null,
84
+ dismiss: () => setOpen(false),
85
+ });
86
+ return () => store.close(myId, closeDelay);
87
+ }, [open, disabled, isPresent, content, shortcut, placement, closeDelay, myId, setOpen]);
88
+
89
+ useEffect(() => {
90
+ if (!isPresent) store.close(myId, 0);
91
+ }, [isPresent, myId]);
61
92
 
62
93
  useEffect(
63
94
  () => () => {
64
95
  clearTimeout(openTimer.current);
65
96
  store.close(myId, 0);
66
97
  },
67
- [],
68
- ); // eslint-disable-line react-hooks/exhaustive-deps
98
+ [myId],
99
+ );
69
100
 
70
101
  function show(immediate: boolean) {
71
- if (disabled) return;
72
102
  clearTimeout(openTimer.current);
73
- if (!anchorEl()) return;
74
- const open = () =>
75
- store.open({
76
- id: myId,
77
- content,
78
- shortcut,
79
- placement,
80
- anchor: anchorEl,
81
- rect: () => anchorEl()!.getBoundingClientRect(),
82
- });
83
- if (immediate || store.isWarm()) open();
84
- else openTimer.current = setTimeout(open, openDelay);
103
+ if (disabled || !wrapRef.current?.firstElementChild) return;
104
+ if (immediate || store.isWarm()) setOpen(true);
105
+ else openTimer.current = setTimeout(() => setOpen(true), openDelay);
85
106
  }
86
107
  function hide() {
87
108
  clearTimeout(openTimer.current);
88
- store.close(myId, closeDelay);
109
+ setOpen(false);
89
110
  }
90
111
 
91
112
  const onEnter = (e: PointerEvent) => {
@@ -100,7 +121,7 @@ export function Tooltip({
100
121
  <span
101
122
  {...htmlProps}
102
123
  ref={wrapRef}
103
- className={cx('tooltip-anchor', htmlProps?.className)}
124
+ className={cx('zc-tooltip-anchor', htmlProps?.className)}
104
125
  onPointerEnter={onEnter}
105
126
  onPointerLeave={hide}
106
127
  onPointerDown={hide}
@@ -5,10 +5,18 @@ Docs: https://ui.zyncat.app/tooltip
5
5
 
6
6
  Transient hint on hover/focus; wraps any child (no ref wiring needed).
7
7
 
8
- content, shortcut, placement top|bottom|left|right.
8
+ content, shortcut, placement top|bottom|left|right; open/defaultOpen/onOpenChange to drive it yourself, for a
9
+ hint no hover would ever fire. With open set, hover, focus and Escape decide nothing on their own - they only
10
+ report through onOpenChange, so a parent that ignores it keeps the bubble up. Scrolling never closes it: the
11
+ bubble tracks its anchor through page and container scroll, and leaves on pointer out, blur, or a handled Escape.
12
+ It also leaves the moment a surface around it starts animating out, so a tooltip inside a closing Popover or
13
+ Modal goes with it rather than outliving the panel.
9
14
 
10
15
  ```tsx
11
16
  <Tooltip content="Save changes" shortcut="⌘S">
12
17
  <Button>Save</Button>
13
18
  </Tooltip>
19
+ <Tooltip content="Drafts land here" open={tour === 'drafts'} onOpenChange={(next) => !next && nextStep()}>
20
+ <Button variant="ghost">Drafts</Button>
21
+ </Tooltip>
14
22
  ```
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { Fragment, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
3
+ import { Fragment, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
 
6
6
  import { Motion } from '../../../motion/element';
@@ -59,6 +59,8 @@ function targetBox(size: Size, t: DOMRect, want: Placement): TargetBox {
59
59
  };
60
60
  }
61
61
 
62
+ const surface = () => document.getElementById(TOOLTIP_DOM_ID);
63
+
62
64
  const fromEdge = (p: Placement) => ({
63
65
  x: p === 'left' ? SM.dist.sm : p === 'right' ? -SM.dist.sm : 0,
64
66
  y: p === 'top' ? SM.dist.sm : p === 'bottom' ? -SM.dist.sm : 0,
@@ -66,11 +68,11 @@ const fromEdge = (p: Placement) => ({
66
68
 
67
69
  function Body({ a, width }: { a: ActivePayload; width?: number }) {
68
70
  return (
69
- <span className="tooltip__body" style={width ? { width } : undefined}>
71
+ <span className="zc-tooltip__body" style={width ? { width } : undefined}>
70
72
  {a.shortcut ? (
71
- <span className="tooltip__row">
73
+ <span className="zc-tooltip__row">
72
74
  <span>{a.content}</span>
73
- <kbd className="tooltip__shortcut">{a.shortcut}</kbd>
75
+ <kbd className="zc-tooltip__shortcut">{a.shortcut}</kbd>
74
76
  </span>
75
77
  ) : (
76
78
  a.content
@@ -85,7 +87,7 @@ function TipSurface({ a, box }: { a: ActivePayload; box: RenderedBox }) {
85
87
  <Motion
86
88
  layout
87
89
  layoutTransition={TIP_LAYOUT}
88
- className="tooltip"
90
+ className="zc-tooltip"
89
91
  id={TOOLTIP_DOM_ID}
90
92
  role="tooltip"
91
93
  data-placement={box.placement}
@@ -109,43 +111,73 @@ function TipSurface({ a, box }: { a: ActivePayload; box: RenderedBox }) {
109
111
  export function TooltipHost() {
110
112
  const active = useSyncExternalStore(store.subscribe, store.get);
111
113
  const measureRef = useRef<HTMLDivElement>(null);
112
- const [box, setBox] = useState<RenderedBox | null>(null);
114
+ const drift = useRef({ x: 0, y: 0 });
115
+ const anchored = useRef({ x: 0, y: 0 });
116
+ const [shown, setShown] = useState<{ a: ActivePayload; box: RenderedBox } | null>(null);
113
117
 
114
118
  useLayoutEffect(() => {
115
119
  if (!active) {
116
- setBox(null);
117
- return;
120
+ setShown(null);
121
+ return undefined;
118
122
  }
119
- const r = measureRef.current.getBoundingClientRect();
120
- const b = (measureRef.current.firstChild as HTMLElement).getBoundingClientRect();
121
- setBox({
122
- ...targetBox({ w: Math.ceil(r.width), h: Math.ceil(r.height) }, active.rect(), active.placement),
123
- bodyW: Math.ceil(b.width),
124
- });
125
- }, [active]);
126
123
 
127
- useEffect(() => {
128
- if (!active) return undefined;
124
+ const place = () => {
125
+ const anchor = active.anchor();
126
+ const measure = measureRef.current;
127
+ if (!anchor || !measure) return;
128
+ const bubble = measure.getBoundingClientRect();
129
+ const body = (measure.firstChild as HTMLElement).getBoundingClientRect();
130
+ const from = anchor.getBoundingClientRect();
131
+ if (!from.width && !from.height) return;
132
+ if (!surface()) drift.current = { x: 0, y: 0 };
133
+ anchored.current = { x: from.left, y: from.top };
134
+ const to = targetBox({ w: Math.ceil(bubble.width), h: Math.ceil(bubble.height) }, from, active.placement);
135
+ setShown({
136
+ a: active,
137
+ box: { ...to, x: to.x - drift.current.x, y: to.y - drift.current.y, bodyW: Math.ceil(body.width) },
138
+ });
139
+ };
140
+
141
+ const track = () => {
142
+ const el = surface();
143
+ const anchor = active.anchor();
144
+ if (!el || !anchor) return;
145
+ const now = anchor.getBoundingClientRect();
146
+ if (!now.width && !now.height) return;
147
+ const at = {
148
+ x: drift.current.x + now.left - anchored.current.x,
149
+ y: drift.current.y + now.top - anchored.current.y,
150
+ };
151
+ drift.current = at;
152
+ anchored.current = { x: now.left, y: now.top };
153
+ el.style.transform = at.x || at.y ? `translate(${at.x}px, ${at.y}px)` : '';
154
+ };
155
+
129
156
  const onKey = (e: KeyboardEvent) => {
130
- if (e.key === 'Escape') store.closeNow();
157
+ if (e.key === 'Escape') store.dismiss();
131
158
  };
132
- const onScroll = () => store.closeNow();
159
+
160
+ place();
133
161
  document.addEventListener('keydown', onKey);
134
- window.addEventListener('scroll', onScroll, true);
162
+ window.addEventListener('scroll', track, true);
163
+ window.addEventListener('resize', place);
135
164
  return () => {
136
165
  document.removeEventListener('keydown', onKey);
137
- window.removeEventListener('scroll', onScroll, true);
166
+ window.removeEventListener('scroll', track, true);
167
+ window.removeEventListener('resize', place);
138
168
  };
139
169
  }, [active]);
140
170
 
171
+ const orphaned = !!shown && !shown.a.anchor();
172
+
141
173
  return createPortal(
142
174
  <Fragment>
143
175
  {active && (
144
- <div className="tooltip tooltip--measure" ref={measureRef} aria-hidden="true">
176
+ <div className="zc-tooltip zc-tooltip--measure" ref={measureRef} aria-hidden="true">
145
177
  <Body a={active} />
146
178
  </div>
147
179
  )}
148
- <Presence>{active && box && <TipSurface key="tip" a={active} box={box} />}</Presence>
180
+ <Presence>{active && shown && !orphaned && <TipSurface key="tip" a={shown.a} box={shown.box} />}</Presence>
149
181
  </Fragment>,
150
182
  document.body,
151
183
  );
@@ -1,6 +1,9 @@
1
1
  'use client';
2
2
 
3
- import { useEffect, useRef, useSyncExternalStore, type ReactNode } from 'react';
3
+ import { type ReactNode } from 'react';
4
+
5
+ import { sharedSlot } from '../../../shared-slot';
6
+ import { hostRegistry, useElectedHost } from '../../internal/hooks/use-host-election';
4
7
 
5
8
  export type Placement = 'top' | 'bottom' | 'left' | 'right';
6
9
 
@@ -10,7 +13,7 @@ export interface ActivePayload {
10
13
  shortcut?: string | null;
11
14
  placement: Placement;
12
15
  anchor: () => HTMLElement | null;
13
- rect: () => DOMRect;
16
+ dismiss: () => void;
14
17
  }
15
18
 
16
19
  export const OPEN_DELAY = 350;
@@ -18,74 +21,54 @@ export const CLOSE_GRACE = 140;
18
21
  export const TOOLTIP_DOM_ID = 'pds-tooltip';
19
22
  const WARM_WINDOW = 300;
20
23
 
21
- export const store = {
22
- active: null as ActivePayload | null,
24
+ export const store = sharedSlot('tooltip.store@1', () => ({
25
+ stack: [] as ActivePayload[],
23
26
  described: null as HTMLElement | null,
24
- closeTimer: 0 as ReturnType<typeof setTimeout> | 0,
27
+ timers: new Map<string, ReturnType<typeof setTimeout>>(),
25
28
  warmUntil: 0,
26
29
  listeners: new Set<() => void>(),
27
- get: () => store.active,
30
+ get: (): ActivePayload | null => store.stack[store.stack.length - 1] ?? null,
28
31
  subscribe(l: () => void) {
29
32
  store.listeners.add(l);
30
33
  return () => store.listeners.delete(l);
31
34
  },
32
35
  emit() {
36
+ const el = store.get()?.anchor() ?? null;
37
+ if (el !== store.described) {
38
+ store.described?.removeAttribute('aria-describedby');
39
+ store.described = el;
40
+ el?.setAttribute('aria-describedby', TOOLTIP_DOM_ID);
41
+ }
33
42
  store.listeners.forEach((l) => l());
34
43
  },
35
- isWarm: () => store.active !== null || performance.now() < store.warmUntil,
36
- describe(el: HTMLElement | null) {
37
- if (store.described === el) return;
38
- store.described?.removeAttribute('aria-describedby');
39
- store.described = el;
40
- el?.setAttribute('aria-describedby', TOOLTIP_DOM_ID);
41
- },
44
+ isWarm: () => store.stack.length > 0 || performance.now() < store.warmUntil,
42
45
  open(payload: ActivePayload) {
43
- clearTimeout(store.closeTimer);
44
- store.active = payload;
45
- store.describe(payload.anchor());
46
+ clearTimeout(store.timers.get(payload.id));
47
+ const at = store.stack.findIndex((entry) => entry.id === payload.id);
48
+ if (at < 0) store.stack.push(payload);
49
+ else store.stack[at] = payload;
46
50
  store.emit();
47
51
  },
48
52
  close(id: string, grace = CLOSE_GRACE) {
49
- clearTimeout(store.closeTimer);
50
- store.closeTimer = setTimeout(() => {
51
- if (store.active && store.active.id === id) store.closeNow();
52
- }, grace);
53
+ clearTimeout(store.timers.get(id));
54
+ const drop = () => {
55
+ store.timers.delete(id);
56
+ const at = store.stack.findIndex((entry) => entry.id === id);
57
+ if (at < 0) return;
58
+ store.stack.splice(at, 1);
59
+ if (!store.stack.length) store.warmUntil = performance.now() + WARM_WINDOW;
60
+ store.emit();
61
+ };
62
+ if (grace > 0) store.timers.set(id, setTimeout(drop, grace));
63
+ else drop();
53
64
  },
54
- closeNow() {
55
- clearTimeout(store.closeTimer);
56
- store.describe(null);
57
- if (!store.active) return;
58
- store.warmUntil = performance.now() + WARM_WINDOW;
59
- store.active = null;
60
- store.emit();
65
+ dismiss() {
66
+ for (const entry of store.stack.slice()) entry.dismiss();
61
67
  },
62
- };
68
+ }));
63
69
 
64
- const hostReg = {
65
- keys: [] as symbol[],
66
- listeners: new Set<() => void>(),
67
- subscribe(l: () => void) {
68
- hostReg.listeners.add(l);
69
- return () => hostReg.listeners.delete(l);
70
- },
71
- register(k: symbol) {
72
- hostReg.keys.push(k);
73
- hostReg.listeners.forEach((l) => l());
74
- return () => {
75
- const i = hostReg.keys.indexOf(k);
76
- if (i >= 0) hostReg.keys.splice(i, 1);
77
- hostReg.listeners.forEach((l) => l());
78
- };
79
- },
80
- };
70
+ const hostReg = hostRegistry('tooltip.host@1');
81
71
 
82
72
  export function useHostElection(): boolean {
83
- const keyRef = useRef<symbol | null>(null);
84
- if (!keyRef.current) keyRef.current = Symbol('tip-host');
85
- useEffect(() => hostReg.register(keyRef.current!), []);
86
- return useSyncExternalStore(
87
- hostReg.subscribe,
88
- () => hostReg.keys[0] === keyRef.current,
89
- () => false,
90
- );
73
+ return useElectedHost(hostReg, 'tip-host');
91
74
  }