@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
@@ -1 +1 @@
1
- {"version":3,"file":"TeachingPopover.cjs","names":["resolveDeprecatedProp","useControllable","useId","useAnnounce","React","usePopupPosition","useMergedRefs","useDismiss","usePopoverTabOrder","getTabbableThrough","Portal","composeEventHandlers","cn","focusRing","PopoverBeak","Button","DismissIcon","forcedColors","focusableDisabledProps","preventIfDisabled","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_useControllable","require_useId","require_useMergedRefs","require_aria","require_useAnnounce","require_useDismiss","require_Portal","require_styles","require_Button","require_icons","require_usePopupPosition","require_useRestoreFocus","require_Popover_shared","react","react_jsx_runtime","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","defaultStepLabel","index","count","isRefObject","target","isElementTarget","resolveTarget","clampStep","step","TeachingPopover","activeStepProp","openProp","rest","controlledStep","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","onStepChange","open","setOpen","defaultOpen","onOpenChange","titleId","announce","steps","shown","outOfRange","stepTitle","isFirst","isLast","hasTarget","stepPosition","labels","surface","setSurface","targetResolved","setTargetResolved","elementAvailable","surfaceRef","targetRef","targetPropRef","availabilityRef","arrowRef","placedSide","targetAvailable","anchorReady","isPositioned","visible","elementRef","ref","setFloating","element","setReference","latest","available","dismiss","onDismiss","onSurfaceKeyDown","announcedIndexRef","handleBack","handleNext","onKeyDown","floatingProps","style","className","arrowStyles","closeLabel","i"],"sources":["../../../src/components/overlays/TeachingPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { DismissIcon } from '../../lib/icons';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport { getTabbableThrough, PopoverBeak, usePopoverTabOrder } from './Popover.shared';\n\n/** Defines a single step in a teaching popover sequence. */\nexport interface TeachingPopoverStep {\n /** Title text for the step. */\n title: string;\n /** Body content for the step. */\n body: React.ReactNode;\n}\n\n/** The built-in text of a TeachingPopover, for localization (see `TeachingPopoverProps.labels`). */\nexport interface TeachingPopoverLabels {\n /** Text of the Back button.\n * @default 'Back'\n */\n back?: string;\n /** Text of the Next button.\n * @default 'Next'\n */\n next?: string;\n /** Text of the button that replaces Next on the last step.\n * @default 'Done'\n */\n done?: string;\n /**\n * The position of the step at `index` (zero-based, like `activeStep`) out of `count` steps. It\n * follows the step title, after a comma, in the visually hidden part of the heading and in the\n * announcement of a step change.\n * @default (index, count) => `step ${index + 1} of ${count}`\n */\n step?: (index: number, count: number) => string;\n}\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /** Called with the requested step index when Next or Back is activated. */\n onStepChange?: (step: number) => void;\n /** Called when the popover is dismissed with Close, Done or Escape. */\n onDismiss?: () => void;\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /** Initial visibility for uncontrolled usage.\n * @default true\n */\n defaultOpen?: boolean;\n /** Called with `false` when Close, Done or Escape dismisses the popover. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons and the wording of the step position (“step 2 of 3”),\n * for localization. Unset members keep their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref or the element). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour).\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /** Ref to the popover surface (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction isRefObject(\n target: NonNullable<TeachingPopoverProps['target']>,\n): target is React.RefObject<HTMLElement | null> {\n return 'current' in target;\n}\n\nfunction isElementTarget(target: TeachingPopoverProps['target']): target is HTMLElement {\n return target != null && !isRefObject(target);\n}\n\nfunction resolveTarget(target: TeachingPopoverProps['target']): HTMLElement | null {\n if (!target) return null;\n return isRefObject(target) ? target.current : target;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * A step-by-step onboarding popover (a non-modal `role=\"dialog\"`) with Back/Next (Done on the\n * last step) and Close.\n *\n * - Visibility is controllable: `open`/`defaultOpen` (default `true`)/`onOpenChange`; Close, Done\n * and Escape (anywhere in the document) dismiss it and call `onDismiss`.\n * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to\n * the available steps. The heading carries a visually hidden “step n of m”, the new step is\n * announced politely, and Back stays focusable (`aria-disabled`) on the first step.\n * - The built-in text is English: `labels` localizes Back, Next, Done and the step position, and\n * `closeLabel` the Close button.\n * - Focus moves to the popover when it opens and returns to the element that had it when it\n * closes (with `target`, to the target when nothing had focus, e.g. a tour opened on page load).\n * - With `target`, the popover is portaled and positioned next to that element with a beak (it\n * inherits the surface colors); it stays hidden while the target is `null`, not positioned yet or\n * no longer mounted (a ref target is read after each render of the popover; see `target`).\n * - With `target`, the keyboard order treats the popover as if it followed the target: Tab past\n * its last button continues after the target, Shift+Tab from its first button (or from the\n * popover itself) returns to the target (for a target outside the Tab order, to the last control\n * inside it, else to the control before it), Tab from there enters the popover, and Shift+Tab\n * from the control after the target enters it at its last button. Tab from the last control of\n * the page moves past the popover (it was visited after the target), and Shift+Tab from outside\n * the page reaches the page's last control first, so a lap visits it once and Tab never cycles.\n * With no control at or before the target, the popover is reached where it is portaled, at the\n * end of the page: Tab from the page's last control and Shift+Tab from outside the page enter\n * it.\n */\nexport const TeachingPopover = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target,\n side = 'bottom',\n align = 'center',\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? true, onOpenChange);\n const titleId = useId('teaching-popover-title');\n const announce = useAnnounce();\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const stepTitle = step?.title;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const hasTarget = target !== undefined;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n // Whether `target` pointed at an element when it was last read. An element (or `null`) is known\n // during render and is mirrored here right away (C-HOOKS: adjust state during render). A ref\n // cannot be read during render, React does not re-render when it attaches or detaches, and\n // floating-ui keeps `isPositioned` after `setReference(null)`, so the layout effect below reads\n // a ref after each commit and mirrors it here through a deferred update (C-HOOKS). Until that\n // update has read a newly passed ref, the ref keeps this last known availability: moving between\n // attached refs (a multi-target tour) or passing a new ref object on every render never hides\n // the popover, and a switch to a ref that is not attached hides it once the update lands.\n const [targetResolved, setTargetResolved] = React.useState(() => isElementTarget(target));\n const elementAvailable = target === null ? false : isElementTarget(target) ? true : undefined;\n if (elementAvailable !== undefined && elementAvailable !== targetResolved) {\n setTargetResolved(elementAvailable);\n }\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const targetRef = React.useRef<HTMLElement | null>(null);\n // The latest `target` prop and committed availability, read by the deferred update so that the\n // newest target and attachment win and an unchanged resolution sets no state.\n const targetPropRef = React.useRef(target);\n const availabilityRef = React.useRef(targetResolved);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n isPositioned,\n } = usePopupPosition({ open: shown && hasTarget, side, align, offset: 12, arrowRef });\n // An anchored popover is shown only while it points at a resolved target: otherwise the surface\n // is rendered (so it can be measured) but hidden, unfocused, silent and without an Escape layer.\n const targetAvailable = target != null && (isRefObject(target) ? targetResolved : true);\n const anchorReady = !hasTarget || (targetAvailable && isPositioned);\n const visible = shown && anchorReady;\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceRef, setSurface, setFloating);\n\n // Point the positioning at the target after every commit. A ref is read once more when the whole\n // commit is done (the C-HOOKS deferred-update pattern): a target that comes after the popover in\n // the tree attaches its ref after this effect has run. That update re-reads the latest target,\n // and only a changed element or availability updates the reference or the state.\n React.useLayoutEffect(() => {\n targetPropRef.current = target;\n availabilityRef.current = targetResolved;\n const element = resolveTarget(target);\n targetRef.current = element;\n setReference(element);\n if (target == null || !isRefObject(target)) return;\n queueMicrotask(() => {\n const latest = resolveTarget(targetPropRef.current);\n if (latest !== targetRef.current) {\n targetRef.current = latest;\n setReference(latest);\n }\n const available = latest !== null;\n if (available !== availabilityRef.current) {\n availabilityRef.current = available;\n setTargetResolved(available);\n }\n });\n });\n\n const dismiss = () => {\n setOpen(false);\n onDismiss?.();\n };\n\n const { layerId } = useDismiss({\n open: visible,\n onDismiss: dismiss,\n refs: [surfaceRef],\n anchorRef: targetRef,\n kind: 'popover',\n outsidePress: false,\n });\n\n useRestoreFocus({\n enabled: visible,\n container: surface,\n fallback: () => targetRef.current,\n onlyIfFocusInside: true,\n });\n\n // Portaled next to a target: the keyboard order of the popover placed right after the target.\n const onSurfaceKeyDown = usePopoverTabOrder({\n enabled: visible && hasTarget,\n surface,\n anchorRef: targetRef,\n getPreviousStop: getTabbableThrough,\n });\n\n // Move focus into the popover when it becomes visible (and when a new surface mounts).\n React.useEffect(() => {\n if (visible && surface) surface.focus({ preventScroll: hasTarget });\n }, [visible, surface, hasTarget]);\n\n // Announce the new step politely after a step change (not on mount, and not while hidden: the\n // heading, which carries the step position, is read when the popover shows and takes focus).\n const announcedIndexRef = React.useRef(index);\n React.useEffect(() => {\n if (announcedIndexRef.current === index) return;\n announcedIndexRef.current = index;\n if (visible && stepTitle !== undefined) {\n announce(`${stepTitle}, ${stepPosition}`);\n }\n }, [index, visible, stepTitle, stepPosition, announce]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n if (!shown || !step) return null;\n\n const handleBack = () => setStep(index - 1);\n const handleNext = () => {\n if (isLast) dismiss();\n else setStep(index + 1);\n };\n\n return (\n <Portal disabled={!hasTarget} layerId={layerId}>\n <div\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n {...rest}\n ref={elementRef}\n onKeyDown={composeEventHandlers(onKeyDown, onSurfaceKeyDown)}\n {...(hasTarget\n ? {\n 'data-side': floatingProps['data-side'],\n 'data-align': floatingProps['data-align'],\n style: {\n ...style,\n ...floatingProps.style,\n ...(anchorReady ? undefined : { visibility: 'hidden' as const }),\n },\n }\n : { style })}\n className={cn(\n 'relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8',\n focusRing,\n className,\n )}\n >\n {hasTarget && (\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-teaching-popover-arrow=\"\"\n />\n )}\n\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n className=\"absolute end-3 top-3\"\n onClick={dismiss}\n />\n\n <h3 id={titleId} className=\"mb-2 pe-8 text-subtitle-1 font-semibold text-foreground\">\n {step.title}\n <span className=\"sr-only\">{`, ${stepPosition}`}</span>\n </h3>\n\n <div className=\"mb-4 text-body-1 text-muted-foreground\">{step.body}</div>\n\n <div className=\"flex items-center justify-between gap-2\">\n <div aria-hidden=\"true\" className=\"flex items-center gap-1.5\">\n {steps.map((_, i) => (\n <span\n key={i}\n data-wave-teaching-popover-dot=\"\"\n aria-current={i === index ? 'step' : undefined}\n className={cn(\n 'h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none',\n i === index\n ? cn('w-4 bg-primary', forcedColors.fill)\n : 'w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none',\n )}\n />\n ))}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {count > 1 && (\n <Button\n {...focusableDisabledProps(isFirst)}\n onClick={preventIfDisabled(isFirst, handleBack)}\n >\n {labels?.back ?? DEFAULT_BACK_LABEL}\n </Button>\n )}\n <Button appearance=\"primary\" onClick={handleNext}>\n {isLast ? (labels?.done ?? DEFAULT_DONE_LABEL) : (labels?.next ?? DEFAULT_NEXT_LABEL)}\n </Button>\n </div>\n </div>\n </div>\n </Portal>\n );\n};\nTeachingPopover.displayName = 'TeachingPopover';\n"],"mappings":"ovBAkDA,IAAMuC,GAAqB,OACrBC,GAAqB,OACrBC,GAAqB,OACrBC,IAAoB,EAAe,IAAkB,QAAQC,EAAQ,EAAE,MAAMC,IA6EnF,SAASC,EACP,EAC+C,CAC/C,MAAO,YAAaC,CACtB,CAEA,SAASC,EAAgB,EAA+D,CACtF,OAAOD,GAAU,MAAQ,CAACD,EAAYC,CAAM,CAC9C,CAEA,SAASE,EAAc,EAA4D,CAEjF,OADKF,EACED,EAAYC,CAAM,EAAIA,EAAO,QAAUA,EAD1B,IAEtB,CAEA,SAASG,GAAU,EAAc,EAAuB,CAEtD,OADK,OAAO,SAASC,CAAI,EAClB,KAAK,IAAI,KAAK,IAAI,KAAK,MAAMA,CAAI,EAAG,CAAC,EAAGN,EAAQ,CAAC,EADrB,CAErC,CA6BA,IAAaO,GAAmB,CAC9B,QACA,WAAYC,EACZ,qBACA,eACA,sBACA,gBACA,YACA,KAAMC,EACN,cACA,eACA,cAAa,QACb,SACA,SACA,QAAO,SACP,SAAQ,SACR,aACA,QACA,aACA,OACA,GAAGC,MACuB,CAC1B,IAAMC,GAAiBvD,EAAAA,sBACrB,kBACAoD,EACAI,GACA,cACA,YACF,EACMC,GACJzD,EAAAA,sBACE,kBACA0D,GACAC,GACA,qBACA,mBACF,GAAK,EACD,CAACC,EAASC,GAAW5D,EAAAA,gBAAgBsD,GAAgBE,GAAaK,EAAY,EAC9E,CAACC,EAAMC,GAAW/D,EAAAA,gBAAgBoD,EAAUY,GAAe,GAAMC,CAAY,EAC7EC,EAAUjE,GAAAA,MAAM,wBAAwB,EACxCkE,EAAWjE,GAAAA,YAAY,EAEvByC,EAAQyB,EAAM,OACdC,EAAQP,GAAQnB,EAAQ,EACxBD,EAAQC,EAAQ,EAAIK,GAAUW,EAAShB,CAAK,EAAI,EAChD2B,EAAa3B,EAAQ,GAAKD,IAAUiB,EACpCV,EAAON,E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AK,EAAG,KACb,EAAA/B,EAAA,IAAA,CAAC,OAAD,CAEE,iCAA+B,GAC/B,eAAc0E,IAAMrE,EAAQ,OAAS,IAAA,GACrC,UAAW/B,EAAAA,GACT,uFACAoG,IAAMrE,EACF/B,EAAAA,GAAG,iBAAkBK,EAAAA,aAAa,IAAI,EACtC,iGACN,CACD,EATM+F,CASN,CACF,CACE,CAAA,GAEL,EAAA1E,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,0BAAf,SAAA,CACGM,EAAQ,IACP,EAAAN,EAAA,IAAA,CAACvB,EAAAA,OAAD,CACE,GAAIG,EAAAA,uBAAuBuD,CAAO,EAClC,QAAStD,EAAAA,kBAAkBsD,EAAS+B,EAAU,EAE7C,SAAA3B,GAAQ,MAAQtC,EACX,CAAA,GAEV,EAAAD,EAAA,IAAA,CAACvB,EAAAA,OAAD,CAAQ,WAAW,UAAU,QAAS0F,GACnC,SAAA/B,EAAUG,GAAQ,MAAQpC,GAAuBoC,GAAQ,MAAQrC,EAC5D,CAAA,CACL,CACF,CAAA,CAAA,GACF,GACC,CAAA,CAEZ,EACA,EAAgB,YAAc"}
1
+ {"version":3,"file":"TeachingPopover.cjs","names":["resolveDeprecatedProp","useControllable","useId","useAnnounce","React","usePopupPosition","useMergedRefs","useDismiss","usePopoverTabOrder","getTabbableThrough","Portal","composeEventHandlers","cn","teachingPopoverClassNames","focusRing","PopoverBeak","Button","DismissIcon","forcedColors","focusableDisabledProps","preventIfDisabled","require_runtime","require_cn","require_dev","require_composeEventHandlers","require_classNames","require_useControllable","require_useId","require_useMergedRefs","require_aria","require_useAnnounce","require_useDismiss","require_Portal","require_styles","require_Button","require_icons","require_usePopupPosition","require_useRestoreFocus","require_Popover_shared","react","react_jsx_runtime","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","defaultStepLabel","index","count","isRefObject","target","isElementTarget","resolveTarget","clampStep","step","TeachingPopover","activeStepProp","openProp","rest","controlledStep","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","onStepChange","open","setOpen","defaultOpen","onOpenChange","titleId","announce","steps","shown","outOfRange","stepTitle","isFirst","isLast","hasTarget","stepPosition","labels","surface","setSurface","targetResolved","setTargetResolved","elementAvailable","surfaceRef","targetRef","targetPropRef","availabilityRef","arrowRef","placedSide","targetAvailable","anchorReady","isPositioned","visible","elementRef","ref","setFloating","element","setReference","latest","available","dismiss","onDismiss","onSurfaceKeyDown","announcedIndexRef","handleBack","handleNext","onKeyDown","floatingProps","style","className","arrowStyles","closeLabel","i"],"sources":["../../../src/components/overlays/TeachingPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { teachingPopoverClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { DismissIcon } from '../../lib/icons';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport { getTabbableThrough, PopoverBeak, usePopoverTabOrder } from './Popover.shared';\n\n/** Defines a single step in a teaching popover sequence. */\nexport interface TeachingPopoverStep {\n /** Title text for the step. */\n title: string;\n /** Body content for the step. */\n body: React.ReactNode;\n}\n\n/** The built-in text of a TeachingPopover, for localization (see `TeachingPopoverProps.labels`). */\nexport interface TeachingPopoverLabels {\n /** Text of the Back button.\n * @default 'Back'\n */\n back?: string;\n /** Text of the Next button.\n * @default 'Next'\n */\n next?: string;\n /** Text of the button that replaces Next on the last step.\n * @default 'Done'\n */\n done?: string;\n /**\n * The position of the step at `index` (zero-based, like `activeStep`) out of `count` steps. It\n * follows the step title, after a comma, in the visually hidden part of the heading and in the\n * announcement of a step change.\n * @default (index, count) => `step ${index + 1} of ${count}`\n */\n step?: (index: number, count: number) => string;\n}\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /** Called with the requested step index when Next or Back is activated. */\n onStepChange?: (step: number) => void;\n /** Called when the popover is dismissed with Close, Done or Escape. */\n onDismiss?: () => void;\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /** Initial visibility for uncontrolled usage.\n * @default true\n */\n defaultOpen?: boolean;\n /** Called with `false` when Close, Done or Escape dismisses the popover. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons and the wording of the step position (“step 2 of 3”),\n * for localization. Unset members keep their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref or the element). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour).\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /** Ref to the popover surface (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction isRefObject(\n target: NonNullable<TeachingPopoverProps['target']>,\n): target is React.RefObject<HTMLElement | null> {\n return 'current' in target;\n}\n\nfunction isElementTarget(target: TeachingPopoverProps['target']): target is HTMLElement {\n return target != null && !isRefObject(target);\n}\n\nfunction resolveTarget(target: TeachingPopoverProps['target']): HTMLElement | null {\n if (!target) return null;\n return isRefObject(target) ? target.current : target;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * A step-by-step onboarding popover (a non-modal `role=\"dialog\"`) with Back/Next (Done on the\n * last step) and Close.\n *\n * - Visibility is controllable: `open`/`defaultOpen` (default `true`)/`onOpenChange`; Close, Done\n * and Escape (anywhere in the document) dismiss it and call `onDismiss`.\n * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to\n * the available steps. The heading carries a visually hidden “step n of m”, the new step is\n * announced politely, and Back stays focusable (`aria-disabled`) on the first step.\n * - The built-in text is English: `labels` localizes Back, Next, Done and the step position, and\n * `closeLabel` the Close button.\n * - Focus moves to the popover when it opens and returns to the element that had it when it\n * closes (with `target`, to the target when nothing had focus, e.g. a tour opened on page load).\n * - With `target`, the popover is portaled and positioned next to that element with a beak (it\n * inherits the surface colors); it stays hidden while the target is `null`, not positioned yet or\n * no longer mounted (a ref target is read after each render of the popover; see `target`).\n * - With `target`, the keyboard order treats the popover as if it followed the target: Tab past\n * its last button continues after the target, Shift+Tab from its first button (or from the\n * popover itself) returns to the target (for a target outside the Tab order, to the last control\n * inside it, else to the control before it), Tab from there enters the popover, and Shift+Tab\n * from the control after the target enters it at its last button. Tab from the last control of\n * the page moves past the popover (it was visited after the target), and Shift+Tab from outside\n * the page reaches the page's last control first, so a lap visits it once and Tab never cycles.\n * With no control at or before the target, the popover is reached where it is portaled, at the\n * end of the page: Tab from the page's last control and Shift+Tab from outside the page enter\n * it.\n */\nexport const TeachingPopover = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target,\n side = 'bottom',\n align = 'center',\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? true, onOpenChange);\n const titleId = useId('teaching-popover-title');\n const announce = useAnnounce();\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const stepTitle = step?.title;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const hasTarget = target !== undefined;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n // Whether `target` pointed at an element when it was last read. An element (or `null`) is known\n // during render and is mirrored here right away (C-HOOKS: adjust state during render). A ref\n // cannot be read during render, React does not re-render when it attaches or detaches, and\n // floating-ui keeps `isPositioned` after `setReference(null)`, so the layout effect below reads\n // a ref after each commit and mirrors it here through a deferred update (C-HOOKS). Until that\n // update has read a newly passed ref, the ref keeps this last known availability: moving between\n // attached refs (a multi-target tour) or passing a new ref object on every render never hides\n // the popover, and a switch to a ref that is not attached hides it once the update lands.\n const [targetResolved, setTargetResolved] = React.useState(() => isElementTarget(target));\n const elementAvailable = target === null ? false : isElementTarget(target) ? true : undefined;\n if (elementAvailable !== undefined && elementAvailable !== targetResolved) {\n setTargetResolved(elementAvailable);\n }\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const targetRef = React.useRef<HTMLElement | null>(null);\n // The latest `target` prop and committed availability, read by the deferred update so that the\n // newest target and attachment win and an unchanged resolution sets no state.\n const targetPropRef = React.useRef(target);\n const availabilityRef = React.useRef(targetResolved);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n isPositioned,\n } = usePopupPosition({ open: shown && hasTarget, side, align, offset: 12, arrowRef });\n // An anchored popover is shown only while it points at a resolved target: otherwise the surface\n // is rendered (so it can be measured) but hidden, unfocused, silent and without an Escape layer.\n const targetAvailable = target != null && (isRefObject(target) ? targetResolved : true);\n const anchorReady = !hasTarget || (targetAvailable && isPositioned);\n const visible = shown && anchorReady;\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceRef, setSurface, setFloating);\n\n // Point the positioning at the target after every commit. A ref is read once more when the whole\n // commit is done (the C-HOOKS deferred-update pattern): a target that comes after the popover in\n // the tree attaches its ref after this effect has run. That update re-reads the latest target,\n // and only a changed element or availability updates the reference or the state.\n React.useLayoutEffect(() => {\n targetPropRef.current = target;\n availabilityRef.current = targetResolved;\n const element = resolveTarget(target);\n targetRef.current = element;\n setReference(element);\n if (target == null || !isRefObject(target)) return;\n queueMicrotask(() => {\n const latest = resolveTarget(targetPropRef.current);\n if (latest !== targetRef.current) {\n targetRef.current = latest;\n setReference(latest);\n }\n const available = latest !== null;\n if (available !== availabilityRef.current) {\n availabilityRef.current = available;\n setTargetResolved(available);\n }\n });\n });\n\n const dismiss = () => {\n setOpen(false);\n onDismiss?.();\n };\n\n const { layerId } = useDismiss({\n open: visible,\n onDismiss: dismiss,\n refs: [surfaceRef],\n anchorRef: targetRef,\n kind: 'popover',\n outsidePress: false,\n });\n\n useRestoreFocus({\n enabled: visible,\n container: surface,\n fallback: () => targetRef.current,\n onlyIfFocusInside: true,\n });\n\n // Portaled next to a target: the keyboard order of the popover placed right after the target.\n const onSurfaceKeyDown = usePopoverTabOrder({\n enabled: visible && hasTarget,\n surface,\n anchorRef: targetRef,\n getPreviousStop: getTabbableThrough,\n });\n\n // Move focus into the popover when it becomes visible (and when a new surface mounts).\n React.useEffect(() => {\n if (visible && surface) surface.focus({ preventScroll: hasTarget });\n }, [visible, surface, hasTarget]);\n\n // Announce the new step politely after a step change (not on mount, and not while hidden: the\n // heading, which carries the step position, is read when the popover shows and takes focus).\n const announcedIndexRef = React.useRef(index);\n React.useEffect(() => {\n if (announcedIndexRef.current === index) return;\n announcedIndexRef.current = index;\n if (visible && stepTitle !== undefined) {\n announce(`${stepTitle}, ${stepPosition}`);\n }\n }, [index, visible, stepTitle, stepPosition, announce]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n if (!shown || !step) return null;\n\n const handleBack = () => setStep(index - 1);\n const handleNext = () => {\n if (isLast) dismiss();\n else setStep(index + 1);\n };\n\n return (\n <Portal disabled={!hasTarget} layerId={layerId}>\n <div\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n {...rest}\n ref={elementRef}\n onKeyDown={composeEventHandlers(onKeyDown, onSurfaceKeyDown)}\n {...(hasTarget\n ? {\n 'data-side': floatingProps['data-side'],\n 'data-align': floatingProps['data-align'],\n style: {\n ...style,\n ...floatingProps.style,\n ...(anchorReady ? undefined : { visibility: 'hidden' as const }),\n },\n }\n : { style })}\n className={cn(\n teachingPopoverClassNames.root,\n 'relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8',\n focusRing,\n className,\n )}\n >\n {hasTarget && (\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-teaching-popover-arrow=\"\"\n className={teachingPopoverClassNames.beak}\n />\n )}\n\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n className={cn(teachingPopoverClassNames.closeButton, 'absolute end-3 top-3')}\n onClick={dismiss}\n />\n\n <h3\n id={titleId}\n className={cn(\n teachingPopoverClassNames.title,\n 'mb-2 pe-8 text-subtitle-1 font-semibold text-foreground',\n )}\n >\n {step.title}\n <span className=\"sr-only\">{`, ${stepPosition}`}</span>\n </h3>\n\n <div\n className={cn(teachingPopoverClassNames.body, 'mb-4 text-body-1 text-muted-foreground')}\n >\n {step.body}\n </div>\n\n <div\n className={cn(\n teachingPopoverClassNames.footer,\n 'flex items-center justify-between gap-2',\n )}\n >\n <div aria-hidden=\"true\" className=\"flex items-center gap-1.5\">\n {steps.map((_, i) => (\n <span\n key={i}\n data-wave-teaching-popover-dot=\"\"\n aria-current={i === index ? 'step' : undefined}\n className={cn(\n teachingPopoverClassNames.dot,\n 'h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none',\n i === index\n ? cn('w-4 bg-primary', forcedColors.fill)\n : 'w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none',\n )}\n />\n ))}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {count > 1 && (\n <Button\n {...focusableDisabledProps(isFirst)}\n className={teachingPopoverClassNames.backButton}\n onClick={preventIfDisabled(isFirst, handleBack)}\n >\n {labels?.back ?? DEFAULT_BACK_LABEL}\n </Button>\n )}\n <Button\n appearance=\"primary\"\n className={teachingPopoverClassNames.nextButton}\n onClick={handleNext}\n >\n {isLast ? (labels?.done ?? DEFAULT_DONE_LABEL) : (labels?.next ?? DEFAULT_NEXT_LABEL)}\n </Button>\n </div>\n </div>\n </div>\n </Portal>\n );\n};\nTeachingPopover.displayName = 'TeachingPopover';\n"],"mappings":"0xBAmDA,IAAMyC,EAAqB,OACrBC,EAAqB,OACrBC,GAAqB,OACrBC,IAAoB,EAAe,IAAkB,QAAQC,EAAQ,EAAE,MAAMC,IA6EnF,SAASC,EACP,EAC+C,CAC/C,MAAO,YAAaC,CACtB,CAEA,SAASC,EAAgB,EAA+D,CACtF,OAAOD,GAAU,MAAQ,CAACD,EAAYC,CAAM,CAC9C,CAEA,SAASE,EAAc,EAA4D,CAEjF,OADKF,EACED,EAAYC,CAAM,EAAIA,EAAO,QAAUA,EAD1B,IAEtB,CAEA,SAASG,GAAU,EAAc,EAAuB,CAEtD,OADK,OAAO,SAASC,CAAI,EAClB,KAAK,IAAI,KAAK,IAAI,KAAK,MAAMA,CAAI,EAAG,CAAC,EAAGN,EAAQ,CAAC,EADrB,CAErC,CA6BA,IAAaO,GAAmB,CAC9B,QACA,WAAYC,EACZ,qBACA,eACA,sBACA,gBACA,aACA,KAAMC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uBAAuBwD,CAAO,EAClC,UAAW9D,EAAAA,0BAA0B,WACrC,QAASO,EAAAA,kBAAkBuD,EAAS+B,EAAU,EAE7C,SAAA3B,GAAQ,MAAQtC,CACX,CAAA,GAEV,EAAAD,EAAA,IAAA,CAACxB,EAAAA,OAAD,CACE,WAAW,UACX,UAAWH,EAAAA,0BAA0B,WACrC,QAAS8F,GAER,SAAA/B,EAAUG,GAAQ,MAAQpC,GAAuBoC,GAAQ,MAAQrC,CAC5D,CAAA,CACL,CACF,CAAA,CAAA,GACF,GACC,CAAA,CAEZ,EACA,EAAgB,YAAc"}
@@ -2,23 +2,24 @@
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
3
  import { resolveDeprecatedProp as t, warnOnce as n } from "../../lib/dev.mjs";
