aeon-ui-engine 1.0.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 (430) hide show
  1. package/.changeset/README.md +23 -0
  2. package/.changeset/combobox-and-changesets.md +9 -0
  3. package/.changeset/config.json +30 -0
  4. package/.changeset/framework-adapters.md +12 -0
  5. package/.changeset/scene-3d.md +6 -0
  6. package/.changeset/scene-plane.md +8 -0
  7. package/.changeset/site-og.md +5 -0
  8. package/.cursor/rules/aeon-ui.mdc +22 -0
  9. package/ACCESSIBILITY.md +32 -0
  10. package/AGENTS.md +226 -0
  11. package/COMPONENTS.md +36 -0
  12. package/FRAMEWORKS.md +57 -0
  13. package/INTEGRATION.md +89 -0
  14. package/LICENSE +21 -0
  15. package/PHILOSOPHY.md +71 -0
  16. package/PUBLISHING.md +85 -0
  17. package/README.md +154 -0
  18. package/SCENE.md +113 -0
  19. package/STATES.md +243 -0
  20. package/apps/demo/index.html +31 -0
  21. package/apps/demo/og.config.mjs +15 -0
  22. package/apps/demo/package.json +41 -0
  23. package/apps/demo/public/favicon.svg +16 -0
  24. package/apps/demo/public/og.png +0 -0
  25. package/apps/demo/public/og.svg +35 -0
  26. package/apps/demo/scripts/generate-og-png.mjs +60 -0
  27. package/apps/demo/src/App.tsx +31 -0
  28. package/apps/demo/src/aeonDiagrams.ts +100 -0
  29. package/apps/demo/src/app.css +16 -0
  30. package/apps/demo/src/components/ActionCluster.tsx +20 -0
  31. package/apps/demo/src/components/AsyncMachineDemo.tsx +97 -0
  32. package/apps/demo/src/components/ButtonLifecycleDemo.tsx +63 -0
  33. package/apps/demo/src/components/CodeExample.tsx +7 -0
  34. package/apps/demo/src/components/ComboboxDemo.tsx +30 -0
  35. package/apps/demo/src/components/DiagramsSection.tsx +38 -0
  36. package/apps/demo/src/components/FieldStateDemo.tsx +51 -0
  37. package/apps/demo/src/components/GridMesh.tsx +8 -0
  38. package/apps/demo/src/components/HeroInstall.tsx +10 -0
  39. package/apps/demo/src/components/LandingFaq.tsx +29 -0
  40. package/apps/demo/src/components/LandingFooter.tsx +22 -0
  41. package/apps/demo/src/components/LandingHeader.tsx +60 -0
  42. package/apps/demo/src/components/LandingHero.tsx +55 -0
  43. package/apps/demo/src/components/LayersSection.tsx +51 -0
  44. package/apps/demo/src/components/MermaidDiagram.tsx +84 -0
  45. package/apps/demo/src/components/PhilosophySection.tsx +33 -0
  46. package/apps/demo/src/components/PlaygroundBlock.tsx +23 -0
  47. package/apps/demo/src/components/PlaygroundSection.tsx +204 -0
  48. package/apps/demo/src/components/SceneSection.tsx +157 -0
  49. package/apps/demo/src/components/ScrollRegionDemo.tsx +74 -0
  50. package/apps/demo/src/components/ThemeSwitcher.tsx +76 -0
  51. package/apps/demo/src/demo-layout.css +264 -0
  52. package/apps/demo/src/landing.css +1094 -0
  53. package/apps/demo/src/main.tsx +14 -0
  54. package/apps/demo/src/nav.ts +9 -0
  55. package/apps/demo/src/site.ts +347 -0
  56. package/apps/demo/tsconfig.json +17 -0
  57. package/apps/demo/vite-plugins/og-meta.ts +30 -0
  58. package/apps/demo/vite.config.ts +69 -0
  59. package/docs/API_PATTERNS.md +234 -0
  60. package/docs/ARCHITECTURE.md +125 -0
  61. package/docs/COMPONENT_CHECKLIST.md +103 -0
  62. package/docs/FILE_MAP.md +122 -0
  63. package/docs/GLOSSARY.md +125 -0
  64. package/docs/INDEX.md +53 -0
  65. package/docs/LAYOUT_COORDINATES.md +178 -0
  66. package/docs/MACHINES.md +166 -0
  67. package/docs/MIGRATION_FROM_ARK.md +295 -0
  68. package/docs/VITE_CONSUMER.md +114 -0
  69. package/package.json +25 -0
  70. package/packages/core/README.md +69 -0
  71. package/packages/core/package.json +37 -0
  72. package/packages/core/src/anatomy.ts +144 -0
  73. package/packages/core/src/attrs.ts +47 -0
  74. package/packages/core/src/index.ts +8 -0
  75. package/packages/core/src/layout.ts +176 -0
  76. package/packages/core/src/machine.test.ts +18 -0
  77. package/packages/core/src/machine.ts +15 -0
  78. package/packages/core/src/philosophy.ts +10 -0
  79. package/packages/core/src/scroll.ts +72 -0
  80. package/packages/core/src/theme.test.ts +14 -0
  81. package/packages/core/src/theme.ts +53 -0
  82. package/packages/core/src/types.ts +25 -0
  83. package/packages/core/theme-transition.css +58 -0
  84. package/packages/core/tsconfig.json +8 -0
  85. package/packages/core/vitest.config.ts +8 -0
  86. package/packages/geometry/README.md +7 -0
  87. package/packages/geometry/package.json +35 -0
  88. package/packages/geometry/src/index.ts +3 -0
  89. package/packages/geometry/src/patterns.ts +55 -0
  90. package/packages/geometry/src/scene-attrs.ts +11 -0
  91. package/packages/geometry/src/svg.ts +60 -0
  92. package/packages/geometry/tsconfig.json +8 -0
  93. package/packages/panda/README.md +66 -0
  94. package/packages/panda/package.json +40 -0
  95. package/packages/panda/panda.config.ts +229 -0
  96. package/packages/panda/scripts/emit-theme-runtime.ts +37 -0
  97. package/packages/panda/src/recipes/accordion.ts +95 -0
  98. package/packages/panda/src/recipes/async.ts +76 -0
  99. package/packages/panda/src/recipes/badge.ts +44 -0
  100. package/packages/panda/src/recipes/button-group.ts +33 -0
  101. package/packages/panda/src/recipes/button.ts +91 -0
  102. package/packages/panda/src/recipes/checkbox.ts +41 -0
  103. package/packages/panda/src/recipes/combobox.ts +121 -0
  104. package/packages/panda/src/recipes/dialog.ts +96 -0
  105. package/packages/panda/src/recipes/field-shared.ts +29 -0
  106. package/packages/panda/src/recipes/field.ts +72 -0
  107. package/packages/panda/src/recipes/floating.ts +170 -0
  108. package/packages/panda/src/recipes/index.ts +14 -0
  109. package/packages/panda/src/recipes/scroll-region.ts +55 -0
  110. package/packages/panda/src/recipes/select.ts +111 -0
  111. package/packages/panda/src/recipes/switch.ts +51 -0
  112. package/packages/panda/src/recipes/tabs.ts +50 -0
  113. package/packages/panda/src/theme/catalog-types.ts +24 -0
  114. package/packages/panda/src/theme/catalog.ts +73 -0
  115. package/packages/panda/src/theme/chrome.css +75 -0
  116. package/packages/panda/src/theme/global-theme-css.ts +42 -0
  117. package/packages/panda/src/theme/index.ts +5 -0
  118. package/packages/panda/src/theme/palette.ts +65 -0
  119. package/packages/panda/src/theme/scrollbars.css +96 -0
  120. package/packages/panda/src/theme/semantic-tokens.ts +17 -0
  121. package/packages/panda/src/theme/themes.config.ts +516 -0
  122. package/packages/panda/src/theme/tokens.ts +51 -0
  123. package/packages/panda/styled-system/css/conditions.mjs +36 -0
  124. package/packages/panda/styled-system/css/css.d.ts +22 -0
  125. package/packages/panda/styled-system/css/css.mjs +45 -0
  126. package/packages/panda/styled-system/css/cva.d.ts +6 -0
  127. package/packages/panda/styled-system/css/cva.mjs +87 -0
  128. package/packages/panda/styled-system/css/cx.d.ts +5 -0
  129. package/packages/panda/styled-system/css/cx.mjs +15 -0
  130. package/packages/panda/styled-system/css/index.d.ts +5 -0
  131. package/packages/panda/styled-system/css/index.mjs +4 -0
  132. package/packages/panda/styled-system/css/sva.d.ts +4 -0
  133. package/packages/panda/styled-system/css/sva.mjs +41 -0
  134. package/packages/panda/styled-system/helpers.mjs +339 -0
  135. package/packages/panda/styled-system/jsx/aspect-ratio.d.ts +10 -0
  136. package/packages/panda/styled-system/jsx/aspect-ratio.mjs +14 -0
  137. package/packages/panda/styled-system/jsx/bleed.d.ts +10 -0
  138. package/packages/panda/styled-system/jsx/bleed.mjs +14 -0
  139. package/packages/panda/styled-system/jsx/box.d.ts +10 -0
  140. package/packages/panda/styled-system/jsx/box.mjs +14 -0
  141. package/packages/panda/styled-system/jsx/center.d.ts +10 -0
  142. package/packages/panda/styled-system/jsx/center.mjs +14 -0
  143. package/packages/panda/styled-system/jsx/circle.d.ts +10 -0
  144. package/packages/panda/styled-system/jsx/circle.mjs +14 -0
  145. package/packages/panda/styled-system/jsx/container.d.ts +10 -0
  146. package/packages/panda/styled-system/jsx/container.mjs +14 -0
  147. package/packages/panda/styled-system/jsx/cq.d.ts +10 -0
  148. package/packages/panda/styled-system/jsx/cq.mjs +14 -0
  149. package/packages/panda/styled-system/jsx/divider.d.ts +10 -0
  150. package/packages/panda/styled-system/jsx/divider.mjs +14 -0
  151. package/packages/panda/styled-system/jsx/factory-helper.mjs +22 -0
  152. package/packages/panda/styled-system/jsx/factory.d.ts +3 -0
  153. package/packages/panda/styled-system/jsx/factory.mjs +80 -0
  154. package/packages/panda/styled-system/jsx/flex.d.ts +10 -0
  155. package/packages/panda/styled-system/jsx/flex.mjs +14 -0
  156. package/packages/panda/styled-system/jsx/float.d.ts +10 -0
  157. package/packages/panda/styled-system/jsx/float.mjs +14 -0
  158. package/packages/panda/styled-system/jsx/grid-item.d.ts +10 -0
  159. package/packages/panda/styled-system/jsx/grid-item.mjs +14 -0
  160. package/packages/panda/styled-system/jsx/grid.d.ts +10 -0
  161. package/packages/panda/styled-system/jsx/grid.mjs +14 -0
  162. package/packages/panda/styled-system/jsx/hstack.d.ts +10 -0
  163. package/packages/panda/styled-system/jsx/hstack.mjs +14 -0
  164. package/packages/panda/styled-system/jsx/index.d.ts +24 -0
  165. package/packages/panda/styled-system/jsx/index.mjs +22 -0
  166. package/packages/panda/styled-system/jsx/is-valid-prop.d.ts +11 -0
  167. package/packages/panda/styled-system/jsx/is-valid-prop.mjs +17 -0
  168. package/packages/panda/styled-system/jsx/link-overlay.d.ts +10 -0
  169. package/packages/panda/styled-system/jsx/link-overlay.mjs +14 -0
  170. package/packages/panda/styled-system/jsx/spacer.d.ts +10 -0
  171. package/packages/panda/styled-system/jsx/spacer.mjs +14 -0
  172. package/packages/panda/styled-system/jsx/square.d.ts +10 -0
  173. package/packages/panda/styled-system/jsx/square.mjs +14 -0
  174. package/packages/panda/styled-system/jsx/stack.d.ts +10 -0
  175. package/packages/panda/styled-system/jsx/stack.mjs +14 -0
  176. package/packages/panda/styled-system/jsx/visually-hidden.d.ts +10 -0
  177. package/packages/panda/styled-system/jsx/visually-hidden.mjs +14 -0
  178. package/packages/panda/styled-system/jsx/vstack.d.ts +10 -0
  179. package/packages/panda/styled-system/jsx/vstack.mjs +14 -0
  180. package/packages/panda/styled-system/jsx/wrap.d.ts +10 -0
  181. package/packages/panda/styled-system/jsx/wrap.mjs +14 -0
  182. package/packages/panda/styled-system/patterns/aspect-ratio.d.ts +21 -0
  183. package/packages/panda/styled-system/patterns/aspect-ratio.mjs +38 -0
  184. package/packages/panda/styled-system/patterns/bleed.d.ts +22 -0
  185. package/packages/panda/styled-system/patterns/bleed.mjs +24 -0
  186. package/packages/panda/styled-system/patterns/box.d.ts +21 -0
  187. package/packages/panda/styled-system/patterns/box.mjs +15 -0
  188. package/packages/panda/styled-system/patterns/center.d.ts +21 -0
  189. package/packages/panda/styled-system/patterns/center.mjs +21 -0
  190. package/packages/panda/styled-system/patterns/circle.d.ts +21 -0
  191. package/packages/panda/styled-system/patterns/circle.mjs +25 -0
  192. package/packages/panda/styled-system/patterns/container.d.ts +21 -0
  193. package/packages/panda/styled-system/patterns/container.mjs +21 -0
  194. package/packages/panda/styled-system/patterns/cq.d.ts +22 -0
  195. package/packages/panda/styled-system/patterns/cq.mjs +21 -0
  196. package/packages/panda/styled-system/patterns/divider.d.ts +23 -0
  197. package/packages/panda/styled-system/patterns/divider.mjs +25 -0
  198. package/packages/panda/styled-system/patterns/flex.d.ts +27 -0
  199. package/packages/panda/styled-system/patterns/flex.mjs +26 -0
  200. package/packages/panda/styled-system/patterns/float.d.ts +24 -0
  201. package/packages/panda/styled-system/patterns/float.mjs +52 -0
  202. package/packages/panda/styled-system/patterns/grid-item.d.ts +26 -0
  203. package/packages/panda/styled-system/patterns/grid-item.mjs +25 -0
  204. package/packages/panda/styled-system/patterns/grid.d.ts +25 -0
  205. package/packages/panda/styled-system/patterns/grid.mjs +27 -0
  206. package/packages/panda/styled-system/patterns/hstack.d.ts +22 -0
  207. package/packages/panda/styled-system/patterns/hstack.mjs +24 -0
  208. package/packages/panda/styled-system/patterns/index.d.ts +21 -0
  209. package/packages/panda/styled-system/patterns/index.mjs +20 -0
  210. package/packages/panda/styled-system/patterns/link-overlay.d.ts +21 -0
  211. package/packages/panda/styled-system/patterns/link-overlay.mjs +24 -0
  212. package/packages/panda/styled-system/patterns/spacer.d.ts +21 -0
  213. package/packages/panda/styled-system/patterns/spacer.mjs +21 -0
  214. package/packages/panda/styled-system/patterns/square.d.ts +21 -0
  215. package/packages/panda/styled-system/patterns/square.mjs +24 -0
  216. package/packages/panda/styled-system/patterns/stack.d.ts +24 -0
  217. package/packages/panda/styled-system/patterns/stack.mjs +24 -0
  218. package/packages/panda/styled-system/patterns/visually-hidden.d.ts +21 -0
  219. package/packages/panda/styled-system/patterns/visually-hidden.mjs +18 -0
  220. package/packages/panda/styled-system/patterns/vstack.d.ts +22 -0
  221. package/packages/panda/styled-system/patterns/vstack.mjs +24 -0
  222. package/packages/panda/styled-system/patterns/wrap.d.ts +25 -0
  223. package/packages/panda/styled-system/patterns/wrap.mjs +25 -0
  224. package/packages/panda/styled-system/recipes/aeon-accordion.d.ts +32 -0
  225. package/packages/panda/styled-system/recipes/aeon-accordion.mjs +48 -0
  226. package/packages/panda/styled-system/recipes/aeon-async.d.ts +32 -0
  227. package/packages/panda/styled-system/recipes/aeon-async.mjs +56 -0
  228. package/packages/panda/styled-system/recipes/aeon-badge.d.ts +31 -0
  229. package/packages/panda/styled-system/recipes/aeon-badge.mjs +32 -0
  230. package/packages/panda/styled-system/recipes/aeon-button-group.d.ts +39 -0
  231. package/packages/panda/styled-system/recipes/aeon-button-group.mjs +37 -0
  232. package/packages/panda/styled-system/recipes/aeon-button.d.ts +39 -0
  233. package/packages/panda/styled-system/recipes/aeon-button.mjs +39 -0
  234. package/packages/panda/styled-system/recipes/aeon-checkbox.d.ts +28 -0
  235. package/packages/panda/styled-system/recipes/aeon-checkbox.mjs +48 -0
  236. package/packages/panda/styled-system/recipes/aeon-combobox.d.ts +32 -0
  237. package/packages/panda/styled-system/recipes/aeon-combobox.mjs +52 -0
  238. package/packages/panda/styled-system/recipes/aeon-dialog.d.ts +28 -0
  239. package/packages/panda/styled-system/recipes/aeon-dialog.mjs +60 -0
  240. package/packages/panda/styled-system/recipes/aeon-field.d.ts +32 -0
  241. package/packages/panda/styled-system/recipes/aeon-field.mjs +52 -0
  242. package/packages/panda/styled-system/recipes/aeon-menu.d.ts +28 -0
  243. package/packages/panda/styled-system/recipes/aeon-menu.mjs +52 -0
  244. package/packages/panda/styled-system/recipes/aeon-popover.d.ts +28 -0
  245. package/packages/panda/styled-system/recipes/aeon-popover.mjs +52 -0
  246. package/packages/panda/styled-system/recipes/aeon-scroll.d.ts +43 -0
  247. package/packages/panda/styled-system/recipes/aeon-scroll.mjs +63 -0
  248. package/packages/panda/styled-system/recipes/aeon-select.d.ts +32 -0
  249. package/packages/panda/styled-system/recipes/aeon-select.mjs +56 -0
  250. package/packages/panda/styled-system/recipes/aeon-switch.d.ts +28 -0
  251. package/packages/panda/styled-system/recipes/aeon-switch.mjs +48 -0
  252. package/packages/panda/styled-system/recipes/aeon-tabs.d.ts +28 -0
  253. package/packages/panda/styled-system/recipes/aeon-tabs.mjs +48 -0
  254. package/packages/panda/styled-system/recipes/aeon-toast.d.ts +28 -0
  255. package/packages/panda/styled-system/recipes/aeon-toast.mjs +48 -0
  256. package/packages/panda/styled-system/recipes/aeon-tooltip.d.ts +28 -0
  257. package/packages/panda/styled-system/recipes/aeon-tooltip.mjs +48 -0
  258. package/packages/panda/styled-system/recipes/create-recipe.mjs +82 -0
  259. package/packages/panda/styled-system/recipes/index.d.ts +18 -0
  260. package/packages/panda/styled-system/recipes/index.mjs +17 -0
  261. package/packages/panda/styled-system/styles.css +2157 -0
  262. package/packages/panda/styled-system/tokens/index.d.ts +9 -0
  263. package/packages/panda/styled-system/tokens/index.mjs +2156 -0
  264. package/packages/panda/styled-system/tokens/tokens.d.ts +60 -0
  265. package/packages/panda/styled-system/types/composition.d.ts +164 -0
  266. package/packages/panda/styled-system/types/conditions.d.ts +322 -0
  267. package/packages/panda/styled-system/types/csstype.d.ts +21298 -0
  268. package/packages/panda/styled-system/types/global.d.ts +20 -0
  269. package/packages/panda/styled-system/types/index.d.ts +8 -0
  270. package/packages/panda/styled-system/types/jsx.d.ts +52 -0
  271. package/packages/panda/styled-system/types/parts.d.ts +8 -0
  272. package/packages/panda/styled-system/types/pattern.d.ts +78 -0
  273. package/packages/panda/styled-system/types/prop-type.d.ts +240 -0
  274. package/packages/panda/styled-system/types/recipe.d.ts +181 -0
  275. package/packages/panda/styled-system/types/selectors.d.ts +59 -0
  276. package/packages/panda/styled-system/types/static-css.d.ts +56 -0
  277. package/packages/panda/styled-system/types/style-props.d.ts +7491 -0
  278. package/packages/panda/styled-system/types/system-types.d.ts +193 -0
  279. package/packages/panda/theme-runtime.css +842 -0
  280. package/packages/panda/tsconfig.json +8 -0
  281. package/packages/primitives/README.md +54 -0
  282. package/packages/primitives/package.json +41 -0
  283. package/packages/primitives/src/__tests__/floating-surface.test.ts +29 -0
  284. package/packages/primitives/src/index.ts +9 -0
  285. package/packages/primitives/src/machines/accordion.ts +56 -0
  286. package/packages/primitives/src/machines/async.ts +108 -0
  287. package/packages/primitives/src/machines/button.ts +66 -0
  288. package/packages/primitives/src/machines/dialog.ts +61 -0
  289. package/packages/primitives/src/machines/field.ts +85 -0
  290. package/packages/primitives/src/machines/popover.ts +52 -0
  291. package/packages/primitives/src/machines/tabs.ts +46 -0
  292. package/packages/primitives/src/machines/toast.ts +48 -0
  293. package/packages/primitives/src/machines/toggle.ts +61 -0
  294. package/packages/primitives/tsconfig.json +8 -0
  295. package/packages/primitives/vitest.config.ts +8 -0
  296. package/packages/react/README.md +65 -0
  297. package/packages/react/package.json +52 -0
  298. package/packages/react/src/accordion/index.tsx +179 -0
  299. package/packages/react/src/async/actions.tsx +22 -0
  300. package/packages/react/src/async/context.tsx +54 -0
  301. package/packages/react/src/async/index.tsx +21 -0
  302. package/packages/react/src/async/legacy-region.tsx +38 -0
  303. package/packages/react/src/async/readout.tsx +34 -0
  304. package/packages/react/src/async/root.tsx +39 -0
  305. package/packages/react/src/async/track.tsx +59 -0
  306. package/packages/react/src/avatar/avatar.test.tsx +27 -0
  307. package/packages/react/src/avatar/index.tsx +122 -0
  308. package/packages/react/src/button/index.tsx +70 -0
  309. package/packages/react/src/checkbox/index.tsx +180 -0
  310. package/packages/react/src/combobox/index.tsx +430 -0
  311. package/packages/react/src/dialog/dialog.test.tsx +50 -0
  312. package/packages/react/src/dialog/index.tsx +275 -0
  313. package/packages/react/src/field/index.tsx +172 -0
  314. package/packages/react/src/hooks/use-aeon-machine.ts +10 -0
  315. package/packages/react/src/hooks/use-anchor-position.ts +33 -0
  316. package/packages/react/src/hooks/use-focus-trap.ts +51 -0
  317. package/packages/react/src/hooks/use-layout-mode.ts +22 -0
  318. package/packages/react/src/hooks/use-outside-click.ts +19 -0
  319. package/packages/react/src/hooks/use-portalled.ts +16 -0
  320. package/packages/react/src/hooks/use-scroll-lock.ts +13 -0
  321. package/packages/react/src/index.ts +18 -0
  322. package/packages/react/src/menu/index.tsx +195 -0
  323. package/packages/react/src/popover/index.tsx +191 -0
  324. package/packages/react/src/scroll/index.tsx +98 -0
  325. package/packages/react/src/scroll/use-scroll-state.ts +30 -0
  326. package/packages/react/src/select/index.tsx +372 -0
  327. package/packages/react/src/select/select.test.tsx +60 -0
  328. package/packages/react/src/switch/index.tsx +215 -0
  329. package/packages/react/src/tabs/index.tsx +140 -0
  330. package/packages/react/src/toast/context.tsx +28 -0
  331. package/packages/react/src/toast/index.tsx +20 -0
  332. package/packages/react/src/toast/primitives.tsx +129 -0
  333. package/packages/react/src/toast/provider.tsx +111 -0
  334. package/packages/react/src/toast/toast-item.tsx +32 -0
  335. package/packages/react/src/tooltip/index.tsx +191 -0
  336. package/packages/react/src/utils/merge-props.ts +24 -0
  337. package/packages/react/tsconfig.json +8 -0
  338. package/packages/react/vitest.config.ts +9 -0
  339. package/packages/react/vitest.setup.ts +5 -0
  340. package/packages/react-scene/README.md +11 -0
  341. package/packages/react-scene/package.json +47 -0
  342. package/packages/react-scene/scene-3d.css +37 -0
  343. package/packages/react-scene/scene-room.css +95 -0
  344. package/packages/react-scene/src/index.ts +20 -0
  345. package/packages/react-scene/src/procedural-grid.tsx +35 -0
  346. package/packages/react-scene/src/scene-layer.tsx +38 -0
  347. package/packages/react-scene/src/scene-plane.tsx +69 -0
  348. package/packages/react-scene/src/scene-room.tsx +81 -0
  349. package/packages/react-scene/src/scene-root.tsx +49 -0
  350. package/packages/react-scene/src/scene-slot.tsx +41 -0
  351. package/packages/react-scene/src/scene-stage.tsx +37 -0
  352. package/packages/react-scene/src/scene-surface.tsx +20 -0
  353. package/packages/react-scene/src/signal-bars.tsx +57 -0
  354. package/packages/react-scene/src/use-signal-visualizer.ts +103 -0
  355. package/packages/react-scene/tsconfig.json +8 -0
  356. package/packages/scene/README.md +5 -0
  357. package/packages/scene/package.json +32 -0
  358. package/packages/scene/src/index.ts +2 -0
  359. package/packages/scene/src/room.ts +40 -0
  360. package/packages/scene/src/transform.ts +60 -0
  361. package/packages/scene/tsconfig.json +8 -0
  362. package/packages/signal/README.md +9 -0
  363. package/packages/signal/package.json +32 -0
  364. package/packages/signal/src/analyser.ts +113 -0
  365. package/packages/signal/src/bands.ts +33 -0
  366. package/packages/signal/src/index.ts +3 -0
  367. package/packages/signal/src/motion.ts +80 -0
  368. package/packages/signal/tsconfig.json +8 -0
  369. package/packages/site/README.md +19 -0
  370. package/packages/site/package.json +32 -0
  371. package/packages/site/src/index.ts +8 -0
  372. package/packages/site/src/open-graph.ts +90 -0
  373. package/packages/site/tsconfig.json +8 -0
  374. package/packages/solid/README.md +30 -0
  375. package/packages/solid/package.json +42 -0
  376. package/packages/solid/src/hooks/use-aeon-machine.ts +10 -0
  377. package/packages/solid/src/index.ts +2 -0
  378. package/packages/solid/src/switch/index.tsx +191 -0
  379. package/packages/solid/src/utils/merge-props.ts +3 -0
  380. package/packages/solid/tsconfig.json +10 -0
  381. package/packages/surface/README.md +10 -0
  382. package/packages/surface/package.json +33 -0
  383. package/packages/surface/src/index.ts +1 -0
  384. package/packages/surface/src/materials.ts +14 -0
  385. package/packages/surface/surface.css +113 -0
  386. package/packages/surface/tsconfig.json +8 -0
  387. package/packages/svelte/README.md +45 -0
  388. package/packages/svelte/package.json +49 -0
  389. package/packages/svelte/src/Switch.svelte +86 -0
  390. package/packages/svelte/src/SwitchControl.svelte +45 -0
  391. package/packages/svelte/src/SwitchHiddenInput.svelte +12 -0
  392. package/packages/svelte/src/SwitchLabel.svelte +9 -0
  393. package/packages/svelte/src/SwitchThumb.svelte +16 -0
  394. package/packages/svelte/src/hooks/use-aeon-machine.ts +23 -0
  395. package/packages/svelte/src/index.ts +2 -0
  396. package/packages/svelte/src/switch-context.ts +13 -0
  397. package/packages/svelte/tsconfig.json +8 -0
  398. package/packages/ui/README.md +63 -0
  399. package/packages/ui/package.json +45 -0
  400. package/packages/ui/src/accordion.tsx +27 -0
  401. package/packages/ui/src/async.tsx +43 -0
  402. package/packages/ui/src/badge.tsx +18 -0
  403. package/packages/ui/src/button.tsx +38 -0
  404. package/packages/ui/src/checkbox.tsx +24 -0
  405. package/packages/ui/src/cn.ts +1 -0
  406. package/packages/ui/src/combobox.tsx +29 -0
  407. package/packages/ui/src/dialog.tsx +32 -0
  408. package/packages/ui/src/field.tsx +33 -0
  409. package/packages/ui/src/index.ts +17 -0
  410. package/packages/ui/src/menu.tsx +25 -0
  411. package/packages/ui/src/popover.tsx +22 -0
  412. package/packages/ui/src/scroll.tsx +51 -0
  413. package/packages/ui/src/select.tsx +33 -0
  414. package/packages/ui/src/styles.css +2 -0
  415. package/packages/ui/src/switch.tsx +22 -0
  416. package/packages/ui/src/tabs.tsx +22 -0
  417. package/packages/ui/src/toast.tsx +36 -0
  418. package/packages/ui/src/tooltip.tsx +19 -0
  419. package/packages/ui/tsconfig.json +12 -0
  420. package/packages/vue/README.md +40 -0
  421. package/packages/vue/package.json +42 -0
  422. package/packages/vue/src/hooks/use-aeon-machine.ts +10 -0
  423. package/packages/vue/src/index.ts +2 -0
  424. package/packages/vue/src/switch/index.ts +208 -0
  425. package/packages/vue/src/utils/part-props.ts +8 -0
  426. package/packages/vue/tsconfig.json +8 -0
  427. package/pnpm-workspace.yaml +3 -0
  428. package/scripts/ensure-headless-built.mjs +25 -0
  429. package/tsconfig.base.json +21 -0
  430. package/vercel.json +12 -0
