@mortenbrudvik/waveui 0.4.0 → 0.7.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 (574) hide show
  1. package/README.md +1221 -173
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/components/button/Button.cjs +2 -0
  4. package/dist/components/button/Button.cjs.map +1 -0
  5. package/dist/components/button/Button.mjs +50 -0
  6. package/dist/components/button/Button.mjs.map +1 -0
  7. package/dist/components/button/Button.semantics.cjs +2 -0
  8. package/dist/components/button/Button.semantics.cjs.map +1 -0
  9. package/dist/components/button/Button.semantics.mjs +61 -0
  10. package/dist/components/button/Button.semantics.mjs.map +1 -0
  11. package/dist/components/button/Button.slots.cjs +2 -0
  12. package/dist/components/button/Button.slots.cjs.map +1 -0
  13. package/dist/components/button/Button.slots.mjs +47 -0
  14. package/dist/components/button/Button.slots.mjs.map +1 -0
  15. package/dist/components/button/CompoundButton.cjs +2 -0
  16. package/dist/components/button/CompoundButton.cjs.map +1 -0
  17. package/dist/components/button/CompoundButton.mjs +53 -0
  18. package/dist/components/button/CompoundButton.mjs.map +1 -0
  19. package/dist/components/button/Link.cjs +2 -0
  20. package/dist/components/button/Link.cjs.map +1 -0
  21. package/dist/components/button/Link.mjs +37 -0
  22. package/dist/components/button/Link.mjs.map +1 -0
  23. package/dist/components/button/MenuButton.cjs +2 -0
  24. package/dist/components/button/MenuButton.cjs.map +1 -0
  25. package/dist/components/button/MenuButton.mjs +45 -0
  26. package/dist/components/button/MenuButton.mjs.map +1 -0
  27. package/dist/components/button/SplitButton.cjs +2 -0
  28. package/dist/components/button/SplitButton.cjs.map +1 -0
  29. package/dist/components/button/SplitButton.mjs +66 -0
  30. package/dist/components/button/SplitButton.mjs.map +1 -0
  31. package/dist/components/button/ToggleButton.cjs +2 -0
  32. package/dist/components/button/ToggleButton.cjs.map +1 -0
  33. package/dist/components/button/ToggleButton.mjs +65 -0
  34. package/dist/components/button/ToggleButton.mjs.map +1 -0
  35. package/dist/components/button/Toolbar.cjs +2 -0
  36. package/dist/components/button/Toolbar.cjs.map +1 -0
  37. package/dist/components/button/Toolbar.context.cjs +2 -0
  38. package/dist/components/button/Toolbar.context.cjs.map +1 -0
  39. package/dist/components/button/Toolbar.context.mjs +31 -0
  40. package/dist/components/button/Toolbar.context.mjs.map +1 -0
  41. package/dist/components/button/Toolbar.mjs +63 -0
  42. package/dist/components/button/Toolbar.mjs.map +1 -0
  43. package/dist/components/button/Toolbar.parts.cjs +2 -0
  44. package/dist/components/button/Toolbar.parts.cjs.map +1 -0
  45. package/dist/components/button/Toolbar.parts.mjs +131 -0
  46. package/dist/components/button/Toolbar.parts.mjs.map +1 -0
  47. package/dist/components/button/buttonStyles.cjs +2 -0
  48. package/dist/components/button/buttonStyles.cjs.map +1 -0
  49. package/dist/components/button/buttonStyles.mjs +39 -0
  50. package/dist/components/button/buttonStyles.mjs.map +1 -0
  51. package/dist/components/data-display/Avatar.cjs +2 -0
  52. package/dist/components/data-display/Avatar.cjs.map +1 -0
  53. package/dist/components/data-display/Avatar.mjs +157 -0
  54. package/dist/components/data-display/Avatar.mjs.map +1 -0
  55. package/dist/components/data-display/AvatarGroup.cjs +2 -0
  56. package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
  57. package/dist/components/data-display/AvatarGroup.mjs +134 -0
  58. package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
  59. package/dist/components/data-display/Badge.cjs +2 -0
  60. package/dist/components/data-display/Badge.cjs.map +1 -0
  61. package/dist/components/data-display/Badge.colors.cjs +2 -0
  62. package/dist/components/data-display/Badge.colors.cjs.map +1 -0
  63. package/dist/components/data-display/Badge.colors.mjs +58 -0
  64. package/dist/components/data-display/Badge.colors.mjs.map +1 -0
  65. package/dist/components/data-display/Badge.mjs +32 -0
  66. package/dist/components/data-display/Badge.mjs.map +1 -0
  67. package/dist/components/data-display/CounterBadge.cjs +2 -0
  68. package/dist/components/data-display/CounterBadge.cjs.map +1 -0
  69. package/dist/components/data-display/CounterBadge.mjs +28 -0
  70. package/dist/components/data-display/CounterBadge.mjs.map +1 -0
  71. package/dist/components/data-display/Divider.cjs +2 -0
  72. package/dist/components/data-display/Divider.cjs.map +1 -0
  73. package/dist/components/data-display/Divider.mjs +52 -0
  74. package/dist/components/data-display/Divider.mjs.map +1 -0
  75. package/dist/components/data-display/Image.cjs +2 -0
  76. package/dist/components/data-display/Image.cjs.map +1 -0
  77. package/dist/components/data-display/Image.mjs +32 -0
  78. package/dist/components/data-display/Image.mjs.map +1 -0
  79. package/dist/components/data-display/InfoLabel.cjs +2 -0
  80. package/dist/components/data-display/InfoLabel.cjs.map +1 -0
  81. package/dist/components/data-display/InfoLabel.mjs +104 -0
  82. package/dist/components/data-display/InfoLabel.mjs.map +1 -0
  83. package/dist/components/data-display/List.cjs +2 -0
  84. package/dist/components/data-display/List.cjs.map +1 -0
  85. package/dist/components/data-display/List.mjs +381 -0
  86. package/dist/components/data-display/List.mjs.map +1 -0
  87. package/dist/components/data-display/List.registry.cjs +2 -0
  88. package/dist/components/data-display/List.registry.cjs.map +1 -0
  89. package/dist/components/data-display/List.registry.mjs +101 -0
  90. package/dist/components/data-display/List.registry.mjs.map +1 -0
  91. package/dist/components/data-display/Persona.cjs +2 -0
  92. package/dist/components/data-display/Persona.cjs.map +1 -0
  93. package/dist/components/data-display/Persona.mjs +48 -0
  94. package/dist/components/data-display/Persona.mjs.map +1 -0
  95. package/dist/components/data-display/PresenceBadge.cjs +2 -0
  96. package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
  97. package/dist/components/data-display/PresenceBadge.mjs +71 -0
  98. package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
  99. package/dist/components/data-display/Tag.cjs +2 -0
  100. package/dist/components/data-display/Tag.cjs.map +1 -0
  101. package/dist/components/data-display/Tag.mjs +147 -0
  102. package/dist/components/data-display/Tag.mjs.map +1 -0
  103. package/dist/components/feedback/MessageBar.cjs +2 -0
  104. package/dist/components/feedback/MessageBar.cjs.map +1 -0
  105. package/dist/components/feedback/MessageBar.mjs +144 -0
  106. package/dist/components/feedback/MessageBar.mjs.map +1 -0
  107. package/dist/components/feedback/MessageBar.status.cjs +2 -0
  108. package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
  109. package/dist/components/feedback/MessageBar.status.mjs +45 -0
  110. package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
  111. package/dist/components/feedback/ProgressBar.cjs +2 -0
  112. package/dist/components/feedback/ProgressBar.cjs.map +1 -0
  113. package/dist/components/feedback/ProgressBar.mjs +72 -0
  114. package/dist/components/feedback/ProgressBar.mjs.map +1 -0
  115. package/dist/components/feedback/Skeleton.cjs +2 -0
  116. package/dist/components/feedback/Skeleton.cjs.map +1 -0
  117. package/dist/components/feedback/Skeleton.mjs +47 -0
  118. package/dist/components/feedback/Skeleton.mjs.map +1 -0
  119. package/dist/components/feedback/Spinner.cjs +2 -0
  120. package/dist/components/feedback/Spinner.cjs.map +1 -0
  121. package/dist/components/feedback/Spinner.mjs +60 -0
  122. package/dist/components/feedback/Spinner.mjs.map +1 -0
  123. package/dist/components/feedback/Toast.cjs +2 -0
  124. package/dist/components/feedback/Toast.cjs.map +1 -0
  125. package/dist/components/feedback/Toast.mjs +347 -0
  126. package/dist/components/feedback/Toast.mjs.map +1 -0
  127. package/dist/components/input/Checkbox.cjs +2 -0
  128. package/dist/components/input/Checkbox.cjs.map +1 -0
  129. package/dist/components/input/Checkbox.mjs +96 -0
  130. package/dist/components/input/Checkbox.mjs.map +1 -0
  131. package/dist/components/input/ColorPicker.cjs +6 -0
  132. package/dist/components/input/ColorPicker.cjs.map +1 -0
  133. package/dist/components/input/ColorPicker.mjs +236 -0
  134. package/dist/components/input/ColorPicker.mjs.map +1 -0
  135. package/dist/components/input/Combobox.cjs +2 -0
  136. package/dist/components/input/Combobox.cjs.map +1 -0
  137. package/dist/components/input/Combobox.expand.cjs +2 -0
  138. package/dist/components/input/Combobox.expand.cjs.map +1 -0
  139. package/dist/components/input/Combobox.expand.mjs +38 -0
  140. package/dist/components/input/Combobox.expand.mjs.map +1 -0
  141. package/dist/components/input/Combobox.mjs +187 -0
  142. package/dist/components/input/Combobox.mjs.map +1 -0
  143. package/dist/components/input/DatePicker.cjs +2 -0
  144. package/dist/components/input/DatePicker.cjs.map +1 -0
  145. package/dist/components/input/DatePicker.mjs +340 -0
  146. package/dist/components/input/DatePicker.mjs.map +1 -0
  147. package/dist/components/input/Dropdown.cjs +2 -0
  148. package/dist/components/input/Dropdown.cjs.map +1 -0
  149. package/dist/components/input/Dropdown.mjs +128 -0
  150. package/dist/components/input/Dropdown.mjs.map +1 -0
  151. package/dist/components/input/Field.cjs +2 -0
  152. package/dist/components/input/Field.cjs.map +1 -0
  153. package/dist/components/input/Field.mjs +200 -0
  154. package/dist/components/input/Field.mjs.map +1 -0
  155. package/dist/components/input/Input.cjs +2 -0
  156. package/dist/components/input/Input.cjs.map +1 -0
  157. package/dist/components/input/Input.mjs +81 -0
  158. package/dist/components/input/Input.mjs.map +1 -0
  159. package/dist/components/input/Label.cjs +2 -0
  160. package/dist/components/input/Label.cjs.map +1 -0
  161. package/dist/components/input/Label.mjs +28 -0
  162. package/dist/components/input/Label.mjs.map +1 -0
  163. package/dist/components/input/Option.cjs +2 -0
  164. package/dist/components/input/Option.cjs.map +1 -0
  165. package/dist/components/input/Option.mjs +169 -0
  166. package/dist/components/input/Option.mjs.map +1 -0
  167. package/dist/components/input/RadioGroup.cjs +2 -0
  168. package/dist/components/input/RadioGroup.cjs.map +1 -0
  169. package/dist/components/input/RadioGroup.mjs +139 -0
  170. package/dist/components/input/RadioGroup.mjs.map +1 -0
  171. package/dist/components/input/Rating.cjs +2 -0
  172. package/dist/components/input/Rating.cjs.map +1 -0
  173. package/dist/components/input/Rating.mjs +196 -0
  174. package/dist/components/input/Rating.mjs.map +1 -0
  175. package/dist/components/input/SearchBox.cjs +2 -0
  176. package/dist/components/input/SearchBox.cjs.map +1 -0
  177. package/dist/components/input/SearchBox.mjs +205 -0
  178. package/dist/components/input/SearchBox.mjs.map +1 -0
  179. package/dist/components/input/Select.cjs +2 -0
  180. package/dist/components/input/Select.cjs.map +1 -0
  181. package/dist/components/input/Select.mjs +33 -0
  182. package/dist/components/input/Select.mjs.map +1 -0
  183. package/dist/components/input/Slider.cjs +2 -0
  184. package/dist/components/input/Slider.cjs.map +1 -0
  185. package/dist/components/input/Slider.mjs +79 -0
  186. package/dist/components/input/Slider.mjs.map +1 -0
  187. package/dist/components/input/SpinButton.cjs +2 -0
  188. package/dist/components/input/SpinButton.cjs.map +1 -0
  189. package/dist/components/input/SpinButton.mjs +157 -0
  190. package/dist/components/input/SpinButton.mjs.map +1 -0
  191. package/dist/components/input/SwatchPicker.cjs +2 -0
  192. package/dist/components/input/SwatchPicker.cjs.map +1 -0
  193. package/dist/components/input/SwatchPicker.mjs +113 -0
  194. package/dist/components/input/SwatchPicker.mjs.map +1 -0
  195. package/dist/components/input/Switch.cjs +2 -0
  196. package/dist/components/input/Switch.cjs.map +1 -0
  197. package/dist/components/input/Switch.mjs +92 -0
  198. package/dist/components/input/Switch.mjs.map +1 -0
  199. package/dist/components/input/TagPicker.cjs +2 -0
  200. package/dist/components/input/TagPicker.cjs.map +1 -0
  201. package/dist/components/input/TagPicker.mjs +249 -0
  202. package/dist/components/input/TagPicker.mjs.map +1 -0
  203. package/dist/components/input/Textarea.cjs +2 -0
  204. package/dist/components/input/Textarea.cjs.map +1 -0
  205. package/dist/components/input/Textarea.mjs +32 -0
  206. package/dist/components/input/Textarea.mjs.map +1 -0
  207. package/dist/components/input/TimePicker.cjs +2 -0
  208. package/dist/components/input/TimePicker.cjs.map +1 -0
  209. package/dist/components/input/TimePicker.mjs +292 -0
  210. package/dist/components/input/TimePicker.mjs.map +1 -0
  211. package/dist/components/input/colorUtils.cjs +2 -0
  212. package/dist/components/input/colorUtils.cjs.map +1 -0
  213. package/dist/components/input/colorUtils.mjs +96 -0
  214. package/dist/components/input/colorUtils.mjs.map +1 -0
  215. package/dist/components/input/dateUtils.cjs +2 -0
  216. package/dist/components/input/dateUtils.cjs.map +1 -0
  217. package/dist/components/input/dateUtils.mjs +250 -0
  218. package/dist/components/input/dateUtils.mjs.map +1 -0
  219. package/dist/components/input/pickerStyles.cjs +2 -0
  220. package/dist/components/input/pickerStyles.cjs.map +1 -0
  221. package/dist/components/input/pickerStyles.mjs +10 -0
  222. package/dist/components/input/pickerStyles.mjs.map +1 -0
  223. package/dist/components/internal/HiddenInput.cjs +2 -0
  224. package/dist/components/internal/HiddenInput.cjs.map +1 -0
  225. package/dist/components/internal/HiddenInput.mjs +88 -0
  226. package/dist/components/internal/HiddenInput.mjs.map +1 -0
  227. package/dist/components/layout/Accordion.cjs +2 -0
  228. package/dist/components/layout/Accordion.cjs.map +1 -0
  229. package/dist/components/layout/Accordion.mjs +236 -0
  230. package/dist/components/layout/Accordion.mjs.map +1 -0
  231. package/dist/components/layout/Card.cjs +2 -0
  232. package/dist/components/layout/Card.cjs.map +1 -0
  233. package/dist/components/layout/Card.mjs +121 -0
  234. package/dist/components/layout/Card.mjs.map +1 -0
  235. package/dist/components/layout/Carousel.cjs +2 -0
  236. package/dist/components/layout/Carousel.cjs.map +1 -0
  237. package/dist/components/layout/Carousel.mjs +205 -0
  238. package/dist/components/layout/Carousel.mjs.map +1 -0
  239. package/dist/components/layout/Flex.cjs +2 -0
  240. package/dist/components/layout/Flex.cjs.map +1 -0
  241. package/dist/components/layout/Flex.mjs +54 -0
  242. package/dist/components/layout/Flex.mjs.map +1 -0
  243. package/dist/components/layout/Grid.cjs +2 -0
  244. package/dist/components/layout/Grid.cjs.map +1 -0
  245. package/dist/components/layout/Grid.mjs +62 -0
  246. package/dist/components/layout/Grid.mjs.map +1 -0
  247. package/dist/components/layout/Overflow.cjs +2 -0
  248. package/dist/components/layout/Overflow.cjs.map +1 -0
  249. package/dist/components/layout/Overflow.mjs +269 -0
  250. package/dist/components/layout/Overflow.mjs.map +1 -0
  251. package/dist/components/layout/Stack.cjs +2 -0
  252. package/dist/components/layout/Stack.cjs.map +1 -0
  253. package/dist/components/layout/Stack.mjs +39 -0
  254. package/dist/components/layout/Stack.mjs.map +1 -0
  255. package/dist/components/layout/TabList.cjs +2 -0
  256. package/dist/components/layout/TabList.cjs.map +1 -0
  257. package/dist/components/layout/TabList.mjs +238 -0
  258. package/dist/components/layout/TabList.mjs.map +1 -0
  259. package/dist/components/layout/Tree.cjs +2 -0
  260. package/dist/components/layout/Tree.cjs.map +1 -0
  261. package/dist/components/layout/Tree.mjs +220 -0
  262. package/dist/components/layout/Tree.mjs.map +1 -0
  263. package/dist/components/layout/disclosureIds.cjs +2 -0
  264. package/dist/components/layout/disclosureIds.cjs.map +1 -0
  265. package/dist/components/layout/disclosureIds.mjs +12 -0
  266. package/dist/components/layout/disclosureIds.mjs.map +1 -0
  267. package/dist/components/motion/Presence.cjs +2 -0
  268. package/dist/components/motion/Presence.cjs.map +1 -0
  269. package/dist/components/motion/Presence.mjs +35 -0
  270. package/dist/components/motion/Presence.mjs.map +1 -0
  271. package/dist/components/navigation/Breadcrumb.cjs +2 -0
  272. package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
  273. package/dist/components/navigation/Breadcrumb.mjs +144 -0
  274. package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
  275. package/dist/components/navigation/Menu.cjs +2 -0
  276. package/dist/components/navigation/Menu.cjs.map +1 -0
  277. package/dist/components/navigation/Menu.context.cjs +2 -0
  278. package/dist/components/navigation/Menu.context.cjs.map +1 -0
  279. package/dist/components/navigation/Menu.context.mjs +82 -0
  280. package/dist/components/navigation/Menu.context.mjs.map +1 -0
  281. package/dist/components/navigation/Menu.group.cjs +2 -0
  282. package/dist/components/navigation/Menu.group.cjs.map +1 -0
  283. package/dist/components/navigation/Menu.group.mjs +58 -0
  284. package/dist/components/navigation/Menu.group.mjs.map +1 -0
  285. package/dist/components/navigation/Menu.items.cjs +2 -0
  286. package/dist/components/navigation/Menu.items.cjs.map +1 -0
  287. package/dist/components/navigation/Menu.items.mjs +127 -0
  288. package/dist/components/navigation/Menu.items.mjs.map +1 -0
  289. package/dist/components/navigation/Menu.link.cjs +2 -0
  290. package/dist/components/navigation/Menu.link.cjs.map +1 -0
  291. package/dist/components/navigation/Menu.link.mjs +41 -0
  292. package/dist/components/navigation/Menu.link.mjs.map +1 -0
  293. package/dist/components/navigation/Menu.mjs +27 -0
  294. package/dist/components/navigation/Menu.mjs.map +1 -0
  295. package/dist/components/navigation/Menu.popover.cjs +2 -0
  296. package/dist/components/navigation/Menu.popover.cjs.map +1 -0
  297. package/dist/components/navigation/Menu.popover.mjs +231 -0
  298. package/dist/components/navigation/Menu.popover.mjs.map +1 -0
  299. package/dist/components/navigation/Menu.root.cjs +2 -0
  300. package/dist/components/navigation/Menu.root.cjs.map +1 -0
  301. package/dist/components/navigation/Menu.root.mjs +308 -0
  302. package/dist/components/navigation/Menu.root.mjs.map +1 -0
  303. package/dist/components/navigation/Menu.selectable.cjs +2 -0
  304. package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
  305. package/dist/components/navigation/Menu.selectable.mjs +89 -0
  306. package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
  307. package/dist/components/navigation/Menu.shared.cjs +2 -0
  308. package/dist/components/navigation/Menu.shared.cjs.map +1 -0
  309. package/dist/components/navigation/Menu.shared.mjs +23 -0
  310. package/dist/components/navigation/Menu.shared.mjs.map +1 -0
  311. package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
  312. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
  313. package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
  314. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
  315. package/dist/components/navigation/Menu.trigger.cjs +2 -0
  316. package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
  317. package/dist/components/navigation/Menu.trigger.mjs +79 -0
  318. package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
  319. package/dist/components/navigation/Nav.cjs +2 -0
  320. package/dist/components/navigation/Nav.cjs.map +1 -0
  321. package/dist/components/navigation/Nav.mjs +276 -0
  322. package/dist/components/navigation/Nav.mjs.map +1 -0
  323. package/dist/components/navigation/Pagination.cjs +2 -0
  324. package/dist/components/navigation/Pagination.cjs.map +1 -0
  325. package/dist/components/navigation/Pagination.mjs +110 -0
  326. package/dist/components/navigation/Pagination.mjs.map +1 -0
  327. package/dist/components/navigation/Stepper.cjs +2 -0
  328. package/dist/components/navigation/Stepper.cjs.map +1 -0
  329. package/dist/components/navigation/Stepper.mjs +204 -0
  330. package/dist/components/navigation/Stepper.mjs.map +1 -0
  331. package/dist/components/overlays/Dialog.cjs +2 -0
  332. package/dist/components/overlays/Dialog.cjs.map +1 -0
  333. package/dist/components/overlays/Dialog.mjs +180 -0
  334. package/dist/components/overlays/Dialog.mjs.map +1 -0
  335. package/dist/components/overlays/Dialog.shared.cjs +2 -0
  336. package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
  337. package/dist/components/overlays/Dialog.shared.mjs +227 -0
  338. package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
  339. package/dist/components/overlays/Drawer.cjs +2 -0
  340. package/dist/components/overlays/Drawer.cjs.map +1 -0
  341. package/dist/components/overlays/Drawer.mjs +192 -0
  342. package/dist/components/overlays/Drawer.mjs.map +1 -0
  343. package/dist/components/overlays/Popover.cjs +2 -0
  344. package/dist/components/overlays/Popover.cjs.map +1 -0
  345. package/dist/components/overlays/Popover.mjs +365 -0
  346. package/dist/components/overlays/Popover.mjs.map +1 -0
  347. package/dist/components/overlays/Popover.shared.cjs +2 -0
  348. package/dist/components/overlays/Popover.shared.cjs.map +1 -0
  349. package/dist/components/overlays/Popover.shared.mjs +182 -0
  350. package/dist/components/overlays/Popover.shared.mjs.map +1 -0
  351. package/dist/components/overlays/TeachingPopover.cjs +2 -0
  352. package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
  353. package/dist/components/overlays/TeachingPopover.mjs +181 -0
  354. package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
  355. package/dist/components/overlays/Tooltip.cjs +2 -0
  356. package/dist/components/overlays/Tooltip.cjs.map +1 -0
  357. package/dist/components/overlays/Tooltip.mjs +160 -0
  358. package/dist/components/overlays/Tooltip.mjs.map +1 -0
  359. package/dist/components/portal/Portal.cjs +2 -0
  360. package/dist/components/portal/Portal.cjs.map +1 -0
  361. package/dist/components/portal/Portal.mjs +45 -0
  362. package/dist/components/portal/Portal.mjs.map +1 -0
  363. package/dist/components/provider/WaveProvider.cjs +2 -0
  364. package/dist/components/provider/WaveProvider.cjs.map +1 -0
  365. package/dist/components/provider/WaveProvider.mjs +51 -0
  366. package/dist/components/provider/WaveProvider.mjs.map +1 -0
  367. package/dist/components/table/DataGrid.cjs +2 -0
  368. package/dist/components/table/DataGrid.cjs.map +1 -0
  369. package/dist/components/table/DataGrid.mjs +489 -0
  370. package/dist/components/table/DataGrid.mjs.map +1 -0
  371. package/dist/components/table/Table.cjs +2 -0
  372. package/dist/components/table/Table.cjs.map +1 -0
  373. package/dist/components/table/Table.mjs +99 -0
  374. package/dist/components/table/Table.mjs.map +1 -0
  375. package/dist/components/table/useGridNavigation.cjs +2 -0
  376. package/dist/components/table/useGridNavigation.cjs.map +1 -0
  377. package/dist/components/table/useGridNavigation.mjs +336 -0
  378. package/dist/components/table/useGridNavigation.mjs.map +1 -0
  379. package/dist/components/typography/Text.cjs +2 -0
  380. package/dist/components/typography/Text.cjs.map +1 -0
  381. package/dist/components/typography/Text.mjs +38 -0
  382. package/dist/components/typography/Text.mjs.map +1 -0
  383. package/dist/hooks/useAnnounce.cjs +2 -0
  384. package/dist/hooks/useAnnounce.cjs.map +1 -0
  385. package/dist/hooks/useAnnounce.mjs +88 -0
  386. package/dist/hooks/useAnnounce.mjs.map +1 -0
  387. package/dist/hooks/useCheckedValues.cjs +2 -0
  388. package/dist/hooks/useCheckedValues.cjs.map +1 -0
  389. package/dist/hooks/useCheckedValues.mjs +102 -0
  390. package/dist/hooks/useCheckedValues.mjs.map +1 -0
  391. package/dist/hooks/useContextMenuAnchor.cjs +2 -0
  392. package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
  393. package/dist/hooks/useContextMenuAnchor.mjs +132 -0
  394. package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
  395. package/dist/hooks/useControllable.cjs +2 -0
  396. package/dist/hooks/useControllable.cjs.map +1 -0
  397. package/dist/hooks/useControllable.mjs +37 -0
  398. package/dist/hooks/useControllable.mjs.map +1 -0
  399. package/dist/hooks/useDirection.cjs +2 -0
  400. package/dist/hooks/useDirection.cjs.map +1 -0
  401. package/dist/hooks/useDirection.mjs +57 -0
  402. package/dist/hooks/useDirection.mjs.map +1 -0
  403. package/dist/hooks/useDismiss.cjs +2 -0
  404. package/dist/hooks/useDismiss.cjs.map +1 -0
  405. package/dist/hooks/useDismiss.mjs +57 -0
  406. package/dist/hooks/useDismiss.mjs.map +1 -0
  407. package/dist/hooks/useEventCallback.cjs +2 -0
  408. package/dist/hooks/useEventCallback.cjs.map +1 -0
  409. package/dist/hooks/useEventCallback.mjs +16 -0
  410. package/dist/hooks/useEventCallback.mjs.map +1 -0
  411. package/dist/hooks/useFieldControl.cjs +2 -0
  412. package/dist/hooks/useFieldControl.cjs.map +1 -0
  413. package/dist/hooks/useFieldControl.mjs +62 -0
  414. package/dist/hooks/useFieldControl.mjs.map +1 -0
  415. package/dist/hooks/useFocusTrap.cjs +2 -0
  416. package/dist/hooks/useFocusTrap.cjs.map +1 -0
  417. package/dist/hooks/useFocusTrap.mjs +266 -0
  418. package/dist/hooks/useFocusTrap.mjs.map +1 -0
  419. package/dist/hooks/useFormReset.cjs +2 -0
  420. package/dist/hooks/useFormReset.cjs.map +1 -0
  421. package/dist/hooks/useFormReset.mjs +33 -0
  422. package/dist/hooks/useFormReset.mjs.map +1 -0
  423. package/dist/hooks/useHoverIntent.cjs +2 -0
  424. package/dist/hooks/useHoverIntent.cjs.map +1 -0
  425. package/dist/hooks/useHoverIntent.mjs +201 -0
  426. package/dist/hooks/useHoverIntent.mjs.map +1 -0
  427. package/dist/hooks/useId.cjs +2 -0
  428. package/dist/hooks/useId.cjs.map +1 -0
  429. package/dist/hooks/useId.mjs +11 -0
  430. package/dist/hooks/useId.mjs.map +1 -0
  431. package/dist/hooks/useIsClient.cjs +2 -0
  432. package/dist/hooks/useIsClient.cjs.map +1 -0
  433. package/dist/hooks/useIsClient.mjs +19 -0
  434. package/dist/hooks/useIsClient.mjs.map +1 -0
  435. package/dist/hooks/useListbox.cjs +2 -0
  436. package/dist/hooks/useListbox.cjs.map +1 -0
  437. package/dist/hooks/useListbox.mjs +492 -0
  438. package/dist/hooks/useListbox.mjs.map +1 -0
  439. package/dist/hooks/useMergedRefs.cjs +2 -0
  440. package/dist/hooks/useMergedRefs.cjs.map +1 -0
  441. package/dist/hooks/useMergedRefs.mjs +57 -0
  442. package/dist/hooks/useMergedRefs.mjs.map +1 -0
  443. package/dist/hooks/useModalIsolation.cjs +2 -0
  444. package/dist/hooks/useModalIsolation.cjs.map +1 -0
  445. package/dist/hooks/useModalIsolation.mjs +87 -0
  446. package/dist/hooks/useModalIsolation.mjs.map +1 -0
  447. package/dist/hooks/useModalLayer.cjs +2 -0
  448. package/dist/hooks/useModalLayer.cjs.map +1 -0
  449. package/dist/hooks/useModalLayer.mjs +30 -0
  450. package/dist/hooks/useModalLayer.mjs.map +1 -0
  451. package/dist/hooks/usePopupPosition.cjs +2 -0
  452. package/dist/hooks/usePopupPosition.cjs.map +1 -0
  453. package/dist/hooks/usePopupPosition.mjs +117 -0
  454. package/dist/hooks/usePopupPosition.mjs.map +1 -0
  455. package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
  456. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
  457. package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
  458. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
  459. package/dist/hooks/usePresence.cjs +2 -0
  460. package/dist/hooks/usePresence.cjs.map +1 -0
  461. package/dist/hooks/usePresence.mjs +136 -0
  462. package/dist/hooks/usePresence.mjs.map +1 -0
  463. package/dist/hooks/usePreserveFocus.cjs +2 -0
  464. package/dist/hooks/usePreserveFocus.cjs.map +1 -0
  465. package/dist/hooks/usePreserveFocus.mjs +50 -0
  466. package/dist/hooks/usePreserveFocus.mjs.map +1 -0
  467. package/dist/hooks/useRestoreFocus.cjs +2 -0
  468. package/dist/hooks/useRestoreFocus.cjs.map +1 -0
  469. package/dist/hooks/useRestoreFocus.mjs +271 -0
  470. package/dist/hooks/useRestoreFocus.mjs.map +1 -0
  471. package/dist/hooks/useRovingTabIndex.cjs +2 -0
  472. package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
  473. package/dist/hooks/useRovingTabIndex.mjs +389 -0
  474. package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
  475. package/dist/hooks/useScrollLock.cjs +2 -0
  476. package/dist/hooks/useScrollLock.cjs.map +1 -0
  477. package/dist/hooks/useScrollLock.mjs +71 -0
  478. package/dist/hooks/useScrollLock.mjs.map +1 -0
  479. package/dist/hooks/useTriggerElement.cjs +2 -0
  480. package/dist/hooks/useTriggerElement.cjs.map +1 -0
  481. package/dist/hooks/useTriggerElement.mjs +126 -0
  482. package/dist/hooks/useTriggerElement.mjs.map +1 -0
  483. package/dist/hooks/useTypeahead.cjs +2 -0
  484. package/dist/hooks/useTypeahead.cjs.map +1 -0
  485. package/dist/hooks/useTypeahead.mjs +38 -0
  486. package/dist/hooks/useTypeahead.mjs.map +1 -0
  487. package/dist/index.cjs +1 -1
  488. package/dist/index.d.cts +9099 -0
  489. package/dist/index.d.ts +7688 -1027
  490. package/dist/index.mjs +91 -5695
  491. package/dist/lib/aria.cjs +2 -0
  492. package/dist/lib/aria.cjs.map +1 -0
  493. package/dist/lib/aria.mjs +29 -0
  494. package/dist/lib/aria.mjs.map +1 -0
  495. package/dist/lib/children.cjs +2 -0
  496. package/dist/lib/children.cjs.map +1 -0
  497. package/dist/lib/children.mjs +37 -0
  498. package/dist/lib/children.mjs.map +1 -0
  499. package/dist/lib/cn.cjs +2 -0
  500. package/dist/lib/cn.cjs.map +1 -0
  501. package/dist/lib/cn.mjs +64 -0
  502. package/dist/lib/cn.mjs.map +1 -0
  503. package/dist/lib/composeEventHandlers.cjs +2 -0
  504. package/dist/lib/composeEventHandlers.cjs.map +1 -0
  505. package/dist/lib/composeEventHandlers.mjs +11 -0
  506. package/dist/lib/composeEventHandlers.mjs.map +1 -0
  507. package/dist/lib/dev.cjs +2 -0
  508. package/dist/lib/dev.cjs.map +1 -0
  509. package/dist/lib/dev.mjs +42 -0
  510. package/dist/lib/dev.mjs.map +1 -0
  511. package/dist/lib/direction.cjs +2 -0
  512. package/dist/lib/direction.cjs.map +1 -0
  513. package/dist/lib/direction.mjs +35 -0
  514. package/dist/lib/direction.mjs.map +1 -0
  515. package/dist/lib/events.cjs +2 -0
  516. package/dist/lib/events.cjs.map +1 -0
  517. package/dist/lib/events.mjs +31 -0
  518. package/dist/lib/events.mjs.map +1 -0
  519. package/dist/lib/focus.cjs +2 -0
  520. package/dist/lib/focus.cjs.map +1 -0
  521. package/dist/lib/focus.mjs +119 -0
  522. package/dist/lib/focus.mjs.map +1 -0
  523. package/dist/lib/globalRegistry.cjs +2 -0
  524. package/dist/lib/globalRegistry.cjs.map +1 -0
  525. package/dist/lib/globalRegistry.mjs +13 -0
  526. package/dist/lib/globalRegistry.mjs.map +1 -0
  527. package/dist/lib/icons.cjs +2 -0
  528. package/dist/lib/icons.cjs.map +1 -0
  529. package/dist/lib/icons.mjs +254 -0
  530. package/dist/lib/icons.mjs.map +1 -0
  531. package/dist/lib/labelInName.cjs +2 -0
  532. package/dist/lib/labelInName.cjs.map +1 -0
  533. package/dist/lib/labelInName.mjs +54 -0
  534. package/dist/lib/labelInName.mjs.map +1 -0
  535. package/dist/lib/layers.cjs +2 -0
  536. package/dist/lib/layers.cjs.map +1 -0
  537. package/dist/lib/layers.mjs +224 -0
  538. package/dist/lib/layers.mjs.map +1 -0
  539. package/dist/lib/mergeProps.cjs +2 -0
  540. package/dist/lib/mergeProps.cjs.map +1 -0
  541. package/dist/lib/mergeProps.mjs +21 -0
  542. package/dist/lib/mergeProps.mjs.map +1 -0
  543. package/dist/lib/mergeRefs.cjs +2 -0
  544. package/dist/lib/mergeRefs.cjs.map +1 -0
  545. package/dist/lib/mergeRefs.mjs +29 -0
  546. package/dist/lib/mergeRefs.mjs.map +1 -0
  547. package/dist/lib/renderTrigger.cjs +2 -0
  548. package/dist/lib/renderTrigger.cjs.map +1 -0
  549. package/dist/lib/renderTrigger.mjs +29 -0
  550. package/dist/lib/renderTrigger.mjs.map +1 -0
  551. package/dist/lib/slot.cjs +2 -0
  552. package/dist/lib/slot.cjs.map +1 -0
  553. package/dist/lib/slot.mjs +122 -0
  554. package/dist/lib/slot.mjs.map +1 -0
  555. package/dist/lib/styles.cjs +2 -0
  556. package/dist/lib/styles.cjs.map +1 -0
  557. package/dist/lib/styles.mjs +16 -0
  558. package/dist/lib/styles.mjs.map +1 -0
  559. package/dist/lib/theme.cjs +2 -0
  560. package/dist/lib/theme.cjs.map +1 -0
  561. package/dist/lib/theme.mjs +16 -0
  562. package/dist/lib/theme.mjs.map +1 -0
  563. package/dist/preflight.css +2 -0
  564. package/dist/styles.css +2 -0
  565. package/package.json +149 -100
  566. package/src/styles/animations.css +7 -39
  567. package/src/styles/base.css +103 -0
  568. package/src/styles/globals.css +10 -22
  569. package/src/styles/legacy-tokens.css +184 -0
  570. package/src/styles/preflight.css +7 -0
  571. package/src/styles/styles.css +32 -0
  572. package/src/styles/tailwind.css +17 -0
  573. package/src/styles/tokens.css +561 -221
  574. package/src/styles/variants.css +29 -0