4
4
  import { composeEventHandlers as ee } from "../../lib/composeEventHandlers.mjs";
5
- import { useControllable as r } from "../../hooks/useControllable.mjs";
5
+ import { teachingPopoverClassNames as r } from "../../lib/classNames.mjs";
6
+ import { useControllable as i } from "../../hooks/useControllable.mjs";
6
7
  import { useId as te } from "../../hooks/useId.mjs";
7
8
  import { useMergedRefs as ne } from "../../hooks/useMergedRefs.mjs";
8
9
  import { focusableDisabledProps as re, preventIfDisabled as ie } from "../../lib/aria.mjs";
9
10
  import { useAnnounce as ae } from "../../hooks/useAnnounce.mjs";
10
11
  import { useDismiss as oe } from "../../hooks/useDismiss.mjs";
11
12
  import { Portal as se } from "../portal/Portal.mjs";
12
- import { focusRing as i, forcedColors as ce } from "../../lib/styles.mjs";
13
+ import { focusRing as ce, forcedColors as le } from "../../lib/styles.mjs";
13
14
  import { Button as a } from "../button/Button.mjs";
14
- import { DismissIcon as le } from "../../lib/icons.mjs";
15
- import { usePopupPosition as o } from "../../hooks/usePopupPosition.mjs";
16
- import { useRestoreFocus as ue } from "../../hooks/useRestoreFocus.mjs";
17
- import { PopoverBeak as de, getTabbableThrough as fe, usePopoverTabOrder as pe } from "./Popover.shared.mjs";
15
+ import { DismissIcon as o } from "../../lib/icons.mjs";
16
+ import { usePopupPosition as ue } from "../../hooks/usePopupPosition.mjs";
17
+ import { useRestoreFocus as de } from "../../hooks/useRestoreFocus.mjs";
18
+ import { PopoverBeak as fe, getTabbableThrough as pe, usePopoverTabOrder as me } from "./Popover.shared.mjs";
18
19
  import * as s from "react";