@@ -0,0 +1,140 @@
1
+ import { partAttrs, tabsAnatomy } from '@aeon-ui/core'
2
+ import { tabsMachine } from '@aeon-ui/primitives'
3
+ import {
4
+ createContext,
5
+ forwardRef,
6
+ useContext,
7
+ useEffect,
8
+ useMemo,
9
+ type ButtonHTMLAttributes,
10
+ type HTMLAttributes,
11
+ type MouseEvent,
12
+ type ReactNode,
13
+ } from 'react'
14
+ import { useAeonMachine } from '../hooks/use-aeon-machine.js'
15
+ import { mergeProps } from '../utils/merge-props.js'
16
+
17
+ interface TabsContextValue {
18
+ value: string
19
+ send: ReturnType<typeof useAeonMachine<typeof tabsMachine>>[1]
20
+ }
21
+
22
+ const TabsCtx = createContext<TabsContextValue | null>(null)
23
+
24
+ function useTabsCtx() {
25
+ const ctx = useContext(TabsCtx)
26
+ if (!ctx) throw new Error('Tabs parts must be used within Tabs.Root')
27
+ return ctx
28
+ }
29
+
30
+ export interface TabsRootProps {
31
+ value?: string
32
+ defaultValue?: string
33
+ onValueChange?: (value: string) => void
34
+ children?: ReactNode
35
+ className?: string
36
+ }
37
+
38
+ const Root = forwardRef<HTMLDivElement, TabsRootProps>(function TabsRoot(
39
+ { value, defaultValue = '', onValueChange, children, className, ...rest },
40
+ ref,
41
+ ) {
42
+ const [snapshot, send] = useAeonMachine(tabsMachine, {
43
+ input: { value: defaultValue, disabled: false },
44
+ })
45
+
46
+ const resolvedValue = value ?? snapshot.context.value
47
+
48
+ useEffect(() => {
49
+ onValueChange?.(resolvedValue)
50
+ }, [resolvedValue, onValueChange])
51
+
52
+ useEffect(() => {
53
+ if (value !== undefined) send({ type: 'SET_VALUE', value })
54
+ }, [value, send])
55
+
56
+ const ctx = useMemo(() => ({ value: resolvedValue, send }), [resolvedValue, send])
57
+
58
+ return (
59
+ <TabsCtx.Provider value={ctx}>
60
+ <div
61
+ ref={ref}
62
+ className={className}
63
+ {...mergeProps(partAttrs(tabsAnatomy.scope, tabsAnatomy.root), rest as HTMLAttributes<HTMLDivElement>)}
64
+ >
65
+ {children}
66
+ </div>
67
+ </TabsCtx.Provider>
68
+ )
69
+ })
70
+
71
+ const List = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function TabsList(props, ref) {
72
+ return <div ref={ref} role="tablist" {...mergeProps(partAttrs(tabsAnatomy.scope, tabsAnatomy.list), props)} />
73
+ })
74
+
75
+ export interface TabsTriggerProps extends ButtonHTMLAttributes<HTMLButtonElement> {
76
+ value: string
77
+ }
78
+
79
+ const Trigger = forwardRef<HTMLButtonElement, TabsTriggerProps>(function TabsTrigger(
80
+ { value: triggerValue, onClick, ...rest },
81
+ ref,
82
+ ) {
83
+ const { value, send } = useTabsCtx()
84
+ const selected = value === triggerValue
85
+
86
+ return (
87
+ <button
88
+ ref={ref}
89
+ type="button"
90
+ role="tab"
91
+ aria-selected={selected}
92
+ data-selected={selected ? '' : undefined}
93
+ {...mergeProps(
94
+ partAttrs(tabsAnatomy.scope, tabsAnatomy.trigger, {
95
+ state: selected ? 'selected' : 'unselected',
96
+ highlighted: selected,
97
+ }),
98
+ {
99
+ onClick: (e: MouseEvent<HTMLButtonElement>) => {
100
+ onClick?.(e)
101
+ send({ type: 'SELECT', value: triggerValue })
102
+ },
103
+ },
104
+ rest,
105
+ )}
106
+ />
107
+ )
108
+ })
109
+
110
+ export interface TabsContentProps extends HTMLAttributes<HTMLDivElement> {
111
+ value: string
112
+ }
113
+
114
+ const Content = forwardRef<HTMLDivElement, TabsContentProps>(function TabsContent(
115
+ { value: contentValue, ...rest },
116
+ ref,
117
+ ) {
118
+ const { value } = useTabsCtx()
119
+ if (value !== contentValue) return null
120
+
121
+ return (
122
+ <div
123
+ ref={ref}
124
+ role="tabpanel"
125
+ {...mergeProps(
126
+ partAttrs(tabsAnatomy.scope, tabsAnatomy.content, { state: 'active' }),
127
+ rest,
128
+ )}
129
+ />
130
+ )
131
+ })
132
+
133
+ const Indicator = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function TabsIndicator(
134
+ props,
135
+ ref,
136
+ ) {
137
+ return <div ref={ref} {...mergeProps(partAttrs(tabsAnatomy.scope, tabsAnatomy.indicator), props)} />
138
+ })
139
+
140
+ export const Tabs = { Root, List, Trigger, Content, Indicator }
@@ -0,0 +1,28 @@
1
+ import { createContext, useContext, type ReactNode } from 'react'
2
+
3
+ export type ToastPublishOptions = {
4
+ id?: string
5
+ title?: ReactNode
6
+ description?: ReactNode
7
+ /** Auto-dismiss after ms (0 = no auto dismiss). Default 5000. */
8
+ durationMs?: number
9
+ }
10
+
11
+ export type ToastRecord = ToastPublishOptions & { id: string }
12
+
13
+ export type ToastStore = {
14
+ items: ToastRecord[]
15
+ publish: (options: ToastPublishOptions) => string
16
+ dismiss: (id: string) => void
17
+ dismissAll: () => void
18
+ }
19
+
20
+ export const ToastStoreCtx = createContext<ToastStore | null>(null)
21
+
22
+ export function useToastStore(): ToastStore {
23
+ const ctx = useContext(ToastStoreCtx)
24
+ if (!ctx) {
25
+ throw new Error('useToast must be used within Toast.Provider')
26
+ }
27
+ return ctx
28
+ }
@@ -0,0 +1,20 @@
1
+ import { CloseTrigger, Description, Root, Show, Title } from './primitives.js'
2
+ import { ToastProvider, ToastViewport, useToast } from './provider.js'
3
+
4
+ export type { ToastRootProps } from './primitives.js'
5
+ export type { ToastPublishOptions, ToastRecord, ToastStore } from './context.js'
6
+ export type { ToastPlacement, ToastProviderProps, ToastViewportProps } from './provider.js'
7
+ export { useToastStore } from './context.js'
8
+ export { ToastItem } from './toast-item.js'
9
+
10
+ export const Toast = {
11
+ Provider: ToastProvider,
12
+ Viewport: ToastViewport,
13
+ Root,
14
+ Title,
15
+ Description,
16
+ CloseTrigger,
17
+ Show,
18
+ }
19
+
20
+ export { useToast }
@@ -0,0 +1,129 @@
1
+ import { toastAnatomy, partAttrs } from '@aeon-ui/core'
2
+ import { toastMachine } from '@aeon-ui/primitives'
3
+ import {
4
+ createContext,
5
+ forwardRef,
6
+ useContext,
7
+ useEffect,
8
+ useId,
9
+ useMemo,
10
+ type ButtonHTMLAttributes,
11
+ type HTMLAttributes,
12
+ type MouseEvent,
13
+ type ReactNode,
14
+ } from 'react'
15
+ import { useAeonMachine } from '../hooks/use-aeon-machine.js'
16
+ import { mergeProps } from '../utils/merge-props.js'
17
+
18
+ interface ToastContextValue {
19
+ visible: boolean
20
+ send: ReturnType<typeof useAeonMachine<typeof toastMachine>>[1]
21
+ titleId: string
22
+ }
23
+
24
+ const ToastCtx = createContext<ToastContextValue | null>(null)
25
+
26
+ function useToastCtx() {
27
+ const ctx = useContext(ToastCtx)
28
+ if (!ctx) throw new Error('Toast parts must be used within Toast.Root')
29
+ return ctx
30
+ }
31
+
32
+ export interface ToastRootProps {
33
+ durationMs?: number
34
+ defaultVisible?: boolean
35
+ onVisibleChange?: (visible: boolean) => void
36
+ children?: ReactNode
37
+ className?: string
38
+ }
39
+
40
+ export const Root = forwardRef<HTMLDivElement, ToastRootProps>(function ToastRoot(
41
+ { durationMs = 5000, defaultVisible = false, onVisibleChange, children, className, ...rest },
42
+ ref,
43
+ ) {
44
+ const [snapshot, send] = useAeonMachine(toastMachine, { input: { durationMs } })
45
+ const visible = snapshot.matches('visible')
46
+ const titleId = useId()
47
+
48
+ useEffect(() => {
49
+ if (defaultVisible) send({ type: 'SHOW' })
50
+ }, [defaultVisible, send])
51
+
52
+ useEffect(() => {
53
+ onVisibleChange?.(visible)
54
+ }, [visible, onVisibleChange])
55
+
56
+ const value = useMemo(() => ({ visible, send, titleId }), [visible, send, titleId])
57
+
58
+ return (
59
+ <ToastCtx.Provider value={value}>
60
+ <div
61
+ ref={ref}
62
+ role="status"
63
+ aria-live="polite"
64
+ aria-atomic="true"
65
+ {...mergeProps(
66
+ partAttrs(toastAnatomy.scope, toastAnatomy.root, { state: visible ? 'visible' : 'hidden' }),
67
+ rest as HTMLAttributes<HTMLDivElement>,
68
+ )}
69
+ className={className}
70
+ hidden={!visible}
71
+ >
72
+ {visible ? children : null}
73
+ </div>
74
+ </ToastCtx.Provider>
75
+ )
76
+ })
77
+
78
+ export const Title = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(function ToastTitle(
79
+ props,
80
+ ref,
81
+ ) {
82
+ const { titleId } = useToastCtx()
83
+ return (
84
+ <p ref={ref} id={titleId} {...mergeProps(partAttrs(toastAnatomy.scope, toastAnatomy.title), props)} />
85
+ )
86
+ })
87
+
88
+ export const Description = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
89
+ function ToastDescription(props, ref) {
90
+ return <p ref={ref} {...mergeProps(partAttrs(toastAnatomy.scope, toastAnatomy.description), props)} />
91
+ },
92
+ )
93
+
94
+ export const CloseTrigger = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLButtonElement>>(
95
+ function ToastCloseTrigger({ onClick, children, ...rest }, ref) {
96
+ const { send } = useToastCtx()
97
+ return (
98
+ <button
99
+ ref={ref}
100
+ type="button"
101
+ aria-label={typeof children === 'string' ? undefined : 'Dismiss'}
102
+ {...mergeProps(
103
+ partAttrs(toastAnatomy.scope, toastAnatomy.closeTrigger),
104
+ {
105
+ onClick: (e: MouseEvent<HTMLButtonElement>) => {
106
+ onClick?.(e)
107
+ send({ type: 'DISMISS' })
108
+ },
109
+ },
110
+ rest,
111
+ )}
112
+ >
113
+ {children ?? 'Dismiss'}
114
+ </button>
115
+ )
116
+ },
117
+ )
118
+
119
+ /** Programmatically show a declarative Toast.Root instance. */
120
+ export function Show({ durationMs }: { durationMs?: number }) {
121
+ const { send } = useToastCtx()
122
+ useEffect(() => {
123
+ send({ type: 'SHOW' })
124
+ if (durationMs !== undefined) {
125
+ return () => send({ type: 'DISMISS' })
126
+ }
127
+ }, [send, durationMs])
128
+ return null
129
+ }
@@ -0,0 +1,111 @@
1
+ import { toastAnatomy, partAttrs } from '@aeon-ui/core'
2
+ import {
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useState,
7
+ type HTMLAttributes,
8
+ type ReactNode,
9
+ } from 'react'
10
+ import { createPortal } from 'react-dom'
11
+ import { mergeProps } from '../utils/merge-props.js'
12
+ import {
13
+ ToastStoreCtx,
14
+ type ToastPublishOptions,
15
+ type ToastRecord,
16
+ useToastStore,
17
+ } from './context.js'
18
+ import { ToastItem } from './toast-item.js'
19
+
20
+ export type ToastPlacement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'
21
+
22
+ const PLACEMENT_ATTR: Record<ToastPlacement, string> = {
23
+ 'top-start': 'top-start',
24
+ 'top-end': 'top-end',
25
+ 'bottom-start': 'bottom-start',
26
+ 'bottom-end': 'bottom-end',
27
+ }
28
+
29
+ function nextToastId(): string {
30
+ return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
31
+ }
32
+
33
+ export interface ToastProviderProps {
34
+ children?: ReactNode
35
+ /** Max simultaneous toasts (oldest removed). Default 5. */
36
+ limit?: number
37
+ }
38
+
39
+ export function ToastProvider({ children, limit = 5 }: ToastProviderProps) {
40
+ const [items, setItems] = useState<ToastRecord[]>([])
41
+
42
+ const dismiss = useCallback((id: string) => {
43
+ setItems((prev) => prev.filter((t) => t.id !== id))
44
+ }, [])
45
+
46
+ const dismissAll = useCallback(() => {
47
+ setItems([])
48
+ }, [])
49
+
50
+ const publish = useCallback(
51
+ (options: ToastPublishOptions) => {
52
+ const id = options.id ?? nextToastId()
53
+ const record: ToastRecord = { ...options, id }
54
+ setItems((prev) => {
55
+ const without = prev.filter((t) => t.id !== id)
56
+ const next = [...without, record]
57
+ return next.length > limit ? next.slice(-limit) : next
58
+ })
59
+ return id
60
+ },
61
+ [limit],
62
+ )
63
+
64
+ const value = useMemo(
65
+ () => ({ items, publish, dismiss, dismissAll }),
66
+ [items, publish, dismiss, dismissAll],
67
+ )
68
+
69
+ return <ToastStoreCtx.Provider value={value}>{children}</ToastStoreCtx.Provider>
70
+ }
71
+
72
+ export interface ToastViewportProps extends HTMLAttributes<HTMLDivElement> {
73
+ placement?: ToastPlacement
74
+ }
75
+
76
+ export function ToastViewport({ placement = 'bottom-end', className, ...rest }: ToastViewportProps) {
77
+ const { items, dismiss } = useToastStore()
78
+ const [mounted, setMounted] = useState(false)
79
+
80
+ useEffect(() => {
81
+ setMounted(true)
82
+ }, [])
83
+
84
+ if (!mounted) return null
85
+
86
+ return createPortal(
87
+ <div
88
+ {...mergeProps(
89
+ partAttrs(toastAnatomy.scope, toastAnatomy.viewport, {
90
+ state: items.length > 0 ? 'active' : 'idle',
91
+ }),
92
+ {
93
+ 'data-placement': PLACEMENT_ATTR[placement],
94
+ },
95
+ rest,
96
+ )}
97
+ className={className}
98
+ >
99
+ {items.map((item) => (
100
+ <ToastItem key={item.id} item={item} onExited={dismiss} />
101
+ ))}
102
+ </div>,
103
+ document.body,
104
+ )
105
+ }
106
+
107
+ /** Imperative toast API — requires `Toast.Provider` ancestor. */
108
+ export function useToast() {
109
+ const { publish, dismiss, dismissAll } = useToastStore()
110
+ return { publish, dismiss, dismissAll }
111
+ }
@@ -0,0 +1,32 @@
1
+ import { forwardRef, type HTMLAttributes } from 'react'
2
+ import type { ToastRecord } from './context.js'
3
+ import { CloseTrigger, Description, Root, Title } from './primitives.js'
4
+
5
+ export type ToastItemProps = HTMLAttributes<HTMLDivElement> & {
6
+ item: ToastRecord
7
+ onExited: (id: string) => void
8
+ }
9
+
10
+ export const ToastItem = forwardRef<HTMLDivElement, ToastItemProps>(function ToastItem(
11
+ { item, onExited, className, ...rest },
12
+ ref,
13
+ ) {
14
+ const { id, title, description, durationMs } = item
15
+
16
+ return (
17
+ <Root
18
+ ref={ref}
19
+ className={className}
20
+ defaultVisible
21
+ durationMs={durationMs ?? 5000}
22
+ onVisibleChange={(visible) => {
23
+ if (!visible) onExited(id)
24
+ }}
25
+ {...rest}
26
+ >
27
+ {title ? <Title>{title}</Title> : null}
28
+ {description ? <Description>{description}</Description> : null}
29
+ <CloseTrigger />
30
+ </Root>
31
+ )
32
+ })
@@ -0,0 +1,191 @@
1
+ import { tooltipAnatomy, partAttrs } from '@aeon-ui/core'
2
+ import {
3
+ createContext,
4
+ forwardRef,
5
+ useContext,
6
+ useEffect,
7
+ useId,
8
+ useMemo,
9
+ useRef,
10
+ useState,
11
+ type HTMLAttributes,
12
+ type ReactNode,
13
+ } from 'react'
14
+ import { mergeProps } from '../utils/merge-props.js'
15
+
16
+ interface TooltipContextValue {
17
+ open: boolean
18
+ setOpen: (open: boolean) => void
19
+ triggerId: string
20
+ contentId: string
21
+ scheduleShow: () => void
22
+ scheduleHide: () => void
23
+ hideNow: () => void
24
+ showOnFocus: boolean
25
+ }
26
+
27
+ const TooltipCtx = createContext<TooltipContextValue | null>(null)
28
+
29
+ function useTooltipCtx() {
30
+ const ctx = useContext(TooltipCtx)
31
+ if (!ctx) throw new Error('Tooltip parts must be used within Tooltip.Root')
32
+ return ctx
33
+ }
34
+
35
+ export interface TooltipRootProps {
36
+ open?: boolean
37
+ defaultOpen?: boolean
38
+ onOpenChange?: (open: boolean) => void
39
+ openDelay?: number
40
+ closeDelay?: number
41
+ /** Focus after click/tap can leave tooltips open; disable for dense click targets. */
42
+ showOnFocus?: boolean
43
+ children?: ReactNode
44
+ className?: string
45
+ }
46
+
47
+ const Root = forwardRef<HTMLDivElement, TooltipRootProps>(function TooltipRoot(
48
+ {
49
+ open,
50
+ defaultOpen = false,
51
+ onOpenChange,
52
+ openDelay = 400,
53
+ closeDelay = 100,
54
+ showOnFocus = true,
55
+ children,
56
+ className,
57
+ ...rest
58
+ },
59
+ ref,
60
+ ) {
61
+ const [uncontrolled, setUncontrolled] = useState(defaultOpen)
62
+ const resolvedOpen = open ?? uncontrolled
63
+ const showTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
64
+ const hideTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
65
+ const triggerId = useId()
66
+ const contentId = useId()
67
+
68
+ const setOpen = (next: boolean) => {
69
+ if (open === undefined) setUncontrolled(next)
70
+ onOpenChange?.(next)
71
+ }
72
+
73
+ useEffect(() => {
74
+ onOpenChange?.(resolvedOpen)
75
+ }, [resolvedOpen, onOpenChange])
76
+
77
+ const hideNow = () => {
78
+ if (showTimer.current !== undefined) clearTimeout(showTimer.current)
79
+ if (hideTimer.current !== undefined) clearTimeout(hideTimer.current)
80
+ setOpen(false)
81
+ }
82
+
83
+ const scheduleShow = () => {
84
+ if (hideTimer.current !== undefined) clearTimeout(hideTimer.current)
85
+ showTimer.current = setTimeout(() => setOpen(true), openDelay)
86
+ }
87
+
88
+ const scheduleHide = () => {
89
+ if (showTimer.current !== undefined) clearTimeout(showTimer.current)
90
+ if (closeDelay <= 0) {
91
+ setOpen(false)
92
+ return
93
+ }
94
+ hideTimer.current = setTimeout(() => setOpen(false), closeDelay)
95
+ }
96
+
97
+ const value = useMemo(
98
+ () => ({
99
+ open: resolvedOpen,
100
+ setOpen,
101
+ triggerId,
102
+ contentId,
103
+ scheduleShow,
104
+ scheduleHide,
105
+ hideNow,
106
+ showOnFocus,
107
+ }),
108
+ [resolvedOpen, triggerId, contentId, openDelay, closeDelay, showOnFocus],
109
+ )
110
+
111
+ return (
112
+ <TooltipCtx.Provider value={value}>
113
+ <div
114
+ ref={ref}
115
+ className={className}
116
+ {...mergeProps(
117
+ partAttrs(tooltipAnatomy.scope, tooltipAnatomy.root, {
118
+ state: resolvedOpen ? 'open' : 'closed',
119
+ }),
120
+ rest as HTMLAttributes<HTMLDivElement>,
121
+ )}
122
+ >
123
+ {children}
124
+ </div>
125
+ </TooltipCtx.Provider>
126
+ )
127
+ })
128
+
129
+ const Trigger = forwardRef<HTMLSpanElement, HTMLAttributes<HTMLSpanElement>>(function TooltipTrigger(
130
+ props,
131
+ ref,
132
+ ) {
133
+ const { open, triggerId, contentId, scheduleShow, scheduleHide, hideNow, showOnFocus } =
134
+ useTooltipCtx()
135
+ return (
136
+ <span
137
+ ref={ref}
138
+ id={triggerId}
139
+ tabIndex={0}
140
+ aria-describedby={open ? contentId : undefined}
141
+ {...mergeProps(
142
+ partAttrs(tooltipAnatomy.scope, tooltipAnatomy.trigger, { state: open ? 'open' : 'closed' }),
143
+ {
144
+ onMouseEnter: scheduleShow,
145
+ onMouseLeave: scheduleHide,
146
+ onFocus: showOnFocus ? scheduleShow : undefined,
147
+ onBlur: showOnFocus ? scheduleHide : undefined,
148
+ /* Dismiss on press only for focus-driven tooltips; on dense click targets
149
+ pointerdown-dismiss races the child button click and drops the event. */
150
+ onPointerDown: showOnFocus ? hideNow : undefined,
151
+ },
152
+ props,
153
+ )}
154
+ />
155
+ )
156
+ })
157
+
158
+ const Positioner = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function TooltipPositioner(
159
+ props,
160
+ ref,
161
+ ) {
162
+ const { open } = useTooltipCtx()
163
+ if (!open) return null
164
+ return (
165
+ <div
166
+ ref={ref}
167
+ {...mergeProps(partAttrs(tooltipAnatomy.scope, tooltipAnatomy.positioner, { state: 'open' }), props)}
168
+ />
169
+ )
170
+ })
171
+
172
+ const Content = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function TooltipContent(props, ref) {
173
+ const { open, contentId } = useTooltipCtx()
174
+ if (!open) return null
175
+ return (
176
+ <div
177
+ ref={ref}
178
+ id={contentId}
179
+ role="tooltip"
180
+ {...mergeProps(partAttrs(tooltipAnatomy.scope, tooltipAnatomy.content, { state: 'open' }), props)}
181
+ />
182
+ )
183
+ })
184
+
185
+ const Arrow = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(function TooltipArrow(props, ref) {
186
+ const { open } = useTooltipCtx()
187
+ if (!open) return null
188
+ return <div ref={ref} {...mergeProps(partAttrs(tooltipAnatomy.scope, tooltipAnatomy.arrow), props)} />
189
+ })
190
+
191
+ export const Tooltip = { Root, Trigger, Positioner, Content, Arrow }
@@ -0,0 +1,24 @@
1
+ export function mergeProps(...parts: Array<object | undefined>): Record<string, unknown> {
2
+ const result: Record<string, unknown> = {}
3
+ for (const props of parts) {
4
+ if (!props) continue
5
+ for (const [key, value] of Object.entries(props)) {
6
+ if (key === 'className') {
7
+ result.className = [result.className, value].filter(Boolean).join(' ')
8
+ } else if (
9
+ key.startsWith('on') &&
10
+ typeof value === 'function' &&
11
+ typeof result[key] === 'function'
12
+ ) {
13
+ const prev = result[key] as (...args: unknown[]) => void
14
+ result[key] = (...args: unknown[]) => {
15
+ prev(...args)
16
+ ;(value as (...args: unknown[]) => void)(...args)
17
+ }
18
+ } else {
19
+ result[key] = value
20
+ }
21
+ }
22
+ }
23
+ return result
24
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src"
6
+ },
7
+ "include": ["src"]
8
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'jsdom',
6
+ include: ['src/**/*.test.tsx'],
7
+ setupFiles: ['./vitest.setup.ts'],
8
+ },
9
+ })
@@ -0,0 +1,5 @@
1
+ import '@testing-library/jest-dom/vitest'
2
+ import { cleanup } from '@testing-library/react'
3
+ import { afterEach } from 'vitest'
4
+
5
+ afterEach(() => cleanup())