@@ -0,0 +1,181 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { resolveDeprecatedProp as t, warnOnce as n } from "../../lib/dev.mjs";
4
+ import { composeEventHandlers as ee } from "../../lib/composeEventHandlers.mjs";
5
+ import { useControllable as r } from "../../hooks/useControllable.mjs";
6
+ import { useId as te } from "../../hooks/useId.mjs";
7
+ import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
8
+ import { focusableDisabledProps as re, preventIfDisabled as ie } from "../../lib/aria.mjs";
9
+ import { useAnnounce as ae } from "../../hooks/useAnnounce.mjs";
10
+ import { useDismiss as oe } from "../../hooks/useDismiss.mjs";
11
+ import { Portal as se } from "../portal/Portal.mjs";
12
+ import { focusRing as i, forcedColors as ce } from "../../lib/styles.mjs";
13
+ import { Button as a } from "../button/Button.mjs";
14
+ import { DismissIcon as le } from "../../lib/icons.mjs";
15
+ import { usePopupPosition as o } from "../../hooks/usePopupPosition.mjs";
16
+ import { useRestoreFocus as ue } from "../../hooks/useRestoreFocus.mjs";
17
+ import { PopoverBeak as de, getTabbableThrough as fe, usePopoverTabOrder as pe } from "./Popover.shared.mjs";
18
+ import * as s from "react";
19
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
20
+ //#region src/components/overlays/TeachingPopover.tsx
21
+ var me = "Back", he = "Next", ge = "Done", _e = (e, t) => `step ${e + 1} of ${t}`;
22
+ function u(e) {
23
+ return "current" in e;
24
+ }
25
+ function d(e) {
26
+ return e != null && !u(e);
27
+ }
28
+ function f(e) {
29
+ return e ? u(e) ? e.current : e : null;
30
+ }
31
+ function p(e, t) {
32
+ return Number.isFinite(e) ? Math.min(Math.max(Math.trunc(e), 0), t - 1) : 0;
33
+ }
34
+ var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, defaultCurrentStep: xe, onStepChange: Se, onDismiss: Ce, open: we, defaultOpen: Te, onOpenChange: Ee, closeLabel: De = "Close", labels: h, target: g, side: Oe = "bottom", align: _ = "center", className: v, style: y, onKeyDown: b, ref: x, ...S }) => {
35
+ let C = t("TeachingPopover", ve, be, "currentStep", "activeStep"), w = t("TeachingPopover", ye, xe, "defaultCurrentStep", "defaultActiveStep") ?? 0, [T, E] = r(C, w, Se), [ke, Ae] = r(we, Te ?? !0, Ee), D = te("teaching-popover-title"), O = ae(), k = m.length, A = ke && k > 0, j = k > 0 ? p(T, k) : 0, M = k > 0 && j !== T, N = k > 0 ? m[j] : void 0, P = N?.title, F = j === 0, I = j === k - 1, L = g !== void 0, R = k > 0 ? (h?.step ?? _e)(j, k) : "", [z, je] = s.useState(null), [B, V] = s.useState(() => d(g)), H = g === null ? !1 : d(g) ? !0 : void 0;
36
+ H !== void 0 && H !== B && V(H);
37
+ let U = s.useRef(null), W = s.useRef(null), G = s.useRef(g), K = s.useRef(B), q = s.useRef(null), { setReference: J, setFloating: Me, floatingProps: Y, arrowStyles: Ne, side: Pe, isPositioned: Fe } = o({
38
+ open: A && L,
39
+ side: Oe,
40
+ align: _,
41
+ offset: 12,
42
+ arrowRef: q
43
+ }), Ie = g != null && (!u(g) || B), X = !L || Ie && Fe, Z = A && X, Le = ne(x, U, je, Me);
44
+ s.useLayoutEffect(() => {
45
+ G.current = g, K.current = B;
46
+ let e = f(g);
47
+ W.current = e, J(e), g != null && u(g) && queueMicrotask(() => {
48
+ let e = f(G.current);
49
+ e !== W.current && (W.current = e, J(e));
50
+ let t = e !== null;
51
+ t !== K.current && (K.current = t, V(t));
52
+ });
53
+ });
54
+ let Q = () => {
55
+ Ae(!1), Ce?.();
56
+ }, { layerId: Re } = oe({
57
+ open: Z,
58
+ onDismiss: Q,
59
+ refs: [U],
60
+ anchorRef: W,
61
+ kind: "popover",
62
+ outsidePress: !1
63
+ });
64
+ ue({
65
+ enabled: Z,
66
+ container: z,
67
+ fallback: () => W.current,
68
+ onlyIfFocusInside: !0
69
+ });
70
+ let ze = pe({
71
+ enabled: Z && L,
72
+ surface: z,
73
+ anchorRef: W,
74
+ getPreviousStop: fe
75
+ });
76
+ s.useEffect(() => {
77
+ Z && z && z.focus({ preventScroll: L });
78
+ }, [
79
+ Z,
80
+ z,
81
+ L
82
+ ]);
83
+ let $ = s.useRef(j);
84
+ if (s.useEffect(() => {
85
+ $.current !== j && ($.current = j, Z && P !== void 0 && O(`${P}, ${R}`));
86
+ }, [
87
+ j,
88
+ Z,
89
+ P,
90
+ R,
91
+ O
92
+ ]), s.useEffect(() => {
93
+ M && n("TeachingPopover:activeStep-range", `TeachingPopover: activeStep ${T} is out of range for ${k} steps; showing step ${j + 1}.`);
94
+ }, [
95
+ M,
96
+ T,
97
+ k,
98
+ j
99
+ ]), !A || !N) return null;
100
+ let Be = () => E(j - 1), Ve = () => {
101
+ I ? Q() : E(j + 1);
102
+ };
103
+ return /* @__PURE__ */ c(se, {
104
+ disabled: !L,
105
+ layerId: Re,
106
+ children: /* @__PURE__ */ l("div", {
107
+ role: "dialog",
108
+ "aria-labelledby": D,
109
+ tabIndex: -1,
110
+ ...S,
111
+ ref: Le,
112
+ onKeyDown: ee(b, ze),
113
+ ...L ? {
114
+ "data-side": Y["data-side"],
115
+ "data-align": Y["data-align"],
116
+ style: {
117
+ ...y,
118
+ ...Y.style,
119
+ ...X ? void 0 : { visibility: "hidden" }
120
+ }
121
+ } : { style: y },
122
+ className: e("relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8", i, v),
123
+ children: [
124
+ L && /* @__PURE__ */ c(de, {
125
+ ref: q,
126
+ side: Pe,
127
+ style: Ne,
128
+ "data-wave-teaching-popover-arrow": ""
129
+ }),
130
+ /* @__PURE__ */ c(a, {
131
+ appearance: "subtle",
132
+ size: "small",
133
+ icon: /* @__PURE__ */ c(le, {}),
134
+ "aria-label": De,
135
+ className: "absolute end-3 top-3",
136
+ onClick: Q
137
+ }),
138
+ /* @__PURE__ */ l("h3", {
139
+ id: D,
140
+ className: "mb-2 pe-8 text-subtitle-1 font-semibold text-foreground",
141
+ children: [N.title, /* @__PURE__ */ c("span", {
142
+ className: "sr-only",
143
+ children: `, ${R}`
144
+ })]
145
+ }),
146
+ /* @__PURE__ */ c("div", {
147
+ className: "mb-4 text-body-1 text-muted-foreground",
148
+ children: N.body
149
+ }),
150
+ /* @__PURE__ */ l("div", {
151
+ className: "flex items-center justify-between gap-2",
152
+ children: [/* @__PURE__ */ c("div", {
153
+ "aria-hidden": "true",
154
+ className: "flex items-center gap-1.5",
155
+ children: m.map((t, n) => /* @__PURE__ */ c("span", {
156
+ "data-wave-teaching-popover-dot": "",
157
+ "aria-current": n === j ? "step" : void 0,
158
+ className: e("h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none", n === j ? e("w-4 bg-primary", ce.fill) : "w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none")
159
+ }, n))
160
+ }), /* @__PURE__ */ l("div", {
161
+ className: "flex items-center gap-2",
162
+ children: [k > 1 && /* @__PURE__ */ c(a, {
163
+ ...re(F),
164
+ onClick: ie(F, Be),
165
+ children: h?.back ?? me
166
+ }), /* @__PURE__ */ c(a, {
167
+ appearance: "primary",
168
+ onClick: Ve,
169
+ children: I ? h?.done ?? ge : h?.next ?? he
170
+ })]
171
+ })]
172
+ })
173
+ ]
174
+ })
175
+ });
176
+ };
177
+ m.displayName = "TeachingPopover";
178
+ //#endregion
179
+ export { m as TeachingPopover };
180
+
181
+ //# sourceMappingURL=TeachingPopover.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TeachingPopover.mjs","names":["useId","useId$1","React","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","defaultStepLabel","index","count","isRefObject","target","isElementTarget","resolveTarget","clampStep","step","TeachingPopover","activeStepProp","openProp","rest","controlledStep","resolveDeprecatedProp","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","useControllable","onStepChange","open","setOpen","defaultOpen","onOpenChange","titleId","announce","useAnnounce","steps","shown","outOfRange","stepTitle","isFirst","isLast","hasTarget","stepPosition","labels","surface","setSurface","targetResolved","setTargetResolved","elementAvailable","surfaceRef","targetRef","targetPropRef","availabilityRef","arrowRef","placedSide","usePopupPosition","targetAvailable","anchorReady","isPositioned","visible","elementRef","useMergedRefs","ref","setFloating","element","setReference","latest","available","dismiss","onDismiss","useDismiss","onSurfaceKeyDown","usePopoverTabOrder","getTabbableThrough","announcedIndexRef","warnOnce","handleBack","handleNext","Portal","composeEventHandlers","onKeyDown","floatingProps","style","cn","focusRing","className","PopoverBeak","arrowStyles","Button","DismissIcon","closeLabel","i","forcedColors","focusableDisabledProps","preventIfDisabled"],"sources":["../../../src/components/overlays/TeachingPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { DismissIcon } from '../../lib/icons';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport { getTabbableThrough, PopoverBeak, usePopoverTabOrder } from './Popover.shared';\n\n/** Defines a single step in a teaching popover sequence. */\nexport interface TeachingPopoverStep {\n /** Title text for the step. */\n title: string;\n /** Body content for the step. */\n body: React.ReactNode;\n}\n\n/** The built-in text of a TeachingPopover, for localization (see `TeachingPopoverProps.labels`). */\nexport interface TeachingPopoverLabels {\n /** Text of the Back button.\n * @default 'Back'\n */\n back?: string;\n /** Text of the Next button.\n * @default 'Next'\n */\n next?: string;\n /** Text of the button that replaces Next on the last step.\n * @default 'Done'\n */\n done?: string;\n /**\n * The position of the step at `index` (zero-based, like `activeStep`) out of `count` steps. It\n * follows the step title, after a comma, in the visually hidden part of the heading and in the\n * announcement of a step change.\n * @default (index, count) => `step ${index + 1} of ${count}`\n */\n step?: (index: number, count: number) => string;\n}\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /** Called with the requested step index when Next or Back is activated. */\n onStepChange?: (step: number) => void;\n /** Called when the popover is dismissed with Close, Done or Escape. */\n onDismiss?: () => void;\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /** Initial visibility for uncontrolled usage.\n * @default true\n */\n defaultOpen?: boolean;\n /** Called with `false` when Close, Done or Escape dismisses the popover. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons and the wording of the step position (“step 2 of 3”),\n * for localization. Unset members keep their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref or the element). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour).\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /** Ref to the popover surface (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction isRefObject(\n target: NonNullable<TeachingPopoverProps['target']>,\n): target is React.RefObject<HTMLElement | null> {\n return 'current' in target;\n}\n\nfunction isElementTarget(target: TeachingPopoverProps['target']): target is HTMLElement {\n return target != null && !isRefObject(target);\n}\n\nfunction resolveTarget(target: TeachingPopoverProps['target']): HTMLElement | null {\n if (!target) return null;\n return isRefObject(target) ? target.current : target;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * A step-by-step onboarding popover (a non-modal `role=\"dialog\"`) with Back/Next (Done on the\n * last step) and Close.\n *\n * - Visibility is controllable: `open`/`defaultOpen` (default `true`)/`onOpenChange`; Close, Done\n * and Escape (anywhere in the document) dismiss it and call `onDismiss`.\n * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to\n * the available steps. The heading carries a visually hidden “step n of m”, the new step is\n * announced politely, and Back stays focusable (`aria-disabled`) on the first step.\n * - The built-in text is English: `labels` localizes Back, Next, Done and the step position, and\n * `closeLabel` the Close button.\n * - Focus moves to the popover when it opens and returns to the element that had it when it\n * closes (with `target`, to the target when nothing had focus, e.g. a tour opened on page load).\n * - With `target`, the popover is portaled and positioned next to that element with a beak (it\n * inherits the surface colors); it stays hidden while the target is `null`, not positioned yet or\n * no longer mounted (a ref target is read after each render of the popover; see `target`).\n * - With `target`, the keyboard order treats the popover as if it followed the target: Tab past\n * its last button continues after the target, Shift+Tab from its first button (or from the\n * popover itself) returns to the target (for a target outside the Tab order, to the last control\n * inside it, else to the control before it), Tab from there enters the popover, and Shift+Tab\n * from the control after the target enters it at its last button. Tab from the last control of\n * the page moves past the popover (it was visited after the target), and Shift+Tab from outside\n * the page reaches the page's last control first, so a lap visits it once and Tab never cycles.\n * With no control at or before the target, the popover is reached where it is portaled, at the\n * end of the page: Tab from the page's last control and Shift+Tab from outside the page enter\n * it.\n */\nexport const TeachingPopover = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target,\n side = 'bottom',\n align = 'center',\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? true, onOpenChange);\n const titleId = useId('teaching-popover-title');\n const announce = useAnnounce();\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const stepTitle = step?.title;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const hasTarget = target !== undefined;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n // Whether `target` pointed at an element when it was last read. An element (or `null`) is known\n // during render and is mirrored here right away (C-HOOKS: adjust state during render). A ref\n // cannot be read during render, React does not re-render when it attaches or detaches, and\n // floating-ui keeps `isPositioned` after `setReference(null)`, so the layout effect below reads\n // a ref after each commit and mirrors it here through a deferred update (C-HOOKS). Until that\n // update has read a newly passed ref, the ref keeps this last known availability: moving between\n // attached refs (a multi-target tour) or passing a new ref object on every render never hides\n // the popover, and a switch to a ref that is not attached hides it once the update lands.\n const [targetResolved, setTargetResolved] = React.useState(() => isElementTarget(target));\n const elementAvailable = target === null ? false : isElementTarget(target) ? true : undefined;\n if (elementAvailable !== undefined && elementAvailable !== targetResolved) {\n setTargetResolved(elementAvailable);\n }\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const targetRef = React.useRef<HTMLElement | null>(null);\n // The latest `target` prop and committed availability, read by the deferred update so that the\n // newest target and attachment win and an unchanged resolution sets no state.\n const targetPropRef = React.useRef(target);\n const availabilityRef = React.useRef(targetResolved);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n isPositioned,\n } = usePopupPosition({ open: shown && hasTarget, side, align, offset: 12, arrowRef });\n // An anchored popover is shown only while it points at a resolved target: otherwise the surface\n // is rendered (so it can be measured) but hidden, unfocused, silent and without an Escape layer.\n const targetAvailable = target != null && (isRefObject(target) ? targetResolved : true);\n const anchorReady = !hasTarget || (targetAvailable && isPositioned);\n const visible = shown && anchorReady;\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceRef, setSurface, setFloating);\n\n // Point the positioning at the target after every commit. A ref is read once more when the whole\n // commit is done (the C-HOOKS deferred-update pattern): a target that comes after the popover in\n // the tree attaches its ref after this effect has run. That update re-reads the latest target,\n // and only a changed element or availability updates the reference or the state.\n React.useLayoutEffect(() => {\n targetPropRef.current = target;\n availabilityRef.current = targetResolved;\n const element = resolveTarget(target);\n targetRef.current = element;\n setReference(element);\n if (target == null || !isRefObject(target)) return;\n queueMicrotask(() => {\n const latest = resolveTarget(targetPropRef.current);\n if (latest !== targetRef.current) {\n targetRef.current = latest;\n setReference(latest);\n }\n const available = latest !== null;\n if (available !== availabilityRef.current) {\n availabilityRef.current = available;\n setTargetResolved(available);\n }\n });\n });\n\n const dismiss = () => {\n setOpen(false);\n onDismiss?.();\n };\n\n const { layerId } = useDismiss({\n open: visible,\n onDismiss: dismiss,\n refs: [surfaceRef],\n anchorRef: targetRef,\n kind: 'popover',\n outsidePress: false,\n });\n\n useRestoreFocus({\n enabled: visible,\n container: surface,\n fallback: () => targetRef.current,\n onlyIfFocusInside: true,\n });\n\n // Portaled next to a target: the keyboard order of the popover placed right after the target.\n const onSurfaceKeyDown = usePopoverTabOrder({\n enabled: visible && hasTarget,\n surface,\n anchorRef: targetRef,\n getPreviousStop: getTabbableThrough,\n });\n\n // Move focus into the popover when it becomes visible (and when a new surface mounts).\n React.useEffect(() => {\n if (visible && surface) surface.focus({ preventScroll: hasTarget });\n }, [visible, surface, hasTarget]);\n\n // Announce the new step politely after a step change (not on mount, and not while hidden: the\n // heading, which carries the step position, is read when the popover shows and takes focus).\n const announcedIndexRef = React.useRef(index);\n React.useEffect(() => {\n if (announcedIndexRef.current === index) return;\n announcedIndexRef.current = index;\n if (visible && stepTitle !== undefined) {\n announce(`${stepTitle}, ${stepPosition}`);\n }\n }, [index, visible, stepTitle, stepPosition, announce]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n if (!shown || !step) return null;\n\n const handleBack = () => setStep(index - 1);\n const handleNext = () => {\n if (isLast) dismiss();\n else setStep(index + 1);\n };\n\n return (\n <Portal disabled={!hasTarget} layerId={layerId}>\n <div\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n {...rest}\n ref={elementRef}\n onKeyDown={composeEventHandlers(onKeyDown, onSurfaceKeyDown)}\n {...(hasTarget\n ? {\n 'data-side': floatingProps['data-side'],\n 'data-align': floatingProps['data-align'],\n style: {\n ...style,\n ...floatingProps.style,\n ...(anchorReady ? undefined : { visibility: 'hidden' as const }),\n },\n }\n : { style })}\n className={cn(\n 'relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8',\n focusRing,\n className,\n )}\n >\n {hasTarget && (\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-teaching-popover-arrow=\"\"\n />\n )}\n\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n className=\"absolute end-3 top-3\"\n onClick={dismiss}\n />\n\n <h3 id={titleId} className=\"mb-2 pe-8 text-subtitle-1 font-semibold text-foreground\">\n {step.title}\n <span className=\"sr-only\">{`, ${stepPosition}`}</span>\n </h3>\n\n <div className=\"mb-4 text-body-1 text-muted-foreground\">{step.body}</div>\n\n <div className=\"flex items-center justify-between gap-2\">\n <div aria-hidden=\"true\" className=\"flex items-center gap-1.5\">\n {steps.map((_, i) => (\n <span\n key={i}\n data-wave-teaching-popover-dot=\"\"\n aria-current={i === index ? 'step' : undefined}\n className={cn(\n 'h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none',\n i === index\n ? cn('w-4 bg-primary', forcedColors.fill)\n : 'w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none',\n )}\n />\n ))}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {count > 1 && (\n <Button\n {...focusableDisabledProps(isFirst)}\n onClick={preventIfDisabled(isFirst, handleBack)}\n >\n {labels?.back ?? DEFAULT_BACK_LABEL}\n </Button>\n )}\n <Button appearance=\"primary\" onClick={handleNext}>\n {isLast ? (labels?.done ?? DEFAULT_DONE_LABEL) : (labels?.next ?? DEFAULT_NEXT_LABEL)}\n </Button>\n </div>\n </div>\n </div>\n </Portal>\n );\n};\nTeachingPopover.displayName = 'TeachingPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDA,IAAMG,KAAqB,QACrBC,KAAqB,QACrBC,KAAqB,QACrBC,MAAoB,GAAe,MAAkB,QAAQC,IAAQ,EAAE,MAAMC;AA6EnF,SAASC,EACP,GAC+C;CAC/C,OAAO,aAAaC;AACtB;AAEA,SAASC,EAAgB,GAA+D;CACtF,OAAOD,KAAU,QAAQ,CAACD,EAAYC,CAAM;AAC9C;AAEA,SAASE,EAAc,GAA4D;CAEjF,OADKF,IACED,EAAYC,CAAM,IAAIA,EAAO,UAAUA,IAD1B;AAEtB;AAEA,SAASG,EAAU,GAAc,GAAuB;CAEtD,OADK,OAAO,SAASC,CAAI,IAClB,KAAK,IAAI,KAAK,IAAI,KAAK,MAAMA,CAAI,GAAG,CAAC,GAAGN,IAAQ,CAAC,IADrB;AAErC;AA6BA,IAAaO,KAAmB,EAC9B,UACA,YAAYC,IACZ,uBACA,iBACA,wBACA,kBACA,eACA,MAAMC,IACN,iBACA,kBACA,iBAAa,SACb,WACA,WACA,WAAO,UACP,WAAQ,UACR,cACA,UACA,cACA,QACA,GAAGC,QACuB;CAC1B,IAAMC,IAAiBC,EACrB,mBACAJ,IACAK,IACA,eACA,YACF,GACMC,IACJF,EACE,mBACAG,IACAC,IACA,sBACA,mBACF,KAAK,GACD,CAACC,GAASC,KAAWC,EAAgBR,GAAgBG,GAAaM,EAAY,GAC9E,CAACC,IAAMC,MAAWH,EAAgBV,IAAUc,MAAe,IAAMC,EAAY,GAC7EC,IAAUjC,GAAM,wBAAwB,GACxCkC,IAAWC,GAAY,GAEvB3B,IAAQ4B,EAAM,QACdC,IAAQR,MAAQrB,IAAQ,GACxBD,IAA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IACtC,iGACN;MACD,GATMD,CASN,CACF;KACE,CAAA,GAEL,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACGpF,IAAQ,KACP,kBAACiF,GAAD;OACE,GAAIK,GAAuBtD,CAAO;OAClC,SAASuD,GAAkBvD,GAASqC,EAAU;OAE7C,UAAAjC,GAAQ,QAAQzC;MACX,CAAA,GAEV,kBAACsF,GAAD;OAAQ,YAAW;OAAU,SAASX;OACnC,UAAArC,IAAUG,GAAQ,QAAQvC,KAAuBuC,GAAQ,QAAQxC;MAC5D,CAAA,CACL;KACF,CAAA,CAAA;;GACF;;CACC,CAAA;AAEZ;AACA,EAAgB,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../hooks/useEventCallback.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../lib/focus.cjs"),c=require("../../hooks/useMergedRefs.cjs"),l=require("../../hooks/useIsClient.cjs"),u=require("../../lib/aria.cjs"),d=require("../../hooks/useDismiss.cjs"),ee=require("../portal/Portal.cjs"),f=require("../../hooks/usePopupPosition.cjs"),p=require("../../lib/renderTrigger.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var te={dark:`inverted`,light:`normal`},g={inverted:`border border-inverted-border bg-inverted text-inverted-foreground`,normal:`border border-border bg-background text-foreground`},_=`max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${[`before:absolute`,`data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2`,`data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2`,`data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2`,`data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2`].join(` `)}`,v=/^on[A-Z]/,y=[`aria-label`,`aria-labelledby`];function b(e){return e.currentTarget.contains(e.target)}function x(e){return t=>{b(t)&&e(t)}}function S(e){let t={},n={};for(let[r,i]of Object.entries(e))r===`id`||r.startsWith(`aria-`)?t[r]=i:n[r]=v.test(r)&&typeof i==`function`?x(i):i;return{childProps:t,wrapperProps:n}}function ne(e,t){let n={...e};for(let e of t)delete n[e];return n}function C(e,t,n){return(e.getAttribute(t)??``).split(/\s+/).includes(n)}function w(e,t,n){let r=(e.getAttribute(t)??``).split(/\s+/).filter(e=>e&&e!==n);r.length>0?e.setAttribute(t,r.join(` `)):e.removeAttribute(t)}function re(e,t,r,i){let a=m.useRef(null),o=r===`label`?`aria-labelledby`:`aria-describedby`;m.useLayoutEffect(()=>{let r=e.current;if(!r)return;let c=()=>{let e=a.current,c=Array.from(r.querySelectorAll(`[${o}]`)).filter(n=>!(e&&e.element===n&&e.attribute===o)&&C(n,o,t)).some(e=>e.matches(s.FOCUSABLE_SELECTOR))?null:s.getFirstTabbable(r);e&&(e.element!==c||e.attribute!==o)&&(w(e.element,e.attribute,t),a.current=null),c&&(C(c,o,t)||c.setAttribute(o,u.joinIds(c.getAttribute(o),t)??``),a.current={element:c,attribute:o},i||n.warnOnce(`Tooltip:focus-target`,`Tooltip: the element that takes focus inside it did not get \`${o}\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content="…"><Button /></Tooltip></Popover.Trigger>.`))};if(c(),!a.current||typeof MutationObserver>`u`)return;let l=new MutationObserver(c);return l.observe(r,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[o]}),()=>l.disconnect()})}var T=({content:e,appearance:s,variant:v,openDelay:C,closeDelay:w=100,delay:T,open:E,defaultOpen:D,onOpenChange:O,relationship:k=`description`,side:ie=`top`,align:ae=`center`,children:oe,className:se,onMouseEnter:ce,onMouseLeave:A,onFocus:j,onBlur:M,ref:N,...P})=>{let F=n.resolveDeprecatedProp(`Tooltip`,s,v===void 0?void 0:te[v],`variant`,`appearance`)??`inverted`,I=n.resolveDeprecatedProp(`Tooltip`,C,T,`delay`,`openDelay`)??200,[L,R]=a.useControllable(E,D??!1,O),z=l.useIsClient(),B=L&&z,V=m.useRef(void 0),H=m.useRef(null),U=m.useRef(null),W=o.useId(`tooltip`),{setReference:le,setFloating:ue,floatingProps:de}=f.usePopupPosition({open:B,side:ie,align:ae,offset:8}),fe=c.useMergedRefs(N,H,le),pe=c.useMergedRefs(U,ue),G=i.useEventCallback(()=>{V.current!==void 0&&(clearTimeout(V.current),V.current=void 0)}),K=i.useEventCallback(()=>{if(G(),!B){if(I<=0){R(!0);return}V.current=setTimeout(()=>{V.current=void 0,R(!0)},I)}}),q=i.useEventCallback(()=>{G(),R(!1)}),me=i.useEventCallback(()=>{G(),B&&(V.current=setTimeout(()=>{V.current=void 0,R(!1)},w))});d.useDismiss({open:B,onDismiss:q,refs:[H,U],anchorRef:H,kind:`tooltip`,outsidePress:!1}),m.useEffect(()=>{let e=V;return()=>clearTimeout(e.current)},[]);let he=i.useEventCallback(e=>{(b(e)||U.current?.contains(e.target))&&K()}),ge=i.useEventCallback(e=>{!b(e)&&!U.current?.contains(e.target)&&q()}),{childProps:J,wrapperProps:Y}=S(P),X=p.unwrapFragment(oe),Z=!p.isCloneableElement(X),Q=k===`label`?`aria-labelledby`:`aria-describedby`,$=Z?ne(J,[...p.STATE_ARIA,...y]):{...J};(!Z||k===`description`)&&($[Q]=u.joinIds(J[Q],W));let _e=p.renderTrigger(X,$,{componentName:`Tooltip`});return re(H,W,k,Z),(0,h.jsxs)(`span`,{ref:fe,...Y,className:t.cn(`inline-block`,se),onMouseEnter:r.composeEventHandlers(ce,he),onMouseLeave:r.composeEventHandlers(A,me),onMouseOver:r.composeEventHandlers(Y.onMouseOver,ge),onFocus:x(r.composeEventHandlers(j,K)),onBlur:x(r.composeEventHandlers(M,q)),children:[_e,(0,h.jsx)(`span`,{id:W,role:`tooltip`,hidden:!0,children:e}),B&&(0,h.jsx)(ee.Portal,{layer:`tooltip`,children:(0,h.jsx)(`span`,{ref:pe,"aria-hidden":`true`,"data-wave-tooltip-surface":``,...de,className:t.cn(_,g[F]),children:e})})]})};T.displayName=`Tooltip`,exports.Tooltip=T;
2
+ //# sourceMappingURL=Tooltip.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.cjs","names":["React","FOCUSABLE_SELECTOR","getFirstTabbable","joinIds","resolveDeprecatedProp","useControllable","useIsClient","useId","usePopupPosition","useMergedRefs","useEventCallback","unwrapFragment","isCloneableElement","STATE_ARIA","renderTrigger","cn","composeEventHandlers","Portal","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_useEventCallback","require_useControllable","require_useId","require_focus","require_useMergedRefs","require_useIsClient","require_aria","require_useDismiss","require_Portal","require_usePopupPosition","require_renderTrigger","react","react_jsx_runtime","VARIANT_APPEARANCE","appearanceClasses","surfaceClasses","HANDLER_KEY","NAMING_ARIA","isOwnEvent","event","ownEventsOnly","handler","splitProps","childProps","wrapperProps","key","value","props","omit","result","keys","hasIdRef","el","attribute","id","removeIdRef","rest","useRelationshipTarget","appliedRef","relationship","wrapper","wrapperRef","update","applied","target","tooltipId","childIsFallback","observer","Tooltip","appearanceProp","openDelayProp","openProp","appearance","variant","openDelay","delay","open","setOpen","defaultOpen","onOpenChange","isClient","visible","timerRef","surfaceRef","wrapperElementRef","ref","setReference","surfaceElementRef","setFloating","clearTimer","show","hide","scheduleHide","closeDelay","timer","showOnEnter","hideOverPortaledPopup","children","triggerProps","child","className","onMouseEnter","onMouseLeave","onFocus","onBlur","content","floatingProps"],"sources":["../../../src/components/overlays/Tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { joinIds } from '../../lib/aria';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { FOCUSABLE_SELECTOR, getFirstTabbable } from '../../lib/focus';\nimport {\n isCloneableElement,\n renderTrigger,\n STATE_ARIA,\n unwrapFragment,\n} from '../../lib/renderTrigger';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { Portal } from '../portal/Portal';\n\n/** Color treatment of a tooltip (`TooltipProps.appearance`). */\nexport type TooltipAppearance = 'inverted' | 'normal';\n\n/** Properties for the Tooltip component. */\nexport interface TooltipProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'content'> {\n /** Content to display inside the tooltip (short, non-interactive text). */\n content: React.ReactNode;\n /**\n * Color treatment: `inverted` (dark surface in the light theme) or `normal` (the page\n * background with a border).\n * @default 'inverted'\n */\n appearance?: TooltipAppearance;\n /**\n * @deprecated Use `appearance` (`'dark'` → `'inverted'`, `'light'` → `'normal'`).\n */\n variant?: 'dark' | 'light';\n /**\n * Milliseconds before the tooltip appears when the pointer rests on the child or the child\n * receives keyboard focus (Fluent's `showDelay`; unlike Menu's and Popover's `openDelay`, it\n * applies to focus too).\n * @default 200\n */\n openDelay?: number;\n /**\n * Milliseconds before it hides once the pointer has left the child and the tooltip (Fluent's\n * `hideDelay`); blur and Escape hide it at once.\n * @default 100\n */\n closeDelay?: number;\n /** @deprecated Use `openDelay`. */\n delay?: number;\n /**\n * Controlled open state (Fluent's `visible`). The tooltip still asks to open on hover and focus\n * (after `openDelay`) and to close on leave, blur and Escape through `onOpenChange`. The surface\n * renders only in the browser: an open tooltip is closed in the server HTML and opens once it\n * has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the new open state when it changes (Fluent's `onVisibleChange`). It has no\n * `details` argument yet.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * How the tooltip relates to its child: `description` adds it to the child's\n * `aria-describedby`; `label` adds it to the child's `aria-labelledby`, naming an icon-only\n * button.\n * @default 'description'\n */\n relationship?: 'description' | 'label';\n /**\n * Side of the target the tooltip opens on. `start`/`end` follow the writing direction; the\n * tooltip flips to the opposite side when there is not enough room.\n * @default 'top'\n */\n side?: PopupSide;\n /** Alignment along the target's edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /**\n * A single element that triggers the tooltip on hover and focus: it receives the\n * `aria-describedby`/`aria-labelledby`, plus any `id` and `aria-*` props given to the Tooltip\n * (a Fragment around one element counts as that element). Other children are wrapped in a\n * described `<span>` with a development warning, and their first focusable element gets the\n * relationship.\n */\n children: React.ReactElement;\n /** Ref to the wrapper `<span>` (the positioning anchor). */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\nconst VARIANT_APPEARANCE: Record<'dark' | 'light', TooltipAppearance> = {\n dark: 'inverted',\n light: 'normal',\n};\n\nconst appearanceClasses: Record<TooltipAppearance, string> = {\n inverted: 'border border-inverted-border bg-inverted text-inverted-foreground',\n normal: 'border border-border bg-background text-foreground',\n};\n\n/**\n * Transparent `::before` hover bridge across the 8px gap (the positioning offset) on the side that\n * faces the trigger only, so the pointer can move onto the tooltip; the other sides get no bridge,\n * which would otherwise catch hovers and clicks meant for neighbouring controls.\n */\nconst bridgeClasses = [\n 'before:absolute',\n // Tooltip above the trigger: a strip below it.\n 'data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2',\n // Tooltip below the trigger: a strip above it.\n 'data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2',\n // wave-allow-physical: data-side is the physical side resolved by the positioning\n 'data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2',\n // wave-allow-physical: data-side is the physical side resolved by the positioning\n 'data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2',\n].join(' ');\n\n/**\n * The visual surface: wrapping text, typography reset against the host (header cells, muted\n * panels), and the hover bridge towards the trigger.\n */\nconst surfaceClasses = `max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${bridgeClasses}`;\n\ntype UnknownProps = Record<string, unknown>;\ntype Relationship = NonNullable<TooltipProps['relationship']>;\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/** Naming attributes a generic element such as the fallback `<span>` must not carry. */\nconst NAMING_ARIA = ['aria-label', 'aria-labelledby'] as const;\n\n/**\n * Whether an event reached the wrapper from its own DOM subtree — the child — rather than through\n * a portal: React bubbles events from portaled content (the tooltip surface, a popup the child\n * renders in a portal) through the component tree.\n */\nfunction isOwnEvent(event: React.SyntheticEvent): boolean {\n return (event.currentTarget as Node).contains(event.target as Node);\n}\n\n/** `handler`, called only for the wrapper's own events (see {@link isOwnEvent}). */\nfunction ownEventsOnly<E extends React.SyntheticEvent>(\n handler: (event: E) => void,\n): (event: E) => void {\n return (event) => {\n if (isOwnEvent(event)) handler(event);\n };\n}\n\n/**\n * Splits the props the Tooltip receives, from its consumer or from a parent that clones its child\n * (Menu.Trigger, Popover.Trigger, Dialog.Trigger, Field): `id` and `aria-*` describe the element\n * the Tooltip is attached to, so they go to the child; the rest stays on the wrapper `<span>`.\n */\nfunction splitProps(props: UnknownProps): { childProps: UnknownProps; wrapperProps: UnknownProps } {\n const childProps: UnknownProps = {};\n const wrapperProps: UnknownProps = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'id' || key.startsWith('aria-')) childProps[key] = value;\n else if (HANDLER_KEY.test(key) && typeof value === 'function') {\n // The wrapper sees the child's events as they bubble, but not those that reach it through\n // a portal, such as a click on the tooltip surface (it would toggle a parent trigger).\n wrapperProps[key] = ownEventsOnly(value as (event: React.SyntheticEvent) => void);\n } else wrapperProps[key] = value;\n }\n return { childProps, wrapperProps };\n}\n\nfunction omit(props: UnknownProps, keys: readonly string[]): UnknownProps {\n const result = { ...props };\n for (const key of keys) delete result[key];\n return result;\n}\n\nfunction hasIdRef(el: Element, attribute: string, id: string): boolean {\n return (el.getAttribute(attribute) ?? '').split(/\\s+/).includes(id);\n}\n\nfunction removeIdRef(el: Element, attribute: string, id: string): void {\n const rest = (el.getAttribute(attribute) ?? '')\n .split(/\\s+/)\n .filter((value) => value && value !== id);\n if (rest.length > 0) el.setAttribute(attribute, rest.join(' '));\n else el.removeAttribute(attribute);\n}\n\n/**\n * Makes sure the element people focus carries the tooltip relationship. After each commit, when no\n * focusable element inside the wrapper references `tooltipId` through `attribute` — children in the\n * fallback span, a non-focusable child element, or a child component that drops the prop (a\n * Popover or Dialog root) — the id is added to the first tabbable element inside the wrapper and\n * kept there while the subtree changes; a development warning explains the nesting, except for\n * the fallback span, whose children shape `renderTrigger` already warned about.\n */\nfunction useRelationshipTarget(\n wrapperRef: React.RefObject<HTMLSpanElement | null>,\n tooltipId: string,\n relationship: Relationship,\n childIsFallback: boolean,\n): void {\n const appliedRef = React.useRef<{ element: Element; attribute: string } | null>(null);\n const attribute = relationship === 'label' ? 'aria-labelledby' : 'aria-describedby';\n\n React.useLayoutEffect(() => {\n const wrapper = wrapperRef.current;\n if (!wrapper) return;\n\n const update = () => {\n const applied = appliedRef.current;\n const carriers = Array.from(wrapper.querySelectorAll(`[${attribute}]`)).filter(\n (el) =>\n !(applied && applied.element === el && applied.attribute === attribute) &&\n hasIdRef(el, attribute, tooltipId),\n );\n const reached = carriers.some((el) => el.matches(FOCUSABLE_SELECTOR));\n const target = reached ? null : getFirstTabbable(wrapper);\n if (applied && (applied.element !== target || applied.attribute !== attribute)) {\n removeIdRef(applied.element, applied.attribute, tooltipId);\n appliedRef.current = null;\n }\n if (!target) return;\n if (!hasIdRef(target, attribute, tooltipId)) {\n target.setAttribute(attribute, joinIds(target.getAttribute(attribute), tooltipId) ?? '');\n }\n appliedRef.current = { element: target, attribute };\n if (!childIsFallback) {\n warnOnce(\n 'Tooltip:focus-target',\n `Tooltip: the element that takes focus inside it did not get \\`${attribute}\\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content=\"…\"><Button /></Tooltip></Popover.Trigger>.`,\n );\n }\n };\n\n update();\n if (!appliedRef.current || typeof MutationObserver === 'undefined') return;\n // Keep it on the focusable element when the child replaces it or rewrites the attribute\n // without the Tooltip re-rendering.\n const observer = new MutationObserver(update);\n observer.observe(wrapper, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: [attribute],\n });\n return () => observer.disconnect();\n });\n}\n\n/**\n * Shows a short text label or description for its child on hover and keyboard focus.\n *\n * - The text is always present as a hidden `role=\"tooltip\"` element referenced by the child's\n * `aria-describedby` (or `aria-labelledby` with `relationship=\"label\"`), so screen readers get\n * it on focus without waiting for the delay; the child's own ids are kept.\n * - The visual surface is rendered in a portal only while visible (it is `aria-hidden`, a copy of\n * the description), positioned on `side`/`align` with flipping and shifting to stay in view.\n * - It appears `openDelay` after the pointer rests on the child or the child takes keyboard focus,\n * stays visible while the pointer moves onto it, hides `closeDelay` after the pointer leaves or\n * immediately on blur, and Escape hides it without closing an enclosing dialog or popover. Focus\n * and hover inside a popup the child renders in a portal (a DatePicker calendar, a listbox) do\n * not show it, and the pointer moving onto such a popup hides it.\n * - The open state is uncontrolled by default (`defaultOpen`). With `open` and `onOpenChange`\n * (Fluent's `visible` and `onVisibleChange`) the parent owns it: hover, focus, leave, blur and\n * Escape then only ask for a change, and `open` alone shows the surface.\n * - `id` and `aria-*` props given to the Tooltip go to its child, merged with the child's own (the\n * child's `id` wins, id lists are joined, `aria-expanded`/`aria-controls`/`aria-haspopup` from\n * the Tooltip win). `className`, `style`, `ref`, `data-*` and event handlers stay on the wrapper\n * `<span>`; the handlers see the child's events as they bubble, not events from portaled\n * content such as the tooltip surface or a popup the child renders in a portal (a DatePicker\n * calendar, a listbox). `onMouseEnter` and `onMouseLeave` are the exception: React fires them\n * along the component tree, so they also fire when the pointer moves onto or off the tooltip\n * surface or such a popup. So the Tooltip can sit inside a trigger, and the trigger's\n * id and state reach the button: `<Menu.Trigger><Tooltip content=\"…\"><Button /></Tooltip>\n * </Menu.Trigger>` (also `Popover.Trigger`, `Dialog.Trigger`, `Drawer.Trigger`). Around a\n * trigger works too, since triggers pass `aria-describedby` on to their child.\n * - Wrap the focusable element itself. When the element that takes focus does not get the\n * relationship (a Popover or Dialog root, a component that drops props, a non-focusable\n * wrapper element), it is added to the first focusable element inside, with a development\n * warning.\n *\n * @example\n * <Menu>\n * <Menu.Trigger>\n * <Tooltip content=\"Edit, duplicate or delete the item\">\n * <Button>Actions</Button>\n * </Tooltip>\n * </Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover>\n * </Menu>\n */\nexport const Tooltip = ({\n content,\n appearance: appearanceProp,\n variant,\n openDelay: openDelayProp,\n closeDelay = 100,\n delay,\n open: openProp,\n defaultOpen,\n onOpenChange,\n relationship = 'description',\n side = 'top',\n align = 'center',\n children,\n className,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TooltipProps) => {\n const appearance =\n resolveDeprecatedProp(\n 'Tooltip',\n appearanceProp,\n variant === undefined ? undefined : VARIANT_APPEARANCE[variant],\n 'variant',\n 'appearance',\n ) ?? 'inverted';\n const openDelay =\n resolveDeprecatedProp('Tooltip', openDelayProp, delay, 'delay', 'openDelay') ?? 200;\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? false, onOpenChange);\n // The surface lives in a portal, which renders only in the browser: until then (the server HTML,\n // hydration) the tooltip is closed; the hidden description is rendered either way.\n const isClient = useIsClient();\n const visible = open && isClient;\n const timerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const wrapperRef = React.useRef<HTMLSpanElement | null>(null);\n const surfaceRef = React.useRef<HTMLSpanElement | null>(null);\n const tooltipId = useId('tooltip');\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: visible,\n side,\n align,\n offset: 8,\n });\n const wrapperElementRef = useMergedRefs<HTMLSpanElement>(ref, wrapperRef, setReference);\n const surfaceElementRef = useMergedRefs<HTMLSpanElement>(surfaceRef, setFloating);\n\n // Timer handlers are event callbacks (stable, latest state): they are composed with the\n // consumer's handlers during render but only run from events and timers.\n const clearTimer = useEventCallback(() => {\n if (timerRef.current !== undefined) {\n clearTimeout(timerRef.current);\n timerRef.current = undefined;\n }\n });\n\n // show, hide and scheduleHide ask for the new state; a controlled tooltip changes only when the\n // parent updates `open`.\n const show = useEventCallback(() => {\n clearTimer();\n if (visible) return;\n if (openDelay <= 0) {\n setOpen(true);\n return;\n }\n timerRef.current = setTimeout(() => {\n timerRef.current = undefined;\n setOpen(true);\n }, openDelay);\n });\n\n const hide = useEventCallback(() => {\n clearTimer();\n setOpen(false);\n });\n\n // The grace period after the pointer leaves lets it move onto the tooltip.\n const scheduleHide = useEventCallback(() => {\n clearTimer();\n if (!visible) return;\n timerRef.current = setTimeout(() => {\n timerRef.current = undefined;\n setOpen(false);\n }, closeDelay);\n });\n\n // An Escape-only layer while visible: Escape hides the tooltip before any enclosing overlay. The\n // wrapper is its anchor (its trigger, not its surface): Tab from the child inside a focus trap\n // moves on from the popover, portal or dialog around the wrapper.\n useDismiss({\n open: visible,\n onDismiss: hide,\n refs: [wrapperRef, surfaceRef],\n anchorRef: wrapperRef,\n kind: 'tooltip',\n outsidePress: false,\n });\n\n React.useEffect(() => {\n const timer = timerRef;\n return () => clearTimeout(timer.current);\n }, []);\n\n // The tooltip's own reactions ignore a popup the child renders in a portal: its focus and blur\n // are not the child's, entering it does not show the tooltip, and the pointer moving onto it\n // (no mouseleave reaches the wrapper then) hides the tooltip, which would cover it. The tooltip\n // surface itself is portaled too but belongs to the tooltip: it stays hoverable.\n const showOnEnter = useEventCallback((event: React.MouseEvent<HTMLSpanElement>) => {\n if (isOwnEvent(event) || surfaceRef.current?.contains(event.target as Node)) show();\n });\n const hideOverPortaledPopup = useEventCallback((event: React.MouseEvent<HTMLSpanElement>) => {\n if (!isOwnEvent(event) && !surfaceRef.current?.contains(event.target as Node)) hide();\n });\n\n const { childProps, wrapperProps } = splitProps(rest);\n const target = unwrapFragment(children);\n const childIsFallback = !isCloneableElement(target);\n const attribute = relationship === 'label' ? 'aria-labelledby' : 'aria-describedby';\n // Props given to the Tooltip come first, as if the child had them; then the tooltip's own id.\n // The fallback span is a generic element: no state ARIA and no naming on it (the relationship\n // then reaches its first focusable element through useRelationshipTarget).\n const triggerProps: UnknownProps = childIsFallback\n ? omit(childProps, [...STATE_ARIA, ...NAMING_ARIA])\n : { ...childProps };\n if (!childIsFallback || relationship === 'description') {\n triggerProps[attribute] = joinIds(childProps[attribute] as string | undefined, tooltipId);\n }\n const child = renderTrigger(target, triggerProps, { componentName: 'Tooltip' });\n useRelationshipTarget(wrapperRef, tooltipId, relationship, childIsFallback);\n\n return (\n <span\n ref={wrapperElementRef}\n {...wrapperProps}\n className={cn('inline-block', className)}\n onMouseEnter={composeEventHandlers(onMouseEnter, showOnEnter)}\n onMouseLeave={composeEventHandlers(onMouseLeave, scheduleHide)}\n onMouseOver={composeEventHandlers(\n wrapperProps.onMouseOver as React.MouseEventHandler<HTMLSpanElement> | undefined,\n hideOverPortaledPopup,\n )}\n onFocus={ownEventsOnly(composeEventHandlers(onFocus, show))}\n onBlur={ownEventsOnly(composeEventHandlers(onBlur, hide))}\n >\n {child}\n <span id={tooltipId} role=\"tooltip\" hidden>\n {content}\n </span>\n {visible && (\n <Portal layer=\"tooltip\">\n <span\n ref={surfaceElementRef}\n aria-hidden=\"true\"\n data-wave-tooltip-surface=\"\"\n {...floatingProps}\n className={cn(surfaceClasses, appearanceClasses[appearance])}\n >\n {content}\n </span>\n </Portal>\n )}\n </span>\n );\n};\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AgBuF,EAAS,EACvC,aAActF,EAAAA,qBAAqBuF,GAAcN,EAAW,EAC5D,aAAcjF,EAAAA,qBAAqBwF,EAAcV,EAAY,EAC7D,YAAa9E,EAAAA,qBACX8B,EAAa,YACboD,EACF,EACA,QAASxD,EAAc1B,EAAAA,qBAAqByF,EAASb,CAAI,CAAC,EAC1D,OAAQlD,EAAc1B,EAAAA,qBAAqB0F,EAAQb,CAAI,CAAC,EAX1D,SAAA,CAaGQ,IACD,EAAAnE,EAAA,IAAA,CAAC,OAAD,CAAM,GAAIiC,EAAW,KAAK,UAAU,OAAA,GACjC,SAAAwC,CACG,CAAA,EACLxB,IACC,EAAAjD,EAAA,IAAA,CAACjB,GAAAA,OAAD,CAAQ,MAAM,UACZ,UAAA,EAAAiB,EAAA,IAAA,CAAC,OAAD,CACE,IAAKuD,GACL,cAAY,OACZ,4BAA0B,GAC1B,GAAImB,GACJ,UAAW7F,EAAAA,GAAGsB,EAAgBD,EAAkBsC,EAAW,EAE1D,SAAAiC,CACG,CAAA,CACA,CAAA,CAEN,GAEV,EAEA,EAAQ,YAAc"}
@@ -0,0 +1,160 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { resolveDeprecatedProp as t, warnOnce as n } from "../../lib/dev.mjs";
4
+ import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
5
+ import { useEventCallback as i } from "../../hooks/useEventCallback.mjs";
6
+ import { useControllable as a } from "../../hooks/useControllable.mjs";
7
+ import { useId as o } from "../../hooks/useId.mjs";
8
+ import { FOCUSABLE_SELECTOR as s, getFirstTabbable as c } from "../../lib/focus.mjs";
9
+ import { useMergedRefs as l } from "../../hooks/useMergedRefs.mjs";
10
+ import { useIsClient as u } from "../../hooks/useIsClient.mjs";
11
+ import { joinIds as d } from "../../lib/aria.mjs";
12
+ import { useDismiss as ee } from "../../hooks/useDismiss.mjs";
13
+ import { Portal as f } from "../portal/Portal.mjs";
14
+ import { usePopupPosition as p } from "../../hooks/usePopupPosition.mjs";
15
+ import { STATE_ARIA as te, isCloneableElement as ne, renderTrigger as m, unwrapFragment as h } from "../../lib/renderTrigger.mjs";
16
+ import * as g from "react";
17
+ import { jsx as _, jsxs as re } from "react/jsx-runtime";
18
+ //#region src/components/overlays/Tooltip.tsx
19
+ var ie = {
20
+ dark: "inverted",
21
+ light: "normal"
22
+ }, ae = {
23
+ inverted: "border border-inverted-border bg-inverted text-inverted-foreground",
24
+ normal: "border border-border bg-background text-foreground"
25
+ }, oe = `max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${[
26
+ "before:absolute",
27
+ "data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2",
28
+ "data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2",
29
+ "data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2",
30
+ "data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2"
31
+ ].join(" ")}`, v = /^on[A-Z]/, se = ["aria-label", "aria-labelledby"];
32
+ function y(e) {
33
+ return e.currentTarget.contains(e.target);
34
+ }
35
+ function b(e) {
36
+ return (t) => {
37
+ y(t) && e(t);
38
+ };
39
+ }
40
+ function x(e) {
41
+ let t = {}, n = {};
42
+ for (let [r, i] of Object.entries(e)) r === "id" || r.startsWith("aria-") ? t[r] = i : n[r] = v.test(r) && typeof i == "function" ? b(i) : i;
43
+ return {
44
+ childProps: t,
45
+ wrapperProps: n
46
+ };
47
+ }
48
+ function ce(e, t) {
49
+ let n = { ...e };
50
+ for (let e of t) delete n[e];
51
+ return n;
52
+ }
53
+ function S(e, t, n) {
54
+ return (e.getAttribute(t) ?? "").split(/\s+/).includes(n);
55
+ }
56
+ function C(e, t, n) {
57
+ let r = (e.getAttribute(t) ?? "").split(/\s+/).filter((e) => e && e !== n);
58
+ r.length > 0 ? e.setAttribute(t, r.join(" ")) : e.removeAttribute(t);
59
+ }
60
+ function le(e, t, r, i) {
61
+ let a = g.useRef(null), o = r === "label" ? "aria-labelledby" : "aria-describedby";
62
+ g.useLayoutEffect(() => {
63
+ let r = e.current;
64
+ if (!r) return;
65
+ let l = () => {
66
+ let e = a.current, l = Array.from(r.querySelectorAll(`[${o}]`)).filter((n) => !(e && e.element === n && e.attribute === o) && S(n, o, t)).some((e) => e.matches(s)) ? null : c(r);
67
+ e && (e.element !== l || e.attribute !== o) && (C(e.element, e.attribute, t), a.current = null), l && (S(l, o, t) || l.setAttribute(o, d(l.getAttribute(o), t) ?? ""), a.current = {
68
+ element: l,
69
+ attribute: o
70
+ }, i || n("Tooltip:focus-target", `Tooltip: the element that takes focus inside it did not get \`${o}\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content="…"><Button /></Tooltip></Popover.Trigger>.`));
71
+ };
72
+ if (l(), !a.current || typeof MutationObserver > "u") return;
73
+ let u = new MutationObserver(l);
74
+ return u.observe(r, {
75
+ subtree: !0,
76
+ childList: !0,
77
+ attributes: !0,
78
+ attributeFilter: [o]
79
+ }), () => u.disconnect();
80
+ });
81
+ }
82
+ var w = ({ content: n, appearance: s, variant: c, openDelay: v, closeDelay: S = 100, delay: C, open: w, defaultOpen: ue, onOpenChange: de, relationship: T = "description", side: fe = "top", align: E = "center", children: D, className: O, onMouseEnter: k, onMouseLeave: A, onFocus: j, onBlur: M, ref: N, ...P }) => {
83
+ let F = t("Tooltip", s, c === void 0 ? void 0 : ie[c], "variant", "appearance") ?? "inverted", I = t("Tooltip", v, C, "delay", "openDelay") ?? 200, [L, R] = a(w, ue ?? !1, de), z = u(), B = L && z, V = g.useRef(void 0), H = g.useRef(null), U = g.useRef(null), W = o("tooltip"), { setReference: pe, setFloating: me, floatingProps: he } = p({
84
+ open: B,
85
+ side: fe,
86
+ align: E,
87
+ offset: 8
88
+ }), ge = l(N, H, pe), _e = l(U, me), G = i(() => {
89
+ V.current !== void 0 && (clearTimeout(V.current), V.current = void 0);
90
+ }), K = i(() => {
91
+ if (G(), !B) {
92
+ if (I <= 0) {
93
+ R(!0);
94
+ return;
95
+ }
96
+ V.current = setTimeout(() => {
97
+ V.current = void 0, R(!0);
98
+ }, I);
99
+ }
100
+ }), q = i(() => {
101
+ G(), R(!1);
102
+ }), ve = i(() => {
103
+ G(), B && (V.current = setTimeout(() => {
104
+ V.current = void 0, R(!1);
105
+ }, S));
106
+ });
107
+ ee({
108
+ open: B,
109
+ onDismiss: q,
110
+ refs: [H, U],
111
+ anchorRef: H,
112
+ kind: "tooltip",
113
+ outsidePress: !1
114
+ }), g.useEffect(() => {
115
+ let e = V;
116
+ return () => clearTimeout(e.current);
117
+ }, []);
118
+ let ye = i((e) => {
119
+ (y(e) || U.current?.contains(e.target)) && K();
120
+ }), be = i((e) => {
121
+ !y(e) && !U.current?.contains(e.target) && q();
122
+ }), { childProps: J, wrapperProps: Y } = x(P), X = h(D), Z = !ne(X), Q = T === "label" ? "aria-labelledby" : "aria-describedby", $ = Z ? ce(J, [...te, ...se]) : { ...J };
123
+ (!Z || T === "description") && ($[Q] = d(J[Q], W));
124
+ let xe = m(X, $, { componentName: "Tooltip" });
125
+ return le(H, W, T, Z), /* @__PURE__ */ re("span", {
126
+ ref: ge,
127
+ ...Y,
128
+ className: e("inline-block", O),
129
+ onMouseEnter: r(k, ye),
130
+ onMouseLeave: r(A, ve),
131
+ onMouseOver: r(Y.onMouseOver, be),
132
+ onFocus: b(r(j, K)),
133
+ onBlur: b(r(M, q)),
134
+ children: [
135
+ xe,
136
+ /* @__PURE__ */ _("span", {
137
+ id: W,
138
+ role: "tooltip",
139
+ hidden: !0,
140
+ children: n
141
+ }),
142
+ B && /* @__PURE__ */ _(f, {
143
+ layer: "tooltip",
144
+ children: /* @__PURE__ */ _("span", {
145
+ ref: _e,
146
+ "aria-hidden": "true",
147
+ "data-wave-tooltip-surface": "",
148
+ ...he,
149
+ className: e(oe, ae[F]),
150
+ children: n
151
+ })
152
+ })
153
+ ]
154
+ });
155
+ };
156
+ w.displayName = "Tooltip";
157
+ //#endregion
158
+ export { w as Tooltip };
159
+
160
+ //# sourceMappingURL=Tooltip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.mjs","names":["useId","useId$1","React","VARIANT_APPEARANCE","appearanceClasses","surfaceClasses","HANDLER_KEY","NAMING_ARIA","isOwnEvent","event","ownEventsOnly","handler","splitProps","childProps","wrapperProps","key","value","props","omit","result","keys","hasIdRef","el","attribute","id","removeIdRef","rest","useRelationshipTarget","appliedRef","relationship","wrapper","wrapperRef","update","applied","target","tooltipId","FOCUSABLE_SELECTOR","getFirstTabbable","joinIds","childIsFallback","warnOnce","observer","Tooltip","appearanceProp","openDelayProp","openProp","appearance","resolveDeprecatedProp","variant","openDelay","delay","open","setOpen","useControllable","defaultOpen","onOpenChange","isClient","useIsClient","visible","timerRef","surfaceRef","usePopupPosition","wrapperElementRef","useMergedRefs","ref","setReference","surfaceElementRef","setFloating","clearTimer","useEventCallback","show","hide","scheduleHide","closeDelay","useDismiss","timer","showOnEnter","hideOverPortaledPopup","unwrapFragment","children","isCloneableElement","triggerProps","STATE_ARIA","child","renderTrigger","cn","className","composeEventHandlers","onMouseEnter","onMouseLeave","onFocus","onBlur","content","Portal","floatingProps"],"sources":["../../../src/components/overlays/Tooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { joinIds } from '../../lib/aria';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { FOCUSABLE_SELECTOR, getFirstTabbable } from '../../lib/focus';\nimport {\n isCloneableElement,\n renderTrigger,\n STATE_ARIA,\n unwrapFragment,\n} from '../../lib/renderTrigger';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { Portal } from '../portal/Portal';\n\n/** Color treatment of a tooltip (`TooltipProps.appearance`). */\nexport type TooltipAppearance = 'inverted' | 'normal';\n\n/** Properties for the Tooltip component. */\nexport interface TooltipProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'content'> {\n /** Content to display inside the tooltip (short, non-interactive text). */\n content: React.ReactNode;\n /**\n * Color treatment: `inverted` (dark surface in the light theme) or `normal` (the page\n * background with a border).\n * @default 'inverted'\n */\n appearance?: TooltipAppearance;\n /**\n * @deprecated Use `appearance` (`'dark'` → `'inverted'`, `'light'` → `'normal'`).\n */\n variant?: 'dark' | 'light';\n /**\n * Milliseconds before the tooltip appears when the pointer rests on the child or the child\n * receives keyboard focus (Fluent's `showDelay`; unlike Menu's and Popover's `openDelay`, it\n * applies to focus too).\n * @default 200\n */\n openDelay?: number;\n /**\n * Milliseconds before it hides once the pointer has left the child and the tooltip (Fluent's\n * `hideDelay`); blur and Escape hide it at once.\n * @default 100\n */\n closeDelay?: number;\n /** @deprecated Use `openDelay`. */\n delay?: number;\n /**\n * Controlled open state (Fluent's `visible`). The tooltip still asks to open on hover and focus\n * (after `openDelay`) and to close on leave, blur and Escape through `onOpenChange`. The surface\n * renders only in the browser: an open tooltip is closed in the server HTML and opens once it\n * has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the new open state when it changes (Fluent's `onVisibleChange`). It has no\n * `details` argument yet.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * How the tooltip relates to its child: `description` adds it to the child's\n * `aria-describedby`; `label` adds it to the child's `aria-labelledby`, naming an icon-only\n * button.\n * @default 'description'\n */\n relationship?: 'description' | 'label';\n /**\n * Side of the target the tooltip opens on. `start`/`end` follow the writing direction; the\n * tooltip flips to the opposite side when there is not enough room.\n * @default 'top'\n */\n side?: PopupSide;\n /** Alignment along the target's edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /**\n * A single element that triggers the tooltip on hover and focus: it receives the\n * `aria-describedby`/`aria-labelledby`, plus any `id` and `aria-*` props given to the Tooltip\n * (a Fragment around one element counts as that element). Other children are wrapped in a\n * described `<span>` with a development warning, and their first focusable element gets the\n * relationship.\n */\n children: React.ReactElement;\n /** Ref to the wrapper `<span>` (the positioning anchor). */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\nconst VARIANT_APPEARANCE: Record<'dark' | 'light', TooltipAppearance> = {\n dark: 'inverted',\n light: 'normal',\n};\n\nconst appearanceClasses: Record<TooltipAppearance, string> = {\n inverted: 'border border-inverted-border bg-inverted text-inverted-foreground',\n normal: 'border border-border bg-background text-foreground',\n};\n\n/**\n * Transparent `::before` hover bridge across the 8px gap (the positioning offset) on the side that\n * faces the trigger only, so the pointer can move onto the tooltip; the other sides get no bridge,\n * which would otherwise catch hovers and clicks meant for neighbouring controls.\n */\nconst bridgeClasses = [\n 'before:absolute',\n // Tooltip above the trigger: a strip below it.\n 'data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2',\n // Tooltip below the trigger: a strip above it.\n 'data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2',\n // wave-allow-physical: data-side is the physical side resolved by the positioning\n 'data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2',\n // wave-allow-physical: data-side is the physical side resolved by the positioning\n 'data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2',\n].join(' ');\n\n/**\n * The visual surface: wrapping text, typography reset against the host (header cells, muted\n * panels), and the hover bridge towards the trigger.\n */\nconst surfaceClasses = `max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${bridgeClasses}`;\n\ntype UnknownProps = Record<string, unknown>;\ntype Relationship = NonNullable<TooltipProps['relationship']>;\n\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/** Naming attributes a generic element such as the fallback `<span>` must not carry. */\nconst NAMING_ARIA = ['aria-label', 'aria-labelledby'] as const;\n\n/**\n * Whether an event reached the wrapper from its own DOM subtree — the child — rather than through\n * a portal: React bubbles events from portaled content (the tooltip surface, a popup the child\n * renders in a portal) through the component tree.\n */\nfunction isOwnEvent(event: React.SyntheticEvent): boolean {\n return (event.currentTarget as Node).contains(event.target as Node);\n}\n\n/** `handler`, called only for the wrapper's own events (see {@link isOwnEvent}). */\nfunction ownEventsOnly<E extends React.SyntheticEvent>(\n handler: (event: E) => void,\n): (event: E) => void {\n return (event) => {\n if (isOwnEvent(event)) handler(event);\n };\n}\n\n/**\n * Splits the props the Tooltip receives, from its consumer or from a parent that clones its child\n * (Menu.Trigger, Popover.Trigger, Dialog.Trigger, Field): `id` and `aria-*` describe the element\n * the Tooltip is attached to, so they go to the child; the rest stays on the wrapper `<span>`.\n */\nfunction splitProps(props: UnknownProps): { childProps: UnknownProps; wrapperProps: UnknownProps } {\n const childProps: UnknownProps = {};\n const wrapperProps: UnknownProps = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'id' || key.startsWith('aria-')) childProps[key] = value;\n else if (HANDLER_KEY.test(key) && typeof value === 'function') {\n // The wrapper sees the child's events as they bubble, but not those that reach it through\n // a portal, such as a click on the tooltip surface (it would toggle a parent trigger).\n wrapperProps[key] = ownEventsOnly(value as (event: React.SyntheticEvent) => void);\n } else wrapperProps[key] = value;\n }\n return { childProps, wrapperProps };\n}\n\nfunction omit(props: UnknownProps, keys: readonly string[]): UnknownProps {\n const result = { ...props };\n for (const key of keys) delete result[key];\n return result;\n}\n\nfunction hasIdRef(el: Element, attribute: string, id: string): boolean {\n return (el.getAttribute(attribute) ?? '').split(/\\s+/).includes(id);\n}\n\nfunction removeIdRef(el: Element, attribute: string, id: string): void {\n const rest = (el.getAttribute(attribute) ?? '')\n .split(/\\s+/)\n .filter((value) => value && value !== id);\n if (rest.length > 0) el.setAttribute(attribute, rest.join(' '));\n else el.removeAttribute(attribute);\n}\n\n/**\n * Makes sure the element people focus carries the tooltip relationship. After each commit, when no\n * focusable element inside the wrapper references `tooltipId` through `attribute` — children in the\n * fallback span, a non-focusable child element, or a child component that drops the prop (a\n * Popover or Dialog root) — the id is added to the first tabbable element inside the wrapper and\n * kept there while the subtree changes; a development warning explains the nesting, except for\n * the fallback span, whose children shape `renderTrigger` already warned about.\n */\nfunction useRelationshipTarget(\n wrapperRef: React.RefObject<HTMLSpanElement | null>,\n tooltipId: string,\n relationship: Relationship,\n childIsFallback: boolean,\n): void {\n const appliedRef = React.useRef<{ element: Element; attribute: string } | null>(null);\n const attribute = relationship === 'label' ? 'aria-labelledby' : 'aria-describedby';\n\n React.useLayoutEffect(() => {\n const wrapper = wrapperRef.current;\n if (!wrapper) return;\n\n const update = () => {\n const applied = appliedRef.current;\n const carriers = Array.from(wrapper.querySelectorAll(`[${attribute}]`)).filter(\n (el) =>\n !(applied && applied.element === el && applied.attribute === attribute) &&\n hasIdRef(el, attribute, tooltipId),\n );\n const reached = carriers.some((el) => el.matches(FOCUSABLE_SELECTOR));\n const target = reached ? null : getFirstTabbable(wrapper);\n if (applied && (applied.element !== target || applied.attribute !== attribute)) {\n removeIdRef(applied.element, applied.attribute, tooltipId);\n appliedRef.current = null;\n }\n if (!target) return;\n if (!hasIdRef(target, attribute, tooltipId)) {\n target.setAttribute(attribute, joinIds(target.getAttribute(attribute), tooltipId) ?? '');\n }\n appliedRef.current = { element: target, attribute };\n if (!childIsFallback) {\n warnOnce(\n 'Tooltip:focus-target',\n `Tooltip: the element that takes focus inside it did not get \\`${attribute}\\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content=\"…\"><Button /></Tooltip></Popover.Trigger>.`,\n );\n }\n };\n\n update();\n if (!appliedRef.current || typeof MutationObserver === 'undefined') return;\n // Keep it on the focusable element when the child replaces it or rewrites the attribute\n // without the Tooltip re-rendering.\n const observer = new MutationObserver(update);\n observer.observe(wrapper, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: [attribute],\n });\n return () => observer.disconnect();\n });\n}\n\n/**\n * Shows a short text label or description for its child on hover and keyboard focus.\n *\n * - The text is always present as a hidden `role=\"tooltip\"` element referenced by the child's\n * `aria-describedby` (or `aria-labelledby` with `relationship=\"label\"`), so screen readers get\n * it on focus without waiting for the delay; the child's own ids are kept.\n * - The visual surface is rendered in a portal only while visible (it is `aria-hidden`, a copy of\n * the description), positioned on `side`/`align` with flipping and shifting to stay in view.\n * - It appears `openDelay` after the pointer rests on the child or the child takes keyboard focus,\n * stays visible while the pointer moves onto it, hides `closeDelay` after the pointer leaves or\n * immediately on blur, and Escape hides it without closing an enclosing dialog or popover. Focus\n * and hover inside a popup the child renders in a portal (a DatePicker calendar, a listbox) do\n * not show it, and the pointer moving onto such a popup hides it.\n * - The open state is uncontrolled by default (`defaultOpen`). With `open` and `onOpenChange`\n * (Fluent's `visible` and `onVisibleChange`) the parent owns it: hover, focus, leave, blur and\n * Escape then only ask for a change, and `open` alone shows the surface.\n * - `id` and `aria-*` props given to the Tooltip go to its child, merged with the child's own (the\n * child's `id` wins, id lists are joined, `aria-expanded`/`aria-controls`/`aria-haspopup` from\n * the Tooltip win). `className`, `style`, `ref`, `data-*` and event handlers stay on the wrapper\n * `<span>`; the handlers see the child's events as they bubble, not events from portaled\n * content such as the tooltip surface or a popup the child renders in a portal (a DatePicker\n * calendar, a listbox). `onMouseEnter` and `onMouseLeave` are the exception: React fires them\n * along the component tree, so they also fire when the pointer moves onto or off the tooltip\n * surface or such a popup. So the Tooltip can sit inside a trigger, and the trigger's\n * id and state reach the button: `<Menu.Trigger><Tooltip content=\"…\"><Button /></Tooltip>\n * </Menu.Trigger>` (also `Popover.Trigger`, `Dialog.Trigger`, `Drawer.Trigger`). Around a\n * trigger works too, since triggers pass `aria-describedby` on to their child.\n * - Wrap the focusable element itself. When the element that takes focus does not get the\n * relationship (a Popover or Dialog root, a component that drops props, a non-focusable\n * wrapper element), it is added to the first focusable element inside, with a development\n * warning.\n *\n * @example\n * <Menu>\n * <Menu.Trigger>\n * <Tooltip content=\"Edit, duplicate or delete the item\">\n * <Button>Actions</Button>\n * </Tooltip>\n * </Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover>\n * </Menu>\n */\nexport const Tooltip = ({\n content,\n appearance: appearanceProp,\n variant,\n openDelay: openDelayProp,\n closeDelay = 100,\n delay,\n open: openProp,\n defaultOpen,\n onOpenChange,\n relationship = 'description',\n side = 'top',\n align = 'center',\n children,\n className,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TooltipProps) => {\n const appearance =\n resolveDeprecatedProp(\n 'Tooltip',\n appearanceProp,\n variant === undefined ? undefined : VARIANT_APPEARANCE[variant],\n 'variant',\n 'appearance',\n ) ?? 'inverted';\n const openDelay =\n resolveDeprecatedProp('Tooltip', openDelayProp, delay, 'delay', 'openDelay') ?? 200;\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? false, onOpenChange);\n // The surface lives in a portal, which renders only in the browser: until then (the server HTML,\n // hydration) the tooltip is closed; the hidden description is rendered either way.\n const isClient = useIsClient();\n const visible = open && isClient;\n const timerRef = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const wrapperRef = React.useRef<HTMLSpanElement | null>(null);\n const surfaceRef = React.useRef<HTMLSpanElement | null>(null);\n const tooltipId = useId('tooltip');\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: visible,\n side,\n align,\n offset: 8,\n });\n const wrapperElementRef = useMergedRefs<HTMLSpanElement>(ref, wrapperRef, setReference);\n const surfaceElementRef = useMergedRefs<HTMLSpanElement>(surfaceRef, setFloating);\n\n // Timer handlers are event callbacks (stable, latest state): they are composed with the\n // consumer's handlers during render but only run from events and timers.\n const clearTimer = useEventCallback(() => {\n if (timerRef.current !== undefined) {\n clearTimeout(timerRef.current);\n timerRef.current = undefined;\n }\n });\n\n // show, hide and scheduleHide ask for the new state; a controlled tooltip changes only when the\n // parent updates `open`.\n const show = useEventCallback(() => {\n clearTimer();\n if (visible) return;\n if (openDelay <= 0) {\n setOpen(true);\n return;\n }\n timerRef.current = setTimeout(() => {\n timerRef.current = undefined;\n setOpen(true);\n }, openDelay);\n });\n\n const hide = useEventCallback(() => {\n clearTimer();\n setOpen(false);\n });\n\n // The grace period after the pointer leaves lets it move onto the tooltip.\n const scheduleHide = useEventCallback(() => {\n clearTimer();\n if (!visible) return;\n timerRef.current = setTimeout(() => {\n timerRef.current = undefined;\n setOpen(false);\n }, closeDelay);\n });\n\n // An Escape-only layer while visible: Escape hides the tooltip before any enclosing overlay. The\n // wrapper is its anchor (its trigger, not its surface): Tab from the child inside a focus trap\n // moves on from the popover, portal or dialog around the wrapper.\n useDismiss({\n open: visible,\n onDismiss: hide,\n refs: [wrapperRef, surfaceRef],\n anchorRef: wrapperRef,\n kind: 'tooltip',\n outsidePress: false,\n });\n\n React.useEffect(() => {\n const timer = timerRef;\n return () => clearTimeout(timer.current);\n }, []);\n\n // The tooltip's own reactions ignore a popup the child renders in a portal: its focus and blur\n // are not the child's, entering it does not show the tooltip, and the pointer moving onto it\n // (no mouseleave reaches the wrapper then) hides the tooltip, which would cover it. The tooltip\n // surface itself is portaled too but belongs to the tooltip: it stays hoverable.\n const showOnEnter = useEventCallback((event: React.MouseEvent<HTMLSpanElement>) => {\n if (isOwnEvent(event) || surfaceRef.current?.contains(event.target as Node)) show();\n });\n const hideOverPortaledPopup = useEventCallback((event: React.MouseEvent<HTMLSpanElement>) => {\n if (!isOwnEvent(event) && !surfaceRef.current?.contains(event.target as Node)) hide();\n });\n\n const { childProps, wrapperProps } = splitProps(rest);\n const target = unwrapFragment(children);\n const childIsFallback = !isCloneableElement(target);\n const attribute = relationship === 'label' ? 'aria-labelledby' : 'aria-describedby';\n // Props given to the Tooltip come first, as if the child had them; then the tooltip's own id.\n // The fallback span is a generic element: no state ARIA and no naming on it (the relationship\n // then reaches its first focusable element through useRelationshipTarget).\n const triggerProps: UnknownProps = childIsFallback\n ? omit(childProps, [...STATE_ARIA, ...NAMING_ARIA])\n : { ...childProps };\n if (!childIsFallback || relationship === 'description') {\n triggerProps[attribute] = joinIds(childProps[attribute] as string | undefined, tooltipId);\n }\n const child = renderTrigger(target, triggerProps, { componentName: 'Tooltip' });\n useRelationshipTarget(wrapperRef, tooltipId, relationship, childIsFallback);\n\n return (\n <span\n ref={wrapperElementRef}\n {...wrapperProps}\n className={cn('inline-block', className)}\n onMouseEnter={composeEventHandlers(onMouseEnter, showOnEnter)}\n onMouseLeave={composeEventHandlers(onMouseLeave, scheduleHide)}\n onMouseOver={composeEventHandlers(\n wrapperProps.onMouseOver as React.MouseEventHandler<HTMLSpanElement> | undefined,\n hideOverPortaledPopup,\n )}\n onFocus={ownEventsOnly(composeEventHandlers(onFocus, show))}\n onBlur={ownEventsOnly(composeEventHandlers(onBlur, hide))}\n >\n {child}\n <span id={tooltipId} role=\"tooltip\" hidden>\n {content}\n </span>\n {visible && (\n <Portal layer=\"tooltip\">\n <span\n ref={surfaceElementRef}\n aria-hidden=\"true\"\n data-wave-tooltip-surface=\"\"\n {...floatingProps}\n className={cn(surfaceClasses, appearanceClasses[appearance])}\n >\n {content}\n </span>\n </Portal>\n )}\n </span>\n );\n};\n\nTooltip.displayName = 'Tooltip';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoGA,IAAMG,KAAkE;CACtE,MAAM;CACN,OAAO;AACT,GAEMC,KAAuD;CAC3D,UAAU;CACV,QAAQ;AACV,GAuBMC,KAAiB,yIAhBD;CACpB;CAEA;CAEA;CAEA;CAEA;AACF,C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AM;IACZ,UAAA,kBAAC,QAAD;KACE,KAAK3B;KACL,eAAY;KACZ,6BAA0B;KAC1B,GAAI4B;KACJ,WAAWT,EAAGhF,IAAgBD,GAAkB0C,EAAW;KAE1D,UAAA8C;IACG,CAAA;GACA,CAAA;EAEN;;AAEV;AAEA,EAAQ,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../hooks/useMergedRefs.cjs"),r=require("../../hooks/useIsClient.cjs"),i=require("../provider/WaveProvider.cjs"),a=require("../../lib/layers.cjs"),o=require("../../hooks/useDirection.cjs"),s=require("../../hooks/useDismiss.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("react/jsx-runtime"),u=require("react-dom");var d=c.createContext(0);d.displayName=`PortalDepthContext`;var f=({children:e,container:f,layer:p=`overlay`,layerId:m,disabled:h=!1,className:g,ref:_})=>{let v=r.useIsClient(),{themeClassName:y,portalContainer:b}=i.useWaveTheme(),x=o.useDirection(),S=c.useContext(d),C=c.useContext(s.DismissLayerContext),w=c.useCallback(e=>{if(e&&C!==null)return a.registerLayerElement(C,e)},[C]),T=n.useMergedRefs(_,w),E=m===void 0?e:(0,l.jsx)(s.DismissLayerProvider,{layerId:m,children:e});if(h)return(0,l.jsx)(l.Fragment,{children:E});if(!v)return null;let D=f??b??document.body;return(0,u.createPortal)((0,l.jsx)(`div`,{ref:T,className:t.cn(`wave-portal`,y,g),dir:x,"data-wave-portal":``,"data-layer":p,style:{position:`relative`,zIndex:`calc(${a.Z_INDEX[p]} + ${S})`},children:(0,l.jsx)(d.Provider,{value:S+1,children:E})}),D)};f.displayName=`Portal`,exports.Portal=f,exports.PortalDepthContext=d;
2
+ //# sourceMappingURL=Portal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.cjs","names":["React","useIsClient","useWaveTheme","useDirection","DismissLayerContext","registerLayerElement","useMergedRefs","DismissLayerProvider","_Fragment","createPortal","cn","Z_INDEX","require_runtime","require_cn","require_useMergedRefs","require_useIsClient","require_WaveProvider","require_layers","require_useDirection","require_useDismiss","react","react_jsx_runtime","react_dom","PortalDepthContext","Portal","isClient","dir","depth","parentLayerId","registerWithParent","el","wrapperRef","ref","content","layerId","children","disabled","target","container","portalContainer","themeClassName","className","layer"],"sources":["../../../src/components/portal/Portal.tsx"],"sourcesContent":["import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../lib/cn';\nimport { Z_INDEX, registerLayerElement } from '../../lib/layers';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useDirection } from '../../hooks/useDirection';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { DismissLayerContext, DismissLayerProvider } from '../../hooks/useDismiss';\nimport { useWaveTheme } from '../provider/WaveProvider';\n\n/** Props accepted by {@link Portal}. */\nexport interface PortalProps {\n /** Content rendered into the portal. */\n children: React.ReactNode;\n /** Element to render into. @default WaveProvider `portalContainer`, else `document.body` */\n container?: HTMLElement | null;\n /**\n * Stacking layer: `--wave-z-overlay` (dialogs, popovers, menus, listboxes), `--wave-z-toast`\n * (above overlays) or `--wave-z-tooltip`. The portal's nesting depth is added.\n * @default 'overlay'\n */\n layer?: 'overlay' | 'toast' | 'tooltip';\n /**\n * The dismiss layer of the content (from `useDismiss`). Provided to the children through\n * `DismissLayerProvider`, so layers opened inside become its descendants.\n */\n layerId?: string;\n /** Render the children inline instead (no portal, no wrapper). @default false */\n disabled?: boolean;\n /** Extra classes for the portal wrapper. */\n className?: string;\n /** Ref to the portal wrapper `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Nesting depth of portals: `0` outside any portal; each `Portal` provides `depth + 1` to its\n * children. Portals add it to their z-index so a surface opened from inside another overlay always\n * stacks above it — also when both mount in the same commit.\n */\nexport const PortalDepthContext = React.createContext(0);\nPortalDepthContext.displayName = 'PortalDepthContext';\n\n/**\n * Renders its children into `document.body` (or the WaveProvider `portalContainer`), wrapped in a\n * `<div class=\"wave-portal …\">` that carries the provider's theme classes, direction and font, so\n * portaled overlays look like the rest of the themed tree. The wrapper paints no background.\n *\n * - **Client only, first commit**: nothing is rendered on the server or during hydration (no\n * mismatch); in every other client render the portal exists in the first commit, so layout\n * effects and ref callbacks of the content see connected elements.\n * - **Stacking**: `z-index: calc(<layer variable> + depth)`, where depth is the number of portals\n * it is rendered in, so a surface opened from inside another overlay always stacks above it,\n * also when both mount in the same commit.\n * - **Layers**: the wrapper is registered with the enclosing dismiss layer (the parent), so presses\n * and focus inside the portal count as inside that layer; `layerId` is provided only to the\n * children.\n *\n * Content that must exist on the server or before an overlay opens (tooltip descriptions, closed\n * listboxes) is rendered inline instead.\n */\nexport const Portal = ({\n children,\n container,\n layer = 'overlay',\n layerId,\n disabled = false,\n className,\n ref,\n}: PortalProps) => {\n const isClient = useIsClient();\n const { themeClassName, portalContainer } = useWaveTheme();\n const dir = useDirection();\n const depth = React.useContext(PortalDepthContext);\n const parentLayerId = React.useContext(DismissLayerContext);\n\n const registerWithParent = React.useCallback(\n (el: HTMLDivElement | null) => {\n if (!el || parentLayerId === null) return;\n return registerLayerElement(parentLayerId, el);\n },\n [parentLayerId],\n );\n const wrapperRef = useMergedRefs<HTMLDivElement>(ref, registerWithParent);\n\n const content =\n layerId === undefined ? (\n children\n ) : (\n <DismissLayerProvider layerId={layerId}>{children}</DismissLayerProvider>\n );\n\n if (disabled) return <>{content}</>;\n if (!isClient) return null;\n\n const target = container ?? portalContainer ?? document.body;\n\n return createPortal(\n <div\n ref={wrapperRef}\n className={cn('wave-portal', themeClassName, className)}\n dir={dir}\n data-wave-portal=\"\"\n data-layer={layer}\n style={{ position: 'relative', zIndex: `calc(${Z_INDEX[layer]} + ${depth})` }}\n >\n <PortalDepthContext.Provider value={depth + 1}>{content}</PortalDepthContext.Provider>\n </div>,\n target,\n );\n};\n\nPortal.displayName = 'Portal';\n"],"mappings":"ubAwCA,IAAauB,EAAqBvB,EAAM,cAAc,CAAC,EACvD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../hooks/useMergedRefs.mjs";
4
+ import { useIsClient as n } from "../../hooks/useIsClient.mjs";
5
+ import { useWaveTheme as r } from "../provider/WaveProvider.mjs";
6
+ import { Z_INDEX as i, registerLayerElement as a } from "../../lib/layers.mjs";
7
+ import { useDirection as o } from "../../hooks/useDirection.mjs";
8
+ import { DismissLayerContext as s, DismissLayerProvider as c } from "../../hooks/useDismiss.mjs";
9
+ import * as l from "react";
10
+ import { Fragment as u, jsx as d } from "react/jsx-runtime";
11
+ import { createPortal as f } from "react-dom";
12
+ //#region src/components/portal/Portal.tsx
13
+ var p = l.createContext(0);
14
+ p.displayName = "PortalDepthContext";
15
+ var m = ({ children: m, container: h, layer: g = "overlay", layerId: _, disabled: v = !1, className: y, ref: b }) => {
16
+ let x = n(), { themeClassName: S, portalContainer: C } = r(), w = o(), T = l.useContext(p), E = l.useContext(s), D = l.useCallback((e) => {
17
+ if (e && E !== null) return a(E, e);
18
+ }, [E]), O = t(b, D), k = _ === void 0 ? m : /* @__PURE__ */ d(c, {
19
+ layerId: _,
20
+ children: m
21
+ });
22
+ if (v) return /* @__PURE__ */ d(u, { children: k });
23
+ if (!x) return null;
24
+ let A = h ?? C ?? document.body;
25
+ return f(/* @__PURE__ */ d("div", {
26
+ ref: O,
27
+ className: e("wave-portal", S, y),
28
+ dir: w,
29
+ "data-wave-portal": "",
30
+ "data-layer": g,
31
+ style: {
32
+ position: "relative",
33
+ zIndex: `calc(${i[g]} + ${T})`
34
+ },
35
+ children: /* @__PURE__ */ d(p.Provider, {
36
+ value: T + 1,
37
+ children: k
38
+ })
39
+ }), A);
40
+ };
41
+ m.displayName = "Portal";
42
+ //#endregion
43
+ export { m as Portal, p as PortalDepthContext };
44
+
45
+ //# sourceMappingURL=Portal.mjs.map