19
20
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
20
21
  //#region src/components/overlays/TeachingPopover.tsx
21
- var me = "Back", he = "Next", ge = "Done", _e = (e, t) => `step ${e + 1} of ${t}`;
22
+ var he = "Back", ge = "Next", _e = "Done", ve = (e, t) => `step ${e + 1} of ${t}`;
22
23
  function u(e) {
23
24
  return "current" in e;
24
25
  }
@@ -31,16 +32,16 @@ function f(e) {
31
32
  function p(e, t) {
32
33
  return Number.isFinite(e) ? Math.min(Math.max(Math.trunc(e), 0), t - 1) : 0;
33
34
  }
34
- var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, defaultCurrentStep: xe, onStepChange: Se, onDismiss: Ce, open: we, defaultOpen: Te, onOpenChange: Ee, closeLabel: De = "Close", labels: h, target: g, side: Oe = "bottom", align: _ = "center", className: v, style: y, onKeyDown: b, ref: x, ...S }) => {
35
- let C = t("TeachingPopover", ve, be, "currentStep", "activeStep"), w = t("TeachingPopover", ye, xe, "defaultCurrentStep", "defaultActiveStep") ?? 0, [T, E] = r(C, w, Se), [ke, Ae] = r(we, Te ?? !0, Ee), D = te("teaching-popover-title"), O = ae(), k = m.length, A = ke && k > 0, j = k > 0 ? p(T, k) : 0, M = k > 0 && j !== T, N = k > 0 ? m[j] : void 0, P = N?.title, F = j === 0, I = j === k - 1, L = g !== void 0, R = k > 0 ? (h?.step ?? _e)(j, k) : "", [z, je] = s.useState(null), [B, V] = s.useState(() => d(g)), H = g === null ? !1 : d(g) ? !0 : void 0;
35
+ var m = ({ steps: m, activeStep: ye, defaultActiveStep: be, currentStep: xe, defaultCurrentStep: Se, onStepChange: Ce, onDismiss: we, open: Te, defaultOpen: Ee, onOpenChange: De, closeLabel: Oe = "Close", labels: h, target: g, side: ke = "bottom", align: _ = "center", className: v, style: y, onKeyDown: b, ref: x, ...S }) => {
36
+ let C = t("TeachingPopover", ye, xe, "currentStep", "activeStep"), w = t("TeachingPopover", be, Se, "defaultCurrentStep", "defaultActiveStep") ?? 0, [T, E] = i(C, w, Ce), [Ae, je] = i(Te, Ee ?? !0, De), D = te("teaching-popover-title"), O = ae(), k = m.length, A = Ae && k > 0, j = k > 0 ? p(T, k) : 0, M = k > 0 && j !== T, N = k > 0 ? m[j] : void 0, P = N?.title, F = j === 0, I = j === k - 1, L = g !== void 0, R = k > 0 ? (h?.step ?? ve)(j, k) : "", [z, Me] = s.useState(null), [B, V] = s.useState(() => d(g)), H = g === null ? !1 : d(g) ? !0 : void 0;
36
37
  H !== void 0 && H !== B && V(H);
37
- let U = s.useRef(null), W = s.useRef(null), G = s.useRef(g), K = s.useRef(B), q = s.useRef(null), { setReference: J, setFloating: Me, floatingProps: Y, arrowStyles: Ne, side: Pe, isPositioned: Fe } = o({
38
+ let U = s.useRef(null), W = s.useRef(null), G = s.useRef(g), K = s.useRef(B), q = s.useRef(null), { setReference: J, setFloating: Ne, floatingProps: Y, arrowStyles: Pe, side: Fe, isPositioned: Ie } = ue({
38
39
  open: A && L,
39
- side: Oe,
40
+ side: ke,
40
41
  align: _,
41
42
  offset: 12,
42
43
  arrowRef: q
43
- }), Ie = g != null && (!u(g) || B), X = !L || Ie && Fe, Z = A && X, Le = ne(x, U, je, Me);
44
+ }), Le = g != null && (!u(g) || B), X = !L || Le && Ie, Z = A && X, Re = ne(x, U, Me, Ne);
44
45
  s.useLayoutEffect(() => {
45
46
  G.current = g, K.current = B;
46
47
  let e = f(g);
@@ -52,8 +53,8 @@ var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, def
52
53
  });
53
54
  });
