@mortenbrudvik/waveui 0.7.0 → 0.9.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 (439) hide show
  1. package/README.md +564 -155
  2. package/dist/components/button/Button.cjs +1 -1
  3. package/dist/components/button/Button.cjs.map +1 -1
  4. package/dist/components/button/Button.mjs +36 -35
  5. package/dist/components/button/Button.mjs.map +1 -1
  6. package/dist/components/button/Button.slots.cjs +1 -1
  7. package/dist/components/button/Button.slots.cjs.map +1 -1
  8. package/dist/components/button/Button.slots.mjs +31 -21
  9. package/dist/components/button/Button.slots.mjs.map +1 -1
  10. package/dist/components/button/CompoundButton.cjs +1 -1
  11. package/dist/components/button/CompoundButton.cjs.map +1 -1
  12. package/dist/components/button/CompoundButton.mjs +31 -29
  13. package/dist/components/button/CompoundButton.mjs.map +1 -1
  14. package/dist/components/button/Link.cjs +1 -1
  15. package/dist/components/button/Link.cjs.map +1 -1
  16. package/dist/components/button/Link.mjs +24 -23
  17. package/dist/components/button/Link.mjs.map +1 -1
  18. package/dist/components/button/MenuButton.cjs +1 -1
  19. package/dist/components/button/MenuButton.cjs.map +1 -1
  20. package/dist/components/button/MenuButton.mjs +29 -28
  21. package/dist/components/button/MenuButton.mjs.map +1 -1
  22. package/dist/components/button/SplitButton.cjs +1 -1
  23. package/dist/components/button/SplitButton.cjs.map +1 -1
  24. package/dist/components/button/SplitButton.mjs +46 -45
  25. package/dist/components/button/SplitButton.mjs.map +1 -1
  26. package/dist/components/button/ToggleButton.cjs +1 -1
  27. package/dist/components/button/ToggleButton.cjs.map +1 -1
  28. package/dist/components/button/ToggleButton.mjs +38 -35
  29. package/dist/components/button/ToggleButton.mjs.map +1 -1
  30. package/dist/components/button/Toolbar.cjs +1 -1
  31. package/dist/components/button/Toolbar.cjs.map +1 -1
  32. package/dist/components/button/Toolbar.mjs +43 -42
  33. package/dist/components/button/Toolbar.mjs.map +1 -1
  34. package/dist/components/button/Toolbar.parts.cjs +1 -1
  35. package/dist/components/button/Toolbar.parts.cjs.map +1 -1
  36. package/dist/components/button/Toolbar.parts.mjs +76 -81
  37. package/dist/components/button/Toolbar.parts.mjs.map +1 -1
  38. package/dist/components/data-display/Avatar.cjs +1 -1
  39. package/dist/components/data-display/Avatar.cjs.map +1 -1
  40. package/dist/components/data-display/Avatar.mjs +72 -67
  41. package/dist/components/data-display/Avatar.mjs.map +1 -1
  42. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  43. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  44. package/dist/components/data-display/AvatarGroup.mjs +89 -88
  45. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  46. package/dist/components/data-display/Badge.cjs +1 -1
  47. package/dist/components/data-display/Badge.cjs.map +1 -1
  48. package/dist/components/data-display/Badge.mjs +17 -16
  49. package/dist/components/data-display/Badge.mjs.map +1 -1
  50. package/dist/components/data-display/CounterBadge.cjs +1 -1
  51. package/dist/components/data-display/CounterBadge.cjs.map +1 -1
  52. package/dist/components/data-display/CounterBadge.mjs +18 -17
  53. package/dist/components/data-display/CounterBadge.mjs.map +1 -1
  54. package/dist/components/data-display/Divider.cjs +1 -1
  55. package/dist/components/data-display/Divider.cjs.map +1 -1
  56. package/dist/components/data-display/Divider.mjs +31 -30
  57. package/dist/components/data-display/Divider.mjs.map +1 -1
  58. package/dist/components/data-display/Image.cjs +1 -1
  59. package/dist/components/data-display/Image.cjs.map +1 -1
  60. package/dist/components/data-display/Image.mjs +16 -15
  61. package/dist/components/data-display/Image.mjs.map +1 -1
  62. package/dist/components/data-display/InfoButton.cjs +2 -0
  63. package/dist/components/data-display/InfoButton.cjs.map +1 -0
  64. package/dist/components/data-display/InfoButton.mjs +173 -0
  65. package/dist/components/data-display/InfoButton.mjs.map +1 -0
  66. package/dist/components/data-display/InfoLabel.cjs +1 -1
  67. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  68. package/dist/components/data-display/InfoLabel.mjs +36 -92
  69. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  70. package/dist/components/data-display/List.cjs +1 -1
  71. package/dist/components/data-display/List.cjs.map +1 -1
  72. package/dist/components/data-display/List.mjs +175 -174
  73. package/dist/components/data-display/List.mjs.map +1 -1
  74. package/dist/components/data-display/Persona.cjs +1 -1
  75. package/dist/components/data-display/Persona.cjs.map +1 -1
  76. package/dist/components/data-display/Persona.mjs +31 -29
  77. package/dist/components/data-display/Persona.mjs.map +1 -1
  78. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  79. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  80. package/dist/components/data-display/PresenceBadge.mjs +25 -24
  81. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  82. package/dist/components/data-display/Tag.cjs +1 -1
  83. package/dist/components/data-display/Tag.cjs.map +1 -1
  84. package/dist/components/data-display/Tag.mjs +87 -82
  85. package/dist/components/data-display/Tag.mjs.map +1 -1
  86. package/dist/components/feedback/MessageBar.cjs +1 -1
  87. package/dist/components/feedback/MessageBar.cjs.map +1 -1
  88. package/dist/components/feedback/MessageBar.mjs +129 -71
  89. package/dist/components/feedback/MessageBar.mjs.map +1 -1
  90. package/dist/components/feedback/MessageBar.parts.cjs +2 -0
  91. package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
  92. package/dist/components/feedback/MessageBar.parts.mjs +84 -0
  93. package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
  94. package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
  95. package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
  96. package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
  97. package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
  98. package/dist/components/feedback/MessageBar.status.cjs +1 -1
  99. package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
  100. package/dist/components/feedback/MessageBar.status.mjs +2 -1
  101. package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
  102. package/dist/components/feedback/ProgressBar.cjs +1 -1
  103. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  104. package/dist/components/feedback/ProgressBar.mjs +44 -43
  105. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  106. package/dist/components/feedback/Skeleton.cjs +1 -1
  107. package/dist/components/feedback/Skeleton.cjs.map +1 -1
  108. package/dist/components/feedback/Skeleton.mjs +26 -24
  109. package/dist/components/feedback/Skeleton.mjs.map +1 -1
  110. package/dist/components/feedback/Spinner.cjs +1 -1
  111. package/dist/components/feedback/Spinner.cjs.map +1 -1
  112. package/dist/components/feedback/Spinner.mjs +32 -31
  113. package/dist/components/feedback/Spinner.mjs.map +1 -1
  114. package/dist/components/feedback/Toast.cjs +1 -1
  115. package/dist/components/feedback/Toast.cjs.map +1 -1
  116. package/dist/components/feedback/Toast.context.cjs +2 -0
  117. package/dist/components/feedback/Toast.context.cjs.map +1 -0
  118. package/dist/components/feedback/Toast.context.mjs +23 -0
  119. package/dist/components/feedback/Toast.context.mjs.map +1 -0
  120. package/dist/components/feedback/Toast.mjs +10 -342
  121. package/dist/components/feedback/Toast.mjs.map +1 -1
  122. package/dist/components/feedback/Toast.parts.cjs +2 -0
  123. package/dist/components/feedback/Toast.parts.cjs.map +1 -0
  124. package/dist/components/feedback/Toast.parts.mjs +98 -0
  125. package/dist/components/feedback/Toast.parts.mjs.map +1 -0
  126. package/dist/components/feedback/Toast.root.cjs +2 -0
  127. package/dist/components/feedback/Toast.root.cjs.map +1 -0
  128. package/dist/components/feedback/Toast.root.mjs +109 -0
  129. package/dist/components/feedback/Toast.root.mjs.map +1 -0
  130. package/dist/components/feedback/Toaster.cjs +2 -0
  131. package/dist/components/feedback/Toaster.cjs.map +1 -0
  132. package/dist/components/feedback/Toaster.mjs +564 -0
  133. package/dist/components/feedback/Toaster.mjs.map +1 -0
  134. package/dist/components/input/AlphaSlider.cjs +2 -0
  135. package/dist/components/input/AlphaSlider.cjs.map +1 -0
  136. package/dist/components/input/AlphaSlider.mjs +115 -0
  137. package/dist/components/input/AlphaSlider.mjs.map +1 -0
  138. package/dist/components/input/Checkbox.cjs +1 -1
  139. package/dist/components/input/Checkbox.cjs.map +1 -1
  140. package/dist/components/input/Checkbox.mjs +87 -70
  141. package/dist/components/input/Checkbox.mjs.map +1 -1
  142. package/dist/components/input/ColorArea.cjs +2 -0
  143. package/dist/components/input/ColorArea.cjs.map +1 -0
  144. package/dist/components/input/ColorArea.mjs +204 -0
  145. package/dist/components/input/ColorArea.mjs.map +1 -0
  146. package/dist/components/input/ColorPicker.cjs +5 -5
  147. package/dist/components/input/ColorPicker.cjs.map +1 -1
  148. package/dist/components/input/ColorPicker.mjs +142 -165
  149. package/dist/components/input/ColorPicker.mjs.map +1 -1
  150. package/dist/components/input/ColorPicker.parts.cjs +2 -0
  151. package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
  152. package/dist/components/input/ColorPicker.parts.mjs +192 -0
  153. package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
  154. package/dist/components/input/ColorSlider.cjs +2 -0
  155. package/dist/components/input/ColorSlider.cjs.map +1 -0
  156. package/dist/components/input/ColorSlider.mjs +138 -0
  157. package/dist/components/input/ColorSlider.mjs.map +1 -0
  158. package/dist/components/input/Combobox.cjs +1 -1
  159. package/dist/components/input/Combobox.cjs.map +1 -1
  160. package/dist/components/input/Combobox.expand.cjs +1 -1
  161. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  162. package/dist/components/input/Combobox.expand.mjs +22 -22
  163. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  164. package/dist/components/input/Combobox.mjs +151 -141
  165. package/dist/components/input/Combobox.mjs.map +1 -1
  166. package/dist/components/input/DatePicker.cjs +1 -1
  167. package/dist/components/input/DatePicker.cjs.map +1 -1
  168. package/dist/components/input/DatePicker.mjs +239 -234
  169. package/dist/components/input/DatePicker.mjs.map +1 -1
  170. package/dist/components/input/Dropdown.cjs +1 -1
  171. package/dist/components/input/Dropdown.cjs.map +1 -1
  172. package/dist/components/input/Dropdown.mjs +109 -100
  173. package/dist/components/input/Dropdown.mjs.map +1 -1
  174. package/dist/components/input/Field.cjs +1 -1
  175. package/dist/components/input/Field.cjs.map +1 -1
  176. package/dist/components/input/Field.mjs +139 -105
  177. package/dist/components/input/Field.mjs.map +1 -1
  178. package/dist/components/input/Input.cjs +1 -1
  179. package/dist/components/input/Input.cjs.map +1 -1
  180. package/dist/components/input/Input.mjs +80 -55
  181. package/dist/components/input/Input.mjs.map +1 -1
  182. package/dist/components/input/Label.cjs +1 -1
  183. package/dist/components/input/Label.cjs.map +1 -1
  184. package/dist/components/input/Label.mjs +19 -12
  185. package/dist/components/input/Label.mjs.map +1 -1
  186. package/dist/components/input/Option.cjs +1 -1
  187. package/dist/components/input/Option.cjs.map +1 -1
  188. package/dist/components/input/Option.mjs +100 -98
  189. package/dist/components/input/Option.mjs.map +1 -1
  190. package/dist/components/input/RadioGroup.cjs +1 -1
  191. package/dist/components/input/RadioGroup.cjs.map +1 -1
  192. package/dist/components/input/RadioGroup.mjs +89 -88
  193. package/dist/components/input/RadioGroup.mjs.map +1 -1
  194. package/dist/components/input/Rating.cjs +1 -1
  195. package/dist/components/input/Rating.cjs.map +1 -1
  196. package/dist/components/input/Rating.item.cjs +2 -0
  197. package/dist/components/input/Rating.item.cjs.map +1 -0
  198. package/dist/components/input/Rating.item.mjs +255 -0
  199. package/dist/components/input/Rating.item.mjs.map +1 -0
  200. package/dist/components/input/Rating.mjs +152 -152
  201. package/dist/components/input/Rating.mjs.map +1 -1
  202. package/dist/components/input/SearchBox.cjs +1 -1
  203. package/dist/components/input/SearchBox.cjs.map +1 -1
  204. package/dist/components/input/SearchBox.mjs +162 -132
  205. package/dist/components/input/SearchBox.mjs.map +1 -1
  206. package/dist/components/input/Select.cjs +1 -1
  207. package/dist/components/input/Select.cjs.map +1 -1
  208. package/dist/components/input/Select.mjs +34 -24
  209. package/dist/components/input/Select.mjs.map +1 -1
  210. package/dist/components/input/Slider.cjs +1 -1
  211. package/dist/components/input/Slider.cjs.map +1 -1
  212. package/dist/components/input/Slider.mjs +78 -54
  213. package/dist/components/input/Slider.mjs.map +1 -1
  214. package/dist/components/input/SpinButton.cjs +1 -1
  215. package/dist/components/input/SpinButton.cjs.map +1 -1
  216. package/dist/components/input/SpinButton.mjs +202 -99
  217. package/dist/components/input/SpinButton.mjs.map +1 -1
  218. package/dist/components/input/SwatchPicker.cjs +1 -1
  219. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  220. package/dist/components/input/SwatchPicker.mjs +38 -37
  221. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  222. package/dist/components/input/Switch.cjs +1 -1
  223. package/dist/components/input/Switch.cjs.map +1 -1
  224. package/dist/components/input/Switch.mjs +75 -58
  225. package/dist/components/input/Switch.mjs.map +1 -1
  226. package/dist/components/input/TagPicker.cjs +1 -1
  227. package/dist/components/input/TagPicker.cjs.map +1 -1
  228. package/dist/components/input/TagPicker.mjs +199 -169
  229. package/dist/components/input/TagPicker.mjs.map +1 -1
  230. package/dist/components/input/Textarea.cjs +1 -1
  231. package/dist/components/input/Textarea.cjs.map +1 -1
  232. package/dist/components/input/Textarea.mjs +31 -23
  233. package/dist/components/input/Textarea.mjs.map +1 -1
  234. package/dist/components/input/TimePicker.cjs +1 -1
  235. package/dist/components/input/TimePicker.cjs.map +1 -1
  236. package/dist/components/input/TimePicker.mjs +185 -177
  237. package/dist/components/input/TimePicker.mjs.map +1 -1
  238. package/dist/components/input/colorName.cjs +2 -0
  239. package/dist/components/input/colorName.cjs.map +1 -0
  240. package/dist/components/input/colorName.mjs +30 -0
  241. package/dist/components/input/colorName.mjs.map +1 -0
  242. package/dist/components/input/colorUtils.cjs +1 -1
  243. package/dist/components/input/colorUtils.cjs.map +1 -1
  244. package/dist/components/input/colorUtils.mjs +154 -56
  245. package/dist/components/input/colorUtils.mjs.map +1 -1
  246. package/dist/components/input/fieldLabel.cjs +2 -0
  247. package/dist/components/input/fieldLabel.cjs.map +1 -0
  248. package/dist/components/input/fieldLabel.mjs +17 -0
  249. package/dist/components/input/fieldLabel.mjs.map +1 -0
  250. package/dist/components/input/inputLook.cjs +2 -0
  251. package/dist/components/input/inputLook.cjs.map +1 -0
  252. package/dist/components/input/inputLook.mjs +28 -0
  253. package/dist/components/input/inputLook.mjs.map +1 -0
  254. package/dist/components/input/pickerStyles.cjs +1 -1
  255. package/dist/components/input/pickerStyles.cjs.map +1 -1
  256. package/dist/components/input/pickerStyles.mjs +42 -4
  257. package/dist/components/input/pickerStyles.mjs.map +1 -1
  258. package/dist/components/layout/Accordion.cjs +1 -1
  259. package/dist/components/layout/Accordion.cjs.map +1 -1
  260. package/dist/components/layout/Accordion.mjs +130 -129
  261. package/dist/components/layout/Accordion.mjs.map +1 -1
  262. package/dist/components/layout/Card.cjs +1 -1
  263. package/dist/components/layout/Card.cjs.map +1 -1
  264. package/dist/components/layout/Card.mjs +78 -77
  265. package/dist/components/layout/Card.mjs.map +1 -1
  266. package/dist/components/layout/Carousel.cjs +1 -1
  267. package/dist/components/layout/Carousel.cjs.map +1 -1
  268. package/dist/components/layout/Carousel.mjs +111 -110
  269. package/dist/components/layout/Carousel.mjs.map +1 -1
  270. package/dist/components/layout/Flex.cjs +1 -1
  271. package/dist/components/layout/Flex.cjs.map +1 -1
  272. package/dist/components/layout/Flex.mjs +22 -21
  273. package/dist/components/layout/Flex.mjs.map +1 -1
  274. package/dist/components/layout/Grid.cjs +1 -1
  275. package/dist/components/layout/Grid.cjs.map +1 -1
  276. package/dist/components/layout/Grid.mjs +19 -18
  277. package/dist/components/layout/Grid.mjs.map +1 -1
  278. package/dist/components/layout/Overflow.cjs +1 -1
  279. package/dist/components/layout/Overflow.cjs.map +1 -1
  280. package/dist/components/layout/Overflow.mjs +92 -91
  281. package/dist/components/layout/Overflow.mjs.map +1 -1
  282. package/dist/components/layout/Stack.cjs +1 -1
  283. package/dist/components/layout/Stack.cjs.map +1 -1
  284. package/dist/components/layout/Stack.mjs +14 -13
  285. package/dist/components/layout/Stack.mjs.map +1 -1
  286. package/dist/components/layout/TabList.cjs +1 -1
  287. package/dist/components/layout/TabList.cjs.map +1 -1
  288. package/dist/components/layout/TabList.mjs +118 -117
  289. package/dist/components/layout/TabList.mjs.map +1 -1
  290. package/dist/components/layout/Tree.cjs +1 -1
  291. package/dist/components/layout/Tree.cjs.map +1 -1
  292. package/dist/components/layout/Tree.context.cjs +2 -0
  293. package/dist/components/layout/Tree.context.cjs.map +1 -0
  294. package/dist/components/layout/Tree.context.mjs +33 -0
  295. package/dist/components/layout/Tree.context.mjs.map +1 -0
  296. package/dist/components/layout/Tree.core.cjs +2 -0
  297. package/dist/components/layout/Tree.core.cjs.map +1 -0
  298. package/dist/components/layout/Tree.core.mjs +416 -0
  299. package/dist/components/layout/Tree.core.mjs.map +1 -0
  300. package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
  301. package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
  302. package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
  303. package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
  304. package/dist/components/layout/Tree.mjs +7 -215
  305. package/dist/components/layout/Tree.mjs.map +1 -1
  306. package/dist/components/layout/Tree.selection.cjs +2 -0
  307. package/dist/components/layout/Tree.selection.cjs.map +1 -0
  308. package/dist/components/layout/Tree.selection.mjs +73 -0
  309. package/dist/components/layout/Tree.selection.mjs.map +1 -0
  310. package/dist/components/navigation/Breadcrumb.cjs +1 -1
  311. package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
  312. package/dist/components/navigation/Breadcrumb.mjs +76 -75
  313. package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
  314. package/dist/components/navigation/Menu.group.cjs +1 -1
  315. package/dist/components/navigation/Menu.group.cjs.map +1 -1
  316. package/dist/components/navigation/Menu.group.mjs +39 -37
  317. package/dist/components/navigation/Menu.group.mjs.map +1 -1
  318. package/dist/components/navigation/Menu.items.cjs +1 -1
  319. package/dist/components/navigation/Menu.items.cjs.map +1 -1
  320. package/dist/components/navigation/Menu.items.mjs +67 -61
  321. package/dist/components/navigation/Menu.items.mjs.map +1 -1
  322. package/dist/components/navigation/Menu.link.cjs +1 -1
  323. package/dist/components/navigation/Menu.link.cjs.map +1 -1
  324. package/dist/components/navigation/Menu.link.mjs +34 -28
  325. package/dist/components/navigation/Menu.link.mjs.map +1 -1
  326. package/dist/components/navigation/Menu.popover.cjs +1 -1
  327. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  328. package/dist/components/navigation/Menu.popover.mjs +114 -113
  329. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  330. package/dist/components/navigation/Menu.root.cjs +1 -1
  331. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  332. package/dist/components/navigation/Menu.root.mjs +171 -170
  333. package/dist/components/navigation/Menu.root.mjs.map +1 -1
  334. package/dist/components/navigation/Menu.selectable.cjs +1 -1
  335. package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
  336. package/dist/components/navigation/Menu.selectable.mjs +85 -63
  337. package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
  338. package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
  339. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
  340. package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
  341. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
  342. package/dist/components/navigation/Menu.trigger.cjs +1 -1
  343. package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
  344. package/dist/components/navigation/Menu.trigger.mjs +6 -6
  345. package/dist/components/navigation/Nav.cjs +1 -1
  346. package/dist/components/navigation/Nav.cjs.map +1 -1
  347. package/dist/components/navigation/Nav.mjs +170 -155
  348. package/dist/components/navigation/Nav.mjs.map +1 -1
  349. package/dist/components/navigation/Pagination.cjs +1 -1
  350. package/dist/components/navigation/Pagination.cjs.map +1 -1
  351. package/dist/components/navigation/Pagination.mjs +73 -65
  352. package/dist/components/navigation/Pagination.mjs.map +1 -1
  353. package/dist/components/navigation/Stepper.cjs +1 -1
  354. package/dist/components/navigation/Stepper.cjs.map +1 -1
  355. package/dist/components/navigation/Stepper.mjs +110 -109
  356. package/dist/components/navigation/Stepper.mjs.map +1 -1
  357. package/dist/components/overlays/Dialog.cjs +1 -1
  358. package/dist/components/overlays/Dialog.cjs.map +1 -1
  359. package/dist/components/overlays/Dialog.mjs +109 -108
  360. package/dist/components/overlays/Dialog.mjs.map +1 -1
  361. package/dist/components/overlays/Drawer.cjs +1 -1
  362. package/dist/components/overlays/Drawer.cjs.map +1 -1
  363. package/dist/components/overlays/Drawer.mjs +110 -109
  364. package/dist/components/overlays/Drawer.mjs.map +1 -1
  365. package/dist/components/overlays/Popover.cjs +1 -1
  366. package/dist/components/overlays/Popover.cjs.map +1 -1
  367. package/dist/components/overlays/Popover.mjs +148 -151
  368. package/dist/components/overlays/Popover.mjs.map +1 -1
  369. package/dist/components/overlays/Popover.shared.cjs +1 -1
  370. package/dist/components/overlays/Popover.shared.cjs.map +1 -1
  371. package/dist/components/overlays/Popover.shared.mjs +82 -77
  372. package/dist/components/overlays/Popover.shared.mjs.map +1 -1
  373. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  374. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  375. package/dist/components/overlays/TeachingPopover.mjs +41 -37
  376. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  377. package/dist/components/overlays/Tooltip.cjs +1 -1
  378. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  379. package/dist/components/overlays/Tooltip.mjs +87 -86
  380. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  381. package/dist/components/portal/Portal.cjs +1 -1
  382. package/dist/components/portal/Portal.cjs.map +1 -1
  383. package/dist/components/portal/Portal.mjs +33 -32
  384. package/dist/components/portal/Portal.mjs.map +1 -1
  385. package/dist/components/provider/WaveProvider.cjs +1 -1
  386. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  387. package/dist/components/provider/WaveProvider.mjs +36 -29
  388. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  389. package/dist/components/table/DataGrid.cjs +1 -1
  390. package/dist/components/table/DataGrid.cjs.map +1 -1
  391. package/dist/components/table/DataGrid.mjs +228 -227
  392. package/dist/components/table/DataGrid.mjs.map +1 -1
  393. package/dist/components/table/Table.cjs +1 -1
  394. package/dist/components/table/Table.cjs.map +1 -1
  395. package/dist/components/table/Table.mjs +60 -59
  396. package/dist/components/table/Table.mjs.map +1 -1
  397. package/dist/components/typography/Text.cjs +1 -1
  398. package/dist/components/typography/Text.cjs.map +1 -1
  399. package/dist/components/typography/Text.mjs +12 -11
  400. package/dist/components/typography/Text.mjs.map +1 -1
  401. package/dist/hooks/useFieldControl.cjs.map +1 -1
  402. package/dist/hooks/useFieldControl.mjs.map +1 -1
  403. package/dist/hooks/useMediaQuery.cjs +2 -0
  404. package/dist/hooks/useMediaQuery.cjs.map +1 -0
  405. package/dist/hooks/useMediaQuery.mjs +20 -0
  406. package/dist/hooks/useMediaQuery.mjs.map +1 -0
  407. package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
  408. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
  409. package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
  410. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
  411. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  412. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  413. package/dist/hooks/useRovingTabIndex.mjs +3 -3
  414. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  415. package/dist/index.cjs +1 -1
  416. package/dist/index.d.cts +2890 -197
  417. package/dist/index.d.ts +2890 -197
  418. package/dist/index.mjs +101 -87
  419. package/dist/lib/classNames.cjs +2 -0
  420. package/dist/lib/classNames.cjs.map +1 -0
  421. package/dist/lib/classNames.mjs +423 -0
  422. package/dist/lib/classNames.mjs.map +1 -0
  423. package/dist/lib/color.cjs +2 -0
  424. package/dist/lib/color.cjs.map +1 -0
  425. package/dist/lib/color.mjs +86 -0
  426. package/dist/lib/color.mjs.map +1 -0
  427. package/dist/lib/globalRegistry.cjs.map +1 -1
  428. package/dist/lib/globalRegistry.mjs.map +1 -1
  429. package/dist/lib/styles.cjs +1 -1
  430. package/dist/lib/styles.cjs.map +1 -1
  431. package/dist/lib/styles.mjs +21 -4
  432. package/dist/lib/styles.mjs.map +1 -1
  433. package/dist/lib/toaster.cjs +2 -0
  434. package/dist/lib/toaster.cjs.map +1 -0
  435. package/dist/lib/toaster.mjs +77 -0
  436. package/dist/lib/toaster.mjs.map +1 -0
  437. package/dist/styles.css +1 -1
  438. package/package.json +1 -1
  439. package/src/styles/tokens.css +13 -0