54
55
  let Q = () => {
55
- Ae(!1), Ce?.();
56
- }, { layerId: Re } = oe({
56
+ je(!1), we?.();
57
+ }, { layerId: ze } = oe({
57
58
  open: Z,
58
59
  onDismiss: Q,
59
60
  refs: [U],
@@ -61,17 +62,17 @@ var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, def
61
62
  kind: "popover",
62
63
  outsidePress: !1
63
64
  });
64
- ue({
65
+ de({
65
66
  enabled: Z,
66
67
  container: z,
67
68
  fallback: () => W.current,
68
69
  onlyIfFocusInside: !0
69
70
  });
70
- let ze = pe({
71
+ let Be = me({
71
72
  enabled: Z && L,
72
73
  surface: z,
73
74
  anchorRef: W,
74
- getPreviousStop: fe
75
+ getPreviousStop: pe
75
76
  });
76
77
  s.useEffect(() => {
77
78
  Z && z && z.focus({ preventScroll: L });
@@ -97,19 +98,19 @@ var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, def
97
98
  k,
98
99
  j
99
100
  ]), !A || !N) return null;
100
- let Be = () => E(j - 1), Ve = () => {
101
+ let Ve = () => E(j - 1), He = () => {
101
102
  I ? Q() : E(j + 1);
102
103
  };
103
104
  return /* @__PURE__ */ c(se, {
104
105
  disabled: !L,
105
- layerId: Re,
106
+ layerId: ze,
106
107
  children: /* @__PURE__ */ l("div", {
107
108
  role: "dialog",
108
109
  "aria-labelledby": D,
109
110
  tabIndex: -1,
110
111
  ...S,
111
- ref: Le,
112
- onKeyDown: ee(b, ze),
112
+ ref: Re,
113
+ onKeyDown: ee(b, Be),
113
114
  ...L ? {
114
115
  "data-side": Y["data-side"],
115
116
  "data-align": Y["data-align"],
@@ -119,54 +120,57 @@ var m = ({ steps: m, activeStep: ve, defaultActiveStep: ye, currentStep: be, def
119
120
  ...X ? void 0 : { visibility: "hidden" }
120
121
  }
121
122
  } : { style: y },
122
- className: e("relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8", i, v),
123
+ className: e(r.root, "relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8", ce, v),
123
124
  children: [
124
- L && /* @__PURE__ */ c(de, {
125
+ L && /* @__PURE__ */ c(fe, {
125
126
  ref: q,
126
- side: Pe,
127
- style: Ne,
128
- "data-wave-teaching-popover-arrow": ""
127
+ side: Fe,
128
+ style: Pe,
129
+ "data-wave-teaching-popover-arrow": "",
130
+ className: r.beak
129
131
  }),
130
132
  /* @__PURE__ */ c(a, {
131
133
  appearance: "subtle",
132
134
  size: "small",
133
- icon: /* @__PURE__ */ c(le, {}),
134
- "aria-label": De,
135
- className: "absolute end-3 top-3",
135
+ icon: /* @__PURE__ */ c(o, {}),
136
+ "aria-label": Oe,
137
+ className: e(r.closeButton, "absolute end-3 top-3"),
136
138
  onClick: Q
137
139
  }),
138
140
  /* @__PURE__ */ l("h3", {
139
141
  id: D,
140
- className: "mb-2 pe-8 text-subtitle-1 font-semibold text-foreground",
142
+ className: e(r.title, "mb-2 pe-8 text-subtitle-1 font-semibold text-foreground"),
141
143
  children: [N.title, /* @__PURE__ */ c("span", {
142
144
  className: "sr-only",
143
145
  children: `, ${R}`
144
146
  })]
145
147
  }),
146
148
  /* @__PURE__ */ c("div", {
147
- className: "mb-4 text-body-1 text-muted-foreground",
149
+ className: e(r.body, "mb-4 text-body-1 text-muted-foreground"),
148
150
  children: N.body
149
151
  }),
150
152
  /* @__PURE__ */ l("div", {
151
- className: "flex items-center justify-between gap-2",
153
+ className: e(r.footer, "flex items-center justify-between gap-2"),
152
154
  children: [/* @__PURE__ */ c("div", {
153
155
  "aria-hidden": "true",
154
156
  className: "flex items-center gap-1.5",
155
157
  children: m.map((t, n) => /* @__PURE__ */ c("span", {
156
158
  "data-wave-teaching-popover-dot": "",
157
159
  "aria-current": n === j ? "step" : void 0,
158
- className: e("h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none", n === j ? e("w-4 bg-primary", ce.fill) : "w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none")
160
+ className: e(r.dot, "h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none", n === j ? e("w-4 bg-primary", le.fill) : "w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none")
159
161
  }, n))
160
162
  }), /* @__PURE__ */ l("div", {
161
163
  className: "flex items-center gap-2",
162
164
  children: [k > 1 && /* @__PURE__ */ c(a, {
163
165
  ...re(F),
164
- onClick: ie(F, Be),
165
- children: h?.back ?? me
166
+ className: r.backButton,
167
+ onClick: ie(F, Ve),
168
+ children: h?.back ?? he
166
169
  }), /* @__PURE__ */ c(a, {
167
170
  appearance: "primary",
168
- onClick: Ve,
169
- children: I ? h?.done ?? ge : h?.next ?? he
171
+ className: r.nextButton,
172
+ onClick: He,
173
+ children: I ? h?.done ?? _e : h?.next ?? ge
170
174
  })]
171
175
  })]
172
176
  })
@@ -1 +1 @@
1
- {"version":3,"file":"TeachingPopover.mjs","names":["useId","useId$1","React","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","defaultStepLabel","index","count","isRefObject","target","isElementTarget","resolveTarget","clampStep","step","TeachingPopover","activeStepProp","openProp","rest","controlledStep","resolveDeprecatedProp","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","useControllable","onStepChange","open","setOpen","defaultOpen","onOpenChange","titleId","announce","useAnnounce","steps","shown","outOfRange","stepTitle","isFirst","isLast","hasTarget","stepPosition","labels","surface","setSurface","targetResolved","setTargetResolved","elementAvailable","surfaceRef","targetRef","targetPropRef","availabilityRef","arrowRef","placedSide","usePopupPosition","targetAvailable","anchorReady","isPositioned","visible","elementRef","useMergedRefs","ref","setFloating","element","setReference","latest","available","dismiss","onDismiss","useDismiss","onSurfaceKeyDown","usePopoverTabOrder","getTabbableThrough","announcedIndexRef","warnOnce","handleBack","handleNext","Portal","composeEventHandlers","onKeyDown","floatingProps","style","cn","focusRing","className","PopoverBeak","arrowStyles","Button","DismissIcon","closeLabel","i","forcedColors","focusableDisabledProps","preventIfDisabled"],"sources":["../../../src/components/overlays/TeachingPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { DismissIcon } from '../../lib/icons';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport { getTabbableThrough, PopoverBeak, usePopoverTabOrder } from './Popover.shared';\n\n/** Defines a single step in a teaching popover sequence. */\nexport interface TeachingPopoverStep {\n /** Title text for the step. */\n title: string;\n /** Body content for the step. */\n body: React.ReactNode;\n}\n\n/** The built-in text of a TeachingPopover, for localization (see `TeachingPopoverProps.labels`). */\nexport interface TeachingPopoverLabels {\n /** Text of the Back button.\n * @default 'Back'\n */\n back?: string;\n /** Text of the Next button.\n * @default 'Next'\n */\n next?: string;\n /** Text of the button that replaces Next on the last step.\n * @default 'Done'\n */\n done?: string;\n /**\n * The position of the step at `index` (zero-based, like `activeStep`) out of `count` steps. It\n * follows the step title, after a comma, in the visually hidden part of the heading and in the\n * announcement of a step change.\n * @default (index, count) => `step ${index + 1} of ${count}`\n */\n step?: (index: number, count: number) => string;\n}\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /** Called with the requested step index when Next or Back is activated. */\n onStepChange?: (step: number) => void;\n /** Called when the popover is dismissed with Close, Done or Escape. */\n onDismiss?: () => void;\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /** Initial visibility for uncontrolled usage.\n * @default true\n */\n defaultOpen?: boolean;\n /** Called with `false` when Close, Done or Escape dismisses the popover. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons and the wording of the step position (“step 2 of 3”),\n * for localization. Unset members keep their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref or the element). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour).\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /** Ref to the popover surface (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction isRefObject(\n target: NonNullable<TeachingPopoverProps['target']>,\n): target is React.RefObject<HTMLElement | null> {\n return 'current' in target;\n}\n\nfunction isElementTarget(target: TeachingPopoverProps['target']): target is HTMLElement {\n return target != null && !isRefObject(target);\n}\n\nfunction resolveTarget(target: TeachingPopoverProps['target']): HTMLElement | null {\n if (!target) return null;\n return isRefObject(target) ? target.current : target;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * A step-by-step onboarding popover (a non-modal `role=\"dialog\"`) with Back/Next (Done on the\n * last step) and Close.\n *\n * - Visibility is controllable: `open`/`defaultOpen` (default `true`)/`onOpenChange`; Close, Done\n * and Escape (anywhere in the document) dismiss it and call `onDismiss`.\n * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to\n * the available steps. The heading carries a visually hidden “step n of m”, the new step is\n * announced politely, and Back stays focusable (`aria-disabled`) on the first step.\n * - The built-in text is English: `labels` localizes Back, Next, Done and the step position, and\n * `closeLabel` the Close button.\n * - Focus moves to the popover when it opens and returns to the element that had it when it\n * closes (with `target`, to the target when nothing had focus, e.g. a tour opened on page load).\n * - With `target`, the popover is portaled and positioned next to that element with a beak (it\n * inherits the surface colors); it stays hidden while the target is `null`, not positioned yet or\n * no longer mounted (a ref target is read after each render of the popover; see `target`).\n * - With `target`, the keyboard order treats the popover as if it followed the target: Tab past\n * its last button continues after the target, Shift+Tab from its first button (or from the\n * popover itself) returns to the target (for a target outside the Tab order, to the last control\n * inside it, else to the control before it), Tab from there enters the popover, and Shift+Tab\n * from the control after the target enters it at its last button. Tab from the last control of\n * the page moves past the popover (it was visited after the target), and Shift+Tab from outside\n * the page reaches the page's last control first, so a lap visits it once and Tab never cycles.\n * With no control at or before the target, the popover is reached where it is portaled, at the\n * end of the page: Tab from the page's last control and Shift+Tab from outside the page enter\n * it.\n */\nexport const TeachingPopover = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target,\n side = 'bottom',\n align = 'center',\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? true, onOpenChange);\n const titleId = useId('teaching-popover-title');\n const announce = useAnnounce();\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const stepTitle = step?.title;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const hasTarget = target !== undefined;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n // Whether `target` pointed at an element when it was last read. An element (or `null`) is known\n // during render and is mirrored here right away (C-HOOKS: adjust state during render). A ref\n // cannot be read during render, React does not re-render when it attaches or detaches, and\n // floating-ui keeps `isPositioned` after `setReference(null)`, so the layout effect below reads\n // a ref after each commit and mirrors it here through a deferred update (C-HOOKS). Until that\n // update has read a newly passed ref, the ref keeps this last known availability: moving between\n // attached refs (a multi-target tour) or passing a new ref object on every render never hides\n // the popover, and a switch to a ref that is not attached hides it once the update lands.\n const [targetResolved, setTargetResolved] = React.useState(() => isElementTarget(target));\n const elementAvailable = target === null ? false : isElementTarget(target) ? true : undefined;\n if (elementAvailable !== undefined && elementAvailable !== targetResolved) {\n setTargetResolved(elementAvailable);\n }\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const targetRef = React.useRef<HTMLElement | null>(null);\n // The latest `target` prop and committed availability, read by the deferred update so that the\n // newest target and attachment win and an unchanged resolution sets no state.\n const targetPropRef = React.useRef(target);\n const availabilityRef = React.useRef(targetResolved);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n isPositioned,\n } = usePopupPosition({ open: shown && hasTarget, side, align, offset: 12, arrowRef });\n // An anchored popover is shown only while it points at a resolved target: otherwise the surface\n // is rendered (so it can be measured) but hidden, unfocused, silent and without an Escape layer.\n const targetAvailable = target != null && (isRefObject(target) ? targetResolved : true);\n const anchorReady = !hasTarget || (targetAvailable && isPositioned);\n const visible = shown && anchorReady;\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceRef, setSurface, setFloating);\n\n // Point the positioning at the target after every commit. A ref is read once more when the whole\n // commit is done (the C-HOOKS deferred-update pattern): a target that comes after the popover in\n // the tree attaches its ref after this effect has run. That update re-reads the latest target,\n // and only a changed element or availability updates the reference or the state.\n React.useLayoutEffect(() => {\n targetPropRef.current = target;\n availabilityRef.current = targetResolved;\n const element = resolveTarget(target);\n targetRef.current = element;\n setReference(element);\n if (target == null || !isRefObject(target)) return;\n queueMicrotask(() => {\n const latest = resolveTarget(targetPropRef.current);\n if (latest !== targetRef.current) {\n targetRef.current = latest;\n setReference(latest);\n }\n const available = latest !== null;\n if (available !== availabilityRef.current) {\n availabilityRef.current = available;\n setTargetResolved(available);\n }\n });\n });\n\n const dismiss = () => {\n setOpen(false);\n onDismiss?.();\n };\n\n const { layerId } = useDismiss({\n open: visible,\n onDismiss: dismiss,\n refs: [surfaceRef],\n anchorRef: targetRef,\n kind: 'popover',\n outsidePress: false,\n });\n\n useRestoreFocus({\n enabled: visible,\n container: surface,\n fallback: () => targetRef.current,\n onlyIfFocusInside: true,\n });\n\n // Portaled next to a target: the keyboard order of the popover placed right after the target.\n const onSurfaceKeyDown = usePopoverTabOrder({\n enabled: visible && hasTarget,\n surface,\n anchorRef: targetRef,\n getPreviousStop: getTabbableThrough,\n });\n\n // Move focus into the popover when it becomes visible (and when a new surface mounts).\n React.useEffect(() => {\n if (visible && surface) surface.focus({ preventScroll: hasTarget });\n }, [visible, surface, hasTarget]);\n\n // Announce the new step politely after a step change (not on mount, and not while hidden: the\n // heading, which carries the step position, is read when the popover shows and takes focus).\n const announcedIndexRef = React.useRef(index);\n React.useEffect(() => {\n if (announcedIndexRef.current === index) return;\n announcedIndexRef.current = index;\n if (visible && stepTitle !== undefined) {\n announce(`${stepTitle}, ${stepPosition}`);\n }\n }, [index, visible, stepTitle, stepPosition, announce]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n if (!shown || !step) return null;\n\n const handleBack = () => setStep(index - 1);\n const handleNext = () => {\n if (isLast) dismiss();\n else setStep(index + 1);\n };\n\n return (\n <Portal disabled={!hasTarget} layerId={layerId}>\n <div\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n {...rest}\n ref={elementRef}\n onKeyDown={composeEventHandlers(onKeyDown, onSurfaceKeyDown)}\n {...(hasTarget\n ? {\n 'data-side': floatingProps['data-side'],\n 'data-align': floatingProps['data-align'],\n style: {\n ...style,\n ...floatingProps.style,\n ...(anchorReady ? undefined : { visibility: 'hidden' as const }),\n },\n }\n : { style })}\n className={cn(\n 'relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8',\n focusRing,\n className,\n )}\n >\n {hasTarget && (\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-teaching-popover-arrow=\"\"\n />\n )}\n\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n className=\"absolute end-3 top-3\"\n onClick={dismiss}\n />\n\n <h3 id={titleId} className=\"mb-2 pe-8 text-subtitle-1 font-semibold text-foreground\">\n {step.title}\n <span className=\"sr-only\">{`, ${stepPosition}`}</span>\n </h3>\n\n <div className=\"mb-4 text-body-1 text-muted-foreground\">{step.body}</div>\n\n <div className=\"flex items-center justify-between gap-2\">\n <div aria-hidden=\"true\" className=\"flex items-center gap-1.5\">\n {steps.map((_, i) => (\n <span\n key={i}\n data-wave-teaching-popover-dot=\"\"\n aria-current={i === index ? 'step' : undefined}\n className={cn(\n 'h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none',\n i === index\n ? cn('w-4 bg-primary', forcedColors.fill)\n : 'w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none',\n )}\n />\n ))}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {count > 1 && (\n <Button\n {...focusableDisabledProps(isFirst)}\n onClick={preventIfDisabled(isFirst, handleBack)}\n >\n {labels?.back ?? DEFAULT_BACK_LABEL}\n </Button>\n )}\n <Button appearance=\"primary\" onClick={handleNext}>\n {isLast ? (labels?.done ?? DEFAULT_DONE_LABEL) : (labels?.next ?? DEFAULT_NEXT_LABEL)}\n </Button>\n </div>\n </div>\n </div>\n </Portal>\n );\n};\nTeachingPopover.displayName = 'TeachingPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkDA,IAAMG,KA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AAD;OAAQ,YAAW;OAAU,SAASX;OACnC,UAAArC,IAAUG,GAAQ,QAAQvC,KAAuBuC,GAAQ,QAAQxC;MAC5D,CAAA,CACL;KACF,CAAA,CAAA;;GACF;;CACC,CAAA;AAEZ;AACA,EAAgB,cAAc"}
1
+ {"version":3,"file":"TeachingPopover.mjs","names":["useId","useId$1","React","DEFAULT_BACK_LABEL","DEFAULT_NEXT_LABEL","DEFAULT_DONE_LABEL","defaultStepLabel","index","count","isRefObject","target","isElementTarget","resolveTarget","clampStep","step","TeachingPopover","activeStepProp","openProp","rest","controlledStep","resolveDeprecatedProp","currentStep","initialStep","defaultActiveStep","defaultCurrentStep","rawStep","setStep","useControllable","onStepChange","open","setOpen","defaultOpen","onOpenChange","titleId","announce","useAnnounce","steps","shown","outOfRange","stepTitle","isFirst","isLast","hasTarget","stepPosition","labels","surface","setSurface","targetResolved","setTargetResolved","elementAvailable","surfaceRef","targetRef","targetPropRef","availabilityRef","arrowRef","placedSide","usePopupPosition","targetAvailable","anchorReady","isPositioned","visible","elementRef","useMergedRefs","ref","setFloating","element","setReference","latest","available","dismiss","onDismiss","useDismiss","onSurfaceKeyDown","usePopoverTabOrder","getTabbableThrough","announcedIndexRef","warnOnce","handleBack","handleNext","Portal","composeEventHandlers","onKeyDown","floatingProps","style","cn","teachingPopoverClassNames","focusRing","className","PopoverBeak","arrowStyles","Button","DismissIcon","closeLabel","i","forcedColors","focusableDisabledProps","preventIfDisabled"],"sources":["../../../src/components/overlays/TeachingPopover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { teachingPopoverClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnOnce } from '../../lib/dev';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { DismissIcon } from '../../lib/icons';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { PopupAlign, PopupSide } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport { getTabbableThrough, PopoverBeak, usePopoverTabOrder } from './Popover.shared';\n\n/** Defines a single step in a teaching popover sequence. */\nexport interface TeachingPopoverStep {\n /** Title text for the step. */\n title: string;\n /** Body content for the step. */\n body: React.ReactNode;\n}\n\n/** The built-in text of a TeachingPopover, for localization (see `TeachingPopoverProps.labels`). */\nexport interface TeachingPopoverLabels {\n /** Text of the Back button.\n * @default 'Back'\n */\n back?: string;\n /** Text of the Next button.\n * @default 'Next'\n */\n next?: string;\n /** Text of the button that replaces Next on the last step.\n * @default 'Done'\n */\n done?: string;\n /**\n * The position of the step at `index` (zero-based, like `activeStep`) out of `count` steps. It\n * follows the step title, after a comma, in the visually hidden part of the heading and in the\n * announcement of a step change.\n * @default (index, count) => `step ${index + 1} of ${count}`\n */\n step?: (index: number, count: number) => string;\n}\n\nconst DEFAULT_BACK_LABEL = 'Back';\nconst DEFAULT_NEXT_LABEL = 'Next';\nconst DEFAULT_DONE_LABEL = 'Done';\nconst defaultStepLabel = (index: number, count: number) => `step ${index + 1} of ${count}`;\n\n/** Properties for the TeachingPopover component. */\nexport interface TeachingPopoverProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Steps to display in the teaching popover (a readonly array is accepted). */\n steps: readonly TeachingPopoverStep[];\n /**\n * Controlled index of the displayed step. Out-of-range values are clamped to the first or last\n * step (with a development warning).\n */\n activeStep?: number;\n /** Initial step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /** @deprecated Use `activeStep`. */\n currentStep?: number;\n /** @deprecated Use `defaultActiveStep`. */\n defaultCurrentStep?: number;\n /** Called with the requested step index when Next or Back is activated. */\n onStepChange?: (step: number) => void;\n /** Called when the popover is dismissed with Close, Done or Escape. */\n onDismiss?: () => void;\n /** Controlled visibility of the teaching popover. */\n open?: boolean;\n /** Initial visibility for uncontrolled usage.\n * @default true\n */\n defaultOpen?: boolean;\n /** Called with `false` when Close, Done or Escape dismisses the popover. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Text of the Back, Next and Done buttons and the wording of the step position (“step 2 of 3”),\n * for localization. Unset members keep their English defaults.\n */\n labels?: TeachingPopoverLabels;\n /**\n * The element the popover points at (a ref or the element). When given, the popover is\n * rendered in a portal, positioned next to it with a beak, and flips or shifts to stay in view;\n * without it (`undefined`) the popover renders inline where it is placed (0.4 behaviour).\n * While the target is `null` or has not been positioned against yet (an element held in state\n * that is not set yet, a ref that is not attached), the popover stays hidden: it is not\n * shown, takes no focus, announces no step change and does not handle Escape until it can\n * point at the target. It hides the same way when the target goes away later and shows again\n * when a target returns.\n *\n * An element (for example one held in state through a callback ref) is followed as soon as the\n * prop changes. A ref cannot be observed, so it is read after each render of the popover is\n * committed, wherever the target is in the tree: an element attaching to or detaching from the\n * ref is noticed the next time the popover renders (for example when the parent that mounts or\n * unmounts the target re-renders it), not in a commit that does not render the popover. A\n * memoized popover whose target mounts or unmounts in another subtree therefore stays hidden,\n * or keeps pointing at the removed element, until it renders again. A newly passed ref keeps\n * the previous visibility until it has been read, so a tour can move between attached refs\n * (`target={step === 0 ? aRef : bRef}`) without hiding, and a switch to a ref that is not\n * attached hides the popover right after that commit. Pass the element held in state when the\n * target can mount or unmount without the popover re-rendering.\n */\n target?: React.RefObject<HTMLElement | null> | HTMLElement | null;\n /** Side of the `target` to open on; `start`/`end` follow the writing direction.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment along the `target`'s edge.\n * @default 'center'\n */\n align?: PopupAlign;\n /** Ref to the popover surface (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction isRefObject(\n target: NonNullable<TeachingPopoverProps['target']>,\n): target is React.RefObject<HTMLElement | null> {\n return 'current' in target;\n}\n\nfunction isElementTarget(target: TeachingPopoverProps['target']): target is HTMLElement {\n return target != null && !isRefObject(target);\n}\n\nfunction resolveTarget(target: TeachingPopoverProps['target']): HTMLElement | null {\n if (!target) return null;\n return isRefObject(target) ? target.current : target;\n}\n\nfunction clampStep(step: number, count: number): number {\n if (!Number.isFinite(step)) return 0;\n return Math.min(Math.max(Math.trunc(step), 0), count - 1);\n}\n\n/**\n * A step-by-step onboarding popover (a non-modal `role=\"dialog\"`) with Back/Next (Done on the\n * last step) and Close.\n *\n * - Visibility is controllable: `open`/`defaultOpen` (default `true`)/`onOpenChange`; Close, Done\n * and Escape (anywhere in the document) dismiss it and call `onDismiss`.\n * - The step is controllable with `activeStep`/`defaultActiveStep`/`onStepChange` and clamped to\n * the available steps. The heading carries a visually hidden “step n of m”, the new step is\n * announced politely, and Back stays focusable (`aria-disabled`) on the first step.\n * - The built-in text is English: `labels` localizes Back, Next, Done and the step position, and\n * `closeLabel` the Close button.\n * - Focus moves to the popover when it opens and returns to the element that had it when it\n * closes (with `target`, to the target when nothing had focus, e.g. a tour opened on page load).\n * - With `target`, the popover is portaled and positioned next to that element with a beak (it\n * inherits the surface colors); it stays hidden while the target is `null`, not positioned yet or\n * no longer mounted (a ref target is read after each render of the popover; see `target`).\n * - With `target`, the keyboard order treats the popover as if it followed the target: Tab past\n * its last button continues after the target, Shift+Tab from its first button (or from the\n * popover itself) returns to the target (for a target outside the Tab order, to the last control\n * inside it, else to the control before it), Tab from there enters the popover, and Shift+Tab\n * from the control after the target enters it at its last button. Tab from the last control of\n * the page moves past the popover (it was visited after the target), and Shift+Tab from outside\n * the page reaches the page's last control first, so a lap visits it once and Tab never cycles.\n * With no control at or before the target, the popover is reached where it is portaled, at the\n * end of the page: Tab from the page's last control and Shift+Tab from outside the page enter\n * it.\n */\nexport const TeachingPopover = ({\n steps,\n activeStep: activeStepProp,\n defaultActiveStep,\n currentStep,\n defaultCurrentStep,\n onStepChange,\n onDismiss,\n open: openProp,\n defaultOpen,\n onOpenChange,\n closeLabel = 'Close',\n labels,\n target,\n side = 'bottom',\n align = 'center',\n className,\n style,\n onKeyDown,\n ref,\n ...rest\n}: TeachingPopoverProps) => {\n const controlledStep = resolveDeprecatedProp(\n 'TeachingPopover',\n activeStepProp,\n currentStep,\n 'currentStep',\n 'activeStep',\n );\n const initialStep =\n resolveDeprecatedProp(\n 'TeachingPopover',\n defaultActiveStep,\n defaultCurrentStep,\n 'defaultCurrentStep',\n 'defaultActiveStep',\n ) ?? 0;\n const [rawStep, setStep] = useControllable(controlledStep, initialStep, onStepChange);\n const [open, setOpen] = useControllable(openProp, defaultOpen ?? true, onOpenChange);\n const titleId = useId('teaching-popover-title');\n const announce = useAnnounce();\n\n const count = steps.length;\n const shown = open && count > 0;\n const index = count > 0 ? clampStep(rawStep, count) : 0;\n const outOfRange = count > 0 && index !== rawStep;\n const step = count > 0 ? steps[index] : undefined;\n const stepTitle = step?.title;\n const isFirst = index === 0;\n const isLast = index === count - 1;\n const hasTarget = target !== undefined;\n const stepPosition = count > 0 ? (labels?.step ?? defaultStepLabel)(index, count) : '';\n\n const [surface, setSurface] = React.useState<HTMLDivElement | null>(null);\n // Whether `target` pointed at an element when it was last read. An element (or `null`) is known\n // during render and is mirrored here right away (C-HOOKS: adjust state during render). A ref\n // cannot be read during render, React does not re-render when it attaches or detaches, and\n // floating-ui keeps `isPositioned` after `setReference(null)`, so the layout effect below reads\n // a ref after each commit and mirrors it here through a deferred update (C-HOOKS). Until that\n // update has read a newly passed ref, the ref keeps this last known availability: moving between\n // attached refs (a multi-target tour) or passing a new ref object on every render never hides\n // the popover, and a switch to a ref that is not attached hides it once the update lands.\n const [targetResolved, setTargetResolved] = React.useState(() => isElementTarget(target));\n const elementAvailable = target === null ? false : isElementTarget(target) ? true : undefined;\n if (elementAvailable !== undefined && elementAvailable !== targetResolved) {\n setTargetResolved(elementAvailable);\n }\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n const targetRef = React.useRef<HTMLElement | null>(null);\n // The latest `target` prop and committed availability, read by the deferred update so that the\n // newest target and attachment win and an unchanged resolution sets no state.\n const targetPropRef = React.useRef(target);\n const availabilityRef = React.useRef(targetResolved);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n isPositioned,\n } = usePopupPosition({ open: shown && hasTarget, side, align, offset: 12, arrowRef });\n // An anchored popover is shown only while it points at a resolved target: otherwise the surface\n // is rendered (so it can be measured) but hidden, unfocused, silent and without an Escape layer.\n const targetAvailable = target != null && (isRefObject(target) ? targetResolved : true);\n const anchorReady = !hasTarget || (targetAvailable && isPositioned);\n const visible = shown && anchorReady;\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceRef, setSurface, setFloating);\n\n // Point the positioning at the target after every commit. A ref is read once more when the whole\n // commit is done (the C-HOOKS deferred-update pattern): a target that comes after the popover in\n // the tree attaches its ref after this effect has run. That update re-reads the latest target,\n // and only a changed element or availability updates the reference or the state.\n React.useLayoutEffect(() => {\n targetPropRef.current = target;\n availabilityRef.current = targetResolved;\n const element = resolveTarget(target);\n targetRef.current = element;\n setReference(element);\n if (target == null || !isRefObject(target)) return;\n queueMicrotask(() => {\n const latest = resolveTarget(targetPropRef.current);\n if (latest !== targetRef.current) {\n targetRef.current = latest;\n setReference(latest);\n }\n const available = latest !== null;\n if (available !== availabilityRef.current) {\n availabilityRef.current = available;\n setTargetResolved(available);\n }\n });\n });\n\n const dismiss = () => {\n setOpen(false);\n onDismiss?.();\n };\n\n const { layerId } = useDismiss({\n open: visible,\n onDismiss: dismiss,\n refs: [surfaceRef],\n anchorRef: targetRef,\n kind: 'popover',\n outsidePress: false,\n });\n\n useRestoreFocus({\n enabled: visible,\n container: surface,\n fallback: () => targetRef.current,\n onlyIfFocusInside: true,\n });\n\n // Portaled next to a target: the keyboard order of the popover placed right after the target.\n const onSurfaceKeyDown = usePopoverTabOrder({\n enabled: visible && hasTarget,\n surface,\n anchorRef: targetRef,\n getPreviousStop: getTabbableThrough,\n });\n\n // Move focus into the popover when it becomes visible (and when a new surface mounts).\n React.useEffect(() => {\n if (visible && surface) surface.focus({ preventScroll: hasTarget });\n }, [visible, surface, hasTarget]);\n\n // Announce the new step politely after a step change (not on mount, and not while hidden: the\n // heading, which carries the step position, is read when the popover shows and takes focus).\n const announcedIndexRef = React.useRef(index);\n React.useEffect(() => {\n if (announcedIndexRef.current === index) return;\n announcedIndexRef.current = index;\n if (visible && stepTitle !== undefined) {\n announce(`${stepTitle}, ${stepPosition}`);\n }\n }, [index, visible, stepTitle, stepPosition, announce]);\n\n React.useEffect(() => {\n if (!outOfRange) return;\n warnOnce(\n 'TeachingPopover:activeStep-range',\n `TeachingPopover: activeStep ${rawStep} is out of range for ${count} steps; showing step ${index + 1}.`,\n );\n }, [outOfRange, rawStep, count, index]);\n\n if (!shown || !step) return null;\n\n const handleBack = () => setStep(index - 1);\n const handleNext = () => {\n if (isLast) dismiss();\n else setStep(index + 1);\n };\n\n return (\n <Portal disabled={!hasTarget} layerId={layerId}>\n <div\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n {...rest}\n ref={elementRef}\n onKeyDown={composeEventHandlers(onKeyDown, onSurfaceKeyDown)}\n {...(hasTarget\n ? {\n 'data-side': floatingProps['data-side'],\n 'data-align': floatingProps['data-align'],\n style: {\n ...style,\n ...floatingProps.style,\n ...(anchorReady ? undefined : { visibility: 'hidden' as const }),\n },\n }\n : { style })}\n className={cn(\n teachingPopoverClassNames.root,\n 'relative w-80 rounded-md border border-border bg-background p-5 text-foreground shadow-8',\n focusRing,\n className,\n )}\n >\n {hasTarget && (\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-teaching-popover-arrow=\"\"\n className={teachingPopoverClassNames.beak}\n />\n )}\n\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n className={cn(teachingPopoverClassNames.closeButton, 'absolute end-3 top-3')}\n onClick={dismiss}\n />\n\n <h3\n id={titleId}\n className={cn(\n teachingPopoverClassNames.title,\n 'mb-2 pe-8 text-subtitle-1 font-semibold text-foreground',\n )}\n >\n {step.title}\n <span className=\"sr-only\">{`, ${stepPosition}`}</span>\n </h3>\n\n <div\n className={cn(teachingPopoverClassNames.body, 'mb-4 text-body-1 text-muted-foreground')}\n >\n {step.body}\n </div>\n\n <div\n className={cn(\n teachingPopoverClassNames.footer,\n 'flex items-center justify-between gap-2',\n )}\n >\n <div aria-hidden=\"true\" className=\"flex items-center gap-1.5\">\n {steps.map((_, i) => (\n <span\n key={i}\n data-wave-teaching-popover-dot=\"\"\n aria-current={i === index ? 'step' : undefined}\n className={cn(\n teachingPopoverClassNames.dot,\n 'h-1.5 rounded-full transition-[width,background-color] motion-reduce:transition-none',\n i === index\n ? cn('w-4 bg-primary', forcedColors.fill)\n : 'w-1.5 bg-stroke-accessible forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none',\n )}\n />\n ))}\n </div>\n\n <div className=\"flex items-center gap-2\">\n {count > 1 && (\n <Button\n {...focusableDisabledProps(isFirst)}\n className={teachingPopoverClassNames.backButton}\n onClick={preventIfDisabled(isFirst, handleBack)}\n >\n {labels?.back ?? DEFAULT_BACK_LABEL}\n </Button>\n )}\n <Button\n appearance=\"primary\"\n className={teachingPopoverClassNames.nextButton}\n onClick={handleNext}\n >\n {isLast ? (labels?.done ?? DEFAULT_DONE_LABEL) : (labels?.next ?? DEFAULT_NEXT_LABEL)}\n </Button>\n </div>\n </div>\n </div>\n </Portal>\n );\n};\nTeachingPopover.displayName = 'TeachingPopover';\n"],"mappings":";;;;;;;;;;;;;;;;;;;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AC,OAAD;MAAK,WAAU;MAAf,UAAA,CACGrF,IAAQ,KACP,kBAACkF,GAAD;OACE,GAAIK,GAAuBvD,CAAO;OAClC,WAAW6C,EAA0B;OACrC,SAASW,GAAkBxD,GAASqC,EAAU;OAE7C,UAAAjC,GAAQ,QAAQzC;MACX,CAAA,GAEV,kBAACuF,GAAD;OACE,YAAW;OACX,WAAWL,EAA0B;OACrC,SAASP;OAER,UAAArC,IAAUG,GAAQ,QAAQvC,KAAuBuC,GAAQ,QAAQxC;MAC5D,CAAA,CACL;KACF,CAAA,CAAA;;GACF;;CACC,CAAA;AAEZ;AACA,EAAgB,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../hooks/useEventCallback.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useId.cjs"),s=require("../../lib/focus.cjs"),c=require("../../hooks/useMergedRefs.cjs"),l=require("../../hooks/useIsClient.cjs"),u=require("../../lib/aria.cjs"),d=require("../../hooks/useDismiss.cjs"),ee=require("../portal/Portal.cjs"),f=require("../../hooks/usePopupPosition.cjs"),p=require("../../lib/renderTrigger.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var te={dark:`inverted`,light:`normal`},g={inverted:`border border-inverted-border bg-inverted text-inverted-foreground`,normal:`border border-border bg-background text-foreground`},_=`max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${[`before:absolute`,`data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2`,`data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2`,`data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2`,`data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2`].join(` `)}`,v=/^on[A-Z]/,y=[`aria-label`,`aria-labelledby`];function b(e){return e.currentTarget.contains(e.target)}function x(e){return t=>{b(t)&&e(t)}}function S(e){let t={},n={};for(let[r,i]of Object.entries(e))r===`id`||r.startsWith(`aria-`)?t[r]=i:n[r]=v.test(r)&&typeof i==`function`?x(i):i;return{childProps:t,wrapperProps:n}}function ne(e,t){let n={...e};for(let e of t)delete n[e];return n}function C(e,t,n){return(e.getAttribute(t)??``).split(/\s+/).includes(n)}function w(e,t,n){let r=(e.getAttribute(t)??``).split(/\s+/).filter(e=>e&&e!==n);r.length>0?e.setAttribute(t,r.join(` `)):e.removeAttribute(t)}function re(e,t,r,i){let a=m.useRef(null),o=r===`label`?`aria-labelledby`:`aria-describedby`;m.useLayoutEffect(()=>{let r=e.current;if(!r)return;let c=()=>{let e=a.current,c=Array.from(r.querySelectorAll(`[${o}]`)).filter(n=>!(e&&e.element===n&&e.attribute===o)&&C(n,o,t)).some(e=>e.matches(s.FOCUSABLE_SELECTOR))?null:s.getFirstTabbable(r);e&&(e.element!==c||e.attribute!==o)&&(w(e.element,e.attribute,t),a.current=null),c&&(C(c,o,t)||c.setAttribute(o,u.joinIds(c.getAttribute(o),t)??``),a.current={element:c,attribute:o},i||n.warnOnce(`Tooltip:focus-target`,`Tooltip: the element that takes focus inside it did not get \`${o}\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content="…"><Button /></Tooltip></Popover.Trigger>.`))};if(c(),!a.current||typeof MutationObserver>`u`)return;let l=new MutationObserver(c);return l.observe(r,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[o]}),()=>l.disconnect()})}var T=({content:e,appearance:s,variant:v,openDelay:C,closeDelay:w=100,delay:T,open:E,defaultOpen:D,onOpenChange:O,relationship:k=`description`,side:ie=`top`,align:ae=`center`,children:oe,className:se,onMouseEnter:ce,onMouseLeave:A,onFocus:j,onBlur:M,ref:N,...P})=>{let F=n.resolveDeprecatedProp(`Tooltip`,s,v===void 0?void 0:te[v],`variant`,`appearance`)??`inverted`,I=n.resolveDeprecatedProp(`Tooltip`,C,T,`delay`,`openDelay`)??200,[L,R]=a.useControllable(E,D??!1,O),z=l.useIsClient(),B=L&&z,V=m.useRef(void 0),H=m.useRef(null),U=m.useRef(null),W=o.useId(`tooltip`),{setReference:le,setFloating:ue,floatingProps:de}=f.usePopupPosition({open:B,side:ie,align:ae,offset:8}),fe=c.useMergedRefs(N,H,le),pe=c.useMergedRefs(U,ue),G=i.useEventCallback(()=>{V.current!==void 0&&(clearTimeout(V.current),V.current=void 0)}),K=i.useEventCallback(()=>{if(G(),!B){if(I<=0){R(!0);return}V.current=setTimeout(()=>{V.current=void 0,R(!0)},I)}}),q=i.useEventCallback(()=>{G(),R(!1)}),me=i.useEventCallback(()=>{G(),B&&(V.current=setTimeout(()=>{V.current=void 0,R(!1)},w))});d.useDismiss({open:B,onDismiss:q,refs:[H,U],anchorRef:H,kind:`tooltip`,outsidePress:!1}),m.useEffect(()=>{let e=V;return()=>clearTimeout(e.current)},[]);let he=i.useEventCallback(e=>{(b(e)||U.current?.contains(e.target))&&K()}),ge=i.useEventCallback(e=>{!b(e)&&!U.current?.contains(e.target)&&q()}),{childProps:J,wrapperProps:Y}=S(P),X=p.unwrapFragment(oe),Z=!p.isCloneableElement(X),Q=k===`label`?`aria-labelledby`:`aria-describedby`,$=Z?ne(J,[...p.STATE_ARIA,...y]):{...J};(!Z||k===`description`)&&($[Q]=u.joinIds(J[Q],W));let _e=p.renderTrigger(X,$,{componentName:`Tooltip`});return re(H,W,k,Z),(0,h.jsxs)(`span`,{ref:fe,...Y,className:t.cn(`inline-block`,se),onMouseEnter:r.composeEventHandlers(ce,he),onMouseLeave:r.composeEventHandlers(A,me),onMouseOver:r.composeEventHandlers(Y.onMouseOver,ge),onFocus:x(r.composeEventHandlers(j,K)),onBlur:x(r.composeEventHandlers(M,q)),children:[_e,(0,h.jsx)(`span`,{id:W,role:`tooltip`,hidden:!0,children:e}),B&&(0,h.jsx)(ee.Portal,{layer:`tooltip`,children:(0,h.jsx)(`span`,{ref:pe,"aria-hidden":`true`,"data-wave-tooltip-surface":``,...de,className:t.cn(_,g[F]),children:e})})]})};T.displayName=`Tooltip`,exports.Tooltip=T;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../hooks/useControllable.cjs"),s=require("../../hooks/useId.cjs"),c=require("../../lib/focus.cjs"),l=require("../../hooks/useMergedRefs.cjs"),ee=require("../../hooks/useIsClient.cjs"),u=require("../../lib/aria.cjs"),d=require("../../hooks/useDismiss.cjs"),f=require("../portal/Portal.cjs"),p=require("../../hooks/usePopupPosition.cjs"),m=require("../../lib/renderTrigger.cjs");let h=require("react");h=e.__toESM(h,1);let g=require("react/jsx-runtime");var te={dark:`inverted`,light:`normal`},_={inverted:`border border-inverted-border bg-inverted text-inverted-foreground`,normal:`border border-border bg-background text-foreground`},v=`max-w-60 whitespace-normal break-words rounded px-3 py-1.5 text-caption-1 font-normal normal-case tracking-normal text-start shadow-8 ${[`before:absolute`,`data-[side=top]:before:inset-x-0 data-[side=top]:before:top-full data-[side=top]:before:h-2`,`data-[side=bottom]:before:inset-x-0 data-[side=bottom]:before:bottom-full data-[side=bottom]:before:h-2`,`data-[side=left]:before:inset-y-0 data-[side=left]:before:left-full data-[side=left]:before:w-2`,`data-[side=right]:before:inset-y-0 data-[side=right]:before:right-full data-[side=right]:before:w-2`].join(` `)}`,y=/^on[A-Z]/,b=[`aria-label`,`aria-labelledby`];function x(e){return e.currentTarget.contains(e.target)}function S(e){return t=>{x(t)&&e(t)}}function ne(e){let t={},n={};for(let[r,i]of Object.entries(e))r===`id`||r.startsWith(`aria-`)?t[r]=i:n[r]=y.test(r)&&typeof i==`function`?S(i):i;return{childProps:t,wrapperProps:n}}function re(e,t){let n={...e};for(let e of t)delete n[e];return n}function C(e,t,n){return(e.getAttribute(t)??``).split(/\s+/).includes(n)}function w(e,t,n){let r=(e.getAttribute(t)??``).split(/\s+/).filter(e=>e&&e!==n);r.length>0?e.setAttribute(t,r.join(` `)):e.removeAttribute(t)}function ie(e,t,r,i){let a=h.useRef(null),o=r===`label`?`aria-labelledby`:`aria-describedby`;h.useLayoutEffect(()=>{let r=e.current;if(!r)return;let s=()=>{let e=a.current,s=Array.from(r.querySelectorAll(`[${o}]`)).filter(n=>!(e&&e.element===n&&e.attribute===o)&&C(n,o,t)).some(e=>e.matches(c.FOCUSABLE_SELECTOR))?null:c.getFirstTabbable(r);e&&(e.element!==s||e.attribute!==o)&&(w(e.element,e.attribute,t),a.current=null),s&&(C(s,o,t)||s.setAttribute(o,u.joinIds(s.getAttribute(o),t)??``),a.current={element:s,attribute:o},i||n.warnOnce(`Tooltip:focus-target`,`Tooltip: the element that takes focus inside it did not get \`${o}\` (the child is not focusable, or is a component, such as a Popover or Dialog root, that does not pass the prop on), so it was added to the first focusable element inside. Put the Tooltip directly around the focusable element, e.g. <Popover.Trigger><Tooltip content="…"><Button /></Tooltip></Popover.Trigger>.`))};if(s(),!a.current||typeof MutationObserver>`u`)return;let l=new MutationObserver(s);return l.observe(r,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[o]}),()=>l.disconnect()})}var T=({content:e,appearance:c,variant:y,openDelay:C,closeDelay:w=100,delay:T,open:E,defaultOpen:D,onOpenChange:ae,relationship:O=`description`,side:oe=`top`,align:se=`center`,children:ce,className:le,onMouseEnter:k,onMouseLeave:A,onFocus:j,onBlur:M,ref:N,...P})=>{let F=n.resolveDeprecatedProp(`Tooltip`,c,y===void 0?void 0:te[y],`variant`,`appearance`)??`inverted`,I=n.resolveDeprecatedProp(`Tooltip`,C,T,`delay`,`openDelay`)??200,[L,R]=o.useControllable(E,D??!1,ae),z=ee.useIsClient(),B=L&&z,V=h.useRef(void 0),H=h.useRef(null),U=h.useRef(null),W=s.useId(`tooltip`),{setReference:ue,setFloating:de,floatingProps:fe}=p.usePopupPosition({open:B,side:oe,align:se,offset:8}),pe=l.useMergedRefs(N,H,ue),me=l.useMergedRefs(U,de),G=a.useEventCallback(()=>{V.current!==void 0&&(clearTimeout(V.current),V.current=void 0)}),K=a.useEventCallback(()=>{if(G(),!B){if(I<=0){R(!0);return}V.current=setTimeout(()=>{V.current=void 0,R(!0)},I)}}),q=a.useEventCallback(()=>{G(),R(!1)}),he=a.useEventCallback(()=>{G(),B&&(V.current=setTimeout(()=>{V.current=void 0,R(!1)},w))});d.useDismiss({open:B,onDismiss:q,refs:[H,U],anchorRef:H,kind:`tooltip`,outsidePress:!1}),h.useEffect(()=>{let e=V;return()=>clearTimeout(e.current)},[]);let ge=a.useEventCallback(e=>{(x(e)||U.current?.contains(e.target))&&K()}),_e=a.useEventCallback(e=>{!x(e)&&!U.current?.contains(e.target)&&q()}),{childProps:J,wrapperProps:Y}=ne(P),X=m.unwrapFragment(ce),Z=!m.isCloneableElement(X),Q=O===`label`?`aria-labelledby`:`aria-describedby`,$=Z?re(J,[...m.STATE_ARIA,...b]):{...J};(!Z||O===`description`)&&($[Q]=u.joinIds(J[Q],W));let ve=m.renderTrigger(X,$,{componentName:`Tooltip`});return ie(H,W,O,Z),(0,g.jsxs)(`span`,{ref:pe,...Y,className:t.cn(i.tooltipClassNames.root,`inline-block`,le),onMouseEnter:r.composeEventHandlers(k,ge),onMouseLeave:r.composeEventHandlers(A,he),onMouseOver:r.composeEventHandlers(Y.onMouseOver,_e),onFocus:S(r.composeEventHandlers(j,K)),onBlur:S(r.composeEventHandlers(M,q)),children:[ve,(0,g.jsx)(`span`,{id:W,role:`tooltip`,hidden:!0,children:e}),B&&(0,g.jsx)(f.Portal,{layer:`tooltip`,children:(0,g.jsx)(`span`,{ref:me,"aria-hidden":`true`,"data-wave-tooltip-surface":``,...fe,className:t.cn(i.tooltipClassNames.content,v,_[F]),children:e})})]})};T.displayName=`Tooltip`,exports.Tooltip=T;
2
2
  //# sourceMappingURL=Tooltip.cjs.map