@@ -3,42 +3,47 @@ import { cn as e } from "../../lib/cn.mjs";
3
3
  import { getGlobalRegistry as t } from "../../lib/globalRegistry.mjs";
4
4
  import { useEventCallback as n } from "../../hooks/useEventCallback.mjs";
5
5
  import { focusElement as r, getLastTabbable as i, getTabbableElements as a } from "../../lib/focus.mjs";
6
- import * as o from "react";
7
- import { jsx as s } from "react/jsx-runtime";
6
+ import { getLayerTreeElements as o } from "../../lib/layers.mjs";
7
+ import * as s from "react";
8
+ import { jsx as c } from "react/jsx-runtime";
8
9
  //#region src/components/overlays/Popover.shared.tsx
9
- var c = {
10
+ var l = {
10
11
  top: "border-b border-r",
11
12
  bottom: "border-t border-l",
12
13
  left: "border-t border-r",
13
14
  right: "border-b border-l"
14
- }, l = ({ side: t, className: n, ref: r, ...i }) => /* @__PURE__ */ s("div", {
15
+ }, u = ({ side: t, className: n, ref: r, ...i }) => /* @__PURE__ */ c("div", {
15
16
  ref: r,
16
17
  "aria-hidden": "true",
17
18
  ...i,
18
- className: e("size-2 rotate-45 border-inherit bg-inherit", c[t], n)
19
+ className: e("size-2 rotate-45 border-inherit bg-inherit", l[t], n)
19
20
  });
20
- l.displayName = "PopoverBeak";
21
- function u(e, t, n = a(e.ownerDocument.body)) {
21
+ u.displayName = "PopoverBeak";
22
+ function d(e, t) {
23
+ let n = e?.ownerDocument.activeElement;
24
+ return !e || !n ? !1 : e.contains(n) ? !0 : o(t, { includeOwnElements: !1 }).some((e) => e.contains(n));
25
+ }
26
+ function f(e, t, n = a(e.ownerDocument.body)) {
22
27
  let r = e.closest("[data-wave-portal]");
23
28
  return n.filter((e) => !t.contains(e) && e.closest("[data-wave-portal]") === r);
24
29
  }
25
- function d(e, t, n) {
26
- return u(e, t, n).find((t) => !e.contains(t) && !!(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING)) ?? null;
30
+ function p(e, t, n) {
31
+ return f(e, t, n).find((t) => !e.contains(t) && !!(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING)) ?? null;
27
32
  }
28
- function f(e, t, n) {
29
- let r = u(e, t, n).filter((t) => e.contains(t) || !!(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_PRECEDING));
33
+ function m(e, t, n) {
34
+ let r = f(e, t, n).filter((t) => e.contains(t) || !!(e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_PRECEDING));
30
35
  return r[r.length - 1] ?? null;
31
36
  }
32
- function p(e, t, n, r) {
33
- return !e || r.includes(e) ? e : f(t, n, r);
37
+ function h(e, t, n, r) {
38
+ return !e || r.includes(e) ? e : m(t, n, r);
34
39
  }
35
- function m(e, t) {
40
+ function g(e, t) {
36
41
  t && (e.preventDefault(), t.focus());
37
42
  }
38
- function h(e, t) {
43
+ function _(e, t) {
39
44
  return !t || t === e.body || t === e.documentElement;
40
45
  }
41
- function g(e) {
46
+ function v(e) {
42
47
  let t = e.ownerDocument, n = t.defaultView, { style: r } = e, i = r.getPropertyValue("visibility"), a = r.getPropertyPriority("visibility");
43
48
  r.setProperty("visibility", "hidden", "important");
44
49
  let o, s = () => {
@@ -46,7 +51,7 @@ function g(e) {
46
51
  };
47
52
  t.addEventListener("focusout", s, !0), n && (o = n.requestAnimationFrame(s));
48
53
  }
49
- var _ = {
54
+ var y = {
50
55
  users: 0,
51
56
  pressed: !1,
52
57
  refocus: null,
@@ -55,128 +60,128 @@ var _ = {
55
60
  epoch: 0,
56
61
  uninstall: null
57
62
  };
58
- function v(e, t) {
59
- let n = _.lastFocused;
63
+ function b(e, t) {
64
+ let n = y.lastFocused;
60
65
  if (!n) return !1;
61
66
  let r = n.element.deref();
62
67
  return r?.isConnected ? !!(e.compareDocumentPosition(r) & Node.DOCUMENT_POSITION_FOLLOWING) : n.surface?.deref() === t;
63
68
  }
64
- function y() {
69
+ function x() {
65
70
  return t("orderedSurfaces", () => /* @__PURE__ */ new Set());
66
71
  }
67
- function b() {
72
+ function S() {
68
73
  if (typeof document > "u") return () => {};
69
- if (_.users += 1, !_.uninstall) {
74
+ if (y.users += 1, !y.uninstall) {
70
75
  let e = document, t = e.defaultView, n = () => {
71
- _.epoch += 1, _.pressed = !0, _.windowFocused = !1;
76
+ y.epoch += 1, y.pressed = !0, y.windowFocused = !1;
72
77
  }, r = () => {
73
- _.epoch += 1, _.windowFocused = !1;
78
+ y.epoch += 1, y.windowFocused = !1;
74
79
  }, i = () => {
75
- _.epoch += 1, _.pressed = !1, _.windowFocused = !1;
80
+ y.epoch += 1, y.pressed = !1, y.windowFocused = !1;
76
81
  let t = e.activeElement;
77
- _.refocus = !t || h(e, t) ? null : new WeakRef(t);
82
+ y.refocus = !t || _(e, t) ? null : new WeakRef(t);
78
83
  }, a = () => {
79
- _.epoch += 1, _.windowFocused = !0;
84
+ y.epoch += 1, y.windowFocused = !0;
80
85
  }, o = (e) => {
81
- let t = e.target, n = t && [...y()].find((e) => e.contains(t));
82
- _.lastFocused = t && {
86
+ let t = e.target, n = t && [...x()].find((e) => e.contains(t));
87
+ y.lastFocused = t && {
83
88
  element: new WeakRef(t),
84
89
  surface: n ? new WeakRef(n) : null
85
90
  };
86
91
  }, s = () => {
87
- _.epoch += 1, _.refocus = null, _.windowFocused = !1;
92
+ y.epoch += 1, y.refocus = null, y.windowFocused = !1;
88
93
  };
89
- e.addEventListener("pointerdown", n, !0), e.addEventListener("mousedown", n, !0), e.addEventListener("keydown", r, !0), e.addEventListener("keyup", r, !0), e.addEventListener("focusin", o, !0), e.addEventListener("focusin", s), t?.addEventListener("blur", i), t?.addEventListener("focus", a), _.uninstall = () => {
90
- e.removeEventListener("pointerdown", n, !0), e.removeEventListener("mousedown", n, !0), e.removeEventListener("keydown", r, !0), e.removeEventListener("keyup", r, !0), e.removeEventListener("focusin", o, !0), e.removeEventListener("focusin", s), t?.removeEventListener("blur", i), t?.removeEventListener("focus", a), _.pressed = !1, _.refocus = null, _.lastFocused = null, _.windowFocused = !1;
94
+ e.addEventListener("pointerdown", n, !0), e.addEventListener("mousedown", n, !0), e.addEventListener("keydown", r, !0), e.addEventListener("keyup", r, !0), e.addEventListener("focusin", o, !0), e.addEventListener("focusin", s), t?.addEventListener("blur", i), t?.addEventListener("focus", a), y.uninstall = () => {
95
+ e.removeEventListener("pointerdown", n, !0), e.removeEventListener("mousedown", n, !0), e.removeEventListener("keydown", r, !0), e.removeEventListener("keyup", r, !0), e.removeEventListener("focusin", o, !0), e.removeEventListener("focusin", s), t?.removeEventListener("blur", i), t?.removeEventListener("focus", a), y.pressed = !1, y.refocus = null, y.lastFocused = null, y.windowFocused = !1;
91
96
  };
92
97
  }
93
98
  let e = !0;
94
99
  return () => {
95
- e && (e = !1, _.users = Math.max(0, _.users - 1), !(_.users > 0) && (_.uninstall?.(), _.uninstall = null));
100
+ e && (e = !1, y.users = Math.max(0, y.users - 1), !(y.users > 0) && (y.uninstall?.(), y.uninstall = null));
96
101
  };
97
102
  }
98
- function x({ enabled: e, surface: t, anchorRef: s, getPreviousStop: c }) {
99
- let l = n(c), u = o.useRef("anchor"), f = o.useRef(null), x = n((e) => {
100
- f.current = null;
101
- let n = s.current;
103
+ function C({ enabled: e, surface: t, anchorRef: o, getPreviousStop: c }) {
104
+ let l = n(c), u = s.useRef("anchor"), d = s.useRef(null), f = n((e) => {
105
+ d.current = null;
106
+ let n = o.current;
102
107
  if (e.key !== "Tab" || e.defaultPrevented || !n || !t) return;
103
108
  let r = t.ownerDocument, i = r.activeElement;
104
109
  if (i && t.contains(i)) return;
105
- let o = a(r.body), c = o.filter((e) => t.contains(e)), u = c[0], y = c[c.length - 1];
106
- if (!u || !y) return;
107
- if (!i || h(r, i)) {
108
- e.shiftKey && !_.pressed && o[o.length - 1] === y && !v(y, t) && (f.current = {
109
- element: y,
110
+ let s = a(r.body), c = s.filter((e) => t.contains(e)), u = c[0], f = c[c.length - 1];
111
+ if (!u || !f) return;
112
+ if (!i || _(r, i)) {
113
+ e.shiftKey && !y.pressed && s[s.length - 1] === f && !b(f, t) && (d.current = {
114
+ element: f,
110
115
  from: "far-end",
111
- epoch: _.epoch
116
+ epoch: y.epoch
112
117
  });
113
118
  return;
114
119
  }
115
- let b = l(n, t, o);
120
+ let m = l(n, t, s);
116
121
  if (e.shiftKey) {
117
- b && i === d(n, t, o) && m(e, y);
122
+ m && i === p(n, t, s) && g(e, f);
118
123
  return;
119
124
  }
120
- let x = p(b, n, t, o);
121
- if (i === b || i === x) {
122
- m(e, u);
125
+ let x = h(m, n, t, s);
126
+ if (i === m || i === x) {
127
+ g(e, u);
123
128
  return;
124
129
  }
125
- let S = o.indexOf(i);
126
- S !== -1 && o[S + 1] === u && (f.current = {
130
+ let S = s.indexOf(i);
131
+ S !== -1 && s[S + 1] === u && (d.current = {
127
132
  element: u,
128
133
  from: "page",
129
- epoch: _.epoch
130
- }, x && g(t));
134
+ epoch: y.epoch
135
+ }, x && v(t));
131
136
  });
132
- return o.useEffect(() => b(), []), o.useEffect(() => {
137
+ return s.useEffect(() => S(), []), s.useEffect(() => {
133
138
  if (!e || !t) return;
134
- let n = t.ownerDocument, o = n.defaultView;
139
+ let n = t.ownerDocument, s = n.defaultView;
135
140
  u.current = "anchor";
136
- let c = null, d = (e) => {
141
+ let c = null, p = (e) => {
137
142
  c = null;
138
- let r = f.current;
139
- f.current = null;
140
- let o = e.relatedTarget;
141
- if (o && t.contains(o)) return;
142
- let d = e.target;
143
- if (!o && d === _.refocus?.deref()) return;
144
- let m = r && r.epoch === _.epoch && r.element === d ? r.from : null;
145
- if (u.current = m === "page" ? "page" : "anchor", m === "page" || !h(n, o) || _.pressed || m !== "far-end" && !_.windowFocused) return;
146
- let g = s.current;
147
- if (!g || d !== i(t)) return;
148
- let v = a(n.body), b = [...y()], x = v.filter((e) => !b.some((t) => t.contains(e))), S = x[x.length - 1], C = l(g, t, v);
149
- C && S && S !== p(C, g, t, v) && (c = {
143
+ let r = d.current;
144
+ d.current = null;
145
+ let s = e.relatedTarget;
146
+ if (s && t.contains(s)) return;
147
+ let f = e.target;
148
+ if (!s && f === y.refocus?.deref()) return;
149
+ let p = r && r.epoch === y.epoch && r.element === f ? r.from : null;
150
+ if (u.current = p === "page" ? "page" : "anchor", p === "page" || !_(n, s) || y.pressed || p !== "far-end" && !y.windowFocused) return;
151
+ let m = o.current;
152
+ if (!m || f !== i(t)) return;
153
+ let g = a(n.body), v = [...x()], b = g.filter((e) => !v.some((t) => t.contains(e))), S = b[b.length - 1], C = l(m, t, g);
154
+ C && S && S !== h(C, m, t, g) && (c = {
150
155
  event: e,
151
156
  pageEnd: S
152
157
  });
153
158
  }, m = (e) => {
154
159
  let t = c;
155
160
  c = null, t?.event === e && n.activeElement === e.target && (r(t.pageEnd) || (u.current = "page"));
156
- }, g = y();
157
- return g.add(t), t.addEventListener("focusin", d), o?.addEventListener("focusin", m), n.addEventListener("keydown", x), () => {
158
- g.delete(t), t.removeEventListener("focusin", d), o?.removeEventListener("focusin", m), n.removeEventListener("keydown", x);
161
+ }, g = x();
162
+ return g.add(t), t.addEventListener("focusin", p), s?.addEventListener("focusin", m), n.addEventListener("keydown", f), () => {
163
+ g.delete(t), t.removeEventListener("focusin", p), s?.removeEventListener("focusin", m), n.removeEventListener("keydown", f);
159
164
  };
160
165
  }, [
161
166
  e,
162
167
  t,
163
- s,
168
+ o,
164
169
  l,
165
- x
170
+ f
166
171
  ]), n((n) => {
167
- let r = s.current;
172
+ let r = o.current;
168
173
  if (n.key !== "Tab" || n.defaultPrevented || !e || !t || !r) return;
169
174
  let i = t.ownerDocument.activeElement;
170
175
  if (!i || !t.contains(i) || u.current === "page") return;
171
- let o = a(t);
176
+ let s = a(t);
172
177
  if (n.shiftKey) {
173
- (i === t || i === o[0]) && m(n, l(r, t));
178
+ (i === t || i === s[0]) && g(n, l(r, t));
174
179
  return;
175
180
  }
176
- o.length > 0 && i !== o[o.length - 1] || m(n, d(r, t));
181
+ s.length > 0 && i !== s[s.length - 1] || g(n, p(r, t));
177
182
  });
178
183
  }
179
184
  //#endregion
180
- export { l as PopoverBeak, d as getTabbableAfter, f as getTabbableThrough, x as usePopoverTabOrder };
185
+ export { u as PopoverBeak, p as getTabbableAfter, m as getTabbableThrough, d as isFocusInSurfaceTree, C as usePopoverTabOrder };
181
186
 
182
187
  //# sourceMappingURL=Popover.shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.shared.mjs","names":["React","BEAK_BORDER","PopoverBeak","rest","cn","side","className","getScopedTabbables","getTabbableElements","anchor","scope","order","exclude","el","getTabbableAfter","getTabbableThrough","through","getEntryStop","previous","surface","focusInstead","target","event","isNothing","node","doc","hideForNativeTab","win","value","style","priority","frame","show","focusOrigin","startsAfter","last","start","getOrderedSurfaces","getGlobalRegistry","retainFocusOrigin","onPress","onKey","onWindowBlur","active","onWindowFocus","onFocusCapture","open","onFocusIn","retained","usePopoverTabOrder","getPrevious","useEventCallback","getPreviousStop","entryRef","pendingRef","onDocumentKeyDown","anchorRef","inside","first","entry","index","enabled","redirect","pending","from","entered","expected","getLastTabbable","surfaces","outside","pageEnd","onWindowFocusIn","focusElement","orderedSurfaces","tabbables"],"sources":["../../../src/components/overlays/Popover.shared.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { focusElement, getLastTabbable, getTabbableElements } from '../../lib/focus';\nimport { getGlobalRegistry } from '../../lib/globalRegistry';\nimport type { UsePopupPositionResult } from '../../hooks/usePopupPosition';\nimport { useEventCallback } from '../../hooks/useEventCallback';\n\n// Parts shared by the anchored popups of this folder: Popover.Content and TeachingPopover with a\n// `target`. Internal: not exported from the barrels.\n\n/** Final physical side of a positioned surface (the `side` result of `usePopupPosition`). */\nexport type PopoverPhysicalSide = UsePopupPositionResult['side'];\n\n/** Borders of the rotated square beak that face the anchor, per final physical side. */\nconst BEAK_BORDER: Record<PopoverPhysicalSide, string> = {\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n top: 'border-b border-r',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n bottom: 'border-t border-l',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n left: 'border-t border-r',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n right: 'border-b border-l',\n};\n\n/** Properties for the internal PopoverBeak. */\nexport interface PopoverBeakProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Final physical side of the surface; the beak is drawn on the edge that faces the anchor. */\n side: PopoverPhysicalSide;\n /** Ref to the beak: pass it to `usePopupPosition` as `arrowRef`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The beak of an anchored surface: a rotated square, hidden from assistive technology, that\n * inherits the surface's background and border colors (so a `className` that changes them\n * restyles the beak too). Position it with the `arrowStyles` of `usePopupPosition`; its size\n * matches the `--wave-popup-arrow-size` the arrow offset is computed from.\n */\nexport const PopoverBeak = ({ side, className, ref, ...rest }: PopoverBeakProps) => (\n <div\n ref={ref}\n aria-hidden=\"true\"\n {...rest}\n className={cn('size-2 rotate-45 border-inherit bg-inherit', BEAK_BORDER[side], className)}\n />\n);\nPopoverBeak.displayName = 'PopoverBeak';\n\n/**\n * The tabbable elements of the anchor's document, in sequential focus order, that are in the same\n * portal as the anchor (or, like it, in the page) and outside `exclude`. `order` is the document's\n * tabbable elements when the caller has them already.\n */\nfunction getScopedTabbables(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order: readonly HTMLElement[] = getTabbableElements(anchor.ownerDocument.body),\n): HTMLElement[] {\n const scope = anchor.closest('[data-wave-portal]');\n return order.filter((el) => !exclude.contains(el) && el.closest('[data-wave-portal]') === scope);\n}\n\n/**\n * The first tabbable element after `anchor` in document order, not inside it, in the same portal\n * as the anchor and outside `exclude`: the tab stop after a surface placed right after the anchor.\n * Pass the document's tabbable elements as `order` when you have them, to spare a second scan.\n */\nexport function getTabbableAfter(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n return (\n getScopedTabbables(anchor, exclude, order).find(\n (el) =>\n !anchor.contains(el) &&\n !!(anchor.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING),\n ) ?? null\n );\n}\n\n/**\n * The last tabbable element that is `anchor`, inside it or before it in document order, in the\n * same portal as the anchor and outside `exclude`: the tab stop before a surface placed right\n * after the anchor. Pass the document's tabbable elements as `order` when you have them.\n */\nexport function getTabbableThrough(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n const through = getScopedTabbables(anchor, exclude, order).filter(\n (el) =>\n anchor.contains(el) ||\n !!(anchor.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING),\n );\n return through[through.length - 1] ?? null;\n}\n\n/**\n * The tab stop that a surface placed right after `anchor` follows, given its previous stop: that\n * stop, or the tab stop at or before the anchor when the previous stop is outside the tab order\n * (a trigger with `tabIndex={-1}`). `null` when nothing in the tab order comes before the place.\n */\nfunction getEntryStop(\n previous: HTMLElement | null,\n anchor: HTMLElement,\n surface: HTMLElement,\n order: readonly HTMLElement[],\n): HTMLElement | null {\n if (!previous || order.includes(previous)) return previous;\n return getTabbableThrough(anchor, surface, order);\n}\n\nfunction focusInstead(event: { preventDefault(): void }, target: HTMLElement | null): void {\n if (!target) return;\n event.preventDefault();\n target.focus();\n}\n\nfunction isNothing(doc: Document, node: EventTarget | null): boolean {\n return !node || node === doc.body || node === doc.documentElement;\n}\n\n/**\n * Hides `surface` (`visibility: hidden`) for the native Tab in progress, so the browser moves past\n * its elements. It is shown again as soon as focus moves (the `focusout` of that Tab, before the\n * next element takes focus), or before the next frame when the Tab moves nothing.\n */\nfunction hideForNativeTab(surface: HTMLElement): void {\n const doc = surface.ownerDocument;\n const win = doc.defaultView;\n const { style } = surface;\n const value = style.getPropertyValue('visibility');\n const priority = style.getPropertyPriority('visibility');\n style.setProperty('visibility', 'hidden', 'important');\n let frame: number | undefined;\n const show = () => {\n doc.removeEventListener('focusout', show, true);\n if (frame !== undefined) win?.cancelAnimationFrame(frame);\n frame = undefined;\n // Left alone when something else changed it meanwhile.\n const ours =\n style.getPropertyValue('visibility') === 'hidden' &&\n style.getPropertyPriority('visibility') === 'important';\n if (!ours) return;\n if (value) style.setProperty('visibility', value, priority);\n else style.removeProperty('visibility');\n };\n doc.addEventListener('focusout', show, true);\n if (win) frame = win.requestAnimationFrame(show);\n}\n\n/**\n * What the document knows about focus that arrives from nothing (the body): whether it can come\n * from the browser's own controls, and where the browser starts Tab and Shift+Tab from nothing.\n * The listeners are installed while a {@link usePopoverTabOrder} is mounted, open or not, so the\n * press that opened a surface counts too. Elements are held through a `WeakRef`, so a removed\n * subtree is not kept alive while a popover is mounted: an element that is gone was removed.\n */\ninterface FocusOrigin {\n /** Mounted `usePopoverTabOrder` instances. */\n users: number;\n /**\n * A pointer press (`pointerdown`/`mousedown`) came since the window last lost focus. The user is\n * then in the page, not arriving from the browser's controls, which the window must lose focus\n * to reach: a key press does not clear it.\n */\n pressed: boolean;\n /**\n * The element that had focus when the window lost it: the browser focuses it again, from\n * nothing, when the window gets focus back. Cleared by the next `focusin`.\n */\n refocus: WeakRef<Element> | null;\n /**\n * The element that took focus last, and the ordered surface ({@link getOrderedSurfaces}) that\n * contained it then. When focus has gone from it to nothing (it was removed, hidden or blurred),\n * the browser starts sequential navigation where it is, or where it was. Recorded in the capture\n * phase, so a handler that stops a `focusin` from propagating does not hide it.\n */\n lastFocused: {\n element: WeakRef<Element>;\n surface: WeakRef<HTMLElement> | null;\n } | null;\n /**\n * The window has just got focus back: no element took focus since, and no key or pointer press\n * reached the page. Sequential navigation from the browser's own controls gives the window focus\n * right before the element it reaches; focus that arrives from nothing without it comes from the\n * page (a focus restore after the focused element was removed, a script).\n */\n windowFocused: boolean;\n /**\n * Counts the events that end a key press's focus change: key presses and releases, pointer\n * presses, `focusin` and the window's blur and focus. An entry the `keydown` of a Tab expects\n * applies only to the `focusin` of that same Tab.\n */\n epoch: number;\n /** Removes the listeners; `null` while none are installed. */\n uninstall: (() => void) | null;\n}\n\n/**\n * One per copy of the library, not in the global registry: every field is derived from document\n * and window events, and only this copy's hooks read it, each of which keeps this copy's\n * listeners installed from its mount on. A second copy (ESM and CJS side by side) installs its own\n * listeners and derives the same state; `epoch` is compared only within the copy that set it.\n */\nconst focusOrigin: FocusOrigin = {\n users: 0,\n pressed: false,\n refocus: null,\n lastFocused: null,\n windowFocused: false,\n epoch: 0,\n uninstall: null,\n};\n\n/**\n * Whether sequential navigation from nothing starts after `el`, the last tabbable element of\n * `surface`: at the element that took focus last, when that comes after `el` in the document or\n * was removed from `surface` (it may have been anywhere in it, after `el` too). An element removed\n * elsewhere does not count: from a place after the surface (a dismissed toast in a later portal),\n * Shift+Tab lands on `el` just as from the document's end, and from a place before it, it does not\n * land on `el`.\n */\nfunction startsAfter(el: HTMLElement, surface: HTMLElement): boolean {\n const last = focusOrigin.lastFocused;\n if (!last) return false;\n const start = last.element.deref();\n if (start?.isConnected) {\n return !!(el.compareDocumentPosition(start) & Node.DOCUMENT_POSITION_FOLLOWING);\n }\n return last.surface?.deref() === surface;\n}\n\n/**\n * The surfaces whose keyboard order a {@link usePopoverTabOrder} manages right now. Their content\n * takes its place after its anchor, not at the end of the document where its portal is, so none\n * of it is \"the last element of the page\". Kept in `getGlobalRegistry('orderedSurfaces')`, so an\n * app that loads both the ESM and the CJS copy of the library excludes the surfaces of both.\n */\nfunction getOrderedSurfaces(): Set<HTMLElement> {\n return getGlobalRegistry('orderedSurfaces', () => new Set<HTMLElement>());\n}\n\nfunction retainFocusOrigin(): () => void {\n if (typeof document === 'undefined') return () => {};\n focusOrigin.users += 1;\n if (!focusOrigin.uninstall) {\n const doc = document;\n const win = doc.defaultView;\n const onPress = () => {\n focusOrigin.epoch += 1;\n focusOrigin.pressed = true;\n focusOrigin.windowFocused = false;\n };\n const onKey = () => {\n focusOrigin.epoch += 1;\n focusOrigin.windowFocused = false;\n };\n // Not capture listeners: they hear only the window's own blur and focus (an element's do not\n // bubble).\n const onWindowBlur = () => {\n focusOrigin.epoch += 1;\n focusOrigin.pressed = false;\n focusOrigin.windowFocused = false;\n const active = doc.activeElement;\n focusOrigin.refocus = !active || isNothing(doc, active) ? null : new WeakRef(active);\n };\n const onWindowFocus = () => {\n focusOrigin.epoch += 1;\n focusOrigin.windowFocused = true;\n };\n // Capture, like the presses and keys, so a handler that stops a `focusin` from propagating\n // does not hide where focus went. Only the `keydown` of a later Tab reads it: recording it\n // before the surfaces' own `focusin` listeners run changes nothing for them.\n const onFocusCapture = (event: FocusEvent) => {\n const target = event.target as Element | null;\n const surface = target && [...getOrderedSurfaces()].find((open) => open.contains(target));\n focusOrigin.lastFocused = target && {\n element: new WeakRef(target),\n surface: surface ? new WeakRef(surface) : null,\n };\n };\n // Bubbling to the document, after the surfaces' own `focusin` listeners have read the state.\n const onFocusIn = () => {\n focusOrigin.epoch += 1;\n focusOrigin.refocus = null;\n focusOrigin.windowFocused = false;\n };\n // Capture: a handler that stops a press or a key from propagating must not hide it.\n doc.addEventListener('pointerdown', onPress, true);\n doc.addEventListener('mousedown', onPress, true);\n doc.addEventListener('keydown', onKey, true);\n doc.addEventListener('keyup', onKey, true);\n doc.addEventListener('focusin', onFocusCapture, true);\n doc.addEventListener('focusin', onFocusIn);\n win?.addEventListener('blur', onWindowBlur);\n win?.addEventListener('focus', onWindowFocus);\n focusOrigin.uninstall = () => {\n doc.removeEventListener('pointerdown', onPress, true);\n doc.removeEventListener('mousedown', onPress, true);\n doc.removeEventListener('keydown', onKey, true);\n doc.removeEventListener('keyup', onKey, true);\n doc.removeEventListener('focusin', onFocusCapture, true);\n doc.removeEventListener('focusin', onFocusIn);\n win?.removeEventListener('blur', onWindowBlur);\n win?.removeEventListener('focus', onWindowFocus);\n focusOrigin.pressed = false;\n focusOrigin.refocus = null;\n focusOrigin.lastFocused = null;\n focusOrigin.windowFocused = false;\n };\n }\n let retained = true;\n return () => {\n if (!retained) return;\n retained = false;\n focusOrigin.users = Math.max(0, focusOrigin.users - 1);\n if (focusOrigin.users > 0) return;\n focusOrigin.uninstall?.();\n focusOrigin.uninstall = null;\n };\n}\n\n/** Options of {@link usePopoverTabOrder}. */\nexport interface PopoverTabOrderOptions {\n /** Whether the surface is shown next to its anchor; the listeners exist only while `true`. */\n enabled: boolean;\n /** The portaled surface, held in state through its callback ref. */\n surface: HTMLElement | null;\n /** The anchor: the surface takes its place in the keyboard order right after it. */\n anchorRef: React.RefObject<HTMLElement | null>;\n /**\n * The element before the surface's place: Tab from it enters the surface, and Shift+Tab from\n * the surface's first element returns to it. When it is outside the tab order (a trigger with\n * `tabIndex={-1}`), Tab from the tab stop at or before the anchor enters the surface too; `null`\n * when nothing comes before the place. `order`, when given, is the document's tabbable elements.\n */\n getPreviousStop: (\n anchor: HTMLElement,\n surface: HTMLElement,\n order?: readonly HTMLElement[],\n ) => HTMLElement | null;\n}\n\n/**\n * Keyboard order of a surface portaled to the end of the document, as if it were rendered right\n * after its anchor (the order of 0.4's inline content). Returns the surface's `onKeyDown`; while\n * `enabled`, a document `keydown` listener and `focusin` listeners on the surface and the window\n * do the rest. While mounted, shared document listeners record pointer presses, key presses, the\n * element that took focus last and the window's blur and focus.\n *\n * - Tab from the previous stop enters the surface at its first tabbable element (so does Tab\n * from the tab stop at or before the anchor when the previous stop is outside the tab order),\n * and Shift+Tab from the tab stop after the anchor enters it at its last one.\n * - Tab past the surface's last element continues after the anchor; Shift+Tab from its first\n * element (or from the surface itself) returns to the previous stop.\n * - The surface is not visited a second time where its portal is. Tab from the element before\n * the portal moves past the surface (it is hidden for that one Tab), to what follows it or out\n * of the page. Shift+Tab from the browser's own controls (the window gets focus back just before\n * it), or from nothing without a pointer press, lands on the surface's last element as the\n * document's last one: focus goes to the last element of the page instead (outside every open\n * surface: another open popover's content has its own place after its anchor), unless that is\n * the tab stop before the surface's place (the surface then ends the order). Focus moves there\n * once the entry's `focusin` has reached the window, so the entered element's focus handlers\n * run before its blur handlers; a handler that stops that `focusin` from propagating (an\n * `onFocus` in the content that calls `stopPropagation()`) leaves focus on the surface's last\n * element, as an entry at its place after the anchor, with no trap and no Tab cycle. Shift+Tab\n * from nothing does not start at the document's end when the element that had focus comes after\n * the surface's last element or was removed from the surface (a control of the surface that hid\n * or removed itself): the browser starts where it is, or was. An element removed elsewhere (a\n * dismissed toast portaled after the surface) keeps the rule: from its place, too, Shift+Tab\n * lands on the surface's last element. A lap in either direction visits every element once, and\n * there is no Tab cycle.\n * - With no tab stop before its place (nothing in the tab order at or before the anchor), Tab\n * reaches the surface where its portal is, from the element before the portal, and it follows\n * the document order from there. When the previous stop is missing too, Shift+Tab reaches it\n * there as well: its first element leads to the element before the portal, so neither Shift+Tab\n * from the tab stop after the anchor nor from outside the page is moved to its place.\n * - Every other entry keeps the place after the anchor: a click, Shift+Tab from a pressed point,\n * focus restored from nothing (a layer opened from the surface's last element closed), a\n * script, focus that returns to an element as the window gets focus back, and focus the content\n * takes as it mounts (`autoFocus`, before the listeners exist).\n * - Content that the Tab from the page still reaches (it shows itself again before the browser\n * moves focus) follows the document order from there, so Tab past it leaves the page rather\n * than jumping back to the anchor.\n *\n * Every Tab outside the surface costs one scan of the document's tabbable elements. The listeners\n * skip events whose default is already prevented; React handlers (a trigger's own `onKeyDown`,\n * the returned one) run before them and before a dialog's focus trap.\n */\nexport function usePopoverTabOrder({\n enabled,\n surface,\n anchorRef,\n getPreviousStop,\n}: PopoverTabOrderOptions): React.KeyboardEventHandler<HTMLElement> {\n const getPrevious = useEventCallback(getPreviousStop);\n /** How focus last entered the surface: at its place after the anchor, or at the portal's. */\n const entryRef = React.useRef<'anchor' | 'page'>('anchor');\n /**\n * Where the Tab being pressed enters the surface natively: at `element`, from the page (had it\n * not moved past the surface) or, Shift+Tab from nothing, at the document's far end. Valid in\n * the `focusin` of that Tab only (same `epoch`).\n */\n const pendingRef = React.useRef<{\n element: HTMLElement;\n from: 'page' | 'far-end';\n epoch: number;\n } | null>(null);\n\n const onDocumentKeyDown = useEventCallback((event: KeyboardEvent) => {\n pendingRef.current = null;\n const anchor = anchorRef.current;\n if (event.key !== 'Tab' || event.defaultPrevented || !anchor || !surface) return;\n const doc = surface.ownerDocument;\n const active = doc.activeElement as HTMLElement | null;\n if (active && surface.contains(active)) return;\n // One scan of the document; everything below is derived from it.\n const order = getTabbableElements(doc.body);\n const inside = order.filter((el) => surface.contains(el));\n const first = inside[0];\n const last = inside[inside.length - 1];\n if (!first || !last) return;\n if (!active || isNothing(doc, active)) {\n // With no pointer press to start from, Shift+Tab from nothing reaches the document's last\n // element, unless the browser starts after it: where the element that had focus is, or was\n // (a control of the surface that removed or hid itself).\n if (\n event.shiftKey &&\n !focusOrigin.pressed &&\n order[order.length - 1] === last &&\n !startsAfter(last, surface)\n ) {\n pendingRef.current = { element: last, from: 'far-end', epoch: focusOrigin.epoch };\n }\n return;\n }\n const previous = getPrevious(anchor, surface, order);\n if (event.shiftKey) {\n // Without a previous stop, Shift+Tab from the surface's first element follows the document\n // order: entering the surface here would form a cycle.\n if (previous && active === getTabbableAfter(anchor, surface, order)) {\n focusInstead(event, last);\n }\n return;\n }\n const entry = getEntryStop(previous, anchor, surface, order);\n if (active === previous || active === entry) {\n focusInstead(event, first);\n return;\n }\n const index = order.indexOf(active);\n if (index === -1 || order[index + 1] !== first) return;\n pendingRef.current = { element: first, from: 'page', epoch: focusOrigin.epoch };\n // The browser would enter the surface where its portal is. When a tab stop comes before its\n // place, the surface was visited after the anchor: move past it. Otherwise this is its entry.\n if (entry) hideForNativeTab(surface);\n });\n\n // Installed while mounted, not only while enabled: the press that opens the surface counts.\n React.useEffect(() => retainFocusOrigin(), []);\n\n React.useEffect(() => {\n if (!enabled || !surface) return;\n const doc = surface.ownerDocument;\n const win = doc.defaultView;\n // A new surface, or one shown again: focus it took as it mounted (before this listener) was\n // not a native entry from the page, and an earlier entry no longer applies.\n entryRef.current = 'anchor';\n /**\n * An entry that goes on to the last element of the page. Focus moves there once the entry's\n * `focusin` has reached the window, after React (which listens where the portal is, above the\n * surface) has handled it: the entered element's focus handlers run before its blur handlers,\n * so a Tooltip on it does not stay open. Not in a microtask: a browser runs microtasks between\n * the listeners of its own events.\n */\n let redirect: { event: FocusEvent; pageEnd: HTMLElement } | null = null;\n const onFocusIn = (event: FocusEvent) => {\n redirect = null;\n const pending = pendingRef.current;\n pendingRef.current = null;\n const from = event.relatedTarget as Node | null;\n if (from && surface.contains(from)) return;\n const entered = event.target;\n // The window got focus back: focus returns to where it was, in the order it had there.\n if (!from && entered === focusOrigin.refocus?.deref()) return;\n const expected =\n pending && pending.epoch === focusOrigin.epoch && pending.element === entered\n ? pending.from\n : null;\n // The Tab from the page reached the surface after all: follow the document order from here,\n // so Tab past it leaves the page instead of forming a cycle through the anchor.\n entryRef.current = expected === 'page' ? 'page' : 'anchor';\n if (expected === 'page' || !isNothing(doc, from) || focusOrigin.pressed) return;\n // Shift+Tab from the browser's own controls, or from nothing: the document's last element.\n if (expected !== 'far-end' && !focusOrigin.windowFocused) return;\n const anchor = anchorRef.current;\n if (!anchor || entered !== getLastTabbable(surface)) return;\n const order = getTabbableElements(doc.body);\n const surfaces = [...getOrderedSurfaces()];\n const outside = order.filter((el) => !surfaces.some((open) => open.contains(el)));\n const pageEnd = outside[outside.length - 1];\n const previous = getPrevious(anchor, surface, order);\n // The surface ends the order when the tab stop before its place is the page's last element.\n // Without a previous stop it keeps the place of its portal, as Shift+Tab from it does.\n if (!previous || !pageEnd || pageEnd === getEntryStop(previous, anchor, surface, order)) {\n return;\n }\n redirect = { event, pageEnd };\n };\n const onWindowFocusIn = (event: FocusEvent) => {\n const pending = redirect;\n redirect = null;\n // Left alone when a handler of the entry has moved focus already.\n if (pending?.event !== event || doc.activeElement !== event.target) return;\n if (!focusElement(pending.pageEnd)) entryRef.current = 'page';\n };\n const orderedSurfaces = getOrderedSurfaces();\n orderedSurfaces.add(surface);\n surface.addEventListener('focusin', onFocusIn);\n win?.addEventListener('focusin', onWindowFocusIn);\n doc.addEventListener('keydown', onDocumentKeyDown);\n return () => {\n orderedSurfaces.delete(surface);\n surface.removeEventListener('focusin', onFocusIn);\n win?.removeEventListener('focusin', onWindowFocusIn);\n doc.removeEventListener('keydown', onDocumentKeyDown);\n };\n }, [enabled, surface, anchorRef, getPrevious, onDocumentKeyDown]);\n\n return useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n const anchor = anchorRef.current;\n if (event.key !== 'Tab' || event.defaultPrevented || !enabled || !surface || !anchor) return;\n const active = surface.ownerDocument.activeElement;\n // Events from nested portaled layers bubble here through React: only handle our own content.\n if (!active || !surface.contains(active) || entryRef.current === 'page') return;\n const tabbables = getTabbableElements(surface);\n if (event.shiftKey) {\n if (active === surface || active === tabbables[0]) {\n focusInstead(event, getPrevious(anchor, surface));\n }\n return;\n }\n if (tabbables.length > 0 && active !== tabbables[tabbables.length - 1]) return;\n focusInstead(event, getTabbableAfter(anchor, surface));\n });\n}\n"],"mappings":";;;;;;;;AAcA,IAAMC,IAAmD;CAEvD,KAAK;CAEL,QAAQ;CAER,MAAM;CAEN,OAAO;AACT,GAgBaC,KAAe,EAAE,SAAM,cAAW,QAAK,GAAGC,QACrD,kBAAC,OAAD;CACO;CACL,eAAY;CACZ,GAAIA;CACJ,WAAWC,EAAG,8CAA8CH,EAAYI,IAAOC,CAAS;AACzF,CAAA;AAEH,EAAY,cAAc;AAO1B,SAASC,EACP,GACA,GACA,IAAgCC,EAAoBC,EAAO,cAAc,IAAI,GAC9D;CACf,IAAMC,IAAQD,EAAO,QAAQ,oBAAoB;CACjD,OAAOE,EAAM,QAAQ,MAA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cn","side","className","isFocusInSurfaceTree","active","surface","getLayerTreeElements","layerId","el","getScopedTabbables","getTabbableElements","anchor","scope","order","exclude","getTabbableAfter","getTabbableThrough","through","getEntryStop","previous","focusInstead","target","event","isNothing","node","doc","hideForNativeTab","win","value","style","priority","frame","show","focusOrigin","startsAfter","last","start","getOrderedSurfaces","getGlobalRegistry","retainFocusOrigin","onPress","onKey","onWindowBlur","onWindowFocus","onFocusCapture","open","onFocusIn","retained","usePopoverTabOrder","getPrevious","useEventCallback","getPreviousStop","entryRef","pendingRef","onDocumentKeyDown","anchorRef","inside","first","entry","index","enabled","redirect","pending","from","entered","expected","getLastTabbable","surfaces","outside","pageEnd","onWindowFocusIn","focusElement","orderedSurfaces","tabbables"],"sources":["../../../src/components/overlays/Popover.shared.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { focusElement, getLastTabbable, getTabbableElements } from '../../lib/focus';\nimport { getGlobalRegistry } from '../../lib/globalRegistry';\nimport { getLayerTreeElements } from '../../lib/layers';\nimport type { UsePopupPositionResult } from '../../hooks/usePopupPosition';\nimport { useEventCallback } from '../../hooks/useEventCallback';\n\n// Parts shared by the anchored popups: Popover.Content and TeachingPopover with a `target`, and\n// InfoButton's note (data-display). Internal: not exported from the barrels.\n\n/** Final physical side of a positioned surface (the `side` result of `usePopupPosition`). */\nexport type PopoverPhysicalSide = UsePopupPositionResult['side'];\n\n/** Borders of the rotated square beak that face the anchor, per final physical side. */\nconst BEAK_BORDER: Record<PopoverPhysicalSide, string> = {\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n top: 'border-b border-r',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n bottom: 'border-t border-l',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n left: 'border-t border-r',\n // wave-allow-physical: the beak follows the physical side resolved by the positioning\n right: 'border-b border-l',\n};\n\n/** Properties for the internal PopoverBeak. */\nexport interface PopoverBeakProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Final physical side of the surface; the beak is drawn on the edge that faces the anchor. */\n side: PopoverPhysicalSide;\n /** Ref to the beak: pass it to `usePopupPosition` as `arrowRef`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The beak of an anchored surface: a rotated square, hidden from assistive technology, that\n * inherits the surface's background and border colors (so a `className` that changes them\n * restyles the beak too). Position it with the `arrowStyles` of `usePopupPosition`; its size\n * matches the `--wave-popup-arrow-size` the arrow offset is computed from.\n */\nexport const PopoverBeak = ({ side, className, ref, ...rest }: PopoverBeakProps) => (\n <div\n ref={ref}\n aria-hidden=\"true\"\n {...rest}\n className={cn('size-2 rotate-45 border-inherit bg-inherit', BEAK_BORDER[side], className)}\n />\n);\nPopoverBeak.displayName = 'PopoverBeak';\n\n/**\n * Whether focus is inside `surface` or in a layer opened from it (a menu or popover of its\n * content, whose portal lives elsewhere): what keeps a hover-opened surface open (Phase 2 D18).\n * Focus on the trigger does not count, although the trigger belongs to the dismiss layer\n * `layerId`. Popover.Content and InfoButton's note pass it to their hover intent's `canClose`.\n */\nexport function isFocusInSurfaceTree(surface: HTMLElement | null, layerId: string): boolean {\n const active = surface?.ownerDocument.activeElement;\n if (!surface || !active) return false;\n if (surface.contains(active)) return true;\n return getLayerTreeElements(layerId, { includeOwnElements: false }).some((el) =>\n el.contains(active),\n );\n}\n\n/**\n * The tabbable elements of the anchor's document, in sequential focus order, that are in the same\n * portal as the anchor (or, like it, in the page) and outside `exclude`. `order` is the document's\n * tabbable elements when the caller has them already.\n */\nfunction getScopedTabbables(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order: readonly HTMLElement[] = getTabbableElements(anchor.ownerDocument.body),\n): HTMLElement[] {\n const scope = anchor.closest('[data-wave-portal]');\n return order.filter((el) => !exclude.contains(el) && el.closest('[data-wave-portal]') === scope);\n}\n\n/**\n * The first tabbable element after `anchor` in document order, not inside it, in the same portal\n * as the anchor and outside `exclude`: the tab stop after a surface placed right after the anchor.\n * Pass the document's tabbable elements as `order` when you have them, to spare a second scan.\n */\nexport function getTabbableAfter(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n return (\n getScopedTabbables(anchor, exclude, order).find(\n (el) =>\n !anchor.contains(el) &&\n !!(anchor.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_FOLLOWING),\n ) ?? null\n );\n}\n\n/**\n * The last tabbable element that is `anchor`, inside it or before it in document order, in the\n * same portal as the anchor and outside `exclude`: the tab stop before a surface placed right\n * after the anchor. Pass the document's tabbable elements as `order` when you have them.\n */\nexport function getTabbableThrough(\n anchor: HTMLElement,\n exclude: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n const through = getScopedTabbables(anchor, exclude, order).filter(\n (el) =>\n anchor.contains(el) ||\n !!(anchor.compareDocumentPosition(el) & Node.DOCUMENT_POSITION_PRECEDING),\n );\n return through[through.length - 1] ?? null;\n}\n\n/**\n * The tab stop that a surface placed right after `anchor` follows, given its previous stop: that\n * stop, or the tab stop at or before the anchor when the previous stop is outside the tab order\n * (a trigger with `tabIndex={-1}`). `null` when nothing in the tab order comes before the place.\n */\nfunction getEntryStop(\n previous: HTMLElement | null,\n anchor: HTMLElement,\n surface: HTMLElement,\n order: readonly HTMLElement[],\n): HTMLElement | null {\n if (!previous || order.includes(previous)) return previous;\n return getTabbableThrough(anchor, surface, order);\n}\n\nfunction focusInstead(event: { preventDefault(): void }, target: HTMLElement | null): void {\n if (!target) return;\n event.preventDefault();\n target.focus();\n}\n\nfunction isNothing(doc: Document, node: EventTarget | null): boolean {\n return !node || node === doc.body || node === doc.documentElement;\n}\n\n/**\n * Hides `surface` (`visibility: hidden`) for the native Tab in progress, so the browser moves past\n * its elements. It is shown again as soon as focus moves (the `focusout` of that Tab, before the\n * next element takes focus), or before the next frame when the Tab moves nothing.\n */\nfunction hideForNativeTab(surface: HTMLElement): void {\n const doc = surface.ownerDocument;\n const win = doc.defaultView;\n const { style } = surface;\n const value = style.getPropertyValue('visibility');\n const priority = style.getPropertyPriority('visibility');\n style.setProperty('visibility', 'hidden', 'important');\n let frame: number | undefined;\n const show = () => {\n doc.removeEventListener('focusout', show, true);\n if (frame !== undefined) win?.cancelAnimationFrame(frame);\n frame = undefined;\n // Left alone when something else changed it meanwhile.\n const ours =\n style.getPropertyValue('visibility') === 'hidden' &&\n style.getPropertyPriority('visibility') === 'important';\n if (!ours) return;\n if (value) style.setProperty('visibility', value, priority);\n else style.removeProperty('visibility');\n };\n doc.addEventListener('focusout', show, true);\n if (win) frame = win.requestAnimationFrame(show);\n}\n\n/**\n * What the document knows about focus that arrives from nothing (the body): whether it can come\n * from the browser's own controls, and where the browser starts Tab and Shift+Tab from nothing.\n * The listeners are installed while a {@link usePopoverTabOrder} is mounted, open or not, so the\n * press that opened a surface counts too. Elements are held through a `WeakRef`, so a removed\n * subtree is not kept alive while a popover is mounted: an element that is gone was removed.\n */\ninterface FocusOrigin {\n /** Mounted `usePopoverTabOrder` instances. */\n users: number;\n /**\n * A pointer press (`pointerdown`/`mousedown`) came since the window last lost focus. The user is\n * then in the page, not arriving from the browser's controls, which the window must lose focus\n * to reach: a key press does not clear it.\n */\n pressed: boolean;\n /**\n * The element that had focus when the window lost it: the browser focuses it again, from\n * nothing, when the window gets focus back. Cleared by the next `focusin`.\n */\n refocus: WeakRef<Element> | null;\n /**\n * The element that took focus last, and the ordered surface ({@link getOrderedSurfaces}) that\n * contained it then. When focus has gone from it to nothing (it was removed, hidden or blurred),\n * the browser starts sequential navigation where it is, or where it was. Recorded in the capture\n * phase, so a handler that stops a `focusin` from propagating does not hide it.\n */\n lastFocused: {\n element: WeakRef<Element>;\n surface: WeakRef<HTMLElement> | null;\n } | null;\n /**\n * The window has just got focus back: no element took focus since, and no key or pointer press\n * reached the page. Sequential navigation from the browser's own controls gives the window focus\n * right before the element it reaches; focus that arrives from nothing without it comes from the\n * page (a focus restore after the focused element was removed, a script).\n */\n windowFocused: boolean;\n /**\n * Counts the events that end a key press's focus change: key presses and releases, pointer\n * presses, `focusin` and the window's blur and focus. An entry the `keydown` of a Tab expects\n * applies only to the `focusin` of that same Tab.\n */\n epoch: number;\n /** Removes the listeners; `null` while none are installed. */\n uninstall: (() => void) | null;\n}\n\n/**\n * One per copy of the library, not in the global registry: every field is derived from document\n * and window events, and only this copy's hooks read it, each of which keeps this copy's\n * listeners installed from its mount on. A second copy (ESM and CJS side by side) installs its own\n * listeners and derives the same state; `epoch` is compared only within the copy that set it.\n */\nconst focusOrigin: FocusOrigin = {\n users: 0,\n pressed: false,\n refocus: null,\n lastFocused: null,\n windowFocused: false,\n epoch: 0,\n uninstall: null,\n};\n\n/**\n * Whether sequential navigation from nothing starts after `el`, the last tabbable element of\n * `surface`: at the element that took focus last, when that comes after `el` in the document or\n * was removed from `surface` (it may have been anywhere in it, after `el` too). An element removed\n * elsewhere does not count: from a place after the surface (a dismissed toast in a later portal),\n * Shift+Tab lands on `el` just as from the document's end, and from a place before it, it does not\n * land on `el`.\n */\nfunction startsAfter(el: HTMLElement, surface: HTMLElement): boolean {\n const last = focusOrigin.lastFocused;\n if (!last) return false;\n const start = last.element.deref();\n if (start?.isConnected) {\n return !!(el.compareDocumentPosition(start) & Node.DOCUMENT_POSITION_FOLLOWING);\n }\n return last.surface?.deref() === surface;\n}\n\n/**\n * The surfaces whose keyboard order a {@link usePopoverTabOrder} manages right now. Their content\n * takes its place after its anchor, not at the end of the document where its portal is, so none\n * of it is \"the last element of the page\". Kept in `getGlobalRegistry('orderedSurfaces')`, so an\n * app that loads both the ESM and the CJS copy of the library excludes the surfaces of both.\n */\nfunction getOrderedSurfaces(): Set<HTMLElement> {\n return getGlobalRegistry('orderedSurfaces', () => new Set<HTMLElement>());\n}\n\nfunction retainFocusOrigin(): () => void {\n if (typeof document === 'undefined') return () => {};\n focusOrigin.users += 1;\n if (!focusOrigin.uninstall) {\n const doc = document;\n const win = doc.defaultView;\n const onPress = () => {\n focusOrigin.epoch += 1;\n focusOrigin.pressed = true;\n focusOrigin.windowFocused = false;\n };\n const onKey = () => {\n focusOrigin.epoch += 1;\n focusOrigin.windowFocused = false;\n };\n // Not capture listeners: they hear only the window's own blur and focus (an element's do not\n // bubble).\n const onWindowBlur = () => {\n focusOrigin.epoch += 1;\n focusOrigin.pressed = false;\n focusOrigin.windowFocused = false;\n const active = doc.activeElement;\n focusOrigin.refocus = !active || isNothing(doc, active) ? null : new WeakRef(active);\n };\n const onWindowFocus = () => {\n focusOrigin.epoch += 1;\n focusOrigin.windowFocused = true;\n };\n // Capture, like the presses and keys, so a handler that stops a `focusin` from propagating\n // does not hide where focus went. Only the `keydown` of a later Tab reads it: recording it\n // before the surfaces' own `focusin` listeners run changes nothing for them.\n const onFocusCapture = (event: FocusEvent) => {\n const target = event.target as Element | null;\n const surface = target && [...getOrderedSurfaces()].find((open) => open.contains(target));\n focusOrigin.lastFocused = target && {\n element: new WeakRef(target),\n surface: surface ? new WeakRef(surface) : null,\n };\n };\n // Bubbling to the document, after the surfaces' own `focusin` listeners have read the state.\n const onFocusIn = () => {\n focusOrigin.epoch += 1;\n focusOrigin.refocus = null;\n focusOrigin.windowFocused = false;\n };\n // Capture: a handler that stops a press or a key from propagating must not hide it.\n doc.addEventListener('pointerdown', onPress, true);\n doc.addEventListener('mousedown', onPress, true);\n doc.addEventListener('keydown', onKey, true);\n doc.addEventListener('keyup', onKey, true);\n doc.addEventListener('focusin', onFocusCapture, true);\n doc.addEventListener('focusin', onFocusIn);\n win?.addEventListener('blur', onWindowBlur);\n win?.addEventListener('focus', onWindowFocus);\n focusOrigin.uninstall = () => {\n doc.removeEventListener('pointerdown', onPress, true);\n doc.removeEventListener('mousedown', onPress, true);\n doc.removeEventListener('keydown', onKey, true);\n doc.removeEventListener('keyup', onKey, true);\n doc.removeEventListener('focusin', onFocusCapture, true);\n doc.removeEventListener('focusin', onFocusIn);\n win?.removeEventListener('blur', onWindowBlur);\n win?.removeEventListener('focus', onWindowFocus);\n focusOrigin.pressed = false;\n focusOrigin.refocus = null;\n focusOrigin.lastFocused = null;\n focusOrigin.windowFocused = false;\n };\n }\n let retained = true;\n return () => {\n if (!retained) return;\n retained = false;\n focusOrigin.users = Math.max(0, focusOrigin.users - 1);\n if (focusOrigin.users > 0) return;\n focusOrigin.uninstall?.();\n focusOrigin.uninstall = null;\n };\n}\n\n/** Options of {@link usePopoverTabOrder}. */\nexport interface PopoverTabOrderOptions {\n /** Whether the surface is shown next to its anchor; the listeners exist only while `true`. */\n enabled: boolean;\n /** The portaled surface, held in state through its callback ref. */\n surface: HTMLElement | null;\n /** The anchor: the surface takes its place in the keyboard order right after it. */\n anchorRef: React.RefObject<HTMLElement | null>;\n /**\n * The element before the surface's place: Tab from it enters the surface, and Shift+Tab from\n * the surface's first element returns to it. When it is outside the tab order (a trigger with\n * `tabIndex={-1}`), Tab from the tab stop at or before the anchor enters the surface too; `null`\n * when nothing comes before the place. `order`, when given, is the document's tabbable elements.\n */\n getPreviousStop: (\n anchor: HTMLElement,\n surface: HTMLElement,\n order?: readonly HTMLElement[],\n ) => HTMLElement | null;\n}\n\n/**\n * Keyboard order of a surface portaled to the end of the document, as if it were rendered right\n * after its anchor (the order of 0.4's inline content). Returns the surface's `onKeyDown`; while\n * `enabled`, a document `keydown` listener and `focusin` listeners on the surface and the window\n * do the rest. While mounted, shared document listeners record pointer presses, key presses, the\n * element that took focus last and the window's blur and focus.\n *\n * - Tab from the previous stop enters the surface at its first tabbable element (so does Tab\n * from the tab stop at or before the anchor when the previous stop is outside the tab order),\n * and Shift+Tab from the tab stop after the anchor enters it at its last one.\n * - Tab past the surface's last element continues after the anchor; Shift+Tab from its first\n * element (or from the surface itself) returns to the previous stop.\n * - The surface is not visited a second time where its portal is. Tab from the element before\n * the portal moves past the surface (it is hidden for that one Tab), to what follows it or out\n * of the page. Shift+Tab from the browser's own controls (the window gets focus back just before\n * it), or from nothing without a pointer press, lands on the surface's last element as the\n * document's last one: focus goes to the last element of the page instead (outside every open\n * surface: another open popover's content has its own place after its anchor), unless that is\n * the tab stop before the surface's place (the surface then ends the order). Focus moves there\n * once the entry's `focusin` has reached the window, so the entered element's focus handlers\n * run before its blur handlers; a handler that stops that `focusin` from propagating (an\n * `onFocus` in the content that calls `stopPropagation()`) leaves focus on the surface's last\n * element, as an entry at its place after the anchor, with no trap and no Tab cycle. Shift+Tab\n * from nothing does not start at the document's end when the element that had focus comes after\n * the surface's last element or was removed from the surface (a control of the surface that hid\n * or removed itself): the browser starts where it is, or was. An element removed elsewhere (a\n * dismissed toast portaled after the surface) keeps the rule: from its place, too, Shift+Tab\n * lands on the surface's last element. A lap in either direction visits every element once, and\n * there is no Tab cycle.\n * - With no tab stop before its place (nothing in the tab order at or before the anchor), Tab\n * reaches the surface where its portal is, from the element before the portal, and it follows\n * the document order from there. When the previous stop is missing too, Shift+Tab reaches it\n * there as well: its first element leads to the element before the portal, so neither Shift+Tab\n * from the tab stop after the anchor nor from outside the page is moved to its place.\n * - Every other entry keeps the place after the anchor: a click, Shift+Tab from a pressed point,\n * focus restored from nothing (a layer opened from the surface's last element closed), a\n * script, focus that returns to an element as the window gets focus back, and focus the content\n * takes as it mounts (`autoFocus`, before the listeners exist).\n * - Content that the Tab from the page still reaches (it shows itself again before the browser\n * moves focus) follows the document order from there, so Tab past it leaves the page rather\n * than jumping back to the anchor.\n *\n * Every Tab outside the surface costs one scan of the document's tabbable elements. The listeners\n * skip events whose default is already prevented; React handlers (a trigger's own `onKeyDown`,\n * the returned one) run before them and before a dialog's focus trap.\n */\nexport function usePopoverTabOrder({\n enabled,\n surface,\n anchorRef,\n getPreviousStop,\n}: PopoverTabOrderOptions): React.KeyboardEventHandler<HTMLElement> {\n const getPrevious = useEventCallback(getPreviousStop);\n /** How focus last entered the surface: at its place after the anchor, or at the portal's. */\n const entryRef = React.useRef<'anchor' | 'page'>('anchor');\n /**\n * Where the Tab being pressed enters the surface natively: at `element`, from the page (had it\n * not moved past the surface) or, Shift+Tab from nothing, at the document's far end. Valid in\n * the `focusin` of that Tab only (same `epoch`).\n */\n const pendingRef = React.useRef<{\n element: HTMLElement;\n from: 'page' | 'far-end';\n epoch: number;\n } | null>(null);\n\n const onDocumentKeyDown = useEventCallback((event: KeyboardEvent) => {\n pendingRef.current = null;\n const anchor = anchorRef.current;\n if (event.key !== 'Tab' || event.defaultPrevented || !anchor || !surface) return;\n const doc = surface.ownerDocument;\n const active = doc.activeElement as HTMLElement | null;\n if (active && surface.contains(active)) return;\n // One scan of the document; everything below is derived from it.\n const order = getTabbableElements(doc.body);\n const inside = order.filter((el) => surface.contains(el));\n const first = inside[0];\n const last = inside[inside.length - 1];\n if (!first || !last) return;\n if (!active || isNothing(doc, active)) {\n // With no pointer press to start from, Shift+Tab from nothing reaches the document's last\n // element, unless the browser starts after it: where the element that had focus is, or was\n // (a control of the surface that removed or hid itself).\n if (\n event.shiftKey &&\n !focusOrigin.pressed &&\n order[order.length - 1] === last &&\n !startsAfter(last, surface)\n ) {\n pendingRef.current = { element: last, from: 'far-end', epoch: focusOrigin.epoch };\n }\n return;\n }\n const previous = getPrevious(anchor, surface, order);\n if (event.shiftKey) {\n // Without a previous stop, Shift+Tab from the surface's first element follows the document\n // order: entering the surface here would form a cycle.\n if (previous && active === getTabbableAfter(anchor, surface, order)) {\n focusInstead(event, last);\n }\n return;\n }\n const entry = getEntryStop(previous, anchor, surface, order);\n if (active === previous || active === entry) {\n focusInstead(event, first);\n return;\n }\n const index = order.indexOf(active);\n if (index === -1 || order[index + 1] !== first) return;\n pendingRef.current = { element: first, from: 'page', epoch: focusOrigin.epoch };\n // The browser would enter the surface where its portal is. When a tab stop comes before its\n // place, the surface was visited after the anchor: move past it. Otherwise this is its entry.\n if (entry) hideForNativeTab(surface);\n });\n\n // Installed while mounted, not only while enabled: the press that opens the surface counts.\n React.useEffect(() => retainFocusOrigin(), []);\n\n React.useEffect(() => {\n if (!enabled || !surface) return;\n const doc = surface.ownerDocument;\n const win = doc.defaultView;\n // A new surface, or one shown again: focus it took as it mounted (before this listener) was\n // not a native entry from the page, and an earlier entry no longer applies.\n entryRef.current = 'anchor';\n /**\n * An entry that goes on to the last element of the page. Focus moves there once the entry's\n * `focusin` has reached the window, after React (which listens where the portal is, above the\n * surface) has handled it: the entered element's focus handlers run before its blur handlers,\n * so a Tooltip on it does not stay open. Not in a microtask: a browser runs microtasks between\n * the listeners of its own events.\n */\n let redirect: { event: FocusEvent; pageEnd: HTMLElement } | null = null;\n const onFocusIn = (event: FocusEvent) => {\n redirect = null;\n const pending = pendingRef.current;\n pendingRef.current = null;\n const from = event.relatedTarget as Node | null;\n if (from && surface.contains(from)) return;\n const entered = event.target;\n // The window got focus back: focus returns to where it was, in the order it had there.\n if (!from && entered === focusOrigin.refocus?.deref()) return;\n const expected =\n pending && pending.epoch === focusOrigin.epoch && pending.element === entered\n ? pending.from\n : null;\n // The Tab from the page reached the surface after all: follow the document order from here,\n // so Tab past it leaves the page instead of forming a cycle through the anchor.\n entryRef.current = expected === 'page' ? 'page' : 'anchor';\n if (expected === 'page' || !isNothing(doc, from) || focusOrigin.pressed) return;\n // Shift+Tab from the browser's own controls, or from nothing: the document's last element.\n if (expected !== 'far-end' && !focusOrigin.windowFocused) return;\n const anchor = anchorRef.current;\n if (!anchor || entered !== getLastTabbable(surface)) return;\n const order = getTabbableElements(doc.body);\n const surfaces = [...getOrderedSurfaces()];\n const outside = order.filter((el) => !surfaces.some((open) => open.contains(el)));\n const pageEnd = outside[outside.length - 1];\n const previous = getPrevious(anchor, surface, order);\n // The surface ends the order when the tab stop before its place is the page's last element.\n // Without a previous stop it keeps the place of its portal, as Shift+Tab from it does.\n if (!previous || !pageEnd || pageEnd === getEntryStop(previous, anchor, surface, order)) {\n return;\n }\n redirect = { event, pageEnd };\n };\n const onWindowFocusIn = (event: FocusEvent) => {\n const pending = redirect;\n redirect = null;\n // Left alone when a handler of the entry has moved focus already.\n if (pending?.event !== event || doc.activeElement !== event.target) return;\n if (!focusElement(pending.pageEnd)) entryRef.current = 'page';\n };\n const orderedSurfaces = getOrderedSurfaces();\n orderedSurfaces.add(surface);\n surface.addEventListener('focusin', onFocusIn);\n win?.addEventListener('focusin', onWindowFocusIn);\n doc.addEventListener('keydown', onDocumentKeyDown);\n return () => {\n orderedSurfaces.delete(surface);\n surface.removeEventListener('focusin', onFocusIn);\n win?.removeEventListener('focusin', onWindowFocusIn);\n doc.removeEventListener('keydown', onDocumentKeyDown);\n };\n }, [enabled, surface, anchorRef, getPrevious, onDocumentKeyDown]);\n\n return useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n const anchor = anchorRef.current;\n if (event.key !== 'Tab' || event.defaultPrevented || !enabled || !surface || !anchor) return;\n const active = surface.ownerDocument.activeElement;\n // Events from nested portaled layers bubble here through React: only handle our own content.\n if (!active || !surface.contains(active) || entryRef.current === 'page') return;\n const tabbables = getTabbableElements(surface);\n if (event.shiftKey) {\n if (active === surface || active === tabbables[0]) {\n focusInstead(event, getPrevious(anchor, surface));\n }\n return;\n }\n if (tabbables.length > 0 && active !== tabbables[tabbables.length - 1]) return;\n focusInstead(event, getTabbableAfter(anchor, surface));\n });\n}\n"],"mappings":";;;;;;;;;AAeA,IAAMC,IAAmD;CAEvD,KAAK;CAEL,QAAQ;CAER,MAAM;CAEN,OAAO;AACT,GAgBaC,KAAe,EAAE,SAAM,cAAW,QAAK,GAAGC,QACrD,kBAAC,OAAD;CACO;CACL,eAAY;CACZ,GAAIA;CACJ,WAAWC,EAAG,8CAA8CH,EAAYI,IAAOC,CAAS;AACzF,CAAA;AAEH,EAAY,cAAc;AAQ1B,SAAgBC,EAAqB,GAA6B,GAA0B;CAC1F,IAAMC,IAASC,GAAS,cAAc;CAGtC,OAFI,CAACA,KAAW,CAACD,IAAe,KAC5BC,EAAQ,SAASD,CAAM,IAAU,KAC9BE,EAAqBC,GAAS,EAAE,oBAAoB,GAAM,CAAC,CAAC,CAAC,MAAM,MACxEC,EAAG,SAASJ,CAAM,CACpB;AACF;AAOA,SAASK,EACP,GACA,GACA,IAAgCC,EAAoBC,EAAO,cAAc,IAAI,GAC9D;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AACH"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),r=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),i=require("../../lib/aria.cjs"),re=require("../../hooks/useAnnounce.cjs"),ie=require("../../hooks/useDismiss.cjs"),ae=require("../portal/Portal.cjs"),a=require("../../lib/styles.cjs"),o=require("../button/Button.cjs"),s=require("../../lib/icons.cjs"),oe=require("../../hooks/usePopupPosition.cjs"),c=require("../../hooks/useRestoreFocus.cjs"),l=require("./Popover.shared.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var se=`Back`,ce=`Next`,le=`Done`,ue=(e,t)=>`step ${e+1} of ${t}`;function f(e){return`current`in e}function p(e){return e!=null&&!f(e)}function m(e){return e?f(e)?e.current:e:null}function de(e,t){return Number.isFinite(e)?Math.min(Math.max(Math.trunc(e),0),t-1):0}var h=({steps:e,activeStep:h,defaultActiveStep:fe,currentStep:pe,defaultCurrentStep:me,onStepChange:he,onDismiss:g,open:_,defaultOpen:v,onOpenChange:y,closeLabel:ge=`Close`,labels:b,target:x,side:_e=`bottom`,align:ve=`center`,className:ye,style:S,onKeyDown:be,ref:xe,...Se})=>{let Ce=n.resolveDeprecatedProp(`TeachingPopover`,h,pe,`currentStep`,`activeStep`),we=n.resolveDeprecatedProp(`TeachingPopover`,fe,me,`defaultCurrentStep`,`defaultActiveStep`)??0,[C,w]=r.useControllable(Ce,we,he),[T,E]=r.useControllable(_,v??!0,y),D=te.useId(`teaching-popover-title`),O=re.useAnnounce(),k=e.length,A=T&&k>0,j=k>0?de(C,k):0,M=k>0&&j!==C,N=k>0?e[j]:void 0,P=N?.title,F=j===0,I=j===k-1,L=x!==void 0,R=k>0?(b?.step??ue)(j,k):``,[z,Te]=u.useState(null),[B,V]=u.useState(()=>p(x)),H=x===null?!1:p(x)?!0:void 0;H!==void 0&&H!==B&&V(H);let U=u.useRef(null),W=u.useRef(null),G=u.useRef(x),K=u.useRef(B),q=u.useRef(null),{setReference:J,setFloating:Ee,floatingProps:Y,arrowStyles:De,side:Oe,isPositioned:ke}=oe.usePopupPosition({open:A&&L,side:_e,align:ve,offset:12,arrowRef:q}),Ae=x!=null&&(!f(x)||B),X=!L||Ae&&ke,Z=A&&X,je=ne.useMergedRefs(xe,U,Te,Ee);u.useLayoutEffect(()=>{G.current=x,K.current=B;let e=m(x);W.current=e,J(e),x!=null&&f(x)&&queueMicrotask(()=>{let e=m(G.current);e!==W.current&&(W.current=e,J(e));let t=e!==null;t!==K.current&&(K.current=t,V(t))})});let Q=()=>{E(!1),g?.()},{layerId:Me}=ie.useDismiss({open:Z,onDismiss:Q,refs:[U],anchorRef:W,kind:`popover`,outsidePress:!1});c.useRestoreFocus({enabled:Z,container:z,fallback:()=>W.current,onlyIfFocusInside:!0});let Ne=l.usePopoverTabOrder({enabled:Z&&L,surface:z,anchorRef:W,getPreviousStop:l.getTabbableThrough});u.useEffect(()=>{Z&&z&&z.focus({preventScroll:L})},[Z,z,L]);let $=u.useRef(j);if(u.useEffect(()=>{$.current!==j&&($.current=j,Z&&P!==void 0&&O(`${P}, ${R}`))},[j,Z,P,R,O]),u.useEffect(()=>{M&&n.warnOnce(`TeachingPopover:activeStep-range`,`TeachingPopover: activeStep ${C} is out of range for ${k} steps; showing step ${j+1}.`)},[M,C,k,j]),!A||!N)return null;let Pe=()=>w(j-1),Fe=()=>{I?Q():w(j+1)};return(0,d.jsx)(ae.Portal,{disabled:!L,layerId:Me,children:(0,d.jsxs)(`div`,{role:`dialog`,"aria-labelledby":D,tabIndex:-1,...Se,ref:je,onKeyDown:ee.composeEventHandlers(be,Ne),...L?{"data-side":Y[`data-side`],"data-align":Y[`data-align`],style:{...S,...Y.style,...X?void 0:{visibility:`hidden`}}}:{style:S},className:t.cn(`relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8`,a.focusRing,ye),children:[L&&(0,d.jsx)(l.PopoverBeak,{ref:q,side:Oe,style:De,"data-wave-teaching-popover-arrow":``}),(0,d.jsx)(o.Button,{appearance:`subtle`,size:`small`,icon:(0,d.jsx)(s.DismissIcon,{}),"aria-label":ge,className:`absolute end-3 top-3`,onClick:Q}),(0,d.jsxs)(`h3`,{id:D,className:`mb-2 pe-8 text-subtitle-1 font-semibold text-foreground`,children:[N.title,(0,d.jsx)(`span`,{className:`sr-only`,children:`, ${R}`})]}),(0,d.jsx)(`div`,{className:`mb-4 text-body-1 text-muted-foreground`,children:N.body}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,d.jsx)(`div`,{"aria-hidden":`true`,className:`flex items-center gap-1.5`,children:e.map((e,n)=>(0,d.jsx)(`span`,{"data-wave-teaching-popover-dot":``,"aria-current":n===j?`step`:void 0,className:t.cn(`h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none`,n===j?t.cn(`w-4 bg-primary`,a.forcedColors.fill):`w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none`)},n))}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k>1&&(0,d.jsx)(o.Button,{...i.focusableDisabledProps(F),onClick:i.preventIfDisabled(F,Pe),children:b?.back??se}),(0,d.jsx)(o.Button,{appearance:`primary`,onClick:Fe,children:I?b?.done??le:b?.next??ce})]})]})]})})};h.displayName=`TeachingPopover`,exports.TeachingPopover=h;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),a=require("../../lib/aria.cjs"),o=require("../../hooks/useAnnounce.cjs"),s=require("../../hooks/useDismiss.cjs"),re=require("../portal/Portal.cjs"),c=require("../../lib/styles.cjs"),l=require("../button/Button.cjs"),ie=require("../../lib/icons.cjs"),ae=require("../../hooks/usePopupPosition.cjs"),oe=require("../../hooks/useRestoreFocus.cjs"),u=require("./Popover.shared.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=`Back`,m=`Next`,se=`Done`,ce=(e,t)=>`step ${e+1} of ${t}`;function h(e){return`current`in e}function g(e){return e!=null&&!h(e)}function _(e){return e?h(e)?e.current:e:null}function le(e,t){return Number.isFinite(e)?Math.min(Math.max(Math.trunc(e),0),t-1):0}var v=({steps:e,activeStep:v,defaultActiveStep:ue,currentStep:de,defaultCurrentStep:fe,onStepChange:pe,onDismiss:me,open:he,defaultOpen:ge,onOpenChange:_e,closeLabel:ve=`Close`,labels:y,target:b,side:ye=`bottom`,align:be=`center`,className:xe,style:x,onKeyDown:Se,ref:Ce,...we})=>{let Te=n.resolveDeprecatedProp(`TeachingPopover`,v,de,`currentStep`,`activeStep`),Ee=n.resolveDeprecatedProp(`TeachingPopover`,ue,fe,`defaultCurrentStep`,`defaultActiveStep`)??0,[S,C]=i.useControllable(Te,Ee,pe),[w,T]=i.useControllable(he,ge??!0,_e),E=te.useId(`teaching-popover-title`),D=o.useAnnounce(),O=e.length,k=w&&O>0,A=O>0?le(S,O):0,j=O>0&&A!==S,M=O>0?e[A]:void 0,N=M?.title,P=A===0,F=A===O-1,I=b!==void 0,L=O>0?(y?.step??ce)(A,O):``,[R,De]=d.useState(null),[z,B]=d.useState(()=>g(b)),V=b===null?!1:g(b)?!0:void 0;V!==void 0&&V!==z&&B(V);let H=d.useRef(null),U=d.useRef(null),W=d.useRef(b),G=d.useRef(z),K=d.useRef(null),{setReference:q,setFloating:Oe,floatingProps:J,arrowStyles:ke,side:Ae,isPositioned:je}=ae.usePopupPosition({open:k&&I,side:ye,align:be,offset:12,arrowRef:K}),Me=b!=null&&(!h(b)||z),Y=!I||Me&&je,X=k&&Y,Z=ne.useMergedRefs(Ce,H,De,Oe);d.useLayoutEffect(()=>{W.current=b,G.current=z;let e=_(b);U.current=e,q(e),b!=null&&h(b)&&queueMicrotask(()=>{let e=_(W.current);e!==U.current&&(U.current=e,q(e));let t=e!==null;t!==G.current&&(G.current=t,B(t))})});let Q=()=>{T(!1),me?.()},{layerId:Ne}=s.useDismiss({open:X,onDismiss:Q,refs:[H],anchorRef:U,kind:`popover`,outsidePress:!1});oe.useRestoreFocus({enabled:X,container:R,fallback:()=>U.current,onlyIfFocusInside:!0});let Pe=u.usePopoverTabOrder({enabled:X&&I,surface:R,anchorRef:U,getPreviousStop:u.getTabbableThrough});d.useEffect(()=>{X&&R&&R.focus({preventScroll:I})},[X,R,I]);let $=d.useRef(A);if(d.useEffect(()=>{$.current!==A&&($.current=A,X&&N!==void 0&&D(`${N}, ${L}`))},[A,X,N,L,D]),d.useEffect(()=>{j&&n.warnOnce(`TeachingPopover:activeStep-range`,`TeachingPopover: activeStep ${S} is out of range for ${O} steps; showing step ${A+1}.`)},[j,S,O,A]),!k||!M)return null;let Fe=()=>C(A-1),Ie=()=>{F?Q():C(A+1)};return(0,f.jsx)(re.Portal,{disabled:!I,layerId:Ne,children:(0,f.jsxs)(`div`,{role:`dialog`,"aria-labelledby":E,tabIndex:-1,...we,ref:Z,onKeyDown:ee.composeEventHandlers(Se,Pe),...I?{"data-side":J[`data-side`],"data-align":J[`data-align`],style:{...x,...J.style,...Y?void 0:{visibility:`hidden`}}}:{style:x},className:t.cn(r.teachingPopoverClassNames.root,`relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8`,c.focusRing,xe),children:[I&&(0,f.jsx)(u.PopoverBeak,{ref:K,side:Ae,style:ke,"data-wave-teaching-popover-arrow":``,className:r.teachingPopoverClassNames.beak}),(0,f.jsx)(l.Button,{appearance:`subtle`,size:`small`,icon:(0,f.jsx)(ie.DismissIcon,{}),"aria-label":ve,className:t.cn(r.teachingPopoverClassNames.closeButton,`absolute end-3 top-3`),onClick:Q}),(0,f.jsxs)(`h3`,{id:E,className:t.cn(r.teachingPopoverClassNames.title,`mb-2 pe-8 text-subtitle-1 font-semibold text-foreground`),children:[M.title,(0,f.jsx)(`span`,{className:`sr-only`,children:`, ${L}`})]}),(0,f.jsx)(`div`,{className:t.cn(r.teachingPopoverClassNames.body,`mb-4 text-body-1 text-muted-foreground`),children:M.body}),(0,f.jsxs)(`div`,{className:t.cn(r.teachingPopoverClassNames.footer,`flex items-center justify-between gap-2`),children:[(0,f.jsx)(`div`,{"aria-hidden":`true`,className:`flex items-center gap-1.5`,children:e.map((e,n)=>(0,f.jsx)(`span`,{"data-wave-teaching-popover-dot":``,"aria-current":n===A?`step`:void 0,className:t.cn(r.teachingPopoverClassNames.dot,`h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none`,n===A?t.cn(`w-4 bg-primary`,c.forcedColors.fill):`w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none`)},n))}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O>1&&(0,f.jsx)(l.Button,{...a.focusableDisabledProps(P),className:r.teachingPopoverClassNames.backButton,onClick:a.preventIfDisabled(P,Fe),children:y?.back??p}),(0,f.jsx)(l.Button,{appearance:`primary`,className:r.teachingPopoverClassNames.nextButton,onClick:Ie,children:F?y?.done??se:y?.next??m})]})]})]})})};v.displayName=`TeachingPopover`,exports.TeachingPopover=v;
2
2
  //# sourceMappingURL=TeachingPopover.cjs.map