@mortenbrudvik/waveui 0.4.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (574) hide show
  1. package/README.md +1221 -173
  2. package/dist/_virtual/_rolldown/runtime.cjs +1 -0
  3. package/dist/components/button/Button.cjs +2 -0
  4. package/dist/components/button/Button.cjs.map +1 -0
  5. package/dist/components/button/Button.mjs +50 -0
  6. package/dist/components/button/Button.mjs.map +1 -0
  7. package/dist/components/button/Button.semantics.cjs +2 -0
  8. package/dist/components/button/Button.semantics.cjs.map +1 -0
  9. package/dist/components/button/Button.semantics.mjs +61 -0
  10. package/dist/components/button/Button.semantics.mjs.map +1 -0
  11. package/dist/components/button/Button.slots.cjs +2 -0
  12. package/dist/components/button/Button.slots.cjs.map +1 -0
  13. package/dist/components/button/Button.slots.mjs +47 -0
  14. package/dist/components/button/Button.slots.mjs.map +1 -0
  15. package/dist/components/button/CompoundButton.cjs +2 -0
  16. package/dist/components/button/CompoundButton.cjs.map +1 -0
  17. package/dist/components/button/CompoundButton.mjs +53 -0
  18. package/dist/components/button/CompoundButton.mjs.map +1 -0
  19. package/dist/components/button/Link.cjs +2 -0
  20. package/dist/components/button/Link.cjs.map +1 -0
  21. package/dist/components/button/Link.mjs +37 -0
  22. package/dist/components/button/Link.mjs.map +1 -0
  23. package/dist/components/button/MenuButton.cjs +2 -0
  24. package/dist/components/button/MenuButton.cjs.map +1 -0
  25. package/dist/components/button/MenuButton.mjs +45 -0
  26. package/dist/components/button/MenuButton.mjs.map +1 -0
  27. package/dist/components/button/SplitButton.cjs +2 -0
  28. package/dist/components/button/SplitButton.cjs.map +1 -0
  29. package/dist/components/button/SplitButton.mjs +66 -0
  30. package/dist/components/button/SplitButton.mjs.map +1 -0
  31. package/dist/components/button/ToggleButton.cjs +2 -0
  32. package/dist/components/button/ToggleButton.cjs.map +1 -0
  33. package/dist/components/button/ToggleButton.mjs +65 -0
  34. package/dist/components/button/ToggleButton.mjs.map +1 -0
  35. package/dist/components/button/Toolbar.cjs +2 -0
  36. package/dist/components/button/Toolbar.cjs.map +1 -0
  37. package/dist/components/button/Toolbar.context.cjs +2 -0
  38. package/dist/components/button/Toolbar.context.cjs.map +1 -0
  39. package/dist/components/button/Toolbar.context.mjs +31 -0
  40. package/dist/components/button/Toolbar.context.mjs.map +1 -0
  41. package/dist/components/button/Toolbar.mjs +63 -0
  42. package/dist/components/button/Toolbar.mjs.map +1 -0
  43. package/dist/components/button/Toolbar.parts.cjs +2 -0
  44. package/dist/components/button/Toolbar.parts.cjs.map +1 -0
  45. package/dist/components/button/Toolbar.parts.mjs +131 -0
  46. package/dist/components/button/Toolbar.parts.mjs.map +1 -0
  47. package/dist/components/button/buttonStyles.cjs +2 -0
  48. package/dist/components/button/buttonStyles.cjs.map +1 -0
  49. package/dist/components/button/buttonStyles.mjs +39 -0
  50. package/dist/components/button/buttonStyles.mjs.map +1 -0
  51. package/dist/components/data-display/Avatar.cjs +2 -0
  52. package/dist/components/data-display/Avatar.cjs.map +1 -0
  53. package/dist/components/data-display/Avatar.mjs +157 -0
  54. package/dist/components/data-display/Avatar.mjs.map +1 -0
  55. package/dist/components/data-display/AvatarGroup.cjs +2 -0
  56. package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
  57. package/dist/components/data-display/AvatarGroup.mjs +134 -0
  58. package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
  59. package/dist/components/data-display/Badge.cjs +2 -0
  60. package/dist/components/data-display/Badge.cjs.map +1 -0
  61. package/dist/components/data-display/Badge.colors.cjs +2 -0
  62. package/dist/components/data-display/Badge.colors.cjs.map +1 -0
  63. package/dist/components/data-display/Badge.colors.mjs +58 -0
  64. package/dist/components/data-display/Badge.colors.mjs.map +1 -0
  65. package/dist/components/data-display/Badge.mjs +32 -0
  66. package/dist/components/data-display/Badge.mjs.map +1 -0
  67. package/dist/components/data-display/CounterBadge.cjs +2 -0
  68. package/dist/components/data-display/CounterBadge.cjs.map +1 -0
  69. package/dist/components/data-display/CounterBadge.mjs +28 -0
  70. package/dist/components/data-display/CounterBadge.mjs.map +1 -0
  71. package/dist/components/data-display/Divider.cjs +2 -0
  72. package/dist/components/data-display/Divider.cjs.map +1 -0
  73. package/dist/components/data-display/Divider.mjs +52 -0
  74. package/dist/components/data-display/Divider.mjs.map +1 -0
  75. package/dist/components/data-display/Image.cjs +2 -0
  76. package/dist/components/data-display/Image.cjs.map +1 -0
  77. package/dist/components/data-display/Image.mjs +32 -0
  78. package/dist/components/data-display/Image.mjs.map +1 -0
  79. package/dist/components/data-display/InfoLabel.cjs +2 -0
  80. package/dist/components/data-display/InfoLabel.cjs.map +1 -0
  81. package/dist/components/data-display/InfoLabel.mjs +104 -0
  82. package/dist/components/data-display/InfoLabel.mjs.map +1 -0
  83. package/dist/components/data-display/List.cjs +2 -0
  84. package/dist/components/data-display/List.cjs.map +1 -0
  85. package/dist/components/data-display/List.mjs +381 -0
  86. package/dist/components/data-display/List.mjs.map +1 -0
  87. package/dist/components/data-display/List.registry.cjs +2 -0
  88. package/dist/components/data-display/List.registry.cjs.map +1 -0
  89. package/dist/components/data-display/List.registry.mjs +101 -0
  90. package/dist/components/data-display/List.registry.mjs.map +1 -0
  91. package/dist/components/data-display/Persona.cjs +2 -0
  92. package/dist/components/data-display/Persona.cjs.map +1 -0
  93. package/dist/components/data-display/Persona.mjs +48 -0
  94. package/dist/components/data-display/Persona.mjs.map +1 -0
  95. package/dist/components/data-display/PresenceBadge.cjs +2 -0
  96. package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
  97. package/dist/components/data-display/PresenceBadge.mjs +71 -0
  98. package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
  99. package/dist/components/data-display/Tag.cjs +2 -0
  100. package/dist/components/data-display/Tag.cjs.map +1 -0
  101. package/dist/components/data-display/Tag.mjs +147 -0
  102. package/dist/components/data-display/Tag.mjs.map +1 -0
  103. package/dist/components/feedback/MessageBar.cjs +2 -0
  104. package/dist/components/feedback/MessageBar.cjs.map +1 -0
  105. package/dist/components/feedback/MessageBar.mjs +144 -0
  106. package/dist/components/feedback/MessageBar.mjs.map +1 -0
  107. package/dist/components/feedback/MessageBar.status.cjs +2 -0
  108. package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
  109. package/dist/components/feedback/MessageBar.status.mjs +45 -0
  110. package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
  111. package/dist/components/feedback/ProgressBar.cjs +2 -0
  112. package/dist/components/feedback/ProgressBar.cjs.map +1 -0
  113. package/dist/components/feedback/ProgressBar.mjs +72 -0
  114. package/dist/components/feedback/ProgressBar.mjs.map +1 -0
  115. package/dist/components/feedback/Skeleton.cjs +2 -0
  116. package/dist/components/feedback/Skeleton.cjs.map +1 -0
  117. package/dist/components/feedback/Skeleton.mjs +47 -0
  118. package/dist/components/feedback/Skeleton.mjs.map +1 -0
  119. package/dist/components/feedback/Spinner.cjs +2 -0
  120. package/dist/components/feedback/Spinner.cjs.map +1 -0
  121. package/dist/components/feedback/Spinner.mjs +60 -0
  122. package/dist/components/feedback/Spinner.mjs.map +1 -0
  123. package/dist/components/feedback/Toast.cjs +2 -0
  124. package/dist/components/feedback/Toast.cjs.map +1 -0
  125. package/dist/components/feedback/Toast.mjs +347 -0
  126. package/dist/components/feedback/Toast.mjs.map +1 -0
  127. package/dist/components/input/Checkbox.cjs +2 -0
  128. package/dist/components/input/Checkbox.cjs.map +1 -0
  129. package/dist/components/input/Checkbox.mjs +96 -0
  130. package/dist/components/input/Checkbox.mjs.map +1 -0
  131. package/dist/components/input/ColorPicker.cjs +6 -0
  132. package/dist/components/input/ColorPicker.cjs.map +1 -0
  133. package/dist/components/input/ColorPicker.mjs +236 -0
  134. package/dist/components/input/ColorPicker.mjs.map +1 -0
  135. package/dist/components/input/Combobox.cjs +2 -0
  136. package/dist/components/input/Combobox.cjs.map +1 -0
  137. package/dist/components/input/Combobox.expand.cjs +2 -0
  138. package/dist/components/input/Combobox.expand.cjs.map +1 -0
  139. package/dist/components/input/Combobox.expand.mjs +38 -0
  140. package/dist/components/input/Combobox.expand.mjs.map +1 -0
  141. package/dist/components/input/Combobox.mjs +187 -0
  142. package/dist/components/input/Combobox.mjs.map +1 -0
  143. package/dist/components/input/DatePicker.cjs +2 -0
  144. package/dist/components/input/DatePicker.cjs.map +1 -0
  145. package/dist/components/input/DatePicker.mjs +340 -0
  146. package/dist/components/input/DatePicker.mjs.map +1 -0
  147. package/dist/components/input/Dropdown.cjs +2 -0
  148. package/dist/components/input/Dropdown.cjs.map +1 -0
  149. package/dist/components/input/Dropdown.mjs +128 -0
  150. package/dist/components/input/Dropdown.mjs.map +1 -0
  151. package/dist/components/input/Field.cjs +2 -0
  152. package/dist/components/input/Field.cjs.map +1 -0
  153. package/dist/components/input/Field.mjs +200 -0
  154. package/dist/components/input/Field.mjs.map +1 -0
  155. package/dist/components/input/Input.cjs +2 -0
  156. package/dist/components/input/Input.cjs.map +1 -0
  157. package/dist/components/input/Input.mjs +81 -0
  158. package/dist/components/input/Input.mjs.map +1 -0
  159. package/dist/components/input/Label.cjs +2 -0
  160. package/dist/components/input/Label.cjs.map +1 -0
  161. package/dist/components/input/Label.mjs +28 -0
  162. package/dist/components/input/Label.mjs.map +1 -0
  163. package/dist/components/input/Option.cjs +2 -0
  164. package/dist/components/input/Option.cjs.map +1 -0
  165. package/dist/components/input/Option.mjs +169 -0
  166. package/dist/components/input/Option.mjs.map +1 -0
  167. package/dist/components/input/RadioGroup.cjs +2 -0
  168. package/dist/components/input/RadioGroup.cjs.map +1 -0
  169. package/dist/components/input/RadioGroup.mjs +139 -0
  170. package/dist/components/input/RadioGroup.mjs.map +1 -0
  171. package/dist/components/input/Rating.cjs +2 -0
  172. package/dist/components/input/Rating.cjs.map +1 -0
  173. package/dist/components/input/Rating.mjs +196 -0
  174. package/dist/components/input/Rating.mjs.map +1 -0
  175. package/dist/components/input/SearchBox.cjs +2 -0
  176. package/dist/components/input/SearchBox.cjs.map +1 -0
  177. package/dist/components/input/SearchBox.mjs +205 -0
  178. package/dist/components/input/SearchBox.mjs.map +1 -0
  179. package/dist/components/input/Select.cjs +2 -0
  180. package/dist/components/input/Select.cjs.map +1 -0
  181. package/dist/components/input/Select.mjs +33 -0
  182. package/dist/components/input/Select.mjs.map +1 -0
  183. package/dist/components/input/Slider.cjs +2 -0
  184. package/dist/components/input/Slider.cjs.map +1 -0
  185. package/dist/components/input/Slider.mjs +79 -0
  186. package/dist/components/input/Slider.mjs.map +1 -0
  187. package/dist/components/input/SpinButton.cjs +2 -0
  188. package/dist/components/input/SpinButton.cjs.map +1 -0
  189. package/dist/components/input/SpinButton.mjs +157 -0
  190. package/dist/components/input/SpinButton.mjs.map +1 -0
  191. package/dist/components/input/SwatchPicker.cjs +2 -0
  192. package/dist/components/input/SwatchPicker.cjs.map +1 -0
  193. package/dist/components/input/SwatchPicker.mjs +113 -0
  194. package/dist/components/input/SwatchPicker.mjs.map +1 -0
  195. package/dist/components/input/Switch.cjs +2 -0
  196. package/dist/components/input/Switch.cjs.map +1 -0
  197. package/dist/components/input/Switch.mjs +92 -0
  198. package/dist/components/input/Switch.mjs.map +1 -0
  199. package/dist/components/input/TagPicker.cjs +2 -0
  200. package/dist/components/input/TagPicker.cjs.map +1 -0
  201. package/dist/components/input/TagPicker.mjs +249 -0
  202. package/dist/components/input/TagPicker.mjs.map +1 -0
  203. package/dist/components/input/Textarea.cjs +2 -0
  204. package/dist/components/input/Textarea.cjs.map +1 -0
  205. package/dist/components/input/Textarea.mjs +32 -0
  206. package/dist/components/input/Textarea.mjs.map +1 -0
  207. package/dist/components/input/TimePicker.cjs +2 -0
  208. package/dist/components/input/TimePicker.cjs.map +1 -0
  209. package/dist/components/input/TimePicker.mjs +292 -0
  210. package/dist/components/input/TimePicker.mjs.map +1 -0
  211. package/dist/components/input/colorUtils.cjs +2 -0
  212. package/dist/components/input/colorUtils.cjs.map +1 -0
  213. package/dist/components/input/colorUtils.mjs +96 -0
  214. package/dist/components/input/colorUtils.mjs.map +1 -0
  215. package/dist/components/input/dateUtils.cjs +2 -0
  216. package/dist/components/input/dateUtils.cjs.map +1 -0
  217. package/dist/components/input/dateUtils.mjs +250 -0
  218. package/dist/components/input/dateUtils.mjs.map +1 -0
  219. package/dist/components/input/pickerStyles.cjs +2 -0
  220. package/dist/components/input/pickerStyles.cjs.map +1 -0
  221. package/dist/components/input/pickerStyles.mjs +10 -0
  222. package/dist/components/input/pickerStyles.mjs.map +1 -0
  223. package/dist/components/internal/HiddenInput.cjs +2 -0
  224. package/dist/components/internal/HiddenInput.cjs.map +1 -0
  225. package/dist/components/internal/HiddenInput.mjs +88 -0
  226. package/dist/components/internal/HiddenInput.mjs.map +1 -0
  227. package/dist/components/layout/Accordion.cjs +2 -0
  228. package/dist/components/layout/Accordion.cjs.map +1 -0
  229. package/dist/components/layout/Accordion.mjs +236 -0
  230. package/dist/components/layout/Accordion.mjs.map +1 -0
  231. package/dist/components/layout/Card.cjs +2 -0
  232. package/dist/components/layout/Card.cjs.map +1 -0
  233. package/dist/components/layout/Card.mjs +121 -0
  234. package/dist/components/layout/Card.mjs.map +1 -0
  235. package/dist/components/layout/Carousel.cjs +2 -0
  236. package/dist/components/layout/Carousel.cjs.map +1 -0
  237. package/dist/components/layout/Carousel.mjs +205 -0
  238. package/dist/components/layout/Carousel.mjs.map +1 -0
  239. package/dist/components/layout/Flex.cjs +2 -0
  240. package/dist/components/layout/Flex.cjs.map +1 -0
  241. package/dist/components/layout/Flex.mjs +54 -0
  242. package/dist/components/layout/Flex.mjs.map +1 -0
  243. package/dist/components/layout/Grid.cjs +2 -0
  244. package/dist/components/layout/Grid.cjs.map +1 -0
  245. package/dist/components/layout/Grid.mjs +62 -0
  246. package/dist/components/layout/Grid.mjs.map +1 -0
  247. package/dist/components/layout/Overflow.cjs +2 -0
  248. package/dist/components/layout/Overflow.cjs.map +1 -0
  249. package/dist/components/layout/Overflow.mjs +269 -0
  250. package/dist/components/layout/Overflow.mjs.map +1 -0
  251. package/dist/components/layout/Stack.cjs +2 -0
  252. package/dist/components/layout/Stack.cjs.map +1 -0
  253. package/dist/components/layout/Stack.mjs +39 -0
  254. package/dist/components/layout/Stack.mjs.map +1 -0
  255. package/dist/components/layout/TabList.cjs +2 -0
  256. package/dist/components/layout/TabList.cjs.map +1 -0
  257. package/dist/components/layout/TabList.mjs +238 -0
  258. package/dist/components/layout/TabList.mjs.map +1 -0
  259. package/dist/components/layout/Tree.cjs +2 -0
  260. package/dist/components/layout/Tree.cjs.map +1 -0
  261. package/dist/components/layout/Tree.mjs +220 -0
  262. package/dist/components/layout/Tree.mjs.map +1 -0
  263. package/dist/components/layout/disclosureIds.cjs +2 -0
  264. package/dist/components/layout/disclosureIds.cjs.map +1 -0
  265. package/dist/components/layout/disclosureIds.mjs +12 -0
  266. package/dist/components/layout/disclosureIds.mjs.map +1 -0
  267. package/dist/components/motion/Presence.cjs +2 -0
  268. package/dist/components/motion/Presence.cjs.map +1 -0
  269. package/dist/components/motion/Presence.mjs +35 -0
  270. package/dist/components/motion/Presence.mjs.map +1 -0
  271. package/dist/components/navigation/Breadcrumb.cjs +2 -0
  272. package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
  273. package/dist/components/navigation/Breadcrumb.mjs +144 -0
  274. package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
  275. package/dist/components/navigation/Menu.cjs +2 -0
  276. package/dist/components/navigation/Menu.cjs.map +1 -0
  277. package/dist/components/navigation/Menu.context.cjs +2 -0
  278. package/dist/components/navigation/Menu.context.cjs.map +1 -0
  279. package/dist/components/navigation/Menu.context.mjs +82 -0
  280. package/dist/components/navigation/Menu.context.mjs.map +1 -0
  281. package/dist/components/navigation/Menu.group.cjs +2 -0
  282. package/dist/components/navigation/Menu.group.cjs.map +1 -0
  283. package/dist/components/navigation/Menu.group.mjs +58 -0
  284. package/dist/components/navigation/Menu.group.mjs.map +1 -0
  285. package/dist/components/navigation/Menu.items.cjs +2 -0
  286. package/dist/components/navigation/Menu.items.cjs.map +1 -0
  287. package/dist/components/navigation/Menu.items.mjs +127 -0
  288. package/dist/components/navigation/Menu.items.mjs.map +1 -0
  289. package/dist/components/navigation/Menu.link.cjs +2 -0
  290. package/dist/components/navigation/Menu.link.cjs.map +1 -0
  291. package/dist/components/navigation/Menu.link.mjs +41 -0
  292. package/dist/components/navigation/Menu.link.mjs.map +1 -0
  293. package/dist/components/navigation/Menu.mjs +27 -0
  294. package/dist/components/navigation/Menu.mjs.map +1 -0
  295. package/dist/components/navigation/Menu.popover.cjs +2 -0
  296. package/dist/components/navigation/Menu.popover.cjs.map +1 -0
  297. package/dist/components/navigation/Menu.popover.mjs +231 -0
  298. package/dist/components/navigation/Menu.popover.mjs.map +1 -0
  299. package/dist/components/navigation/Menu.root.cjs +2 -0
  300. package/dist/components/navigation/Menu.root.cjs.map +1 -0
  301. package/dist/components/navigation/Menu.root.mjs +308 -0
  302. package/dist/components/navigation/Menu.root.mjs.map +1 -0
  303. package/dist/components/navigation/Menu.selectable.cjs +2 -0
  304. package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
  305. package/dist/components/navigation/Menu.selectable.mjs +89 -0
  306. package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
  307. package/dist/components/navigation/Menu.shared.cjs +2 -0
  308. package/dist/components/navigation/Menu.shared.cjs.map +1 -0
  309. package/dist/components/navigation/Menu.shared.mjs +23 -0
  310. package/dist/components/navigation/Menu.shared.mjs.map +1 -0
  311. package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
  312. package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
  313. package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
  314. package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
  315. package/dist/components/navigation/Menu.trigger.cjs +2 -0
  316. package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
  317. package/dist/components/navigation/Menu.trigger.mjs +79 -0
  318. package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
  319. package/dist/components/navigation/Nav.cjs +2 -0
  320. package/dist/components/navigation/Nav.cjs.map +1 -0
  321. package/dist/components/navigation/Nav.mjs +276 -0
  322. package/dist/components/navigation/Nav.mjs.map +1 -0
  323. package/dist/components/navigation/Pagination.cjs +2 -0
  324. package/dist/components/navigation/Pagination.cjs.map +1 -0
  325. package/dist/components/navigation/Pagination.mjs +110 -0
  326. package/dist/components/navigation/Pagination.mjs.map +1 -0
  327. package/dist/components/navigation/Stepper.cjs +2 -0
  328. package/dist/components/navigation/Stepper.cjs.map +1 -0
  329. package/dist/components/navigation/Stepper.mjs +204 -0
  330. package/dist/components/navigation/Stepper.mjs.map +1 -0
  331. package/dist/components/overlays/Dialog.cjs +2 -0
  332. package/dist/components/overlays/Dialog.cjs.map +1 -0
  333. package/dist/components/overlays/Dialog.mjs +180 -0
  334. package/dist/components/overlays/Dialog.mjs.map +1 -0
  335. package/dist/components/overlays/Dialog.shared.cjs +2 -0
  336. package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
  337. package/dist/components/overlays/Dialog.shared.mjs +227 -0
  338. package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
  339. package/dist/components/overlays/Drawer.cjs +2 -0
  340. package/dist/components/overlays/Drawer.cjs.map +1 -0
  341. package/dist/components/overlays/Drawer.mjs +192 -0
  342. package/dist/components/overlays/Drawer.mjs.map +1 -0
  343. package/dist/components/overlays/Popover.cjs +2 -0
  344. package/dist/components/overlays/Popover.cjs.map +1 -0
  345. package/dist/components/overlays/Popover.mjs +365 -0
  346. package/dist/components/overlays/Popover.mjs.map +1 -0
  347. package/dist/components/overlays/Popover.shared.cjs +2 -0
  348. package/dist/components/overlays/Popover.shared.cjs.map +1 -0
  349. package/dist/components/overlays/Popover.shared.mjs +182 -0
  350. package/dist/components/overlays/Popover.shared.mjs.map +1 -0
  351. package/dist/components/overlays/TeachingPopover.cjs +2 -0
  352. package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
  353. package/dist/components/overlays/TeachingPopover.mjs +181 -0
  354. package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
  355. package/dist/components/overlays/Tooltip.cjs +2 -0
  356. package/dist/components/overlays/Tooltip.cjs.map +1 -0
  357. package/dist/components/overlays/Tooltip.mjs +160 -0
  358. package/dist/components/overlays/Tooltip.mjs.map +1 -0
  359. package/dist/components/portal/Portal.cjs +2 -0
  360. package/dist/components/portal/Portal.cjs.map +1 -0
  361. package/dist/components/portal/Portal.mjs +45 -0
  362. package/dist/components/portal/Portal.mjs.map +1 -0
  363. package/dist/components/provider/WaveProvider.cjs +2 -0
  364. package/dist/components/provider/WaveProvider.cjs.map +1 -0
  365. package/dist/components/provider/WaveProvider.mjs +51 -0
  366. package/dist/components/provider/WaveProvider.mjs.map +1 -0
  367. package/dist/components/table/DataGrid.cjs +2 -0
  368. package/dist/components/table/DataGrid.cjs.map +1 -0
  369. package/dist/components/table/DataGrid.mjs +489 -0
  370. package/dist/components/table/DataGrid.mjs.map +1 -0
  371. package/dist/components/table/Table.cjs +2 -0
  372. package/dist/components/table/Table.cjs.map +1 -0
  373. package/dist/components/table/Table.mjs +99 -0
  374. package/dist/components/table/Table.mjs.map +1 -0
  375. package/dist/components/table/useGridNavigation.cjs +2 -0
  376. package/dist/components/table/useGridNavigation.cjs.map +1 -0
  377. package/dist/components/table/useGridNavigation.mjs +336 -0
  378. package/dist/components/table/useGridNavigation.mjs.map +1 -0
  379. package/dist/components/typography/Text.cjs +2 -0
  380. package/dist/components/typography/Text.cjs.map +1 -0
  381. package/dist/components/typography/Text.mjs +38 -0
  382. package/dist/components/typography/Text.mjs.map +1 -0
  383. package/dist/hooks/useAnnounce.cjs +2 -0
  384. package/dist/hooks/useAnnounce.cjs.map +1 -0
  385. package/dist/hooks/useAnnounce.mjs +88 -0
  386. package/dist/hooks/useAnnounce.mjs.map +1 -0
  387. package/dist/hooks/useCheckedValues.cjs +2 -0
  388. package/dist/hooks/useCheckedValues.cjs.map +1 -0
  389. package/dist/hooks/useCheckedValues.mjs +102 -0
  390. package/dist/hooks/useCheckedValues.mjs.map +1 -0
  391. package/dist/hooks/useContextMenuAnchor.cjs +2 -0
  392. package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
  393. package/dist/hooks/useContextMenuAnchor.mjs +132 -0
  394. package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
  395. package/dist/hooks/useControllable.cjs +2 -0
  396. package/dist/hooks/useControllable.cjs.map +1 -0
  397. package/dist/hooks/useControllable.mjs +37 -0
  398. package/dist/hooks/useControllable.mjs.map +1 -0
  399. package/dist/hooks/useDirection.cjs +2 -0
  400. package/dist/hooks/useDirection.cjs.map +1 -0
  401. package/dist/hooks/useDirection.mjs +57 -0
  402. package/dist/hooks/useDirection.mjs.map +1 -0
  403. package/dist/hooks/useDismiss.cjs +2 -0
  404. package/dist/hooks/useDismiss.cjs.map +1 -0
  405. package/dist/hooks/useDismiss.mjs +57 -0
  406. package/dist/hooks/useDismiss.mjs.map +1 -0
  407. package/dist/hooks/useEventCallback.cjs +2 -0
  408. package/dist/hooks/useEventCallback.cjs.map +1 -0
  409. package/dist/hooks/useEventCallback.mjs +16 -0
  410. package/dist/hooks/useEventCallback.mjs.map +1 -0
  411. package/dist/hooks/useFieldControl.cjs +2 -0
  412. package/dist/hooks/useFieldControl.cjs.map +1 -0
  413. package/dist/hooks/useFieldControl.mjs +62 -0
  414. package/dist/hooks/useFieldControl.mjs.map +1 -0
  415. package/dist/hooks/useFocusTrap.cjs +2 -0
  416. package/dist/hooks/useFocusTrap.cjs.map +1 -0
  417. package/dist/hooks/useFocusTrap.mjs +266 -0
  418. package/dist/hooks/useFocusTrap.mjs.map +1 -0
  419. package/dist/hooks/useFormReset.cjs +2 -0
  420. package/dist/hooks/useFormReset.cjs.map +1 -0
  421. package/dist/hooks/useFormReset.mjs +33 -0
  422. package/dist/hooks/useFormReset.mjs.map +1 -0
  423. package/dist/hooks/useHoverIntent.cjs +2 -0
  424. package/dist/hooks/useHoverIntent.cjs.map +1 -0
  425. package/dist/hooks/useHoverIntent.mjs +201 -0
  426. package/dist/hooks/useHoverIntent.mjs.map +1 -0
  427. package/dist/hooks/useId.cjs +2 -0
  428. package/dist/hooks/useId.cjs.map +1 -0
  429. package/dist/hooks/useId.mjs +11 -0
  430. package/dist/hooks/useId.mjs.map +1 -0
  431. package/dist/hooks/useIsClient.cjs +2 -0
  432. package/dist/hooks/useIsClient.cjs.map +1 -0
  433. package/dist/hooks/useIsClient.mjs +19 -0
  434. package/dist/hooks/useIsClient.mjs.map +1 -0
  435. package/dist/hooks/useListbox.cjs +2 -0
  436. package/dist/hooks/useListbox.cjs.map +1 -0
  437. package/dist/hooks/useListbox.mjs +492 -0
  438. package/dist/hooks/useListbox.mjs.map +1 -0
  439. package/dist/hooks/useMergedRefs.cjs +2 -0
  440. package/dist/hooks/useMergedRefs.cjs.map +1 -0
  441. package/dist/hooks/useMergedRefs.mjs +57 -0
  442. package/dist/hooks/useMergedRefs.mjs.map +1 -0
  443. package/dist/hooks/useModalIsolation.cjs +2 -0
  444. package/dist/hooks/useModalIsolation.cjs.map +1 -0
  445. package/dist/hooks/useModalIsolation.mjs +87 -0
  446. package/dist/hooks/useModalIsolation.mjs.map +1 -0
  447. package/dist/hooks/useModalLayer.cjs +2 -0
  448. package/dist/hooks/useModalLayer.cjs.map +1 -0
  449. package/dist/hooks/useModalLayer.mjs +30 -0
  450. package/dist/hooks/useModalLayer.mjs.map +1 -0
  451. package/dist/hooks/usePopupPosition.cjs +2 -0
  452. package/dist/hooks/usePopupPosition.cjs.map +1 -0
  453. package/dist/hooks/usePopupPosition.mjs +117 -0
  454. package/dist/hooks/usePopupPosition.mjs.map +1 -0
  455. package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
  456. package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
  457. package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
  458. package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
  459. package/dist/hooks/usePresence.cjs +2 -0
  460. package/dist/hooks/usePresence.cjs.map +1 -0
  461. package/dist/hooks/usePresence.mjs +136 -0
  462. package/dist/hooks/usePresence.mjs.map +1 -0
  463. package/dist/hooks/usePreserveFocus.cjs +2 -0
  464. package/dist/hooks/usePreserveFocus.cjs.map +1 -0
  465. package/dist/hooks/usePreserveFocus.mjs +50 -0
  466. package/dist/hooks/usePreserveFocus.mjs.map +1 -0
  467. package/dist/hooks/useRestoreFocus.cjs +2 -0
  468. package/dist/hooks/useRestoreFocus.cjs.map +1 -0
  469. package/dist/hooks/useRestoreFocus.mjs +271 -0
  470. package/dist/hooks/useRestoreFocus.mjs.map +1 -0
  471. package/dist/hooks/useRovingTabIndex.cjs +2 -0
  472. package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
  473. package/dist/hooks/useRovingTabIndex.mjs +389 -0
  474. package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
  475. package/dist/hooks/useScrollLock.cjs +2 -0
  476. package/dist/hooks/useScrollLock.cjs.map +1 -0
  477. package/dist/hooks/useScrollLock.mjs +71 -0
  478. package/dist/hooks/useScrollLock.mjs.map +1 -0
  479. package/dist/hooks/useTriggerElement.cjs +2 -0
  480. package/dist/hooks/useTriggerElement.cjs.map +1 -0
  481. package/dist/hooks/useTriggerElement.mjs +126 -0
  482. package/dist/hooks/useTriggerElement.mjs.map +1 -0
  483. package/dist/hooks/useTypeahead.cjs +2 -0
  484. package/dist/hooks/useTypeahead.cjs.map +1 -0
  485. package/dist/hooks/useTypeahead.mjs +38 -0
  486. package/dist/hooks/useTypeahead.mjs.map +1 -0
  487. package/dist/index.cjs +1 -1
  488. package/dist/index.d.cts +9099 -0
  489. package/dist/index.d.ts +7688 -1027
  490. package/dist/index.mjs +91 -5695
  491. package/dist/lib/aria.cjs +2 -0
  492. package/dist/lib/aria.cjs.map +1 -0
  493. package/dist/lib/aria.mjs +29 -0
  494. package/dist/lib/aria.mjs.map +1 -0
  495. package/dist/lib/children.cjs +2 -0
  496. package/dist/lib/children.cjs.map +1 -0
  497. package/dist/lib/children.mjs +37 -0
  498. package/dist/lib/children.mjs.map +1 -0
  499. package/dist/lib/cn.cjs +2 -0
  500. package/dist/lib/cn.cjs.map +1 -0
  501. package/dist/lib/cn.mjs +64 -0
  502. package/dist/lib/cn.mjs.map +1 -0
  503. package/dist/lib/composeEventHandlers.cjs +2 -0
  504. package/dist/lib/composeEventHandlers.cjs.map +1 -0
  505. package/dist/lib/composeEventHandlers.mjs +11 -0
  506. package/dist/lib/composeEventHandlers.mjs.map +1 -0
  507. package/dist/lib/dev.cjs +2 -0
  508. package/dist/lib/dev.cjs.map +1 -0
  509. package/dist/lib/dev.mjs +42 -0
  510. package/dist/lib/dev.mjs.map +1 -0
  511. package/dist/lib/direction.cjs +2 -0
  512. package/dist/lib/direction.cjs.map +1 -0
  513. package/dist/lib/direction.mjs +35 -0
  514. package/dist/lib/direction.mjs.map +1 -0
  515. package/dist/lib/events.cjs +2 -0
  516. package/dist/lib/events.cjs.map +1 -0
  517. package/dist/lib/events.mjs +31 -0
  518. package/dist/lib/events.mjs.map +1 -0
  519. package/dist/lib/focus.cjs +2 -0
  520. package/dist/lib/focus.cjs.map +1 -0
  521. package/dist/lib/focus.mjs +119 -0
  522. package/dist/lib/focus.mjs.map +1 -0
  523. package/dist/lib/globalRegistry.cjs +2 -0
  524. package/dist/lib/globalRegistry.cjs.map +1 -0
  525. package/dist/lib/globalRegistry.mjs +13 -0
  526. package/dist/lib/globalRegistry.mjs.map +1 -0
  527. package/dist/lib/icons.cjs +2 -0
  528. package/dist/lib/icons.cjs.map +1 -0
  529. package/dist/lib/icons.mjs +254 -0
  530. package/dist/lib/icons.mjs.map +1 -0
  531. package/dist/lib/labelInName.cjs +2 -0
  532. package/dist/lib/labelInName.cjs.map +1 -0
  533. package/dist/lib/labelInName.mjs +54 -0
  534. package/dist/lib/labelInName.mjs.map +1 -0
  535. package/dist/lib/layers.cjs +2 -0
  536. package/dist/lib/layers.cjs.map +1 -0
  537. package/dist/lib/layers.mjs +224 -0
  538. package/dist/lib/layers.mjs.map +1 -0
  539. package/dist/lib/mergeProps.cjs +2 -0
  540. package/dist/lib/mergeProps.cjs.map +1 -0
  541. package/dist/lib/mergeProps.mjs +21 -0
  542. package/dist/lib/mergeProps.mjs.map +1 -0
  543. package/dist/lib/mergeRefs.cjs +2 -0
  544. package/dist/lib/mergeRefs.cjs.map +1 -0
  545. package/dist/lib/mergeRefs.mjs +29 -0
  546. package/dist/lib/mergeRefs.mjs.map +1 -0
  547. package/dist/lib/renderTrigger.cjs +2 -0
  548. package/dist/lib/renderTrigger.cjs.map +1 -0
  549. package/dist/lib/renderTrigger.mjs +29 -0
  550. package/dist/lib/renderTrigger.mjs.map +1 -0
  551. package/dist/lib/slot.cjs +2 -0
  552. package/dist/lib/slot.cjs.map +1 -0
  553. package/dist/lib/slot.mjs +122 -0
  554. package/dist/lib/slot.mjs.map +1 -0
  555. package/dist/lib/styles.cjs +2 -0
  556. package/dist/lib/styles.cjs.map +1 -0
  557. package/dist/lib/styles.mjs +16 -0
  558. package/dist/lib/styles.mjs.map +1 -0
  559. package/dist/lib/theme.cjs +2 -0
  560. package/dist/lib/theme.cjs.map +1 -0
  561. package/dist/lib/theme.mjs +16 -0
  562. package/dist/lib/theme.mjs.map +1 -0
  563. package/dist/preflight.css +2 -0
  564. package/dist/styles.css +2 -0
  565. package/package.json +149 -100
  566. package/src/styles/animations.css +7 -39
  567. package/src/styles/base.css +103 -0
  568. package/src/styles/globals.css +10 -22
  569. package/src/styles/legacy-tokens.css +184 -0
  570. package/src/styles/preflight.css +7 -0
  571. package/src/styles/styles.css +32 -0
  572. package/src/styles/tailwind.css +17 -0
  573. package/src/styles/tokens.css +561 -221
  574. package/src/styles/variants.css +29 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labelInName.mjs","names":["React","LABEL_CHARACTER","MIN_LABEL_CHARACTERS","NON_LABEL_ELEMENTS","countLabelCharacters","text","countLiteralLabelCharacters","node","ariaHidden","props","iterable","count","item","hasTextLabel","hasRenderedTextLabel","walker","element","child","LABEL_MUTATIONS","observeTextLabel","observer","onChange"],"sources":["../../src/lib/labelInName.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * The C-SLOTS naming predicate (spec §1, WCAG 2.5.3 Label in Name): whether the content of a wired\n * dismiss/clear button (MessageBar `dismiss`, SearchBox `dismiss`, Tag `dismissIcon`) has a\n * **text label**, so the text names the button instead of the default name.\n *\n * A text label is text with **at least two letters or digits** (`\\p{L}`/`\\p{N}`) in total, outside\n * `aria-hidden=\"true\"`/`hidden` subtrees and outside SVG `<title>`/`<desc>`, `<script>`, `<style>`\n * and `<template>`. A lone character (`X`, `x`, `×`, `+`) is a symbolic glyph and keeps the\n * default name, as an icon does.\n *\n * Consumers keep the React glue: the literal check for the server render and the first client\n * render (so hydration matches), then the rendered DOM after mount, re-checked on every change:\n *\n * ```ts\n * const literal = hasTextLabel(children);\n * const [target, setTarget] = React.useState<HTMLElement | null>(null); // callback ref (C-HOOKS)\n * const subscribe = React.useCallback(\n * (onChange: () => void) => (target ? observeTextLabel(target, onChange) : noop),\n * [target],\n * );\n * const textLabel = React.useSyncExternalStore(\n * subscribe,\n * () => (target ? hasRenderedTextLabel(target) : literal),\n * () => literal,\n * );\n * ```\n *\n * Text hidden only by CSS (a responsive `hidden sm:inline` label) is not detected and counts as a\n * label, because a computed-style check would not follow media queries: document an explicit\n * `aria-label` for such buttons on the consuming prop.\n */\n\n/** A letter or a digit. */\nconst LABEL_CHARACTER = /[\\p{L}\\p{N}]/gu;\n\n/** Letters and digits a text label needs: a lone character (`X`, `×`, `+`) is a symbol. */\nconst MIN_LABEL_CHARACTERS = 2;\n\n/** Elements whose text is never a visible label (SVG `<title>`/`<desc>`, scripts, styles). */\nconst NON_LABEL_ELEMENTS: ReadonlySet<string> = new Set([\n 'title',\n 'desc',\n 'style',\n 'script',\n 'template',\n]);\n\ntype UnknownProps = Record<string, unknown>;\n\nfunction countLabelCharacters(text: string): number {\n return text.match(LABEL_CHARACTER)?.length ?? 0;\n}\n\n/**\n * Letters and digits in the literal strings and numbers of `node`, outside `aria-hidden`/`hidden`\n * elements (counting stops at {@link MIN_LABEL_CHARACTERS}). Text rendered by components, and\n * one-shot iterators (which reading would consume), are found by the DOM check after mount.\n */\nfunction countLiteralLabelCharacters(node: unknown): number {\n if (typeof node === 'string') return countLabelCharacters(node);\n if (typeof node === 'number' || typeof node === 'bigint') {\n return countLabelCharacters(String(node));\n }\n if (typeof node !== 'object' || node === null) return 0;\n if (React.isValidElement<UnknownProps>(node)) {\n const { props } = node;\n const ariaHidden = props['aria-hidden'];\n if (ariaHidden === true || ariaHidden === 'true' || props.hidden) return 0;\n if (typeof node.type === 'string' && NON_LABEL_ELEMENTS.has(node.type)) return 0;\n return countLiteralLabelCharacters(props.children);\n }\n if (!(Symbol.iterator in node)) return 0;\n const iterable = node as Iterable<unknown>;\n // A one-shot iterator (a generator) returns itself: reading it would consume it.\n if (!Array.isArray(iterable) && (iterable[Symbol.iterator]() as unknown) === iterable) return 0;\n let count = 0;\n for (const item of iterable) {\n count += countLiteralLabelCharacters(item);\n if (count >= MIN_LABEL_CHARACTERS) break;\n }\n return count;\n}\n\n/**\n * Whether the literal `node` has a text label: strings, numbers, elements (skipping\n * `aria-hidden`/`hidden` elements and SVG `<title>`/`<desc>`, `<script>`, `<style>`,\n * `<template>`), arrays and re-iterable collections such as a `Set`. A one-shot iterator (a\n * generator) is never read, and text rendered by a component is not seen: both are found by\n * {@link hasRenderedTextLabel} after mount.\n *\n * Takes a `React.ReactNode`, typed `unknown` because a slot's `children` prop is `unknown` at the\n * call sites; anything that is not a React node has no text label.\n */\nexport function hasTextLabel(node: unknown): boolean {\n return countLiteralLabelCharacters(node) >= MIN_LABEL_CHARACTERS;\n}\n\n/**\n * Whether the rendered `element` contains a text label: at least two letters or digits in text\n * outside `aria-hidden` and `hidden` subtrees and outside SVG `<title>`/`<desc>`, `<script>`,\n * `<style>` and `<template>` (visually hidden text included, since it names the button too).\n * Walks the descendants of `element` with a `TreeWalker` and stops as soon as two characters are\n * found. Text hidden only by CSS is not detected and counts as a label.\n */\nexport function hasRenderedTextLabel(element: Element): boolean {\n const walker = element.ownerDocument.createTreeWalker(\n element,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,\n {\n acceptNode(node) {\n if (node.nodeType === Node.TEXT_NODE) return NodeFilter.FILTER_ACCEPT;\n const child = node as Element;\n return child.getAttribute('aria-hidden') === 'true' ||\n child.hasAttribute('hidden') ||\n NON_LABEL_ELEMENTS.has(child.localName)\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_SKIP;\n },\n },\n );\n let count = 0;\n while (walker.nextNode()) {\n count += countLabelCharacters(walker.currentNode.nodeValue ?? '');\n if (count >= MIN_LABEL_CHARACTERS) return true;\n }\n return false;\n}\n\n/** Re-checks the name whenever the content changes (e.g. a translation loads). */\nconst LABEL_MUTATIONS: MutationObserverInit = {\n childList: true,\n subtree: true,\n characterData: true,\n attributes: true,\n attributeFilter: ['aria-hidden', 'hidden'],\n};\n\n/**\n * Calls `onChange` whenever the text label of `element` may have changed: text edits, added or\n * removed nodes at any depth, and `aria-hidden`/`hidden` changes. Returns the disconnect, so it\n * can be the `subscribe` of `useSyncExternalStore` directly.\n */\nexport function observeTextLabel(element: Element, onChange: () => void): () => void {\n const observer = new MutationObserver(() => onChange());\n observer.observe(element, LABEL_MUTATIONS);\n return () => observer.disconnect();\n}\n"],"mappings":";;AAmCA,IAAMC,IAAkB,kBAGlBC,IAAuB,GAGvBC,oBAA0C,IAAI,IAAI;CACtD;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,SAASC,EAAqB,GAAsB;CAClD,OAAOC,EAAK,MAAMJ,CAAe,CAAC,EAAE,UAAU;AAChD;AAOA,SAASK,EAA4B,GAAuB;CAC1D,IAAI,OAAOC,KAAS,UAAU,OAAOH,EAAqBG,CAAI;CAC9D,IAAI,OAAOA,KAAS,YAAY,OAAOA,KAAS,UAC9C,OAAOH,EAAqB,OAAOG,CAAI,CAAC;CAE1C,IAAI,OAAOA,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uBC,EAAS,CAAC;CAEtD,OADAD,EAAS,QAAQJ,GAASE,CAAe,SAC5BE,EAAS,WAAW;AACnC"}
@@ -0,0 +1,2 @@
1
+ const e=require("./globalRegistry.cjs");var t={overlay:`var(--wave-z-overlay, 1000)`,toast:`var(--wave-z-toast, 1100)`,tooltip:`var(--wave-z-tooltip, 1200)`},n=`[data-wave-focus-trap-allow]`;function r(){let t=e.getGlobalRegistry(`layers`,()=>({stack:[],elements:new Map,counter:0,press:null,listeners:null,subscribers:new Set,isolated:new Map}));return t.subscribers??=new Set,t.isolated??=new Map,t}function i(e){for(let t of Array.from(e.subscribers))t()}var a=1;function o(e,t){if(t!==null)return e.stack.find(e=>e.id===t)}function s(e,t,n){let r=new Set([t.id]),i=t.parentId;for(;i!==null&&!r.has(i);){if(i===n)return!0;r.add(i),i=o(e,i)?.parentId??null}return!1}function c(e,t){return!!e&&e.contains(t)}function l(e,t,n,r){if(r.has(t))return!1;r.add(t);let i=o(e,t);if(i&&i.getElements().some(e=>c(e,n)))return!0;let a=e.elements.get(t);if(a){for(let e of a)if(c(e,n))return!0}for(let i of e.stack)if(i.parentId===t&&l(e,i.id,n,r))return!0;return!1}function u(e){let t=e.nodeType===a?e:e.parentElement;return!!t&&t.closest(`[data-wave-focus-trap-allow]`)!==null}function d(e,t){return u(t)?!0:l(r(),e,t,new Set)}function f(e,t){if(e===t||e.id===t.id)return 0;let n=r();if(s(n,e,t.id))return 1;if(s(n,t,e.id))return-1;let i=n.stack.indexOf(e),a=n.stack.indexOf(t);return i!==-1&&a!==-1?i-a:e.order-t.order}function p(e){let{stack:t}=r();for(let n=t.length-1;n>=0;n--){let r=t[n];if(!e||e(r))return r}return null}function m(e){let{isolated:t}=r();t.set(e,(t.get(e)??0)+1);let n=!0;return()=>{if(!n)return;n=!1;let r=(t.get(e)??1)-1;r>0?t.set(e,r):t.delete(e)}}function h(e){return e.isolated.size===0?null:p(t=>e.isolated.has(t.id))}function g(e,t){return!!t&&t!==e&&f(t,e)>0}function _(e){let{subscribers:t}=r();return t.add(e),()=>{t.delete(e)}}function v(){return[...r().stack]}function y(e){return o(r(),e)??null}function b(e,t){let n=r(),i=o(n,e);return!!i&&s(n,i,t)}function x(e,t){let n=r(),i=[],a=t?.includeOwnElements??!0,s=(t,r)=>{if(r.has(t))return;r.add(t);let c=o(n,t);if(c&&(a||t!==e))for(let e of c.getElements())e&&!i.includes(e)&&i.push(e);for(let e of n.elements.get(t)??[])i.includes(e)||i.push(e);for(let e of n.stack)e.parentId===t&&s(e.id,r)};return s(e,new Set),i}function S(e,t){let n=r();for(let r=n.stack.length-1;r>=0;r--){let i=n.stack[r];if(i.kind===`modal`&&(t===void 0||i.id!==t&&!s(n,i,t)))return!d(i.id,e)}return!1}function C(e,t){let n=r(),i=n.elements.get(e);return i||(i=new Set,n.elements.set(e,i)),i.add(t),()=>{let r=n.elements.get(e);r&&(r.delete(t),r.size===0&&n.elements.delete(e))}}function w(e){let t=r();t.counter+=1,e.order=t.counter;let n=t.stack.findIndex(n=>s(t,n,e.id));n===-1?t.stack.push(e):t.stack.splice(n,0,e),L(t),i(t);let a=!0;return()=>{if(!a)return;a=!1;let n=t.stack.indexOf(e);n!==-1&&t.stack.splice(n,1),t.press&&(t.press.layers=t.press.layers.filter(t=>t!==e)),t.stack.length===0&&R(t),i(t)}}function T(e){let t=e.target;return t&&typeof t.nodeType==`number`?t:null}function E(e){return[...e].sort((e,t)=>f(t,e))}function D(e,t,n){let r=h(e),i=e=>e.escape&&!g(e,r),a=e=>!!t&&d(e.id,t)||!!n&&d(e.id,n),o=p(a);return(o?p(t=>i(t)&&(t===o||s(e,t,o.id)))??p(e=>i(e)&&a(e)):null)??p(i)}function O(e){return e===`Enter`||e===` `||e===`Spacebar`}function k(e){let t=r();if(e.key===`Escape`||e.key===`Esc`){if(e.defaultPrevented||e.isComposing)return;let n=D(t,T(e),document.activeElement);if(!n)return;e.preventDefault(),n.onDismiss(`escape`,e);return}O(e.key)&&(t.press=null)}function A(e){let t=r(),n=T(e);if(!n||e.button!==0){t.press=null;return}let i=h(t);t.press={layers:t.stack.filter(t=>{let{outsidePress:r}=t;return!r||g(t,i)||d(t.id,n)?!1:typeof r!=`function`||r(e)!==!1})}}var j=1e3;function M(e){let t=r().press;if(!t)return;let n=e.pointerType===`mouse`?0:j;setTimeout(()=>{let e=r();e.press===t&&(e.press=null)},n)}function N(){r().press=null}function P(e){let t=r(),n=t.press;if(t.press=null,!n)return;let i=T(e),a=n.layers.filter(e=>!(i&&d(e.id,i)));for(let n of E(a))t.stack.includes(n)&&n.onDismiss(`outside-press`,e)}function F(e){let t=T(e);if(!t)return;let n=r().stack.filter(e=>e.focusOutside&&!d(e.id,t));n.length!==0&&queueMicrotask(()=>I(n,t,e))}function I(e,t,n){let i=r(),a=(t.ownerDocument??document).activeElement,o=e.filter(e=>i.stack.includes(e)&&!d(e.id,t)&&!(a&&d(e.id,a)));for(let e of E(o))i.stack.includes(e)&&e.onDismiss(`focus-outside`,n)}function L(e){if(e.listeners||typeof document>`u`)return;let t=document;t.addEventListener(`keydown`,k),t.addEventListener(`pointerdown`,A,!0),t.addEventListener(`pointerup`,M,!0),t.addEventListener(`pointercancel`,N,!0),t.addEventListener(`contextmenu`,N,!0),t.addEventListener(`click`,P),t.addEventListener(`focusin`,F,!0),e.listeners={remove(){t.removeEventListener(`keydown`,k),t.removeEventListener(`pointerdown`,A,!0),t.removeEventListener(`pointerup`,M,!0),t.removeEventListener(`pointercancel`,N,!0),t.removeEventListener(`contextmenu`,N,!0),t.removeEventListener(`click`,P),t.removeEventListener(`focusin`,F,!0)}}}function R(e){e.listeners?.remove(),e.listeners=null,e.press=null}exports.ALLOW_OUTSIDE_SELECTOR=n,exports.Z_INDEX=t,exports.compareLayers=f,exports.getLayer=y,exports.getLayerTreeElements=x,exports.getOpenLayers=v,exports.getTopmostLayer=p,exports.isDescendantLayer=b,exports.isInsideLayerTree=d,exports.isInsideOtherOpenModal=S,exports.registerLayer=w,exports.registerLayerElement=C,exports.registerLayerIsolation=m,exports.subscribeLayers=_;
2
+ //# sourceMappingURL=layers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.cjs","names":["getGlobalRegistry","require_globalRegistry","Z_INDEX","ALLOW_OUTSIDE_SELECTOR","getState","state","notifySubscribers","subscriber","ELEMENT_NODE","findLayer","id","layer","isDescendantOf","visited","parentId","ancestorId","containsNode","container","target","isInsideTreeWithoutAllowList","layerId","record","el","registered","isInsideAllowList","isInsideLayerTree","compareLayers","a","b","indexA","indexB","getTopmostLayer","i","stack","predicate","registerLayerIsolation","isolated","count","getIsolationBarrier","isBelowBarrier","barrier","subscribeLayers","subscribers","listener","getOpenLayers","getLayer","isDescendantLayer","getLayerTreeElements","result","includeOwn","options","visit","isInsideOtherOpenModal","exceptLayerId","registerLayerElement","set","current","registerLayer","firstDescendant","ensureListeners","index","removeListeners","getEventTargetNode","event","sortTopmostFirst","layers","findEscapeHandler","isCandidate","contains","active","scope","isClickActivationKey","key","handleKeyDown","handler","handlePointerDown","outsidePress","GESTURE_CLICK_TIMEOUT_MS","handlePointerUp","press","timeout","forgetPress","handleClick","toDismiss","handleFocusIn","candidates","dismissFocusOutside","doc"],"sources":["../../src/lib/layers.ts"],"sourcesContent":["import { getGlobalRegistry } from './globalRegistry';\n\n/**\n * The shared stack of open dismissable layers (dialogs, drawers, popovers, menus, listboxes,\n * tooltips) and the document listeners that route Escape, outside presses and focus changes to\n * them. `useDismiss` registers layers; focus traps, modal isolation and focus restore read the\n * stack. It lives in `getGlobalRegistry('layers')`, so an app that loads both the ESM and the CJS\n * build still has one stack and one set of listeners.\n */\n\n/**\n * z-index of each portal layer. `Portal` adds its nesting depth, so a surface opened from inside\n * another overlay always stacks above it. The values fall back to the defaults of `tokens.css`.\n */\nexport const Z_INDEX = {\n overlay: 'var(--wave-z-overlay, 1000)',\n toast: 'var(--wave-z-toast, 1100)',\n tooltip: 'var(--wave-z-tooltip, 1200)',\n} as const;\n\n/**\n * What kind of surface a layer is. `modal` marks dialog-like surfaces (focus-restore validation and\n * modal isolation look for them); a modal blocks presses and Escape for the layers below it only\n * while its page isolation is active ({@link registerLayerIsolation}).\n */\nexport type LayerKind = 'modal' | 'popover' | 'menu' | 'listbox' | 'tooltip' | 'toast';\n\n/** Why a layer is being dismissed. */\nexport type DismissReason = 'escape' | 'outside-press' | 'focus-outside';\n\n/** A registered layer. Getters are allowed, so fields can read the latest options. */\nexport interface LayerRecord {\n /** Unique id; children name it as their `parentId` (through `DismissLayerContext`). */\n id: string;\n /** The enclosing layer (React parentage, which survives portals), or `null`. */\n parentId: string | null;\n kind: LayerKind;\n /** Global open-order counter, assigned by {@link registerLayer} (the passed value is replaced). */\n order: number;\n /** The elements that belong to the layer: its surface, its trigger, extra ignore targets. */\n getElements(): Array<HTMLElement | null>;\n /** The element the layer is anchored to (its trigger); focus traps leave the layer through it. */\n getAnchor(): HTMLElement | null;\n /** Whether Escape dismisses the layer. */\n escape: boolean;\n /** Whether a press outside the layer's tree dismisses it; a predicate returning `false` opts out. */\n outsidePress: boolean | ((event: PointerEvent | MouseEvent) => boolean);\n /** Whether focus moving outside the layer's tree dismisses it. */\n focusOutside: boolean;\n /** Called when the layer should close. */\n onDismiss(reason: DismissReason, event: Event): void;\n}\n\n/**\n * Regions (the Toaster viewport) whose content counts as inside **every** layer and whose\n * tabbables join every focus trap's Tab cycle. Modal isolation never makes them inert.\n */\nexport const ALLOW_OUTSIDE_SELECTOR = '[data-wave-focus-trap-allow]';\n\ninterface PressSnapshot {\n /**\n * Layers with outside press enabled whose tree did not contain the pointerdown target. Only these\n * can be dismissed by the click: a layer registered later (opened by that press, or closed and\n * reopened, which registers a new record) is not in it, and a layer that unregisters is removed.\n */\n layers: LayerRecord[];\n}\n\ninterface InstalledListeners {\n remove(): void;\n}\n\ninterface LayerState {\n /** Open layers from bottom to top. A parent always precedes its descendants. */\n stack: LayerRecord[];\n /** Elements registered per layer id (portal wrappers of the layer's descendants). */\n elements: Map<string, Set<HTMLElement>>;\n counter: number;\n press: PressSnapshot | null;\n listeners: InstalledListeners | null;\n /** Called after a layer registers or unregisters (modal isolation re-plans). */\n subscribers: Set<() => void>;\n /** Ids of layers whose modal isolation currently makes the page inert, with a use count. */\n isolated: Map<string, number>;\n}\n\nfunction getState(): LayerState {\n const state = getGlobalRegistry<LayerState>('layers', () => ({\n stack: [],\n elements: new Map(),\n counter: 0,\n press: null,\n listeners: null,\n subscribers: new Set(),\n isolated: new Map(),\n }));\n // A registry created by an earlier copy of this module (hot reload) may predate these fields.\n state.subscribers ??= new Set();\n state.isolated ??= new Map();\n return state;\n}\n\nfunction notifySubscribers(state: LayerState): void {\n for (const subscriber of Array.from(state.subscribers)) subscriber();\n}\n\nconst ELEMENT_NODE = 1;\n\nfunction findLayer(state: LayerState, id: string | null): LayerRecord | undefined {\n if (id === null) return undefined;\n return state.stack.find((layer) => layer.id === id);\n}\n\n/** Whether `layer` is a (possibly indirect) descendant of the layer `ancestorId`. */\nfunction isDescendantOf(state: LayerState, layer: LayerRecord, ancestorId: string): boolean {\n const visited = new Set<string>([layer.id]);\n let parentId = layer.parentId;\n while (parentId !== null && !visited.has(parentId)) {\n if (parentId === ancestorId) return true;\n visited.add(parentId);\n parentId = findLayer(state, parentId)?.parentId ?? null;\n }\n return false;\n}\n\nfunction containsNode(container: Node | null | undefined, target: Node): boolean {\n return !!container && container.contains(target);\n}\n\nfunction isInsideTreeWithoutAllowList(\n state: LayerState,\n layerId: string,\n target: Node,\n visited: Set<string>,\n): boolean {\n if (visited.has(layerId)) return false;\n visited.add(layerId);\n\n const record = findLayer(state, layerId);\n if (record && record.getElements().some((el) => containsNode(el, target))) return true;\n\n const registered = state.elements.get(layerId);\n if (registered) {\n for (const el of registered) {\n if (containsNode(el, target)) return true;\n }\n }\n\n for (const layer of state.stack) {\n if (\n layer.parentId === layerId &&\n isInsideTreeWithoutAllowList(state, layer.id, target, visited)\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction isInsideAllowList(target: Node): boolean {\n const el = target.nodeType === ELEMENT_NODE ? (target as Element) : target.parentElement;\n return !!el && el.closest(ALLOW_OUTSIDE_SELECTOR) !== null;\n}\n\n/**\n * Whether `target` belongs to the tree of the layer `layerId`:\n * - the layer's own elements (`getElements()`),\n * - elements registered for it with {@link registerLayerElement} (portal wrappers of overlays\n * rendered inside it — React parentage survives portals, the DOM does not),\n * - every descendant layer's tree, and\n * - regions matching {@link ALLOW_OUTSIDE_SELECTOR} (the Toaster viewport), which count as inside\n * every layer.\n */\nexport function isInsideLayerTree(layerId: string, target: Node): boolean {\n if (isInsideAllowList(target)) return true;\n return isInsideTreeWithoutAllowList(getState(), layerId, target, new Set());\n}\n\n/**\n * Compares two layers for stacking: `> 0` when `a` is above `b`. A descendant layer is above its\n * ancestor; otherwise the layer whose tree opened later is above. (A parent that registers after\n * its descendants — effects run child-first when both open in one commit — takes the place of its\n * earliest descendant.)\n */\nexport function compareLayers(a: LayerRecord, b: LayerRecord): number {\n if (a === b || a.id === b.id) return 0;\n const state = getState();\n if (isDescendantOf(state, a, b.id)) return 1;\n if (isDescendantOf(state, b, a.id)) return -1;\n const indexA = state.stack.indexOf(a);\n const indexB = state.stack.indexOf(b);\n if (indexA !== -1 && indexB !== -1) return indexA - indexB;\n return a.order - b.order;\n}\n\n/** The topmost open layer (optionally the topmost one matching `predicate`), or `null`. */\nexport function getTopmostLayer(predicate?: (layer: LayerRecord) => boolean): LayerRecord | null {\n const { stack } = getState();\n for (let i = stack.length - 1; i >= 0; i--) {\n const layer = stack[i];\n if (!predicate || predicate(layer)) return layer;\n }\n return null;\n}\n\n/**\n * Marks the layer `layerId` as isolating the page: `useModalIsolation` made everything outside its\n * tree inert (Dialog, Drawer). While it is open, the topmost isolating layer is a barrier — layers\n * stacked below it (its ancestors and older siblings) are never dismissed by outside presses and\n * never receive Escape, the way a modal blocks the page behind it. Layers above it (its\n * descendants, or a modal opened later) are unaffected. A `kind: 'modal'` layer without isolation\n * (a transient popup such as the DatePicker calendar, whose page stays interactive) is no barrier.\n * Returns the unregister function; registrations are counted, so the layer stays marked until\n * every registration is removed.\n */\nexport function registerLayerIsolation(layerId: string): () => void {\n const { isolated } = getState();\n isolated.set(layerId, (isolated.get(layerId) ?? 0) + 1);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n const count = (isolated.get(layerId) ?? 1) - 1;\n if (count > 0) isolated.set(layerId, count);\n else isolated.delete(layerId);\n };\n}\n\n/** The topmost open layer whose modal isolation is active, or `null`. */\nfunction getIsolationBarrier(state: LayerState): LayerRecord | null {\n if (state.isolated.size === 0) return null;\n return getTopmostLayer((layer) => state.isolated.has(layer.id));\n}\n\n/** Whether `layer` is stacked below `barrier` (neither the barrier itself nor above it). */\nfunction isBelowBarrier(layer: LayerRecord, barrier: LayerRecord | null): boolean {\n return !!barrier && barrier !== layer && compareLayers(barrier, layer) > 0;\n}\n\n/**\n * Whether `layer` is stacked below the topmost open **isolating** modal (see\n * {@link registerLayerIsolation}). Such a layer is behind the modal and inert: outside presses\n * never dismiss it and Escape never reaches it. The modal's descendants are above it and stay\n * reachable; a modal-kind layer without isolation shields nothing.\n */\nexport function isBehindIsolatingModal(layer: LayerRecord): boolean {\n return isBelowBarrier(layer, getIsolationBarrier(getState()));\n}\n\n/**\n * Calls `listener` synchronously after any layer registers or unregisters (in the committing\n * component's layout effect, so a modal can re-plan its isolation before a newly opened modal\n * moves focus). Returns the unsubscribe function.\n */\nexport function subscribeLayers(listener: () => void): () => void {\n const { subscribers } = getState();\n subscribers.add(listener);\n return () => {\n subscribers.delete(listener);\n };\n}\n\n/** The open layers from bottom to top (a copy; a parent always precedes its descendants). */\nexport function getOpenLayers(): LayerRecord[] {\n return [...getState().stack];\n}\n\n/** The open layer with this id, or `null`. */\nexport function getLayer(layerId: string): LayerRecord | null {\n return findLayer(getState(), layerId) ?? null;\n}\n\n/** Whether the open layer `layerId` is a (possibly indirect) descendant of `ancestorId`. */\nexport function isDescendantLayer(layerId: string, ancestorId: string): boolean {\n const state = getState();\n const layer = findLayer(state, layerId);\n return !!layer && isDescendantOf(state, layer, ancestorId);\n}\n\n/**\n * Every element that makes up the tree of `layerId`: the layer's own elements, the elements\n * registered for it and the same for each descendant layer (the allow-list is not included).\n * With `includeOwnElements: false` the layer's own `getElements()` are left out (its descendants'\n * are still included).\n */\nexport function getLayerTreeElements(\n layerId: string,\n options?: { includeOwnElements?: boolean },\n): HTMLElement[] {\n const state = getState();\n const result: HTMLElement[] = [];\n const includeOwn = options?.includeOwnElements ?? true;\n const visit = (id: string, visited: Set<string>) => {\n if (visited.has(id)) return;\n visited.add(id);\n const record = findLayer(state, id);\n if (record && (includeOwn || id !== layerId)) {\n for (const el of record.getElements()) {\n if (el && !result.includes(el)) result.push(el);\n }\n }\n for (const el of state.elements.get(id) ?? []) {\n if (!result.includes(el)) result.push(el);\n }\n for (const layer of state.stack) {\n if (layer.parentId === id) visit(layer.id, visited);\n }\n };\n visit(layerId, new Set());\n return result;\n}\n\n/**\n * Whether focusing `el` would send focus behind another open modal layer: the topmost open modal\n * layer other than `exceptLayerId` (and its descendants, which close with it) does not contain\n * `el` in its tree. An element inside that modal's tree (for example an opener inside a parent\n * dialog) is reachable and returns `false`. Used to validate focus-restore targets.\n */\nexport function isInsideOtherOpenModal(el: Element, exceptLayerId?: string): boolean {\n const state = getState();\n for (let i = state.stack.length - 1; i >= 0; i--) {\n const layer = state.stack[i];\n if (layer.kind !== 'modal') continue;\n if (exceptLayerId !== undefined) {\n if (layer.id === exceptLayerId || isDescendantOf(state, layer, exceptLayerId)) continue;\n }\n return !isInsideLayerTree(layer.id, el);\n }\n return false;\n}\n\n/**\n * Registers an element (a portal wrapper) as part of the layer `layerId`, so presses and focus\n * inside it count as inside that layer and its ancestors. Returns the unregister function (usable\n * as a React 19 ref-callback cleanup). The layer does not need to be registered yet.\n */\nexport function registerLayerElement(layerId: string, el: HTMLElement): () => void {\n const state = getState();\n let set = state.elements.get(layerId);\n if (!set) {\n set = new Set();\n state.elements.set(layerId, set);\n }\n set.add(el);\n return () => {\n const current = state.elements.get(layerId);\n if (!current) return;\n current.delete(el);\n if (current.size === 0) state.elements.delete(layerId);\n };\n}\n\n/**\n * Registers an open layer and returns its unregister function. `record.order` is set to the next\n * value of the global open-order counter. The layer is placed on top of the stack — or, when some\n * of its descendants registered first (same commit), directly below the earliest of them.\n */\nexport function registerLayer(record: LayerRecord): () => void {\n const state = getState();\n state.counter += 1;\n record.order = state.counter;\n\n const firstDescendant = state.stack.findIndex((layer) => isDescendantOf(state, layer, record.id));\n if (firstDescendant === -1) state.stack.push(record);\n else state.stack.splice(firstDescendant, 0, record);\n\n ensureListeners(state);\n notifySubscribers(state);\n\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n const index = state.stack.indexOf(record);\n if (index !== -1) state.stack.splice(index, 1);\n if (state.press) {\n state.press.layers = state.press.layers.filter((layer) => layer !== record);\n }\n if (state.stack.length === 0) removeListeners(state);\n notifySubscribers(state);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Document listeners\n// ---------------------------------------------------------------------------\n\nfunction getEventTargetNode(event: Event): Node | null {\n const target = event.target as { nodeType?: unknown } | null;\n return target && typeof target.nodeType === 'number' ? (target as Node) : null;\n}\n\n/** Topmost first: descendants before their ancestors. */\nfunction sortTopmostFirst(layers: LayerRecord[]): LayerRecord[] {\n return [...layers].sort((a, b) => compareLayers(b, a));\n}\n\n/**\n * The layer that handles an Escape whose target / focused element is `target` / `active`.\n * Candidates are the escape-enabled layers that are not stacked below the topmost isolating modal\n * (a modal that ignores Escape never lets the key close something inert behind it — its ancestor\n * dialog as much as an older sibling):\n * 1. the innermost layer whose tree contains them (the topmost such layer) is the focus scope;\n * 2. the topmost candidate of that scope's subtree handles it — the scope itself or an open\n * descendant above it (a tooltip or popover opened from the focused dialog closes first, while\n * a sibling of the focused layer is not in its subtree);\n * 3. else the topmost candidate whose tree contains them (an ancestor);\n * 4. else — no layer contains them, or none of the containing layers takes Escape — the global\n * topmost candidate.\n */\nfunction findEscapeHandler(\n state: LayerState,\n target: Node | null,\n active: Element | null,\n): LayerRecord | null {\n const barrier = getIsolationBarrier(state);\n const isCandidate = (layer: LayerRecord) => layer.escape && !isBelowBarrier(layer, barrier);\n const contains = (layer: LayerRecord) =>\n (!!target && isInsideLayerTree(layer.id, target)) ||\n (!!active && isInsideLayerTree(layer.id, active));\n const scope = getTopmostLayer(contains);\n const handler = scope\n ? (getTopmostLayer(\n (layer) =>\n isCandidate(layer) && (layer === scope || isDescendantOf(state, layer, scope.id)),\n ) ?? getTopmostLayer((layer) => isCandidate(layer) && contains(layer)))\n : null;\n return handler ?? getTopmostLayer(isCandidate);\n}\n\n/** Keys that activate the focused control with a synthetic click. */\nfunction isClickActivationKey(key: string): boolean {\n return key === 'Enter' || key === ' ' || key === 'Spacebar';\n}\n\nfunction handleKeyDown(event: KeyboardEvent): void {\n const state = getState();\n if (event.key === 'Escape' || event.key === 'Esc') {\n if (event.defaultPrevented || event.isComposing) return;\n const handler = findEscapeHandler(state, getEventTargetNode(event), document.activeElement);\n if (!handler) return;\n event.preventDefault();\n handler.onDismiss('escape', event);\n return;\n }\n // A keyboard-activated click (Enter/Space) must not dismiss layers recorded by an unrelated\n // earlier pointerdown. Other keys keep the pending press: modifiers held for a Shift/Ctrl+click\n // auto-repeat their keydown while the pointer is down.\n if (isClickActivationKey(event.key)) state.press = null;\n}\n\nfunction handlePointerDown(event: PointerEvent): void {\n const state = getState();\n const target = getEventTargetNode(event);\n // Only a primary press is followed by a click (right/middle buttons fire contextmenu/auxclick).\n if (!target || event.button !== 0) {\n state.press = null;\n return;\n }\n const barrier = getIsolationBarrier(state);\n const layers = state.stack.filter((layer) => {\n const { outsidePress } = layer;\n if (!outsidePress) return false;\n // A layer behind an open isolating modal (its parent dialog, or a dialog below a sibling\n // modal opened from inside it) is inert and not reachable: presses inside that modal, or on\n // its backdrop, are not \"outside\" presses for it.\n if (isBelowBarrier(layer, barrier)) return false;\n if (isInsideLayerTree(layer.id, target)) return false;\n return typeof outsidePress !== 'function' || outsidePress(event) !== false;\n });\n state.press = { layers };\n}\n\n/**\n * How long (ms) a touch, pen or unknown-device press waits for its click after the pointerup. A\n * tap's click follows within about 350 ms (at most the double-tap delay); a press that gets no\n * click (a long press that opened the context menu, a tap on a non-clickable area) is forgotten\n * after this, so a later programmatic `click()` cannot complete it.\n */\nconst GESTURE_CLICK_TIMEOUT_MS = 1000;\n\n/**\n * A mouse click is dispatched right after its pointerup, in the same task. When none follows (the\n * pointer was released over another window or element tree), a mouse press is forgotten on the\n * next macrotask, so a later programmatic `click()` cannot complete it. Touch and stylus taps are\n * turned into a click by a separate gesture event in a later task (Apple Pencil on iPadOS and\n * Android styluses report `pointerType: 'pen'`, and an unknown device type `''` may behave the\n * same way), so every other pointer type keeps its press for {@link GESTURE_CLICK_TIMEOUT_MS}.\n * The next pointerdown, pointercancel, contextmenu or Enter/Space forgets a press earlier.\n */\nfunction handlePointerUp(event: PointerEvent): void {\n const press = getState().press;\n if (!press) return;\n const timeout = event.pointerType === 'mouse' ? 0 : GESTURE_CLICK_TIMEOUT_MS;\n setTimeout(() => {\n const current = getState();\n if (current.press === press) current.press = null;\n }, timeout);\n}\n\n/** A cancelled pointer stream, or a context menu (a long press, a Mac Ctrl+click), gets no click. */\nfunction forgetPress(): void {\n getState().press = null;\n}\n\nfunction handleClick(event: MouseEvent): void {\n const state = getState();\n const press = state.press;\n state.press = null;\n if (!press) return;\n const target = getEventTargetNode(event);\n const toDismiss = press.layers.filter(\n (layer) => !(target && isInsideLayerTree(layer.id, target)),\n );\n for (const layer of sortTopmostFirst(toDismiss)) {\n // An earlier layer's onDismiss may already have unregistered this one.\n if (state.stack.includes(layer)) layer.onDismiss('outside-press', event);\n }\n}\n\nfunction handleFocusIn(event: FocusEvent): void {\n const target = getEventTargetNode(event);\n if (!target) return;\n const candidates = getState().stack.filter(\n (layer) => layer.focusOutside && !isInsideLayerTree(layer.id, target),\n );\n if (candidates.length === 0) return;\n // Not in this dispatch: React applies `autoFocus` in the layout phase of the commit that mounts\n // a surface, before that surface's portal wrapper and dismiss layer register. A field focused\n // as a popover or dialog opens inside the layer is inside its tree once that commit has run.\n queueMicrotask(() => dismissFocusOutside(candidates, target, event));\n}\n\n/**\n * Dismisses each of `candidates` that is still open and whose tree still contains neither the\n * focusin `target` nor the element focused now (focus that came back inside keeps it open; focus\n * lost to `<body>` after leaving does not).\n */\nfunction dismissFocusOutside(candidates: LayerRecord[], target: Node, event: FocusEvent): void {\n const state = getState();\n const active = (target.ownerDocument ?? document).activeElement;\n const toDismiss = candidates.filter(\n (layer) =>\n state.stack.includes(layer) &&\n !isInsideLayerTree(layer.id, target) &&\n !(active && isInsideLayerTree(layer.id, active)),\n );\n for (const layer of sortTopmostFirst(toDismiss)) {\n // An earlier layer's onDismiss may already have unregistered this one.\n if (state.stack.includes(layer)) layer.onDismiss('focus-outside', event);\n }\n}\n\nfunction ensureListeners(state: LayerState): void {\n if (state.listeners || typeof document === 'undefined') return;\n const doc = document;\n doc.addEventListener('keydown', handleKeyDown);\n doc.addEventListener('pointerdown', handlePointerDown, true);\n doc.addEventListener('pointerup', handlePointerUp, true);\n doc.addEventListener('pointercancel', forgetPress, true);\n doc.addEventListener('contextmenu', forgetPress, true);\n doc.addEventListener('click', handleClick);\n doc.addEventListener('focusin', handleFocusIn, true);\n state.listeners = {\n remove() {\n doc.removeEventListener('keydown', handleKeyDown);\n doc.removeEventListener('pointerdown', handlePointerDown, true);\n doc.removeEventListener('pointerup', handlePointerUp, true);\n doc.removeEventListener('pointercancel', forgetPress, true);\n doc.removeEventListener('contextmenu', forgetPress, true);\n doc.removeEventListener('click', handleClick);\n doc.removeEventListener('focusin', handleFocusIn, true);\n },\n };\n}\n\nfunction removeListeners(state: LayerState): void {\n state.listeners?.remove();\n state.listeners = null;\n state.press = null;\n}\n"],"mappings":"wCAcA,IAAaE,EAAU,CACrB,QAAS,8BACT,MAAO,4BACP,QAAS,6BACX,EAuCaC,EAAyB,+BA6BtC,SAASC,GAAuB,CAC9B,IAAMC,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AAI,iBAAiB,YAAaT,EAAiB,EAAI,EACvDS,EAAI,iBAAiB,gBAAiBN,EAAa,EAAI,EACvDM,EAAI,iBAAiB,cAAeN,EAAa,EAAI,EACrDM,EAAI,iBAAiB,QAASL,CAAW,EACzCK,EAAI,iBAAiB,UAAWH,EAAe,EAAI,EACnD,EAAM,UAAY,CAChB,QAAS,CACPG,EAAI,oBAAoB,UAAWd,CAAa,EAChDc,EAAI,oBAAoB,cAAeZ,EAAmB,EAAI,EAC9DY,EAAI,oBAAoB,YAAaT,EAAiB,EAAI,EAC1DS,EAAI,oBAAoB,gBAAiBN,EAAa,EAAI,EAC1DM,EAAI,oBAAoB,cAAeN,EAAa,EAAI,EACxDM,EAAI,oBAAoB,QAASL,CAAW,EAC5CK,EAAI,oBAAoB,UAAWH,EAAe,EAAI,CACxD,CACF,CACF,CAEA,SAASvB,EAAgB,EAAyB,CAChDxD,EAAM,WAAW,OAAO,EACxB,EAAM,UAAY,KAClB,EAAM,MAAQ,IAChB"}
@@ -0,0 +1,224 @@
1
+ import { getGlobalRegistry as e } from "./globalRegistry.mjs";
2
+ //#region src/lib/layers.ts
3
+ var t = {
4
+ overlay: "var(--wave-z-overlay, 1000)",
5
+ toast: "var(--wave-z-toast, 1100)",
6
+ tooltip: "var(--wave-z-tooltip, 1200)"
7
+ }, n = "[data-wave-focus-trap-allow]";
8
+ function r() {
9
+ let t = e("layers", () => ({
10
+ stack: [],
11
+ elements: /* @__PURE__ */ new Map(),
12
+ counter: 0,
13
+ press: null,
14
+ listeners: null,
15
+ subscribers: /* @__PURE__ */ new Set(),
16
+ isolated: /* @__PURE__ */ new Map()
17
+ }));
18
+ return t.subscribers ??= /* @__PURE__ */ new Set(), t.isolated ??= /* @__PURE__ */ new Map(), t;
19
+ }
20
+ function i(e) {
21
+ for (let t of Array.from(e.subscribers)) t();
22
+ }
23
+ var a = 1;
24
+ function o(e, t) {
25
+ if (t !== null) return e.stack.find((e) => e.id === t);
26
+ }
27
+ function s(e, t, n) {
28
+ let r = /* @__PURE__ */ new Set([t.id]), i = t.parentId;
29
+ for (; i !== null && !r.has(i);) {
30
+ if (i === n) return !0;
31
+ r.add(i), i = o(e, i)?.parentId ?? null;
32
+ }
33
+ return !1;
34
+ }
35
+ function c(e, t) {
36
+ return !!e && e.contains(t);
37
+ }
38
+ function l(e, t, n, r) {
39
+ if (r.has(t)) return !1;
40
+ r.add(t);
41
+ let i = o(e, t);
42
+ if (i && i.getElements().some((e) => c(e, n))) return !0;
43
+ let a = e.elements.get(t);
44
+ if (a) {
45
+ for (let e of a) if (c(e, n)) return !0;
46
+ }
47
+ for (let i of e.stack) if (i.parentId === t && l(e, i.id, n, r)) return !0;
48
+ return !1;
49
+ }
50
+ function u(e) {
51
+ let t = e.nodeType === a ? e : e.parentElement;
52
+ return !!t && t.closest("[data-wave-focus-trap-allow]") !== null;
53
+ }
54
+ function d(e, t) {
55
+ return u(t) ? !0 : l(r(), e, t, /* @__PURE__ */ new Set());
56
+ }
57
+ function f(e, t) {
58
+ if (e === t || e.id === t.id) return 0;
59
+ let n = r();
60
+ if (s(n, e, t.id)) return 1;
61
+ if (s(n, t, e.id)) return -1;
62
+ let i = n.stack.indexOf(e), a = n.stack.indexOf(t);
63
+ return i !== -1 && a !== -1 ? i - a : e.order - t.order;
64
+ }
65
+ function p(e) {
66
+ let { stack: t } = r();
67
+ for (let n = t.length - 1; n >= 0; n--) {
68
+ let r = t[n];
69
+ if (!e || e(r)) return r;
70
+ }
71
+ return null;
72
+ }
73
+ function m(e) {
74
+ let { isolated: t } = r();
75
+ t.set(e, (t.get(e) ?? 0) + 1);
76
+ let n = !0;
77
+ return () => {
78
+ if (!n) return;
79
+ n = !1;
80
+ let r = (t.get(e) ?? 1) - 1;
81
+ r > 0 ? t.set(e, r) : t.delete(e);
82
+ };
83
+ }
84
+ function h(e) {
85
+ return e.isolated.size === 0 ? null : p((t) => e.isolated.has(t.id));
86
+ }
87
+ function g(e, t) {
88
+ return !!t && t !== e && f(t, e) > 0;
89
+ }
90
+ function _(e) {
91
+ let { subscribers: t } = r();
92
+ return t.add(e), () => {
93
+ t.delete(e);
94
+ };
95
+ }
96
+ function v() {
97
+ return [...r().stack];
98
+ }
99
+ function y(e) {
100
+ return o(r(), e) ?? null;
101
+ }
102
+ function b(e, t) {
103
+ let n = r(), i = o(n, e);
104
+ return !!i && s(n, i, t);
105
+ }
106
+ function x(e, t) {
107
+ let n = r(), i = [], a = t?.includeOwnElements ?? !0, s = (t, r) => {
108
+ if (r.has(t)) return;
109
+ r.add(t);
110
+ let c = o(n, t);
111
+ if (c && (a || t !== e)) for (let e of c.getElements()) e && !i.includes(e) && i.push(e);
112
+ for (let e of n.elements.get(t) ?? []) i.includes(e) || i.push(e);
113
+ for (let e of n.stack) e.parentId === t && s(e.id, r);
114
+ };
115
+ return s(e, /* @__PURE__ */ new Set()), i;
116
+ }
117
+ function S(e, t) {
118
+ let n = r();
119
+ for (let r = n.stack.length - 1; r >= 0; r--) {
120
+ let i = n.stack[r];
121
+ if (i.kind === "modal" && (t === void 0 || i.id !== t && !s(n, i, t))) return !d(i.id, e);
122
+ }
123
+ return !1;
124
+ }
125
+ function C(e, t) {
126
+ let n = r(), i = n.elements.get(e);
127
+ return i || (i = /* @__PURE__ */ new Set(), n.elements.set(e, i)), i.add(t), () => {
128
+ let r = n.elements.get(e);
129
+ r && (r.delete(t), r.size === 0 && n.elements.delete(e));
130
+ };
131
+ }
132
+ function w(e) {
133
+ let t = r();
134
+ t.counter += 1, e.order = t.counter;
135
+ let n = t.stack.findIndex((n) => s(t, n, e.id));
136
+ n === -1 ? t.stack.push(e) : t.stack.splice(n, 0, e), L(t), i(t);
137
+ let a = !0;
138
+ return () => {
139
+ if (!a) return;
140
+ a = !1;
141
+ let n = t.stack.indexOf(e);
142
+ n !== -1 && t.stack.splice(n, 1), t.press && (t.press.layers = t.press.layers.filter((t) => t !== e)), t.stack.length === 0 && R(t), i(t);
143
+ };
144
+ }
145
+ function T(e) {
146
+ let t = e.target;
147
+ return t && typeof t.nodeType == "number" ? t : null;
148
+ }
149
+ function E(e) {
150
+ return [...e].sort((e, t) => f(t, e));
151
+ }
152
+ function D(e, t, n) {
153
+ let r = h(e), i = (e) => e.escape && !g(e, r), a = (e) => !!t && d(e.id, t) || !!n && d(e.id, n), o = p(a);
154
+ return (o ? p((t) => i(t) && (t === o || s(e, t, o.id))) ?? p((e) => i(e) && a(e)) : null) ?? p(i);
155
+ }
156
+ function O(e) {
157
+ return e === "Enter" || e === " " || e === "Spacebar";
158
+ }
159
+ function k(e) {
160
+ let t = r();
161
+ if (e.key === "Escape" || e.key === "Esc") {
162
+ if (e.defaultPrevented || e.isComposing) return;
163
+ let n = D(t, T(e), document.activeElement);
164
+ if (!n) return;
165
+ e.preventDefault(), n.onDismiss("escape", e);
166
+ return;
167
+ }
168
+ O(e.key) && (t.press = null);
169
+ }
170
+ function A(e) {
171
+ let t = r(), n = T(e);
172
+ if (!n || e.button !== 0) {
173
+ t.press = null;
174
+ return;
175
+ }
176
+ let i = h(t);
177
+ t.press = { layers: t.stack.filter((t) => {
178
+ let { outsidePress: r } = t;
179
+ return !r || g(t, i) || d(t.id, n) ? !1 : typeof r != "function" || r(e) !== !1;
180
+ }) };
181
+ }
182
+ var j = 1e3;
183
+ function M(e) {
184
+ let t = r().press;
185
+ if (!t) return;
186
+ let n = e.pointerType === "mouse" ? 0 : j;
187
+ setTimeout(() => {
188
+ let e = r();
189
+ e.press === t && (e.press = null);
190
+ }, n);
191
+ }
192
+ function N() {
193
+ r().press = null;
194
+ }
195
+ function P(e) {
196
+ let t = r(), n = t.press;
197
+ if (t.press = null, !n) return;
198
+ let i = T(e), a = n.layers.filter((e) => !(i && d(e.id, i)));
199
+ for (let n of E(a)) t.stack.includes(n) && n.onDismiss("outside-press", e);
200
+ }
201
+ function F(e) {
202
+ let t = T(e);
203
+ if (!t) return;
204
+ let n = r().stack.filter((e) => e.focusOutside && !d(e.id, t));
205
+ n.length !== 0 && queueMicrotask(() => I(n, t, e));
206
+ }
207
+ function I(e, t, n) {
208
+ let i = r(), a = (t.ownerDocument ?? document).activeElement, o = e.filter((e) => i.stack.includes(e) && !d(e.id, t) && !(a && d(e.id, a)));
209
+ for (let e of E(o)) i.stack.includes(e) && e.onDismiss("focus-outside", n);
210
+ }
211
+ function L(e) {
212
+ if (e.listeners || typeof document > "u") return;
213
+ let t = document;
214
+ t.addEventListener("keydown", k), t.addEventListener("pointerdown", A, !0), t.addEventListener("pointerup", M, !0), t.addEventListener("pointercancel", N, !0), t.addEventListener("contextmenu", N, !0), t.addEventListener("click", P), t.addEventListener("focusin", F, !0), e.listeners = { remove() {
215
+ t.removeEventListener("keydown", k), t.removeEventListener("pointerdown", A, !0), t.removeEventListener("pointerup", M, !0), t.removeEventListener("pointercancel", N, !0), t.removeEventListener("contextmenu", N, !0), t.removeEventListener("click", P), t.removeEventListener("focusin", F, !0);
216
+ } };
217
+ }
218
+ function R(e) {
219
+ e.listeners?.remove(), e.listeners = null, e.press = null;
220
+ }
221
+ //#endregion
222
+ export { n as ALLOW_OUTSIDE_SELECTOR, t as Z_INDEX, f as compareLayers, y as getLayer, x as getLayerTreeElements, v as getOpenLayers, p as getTopmostLayer, b as isDescendantLayer, d as isInsideLayerTree, S as isInsideOtherOpenModal, w as registerLayer, C as registerLayerElement, m as registerLayerIsolation, _ as subscribeLayers };
223
+
224
+ //# sourceMappingURL=layers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.mjs","names":["Z_INDEX","ALLOW_OUTSIDE_SELECTOR","getState","state","getGlobalRegistry","notifySubscribers","subscriber","ELEMENT_NODE","findLayer","id","layer","isDescendantOf","visited","parentId","ancestorId","containsNode","container","target","isInsideTreeWithoutAllowList","layerId","record","el","registered","isInsideAllowList","isInsideLayerTree","compareLayers","a","b","indexA","indexB","getTopmostLayer","i","stack","predicate","registerLayerIsolation","isolated","count","getIsolationBarrier","isBelowBarrier","barrier","subscribeLayers","subscribers","listener","getOpenLayers","getLayer","isDescendantLayer","getLayerTreeElements","result","includeOwn","options","visit","isInsideOtherOpenModal","exceptLayerId","registerLayerElement","set","current","registerLayer","firstDescendant","ensureListeners","index","removeListeners","getEventTargetNode","event","sortTopmostFirst","layers","findEscapeHandler","isCandidate","contains","active","scope","isClickActivationKey","key","handleKeyDown","handler","handlePointerDown","outsidePress","GESTURE_CLICK_TIMEOUT_MS","handlePointerUp","press","timeout","forgetPress","handleClick","toDismiss","handleFocusIn","candidates","dismissFocusOutside","doc"],"sources":["../../src/lib/layers.ts"],"sourcesContent":["import { getGlobalRegistry } from './globalRegistry';\n\n/**\n * The shared stack of open dismissable layers (dialogs, drawers, popovers, menus, listboxes,\n * tooltips) and the document listeners that route Escape, outside presses and focus changes to\n * them. `useDismiss` registers layers; focus traps, modal isolation and focus restore read the\n * stack. It lives in `getGlobalRegistry('layers')`, so an app that loads both the ESM and the CJS\n * build still has one stack and one set of listeners.\n */\n\n/**\n * z-index of each portal layer. `Portal` adds its nesting depth, so a surface opened from inside\n * another overlay always stacks above it. The values fall back to the defaults of `tokens.css`.\n */\nexport const Z_INDEX = {\n overlay: 'var(--wave-z-overlay, 1000)',\n toast: 'var(--wave-z-toast, 1100)',\n tooltip: 'var(--wave-z-tooltip, 1200)',\n} as const;\n\n/**\n * What kind of surface a layer is. `modal` marks dialog-like surfaces (focus-restore validation and\n * modal isolation look for them); a modal blocks presses and Escape for the layers below it only\n * while its page isolation is active ({@link registerLayerIsolation}).\n */\nexport type LayerKind = 'modal' | 'popover' | 'menu' | 'listbox' | 'tooltip' | 'toast';\n\n/** Why a layer is being dismissed. */\nexport type DismissReason = 'escape' | 'outside-press' | 'focus-outside';\n\n/** A registered layer. Getters are allowed, so fields can read the latest options. */\nexport interface LayerRecord {\n /** Unique id; children name it as their `parentId` (through `DismissLayerContext`). */\n id: string;\n /** The enclosing layer (React parentage, which survives portals), or `null`. */\n parentId: string | null;\n kind: LayerKind;\n /** Global open-order counter, assigned by {@link registerLayer} (the passed value is replaced). */\n order: number;\n /** The elements that belong to the layer: its surface, its trigger, extra ignore targets. */\n getElements(): Array<HTMLElement | null>;\n /** The element the layer is anchored to (its trigger); focus traps leave the layer through it. */\n getAnchor(): HTMLElement | null;\n /** Whether Escape dismisses the layer. */\n escape: boolean;\n /** Whether a press outside the layer's tree dismisses it; a predicate returning `false` opts out. */\n outsidePress: boolean | ((event: PointerEvent | MouseEvent) => boolean);\n /** Whether focus moving outside the layer's tree dismisses it. */\n focusOutside: boolean;\n /** Called when the layer should close. */\n onDismiss(reason: DismissReason, event: Event): void;\n}\n\n/**\n * Regions (the Toaster viewport) whose content counts as inside **every** layer and whose\n * tabbables join every focus trap's Tab cycle. Modal isolation never makes them inert.\n */\nexport const ALLOW_OUTSIDE_SELECTOR = '[data-wave-focus-trap-allow]';\n\ninterface PressSnapshot {\n /**\n * Layers with outside press enabled whose tree did not contain the pointerdown target. Only these\n * can be dismissed by the click: a layer registered later (opened by that press, or closed and\n * reopened, which registers a new record) is not in it, and a layer that unregisters is removed.\n */\n layers: LayerRecord[];\n}\n\ninterface InstalledListeners {\n remove(): void;\n}\n\ninterface LayerState {\n /** Open layers from bottom to top. A parent always precedes its descendants. */\n stack: LayerRecord[];\n /** Elements registered per layer id (portal wrappers of the layer's descendants). */\n elements: Map<string, Set<HTMLElement>>;\n counter: number;\n press: PressSnapshot | null;\n listeners: InstalledListeners | null;\n /** Called after a layer registers or unregisters (modal isolation re-plans). */\n subscribers: Set<() => void>;\n /** Ids of layers whose modal isolation currently makes the page inert, with a use count. */\n isolated: Map<string, number>;\n}\n\nfunction getState(): LayerState {\n const state = getGlobalRegistry<LayerState>('layers', () => ({\n stack: [],\n elements: new Map(),\n counter: 0,\n press: null,\n listeners: null,\n subscribers: new Set(),\n isolated: new Map(),\n }));\n // A registry created by an earlier copy of this module (hot reload) may predate these fields.\n state.subscribers ??= new Set();\n state.isolated ??= new Map();\n return state;\n}\n\nfunction notifySubscribers(state: LayerState): void {\n for (const subscriber of Array.from(state.subscribers)) subscriber();\n}\n\nconst ELEMENT_NODE = 1;\n\nfunction findLayer(state: LayerState, id: string | null): LayerRecord | undefined {\n if (id === null) return undefined;\n return state.stack.find((layer) => layer.id === id);\n}\n\n/** Whether `layer` is a (possibly indirect) descendant of the layer `ancestorId`. */\nfunction isDescendantOf(state: LayerState, layer: LayerRecord, ancestorId: string): boolean {\n const visited = new Set<string>([layer.id]);\n let parentId = layer.parentId;\n while (parentId !== null && !visited.has(parentId)) {\n if (parentId === ancestorId) return true;\n visited.add(parentId);\n parentId = findLayer(state, parentId)?.parentId ?? null;\n }\n return false;\n}\n\nfunction containsNode(container: Node | null | undefined, target: Node): boolean {\n return !!container && container.contains(target);\n}\n\nfunction isInsideTreeWithoutAllowList(\n state: LayerState,\n layerId: string,\n target: Node,\n visited: Set<string>,\n): boolean {\n if (visited.has(layerId)) return false;\n visited.add(layerId);\n\n const record = findLayer(state, layerId);\n if (record && record.getElements().some((el) => containsNode(el, target))) return true;\n\n const registered = state.elements.get(layerId);\n if (registered) {\n for (const el of registered) {\n if (containsNode(el, target)) return true;\n }\n }\n\n for (const layer of state.stack) {\n if (\n layer.parentId === layerId &&\n isInsideTreeWithoutAllowList(state, layer.id, target, visited)\n ) {\n return true;\n }\n }\n return false;\n}\n\nfunction isInsideAllowList(target: Node): boolean {\n const el = target.nodeType === ELEMENT_NODE ? (target as Element) : target.parentElement;\n return !!el && el.closest(ALLOW_OUTSIDE_SELECTOR) !== null;\n}\n\n/**\n * Whether `target` belongs to the tree of the layer `layerId`:\n * - the layer's own elements (`getElements()`),\n * - elements registered for it with {@link registerLayerElement} (portal wrappers of overlays\n * rendered inside it — React parentage survives portals, the DOM does not),\n * - every descendant layer's tree, and\n * - regions matching {@link ALLOW_OUTSIDE_SELECTOR} (the Toaster viewport), which count as inside\n * every layer.\n */\nexport function isInsideLayerTree(layerId: string, target: Node): boolean {\n if (isInsideAllowList(target)) return true;\n return isInsideTreeWithoutAllowList(getState(), layerId, target, new Set());\n}\n\n/**\n * Compares two layers for stacking: `> 0` when `a` is above `b`. A descendant layer is above its\n * ancestor; otherwise the layer whose tree opened later is above. (A parent that registers after\n * its descendants — effects run child-first when both open in one commit — takes the place of its\n * earliest descendant.)\n */\nexport function compareLayers(a: LayerRecord, b: LayerRecord): number {\n if (a === b || a.id === b.id) return 0;\n const state = getState();\n if (isDescendantOf(state, a, b.id)) return 1;\n if (isDescendantOf(state, b, a.id)) return -1;\n const indexA = state.stack.indexOf(a);\n const indexB = state.stack.indexOf(b);\n if (indexA !== -1 && indexB !== -1) return indexA - indexB;\n return a.order - b.order;\n}\n\n/** The topmost open layer (optionally the topmost one matching `predicate`), or `null`. */\nexport function getTopmostLayer(predicate?: (layer: LayerRecord) => boolean): LayerRecord | null {\n const { stack } = getState();\n for (let i = stack.length - 1; i >= 0; i--) {\n const layer = stack[i];\n if (!predicate || predicate(layer)) return layer;\n }\n return null;\n}\n\n/**\n * Marks the layer `layerId` as isolating the page: `useModalIsolation` made everything outside its\n * tree inert (Dialog, Drawer). While it is open, the topmost isolating layer is a barrier — layers\n * stacked below it (its ancestors and older siblings) are never dismissed by outside presses and\n * never receive Escape, the way a modal blocks the page behind it. Layers above it (its\n * descendants, or a modal opened later) are unaffected. A `kind: 'modal'` layer without isolation\n * (a transient popup such as the DatePicker calendar, whose page stays interactive) is no barrier.\n * Returns the unregister function; registrations are counted, so the layer stays marked until\n * every registration is removed.\n */\nexport function registerLayerIsolation(layerId: string): () => void {\n const { isolated } = getState();\n isolated.set(layerId, (isolated.get(layerId) ?? 0) + 1);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n const count = (isolated.get(layerId) ?? 1) - 1;\n if (count > 0) isolated.set(layerId, count);\n else isolated.delete(layerId);\n };\n}\n\n/** The topmost open layer whose modal isolation is active, or `null`. */\nfunction getIsolationBarrier(state: LayerState): LayerRecord | null {\n if (state.isolated.size === 0) return null;\n return getTopmostLayer((layer) => state.isolated.has(layer.id));\n}\n\n/** Whether `layer` is stacked below `barrier` (neither the barrier itself nor above it). */\nfunction isBelowBarrier(layer: LayerRecord, barrier: LayerRecord | null): boolean {\n return !!barrier && barrier !== layer && compareLayers(barrier, layer) > 0;\n}\n\n/**\n * Whether `layer` is stacked below the topmost open **isolating** modal (see\n * {@link registerLayerIsolation}). Such a layer is behind the modal and inert: outside presses\n * never dismiss it and Escape never reaches it. The modal's descendants are above it and stay\n * reachable; a modal-kind layer without isolation shields nothing.\n */\nexport function isBehindIsolatingModal(layer: LayerRecord): boolean {\n return isBelowBarrier(layer, getIsolationBarrier(getState()));\n}\n\n/**\n * Calls `listener` synchronously after any layer registers or unregisters (in the committing\n * component's layout effect, so a modal can re-plan its isolation before a newly opened modal\n * moves focus). Returns the unsubscribe function.\n */\nexport function subscribeLayers(listener: () => void): () => void {\n const { subscribers } = getState();\n subscribers.add(listener);\n return () => {\n subscribers.delete(listener);\n };\n}\n\n/** The open layers from bottom to top (a copy; a parent always precedes its descendants). */\nexport function getOpenLayers(): LayerRecord[] {\n return [...getState().stack];\n}\n\n/** The open layer with this id, or `null`. */\nexport function getLayer(layerId: string): LayerRecord | null {\n return findLayer(getState(), layerId) ?? null;\n}\n\n/** Whether the open layer `layerId` is a (possibly indirect) descendant of `ancestorId`. */\nexport function isDescendantLayer(layerId: string, ancestorId: string): boolean {\n const state = getState();\n const layer = findLayer(state, layerId);\n return !!layer && isDescendantOf(state, layer, ancestorId);\n}\n\n/**\n * Every element that makes up the tree of `layerId`: the layer's own elements, the elements\n * registered for it and the same for each descendant layer (the allow-list is not included).\n * With `includeOwnElements: false` the layer's own `getElements()` are left out (its descendants'\n * are still included).\n */\nexport function getLayerTreeElements(\n layerId: string,\n options?: { includeOwnElements?: boolean },\n): HTMLElement[] {\n const state = getState();\n const result: HTMLElement[] = [];\n const includeOwn = options?.includeOwnElements ?? true;\n const visit = (id: string, visited: Set<string>) => {\n if (visited.has(id)) return;\n visited.add(id);\n const record = findLayer(state, id);\n if (record && (includeOwn || id !== layerId)) {\n for (const el of record.getElements()) {\n if (el && !result.includes(el)) result.push(el);\n }\n }\n for (const el of state.elements.get(id) ?? []) {\n if (!result.includes(el)) result.push(el);\n }\n for (const layer of state.stack) {\n if (layer.parentId === id) visit(layer.id, visited);\n }\n };\n visit(layerId, new Set());\n return result;\n}\n\n/**\n * Whether focusing `el` would send focus behind another open modal layer: the topmost open modal\n * layer other than `exceptLayerId` (and its descendants, which close with it) does not contain\n * `el` in its tree. An element inside that modal's tree (for example an opener inside a parent\n * dialog) is reachable and returns `false`. Used to validate focus-restore targets.\n */\nexport function isInsideOtherOpenModal(el: Element, exceptLayerId?: string): boolean {\n const state = getState();\n for (let i = state.stack.length - 1; i >= 0; i--) {\n const layer = state.stack[i];\n if (layer.kind !== 'modal') continue;\n if (exceptLayerId !== undefined) {\n if (layer.id === exceptLayerId || isDescendantOf(state, layer, exceptLayerId)) continue;\n }\n return !isInsideLayerTree(layer.id, el);\n }\n return false;\n}\n\n/**\n * Registers an element (a portal wrapper) as part of the layer `layerId`, so presses and focus\n * inside it count as inside that layer and its ancestors. Returns the unregister function (usable\n * as a React 19 ref-callback cleanup). The layer does not need to be registered yet.\n */\nexport function registerLayerElement(layerId: string, el: HTMLElement): () => void {\n const state = getState();\n let set = state.elements.get(layerId);\n if (!set) {\n set = new Set();\n state.elements.set(layerId, set);\n }\n set.add(el);\n return () => {\n const current = state.elements.get(layerId);\n if (!current) return;\n current.delete(el);\n if (current.size === 0) state.elements.delete(layerId);\n };\n}\n\n/**\n * Registers an open layer and returns its unregister function. `record.order` is set to the next\n * value of the global open-order counter. The layer is placed on top of the stack — or, when some\n * of its descendants registered first (same commit), directly below the earliest of them.\n */\nexport function registerLayer(record: LayerRecord): () => void {\n const state = getState();\n state.counter += 1;\n record.order = state.counter;\n\n const firstDescendant = state.stack.findIndex((layer) => isDescendantOf(state, layer, record.id));\n if (firstDescendant === -1) state.stack.push(record);\n else state.stack.splice(firstDescendant, 0, record);\n\n ensureListeners(state);\n notifySubscribers(state);\n\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n const index = state.stack.indexOf(record);\n if (index !== -1) state.stack.splice(index, 1);\n if (state.press) {\n state.press.layers = state.press.layers.filter((layer) => layer !== record);\n }\n if (state.stack.length === 0) removeListeners(state);\n notifySubscribers(state);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Document listeners\n// ---------------------------------------------------------------------------\n\nfunction getEventTargetNode(event: Event): Node | null {\n const target = event.target as { nodeType?: unknown } | null;\n return target && typeof target.nodeType === 'number' ? (target as Node) : null;\n}\n\n/** Topmost first: descendants before their ancestors. */\nfunction sortTopmostFirst(layers: LayerRecord[]): LayerRecord[] {\n return [...layers].sort((a, b) => compareLayers(b, a));\n}\n\n/**\n * The layer that handles an Escape whose target / focused element is `target` / `active`.\n * Candidates are the escape-enabled layers that are not stacked below the topmost isolating modal\n * (a modal that ignores Escape never lets the key close something inert behind it — its ancestor\n * dialog as much as an older sibling):\n * 1. the innermost layer whose tree contains them (the topmost such layer) is the focus scope;\n * 2. the topmost candidate of that scope's subtree handles it — the scope itself or an open\n * descendant above it (a tooltip or popover opened from the focused dialog closes first, while\n * a sibling of the focused layer is not in its subtree);\n * 3. else the topmost candidate whose tree contains them (an ancestor);\n * 4. else — no layer contains them, or none of the containing layers takes Escape — the global\n * topmost candidate.\n */\nfunction findEscapeHandler(\n state: LayerState,\n target: Node | null,\n active: Element | null,\n): LayerRecord | null {\n const barrier = getIsolationBarrier(state);\n const isCandidate = (layer: LayerRecord) => layer.escape && !isBelowBarrier(layer, barrier);\n const contains = (layer: LayerRecord) =>\n (!!target && isInsideLayerTree(layer.id, target)) ||\n (!!active && isInsideLayerTree(layer.id, active));\n const scope = getTopmostLayer(contains);\n const handler = scope\n ? (getTopmostLayer(\n (layer) =>\n isCandidate(layer) && (layer === scope || isDescendantOf(state, layer, scope.id)),\n ) ?? getTopmostLayer((layer) => isCandidate(layer) && contains(layer)))\n : null;\n return handler ?? getTopmostLayer(isCandidate);\n}\n\n/** Keys that activate the focused control with a synthetic click. */\nfunction isClickActivationKey(key: string): boolean {\n return key === 'Enter' || key === ' ' || key === 'Spacebar';\n}\n\nfunction handleKeyDown(event: KeyboardEvent): void {\n const state = getState();\n if (event.key === 'Escape' || event.key === 'Esc') {\n if (event.defaultPrevented || event.isComposing) return;\n const handler = findEscapeHandler(state, getEventTargetNode(event), document.activeElement);\n if (!handler) return;\n event.preventDefault();\n handler.onDismiss('escape', event);\n return;\n }\n // A keyboard-activated click (Enter/Space) must not dismiss layers recorded by an unrelated\n // earlier pointerdown. Other keys keep the pending press: modifiers held for a Shift/Ctrl+click\n // auto-repeat their keydown while the pointer is down.\n if (isClickActivationKey(event.key)) state.press = null;\n}\n\nfunction handlePointerDown(event: PointerEvent): void {\n const state = getState();\n const target = getEventTargetNode(event);\n // Only a primary press is followed by a click (right/middle buttons fire contextmenu/auxclick).\n if (!target || event.button !== 0) {\n state.press = null;\n return;\n }\n const barrier = getIsolationBarrier(state);\n const layers = state.stack.filter((layer) => {\n const { outsidePress } = layer;\n if (!outsidePress) return false;\n // A layer behind an open isolating modal (its parent dialog, or a dialog below a sibling\n // modal opened from inside it) is inert and not reachable: presses inside that modal, or on\n // its backdrop, are not \"outside\" presses for it.\n if (isBelowBarrier(layer, barrier)) return false;\n if (isInsideLayerTree(layer.id, target)) return false;\n return typeof outsidePress !== 'function' || outsidePress(event) !== false;\n });\n state.press = { layers };\n}\n\n/**\n * How long (ms) a touch, pen or unknown-device press waits for its click after the pointerup. A\n * tap's click follows within about 350 ms (at most the double-tap delay); a press that gets no\n * click (a long press that opened the context menu, a tap on a non-clickable area) is forgotten\n * after this, so a later programmatic `click()` cannot complete it.\n */\nconst GESTURE_CLICK_TIMEOUT_MS = 1000;\n\n/**\n * A mouse click is dispatched right after its pointerup, in the same task. When none follows (the\n * pointer was released over another window or element tree), a mouse press is forgotten on the\n * next macrotask, so a later programmatic `click()` cannot complete it. Touch and stylus taps are\n * turned into a click by a separate gesture event in a later task (Apple Pencil on iPadOS and\n * Android styluses report `pointerType: 'pen'`, and an unknown device type `''` may behave the\n * same way), so every other pointer type keeps its press for {@link GESTURE_CLICK_TIMEOUT_MS}.\n * The next pointerdown, pointercancel, contextmenu or Enter/Space forgets a press earlier.\n */\nfunction handlePointerUp(event: PointerEvent): void {\n const press = getState().press;\n if (!press) return;\n const timeout = event.pointerType === 'mouse' ? 0 : GESTURE_CLICK_TIMEOUT_MS;\n setTimeout(() => {\n const current = getState();\n if (current.press === press) current.press = null;\n }, timeout);\n}\n\n/** A cancelled pointer stream, or a context menu (a long press, a Mac Ctrl+click), gets no click. */\nfunction forgetPress(): void {\n getState().press = null;\n}\n\nfunction handleClick(event: MouseEvent): void {\n const state = getState();\n const press = state.press;\n state.press = null;\n if (!press) return;\n const target = getEventTargetNode(event);\n const toDismiss = press.layers.filter(\n (layer) => !(target && isInsideLayerTree(layer.id, target)),\n );\n for (const layer of sortTopmostFirst(toDismiss)) {\n // An earlier layer's onDismiss may already have unregistered this one.\n if (state.stack.includes(layer)) layer.onDismiss('outside-press', event);\n }\n}\n\nfunction handleFocusIn(event: FocusEvent): void {\n const target = getEventTargetNode(event);\n if (!target) return;\n const candidates = getState().stack.filter(\n (layer) => layer.focusOutside && !isInsideLayerTree(layer.id, target),\n );\n if (candidates.length === 0) return;\n // Not in this dispatch: React applies `autoFocus` in the layout phase of the commit that mounts\n // a surface, before that surface's portal wrapper and dismiss layer register. A field focused\n // as a popover or dialog opens inside the layer is inside its tree once that commit has run.\n queueMicrotask(() => dismissFocusOutside(candidates, target, event));\n}\n\n/**\n * Dismisses each of `candidates` that is still open and whose tree still contains neither the\n * focusin `target` nor the element focused now (focus that came back inside keeps it open; focus\n * lost to `<body>` after leaving does not).\n */\nfunction dismissFocusOutside(candidates: LayerRecord[], target: Node, event: FocusEvent): void {\n const state = getState();\n const active = (target.ownerDocument ?? document).activeElement;\n const toDismiss = candidates.filter(\n (layer) =>\n state.stack.includes(layer) &&\n !isInsideLayerTree(layer.id, target) &&\n !(active && isInsideLayerTree(layer.id, active)),\n );\n for (const layer of sortTopmostFirst(toDismiss)) {\n // An earlier layer's onDismiss may already have unregistered this one.\n if (state.stack.includes(layer)) layer.onDismiss('focus-outside', event);\n }\n}\n\nfunction ensureListeners(state: LayerState): void {\n if (state.listeners || typeof document === 'undefined') return;\n const doc = document;\n doc.addEventListener('keydown', handleKeyDown);\n doc.addEventListener('pointerdown', handlePointerDown, true);\n doc.addEventListener('pointerup', handlePointerUp, true);\n doc.addEventListener('pointercancel', forgetPress, true);\n doc.addEventListener('contextmenu', forgetPress, true);\n doc.addEventListener('click', handleClick);\n doc.addEventListener('focusin', handleFocusIn, true);\n state.listeners = {\n remove() {\n doc.removeEventListener('keydown', handleKeyDown);\n doc.removeEventListener('pointerdown', handlePointerDown, true);\n doc.removeEventListener('pointerup', handlePointerUp, true);\n doc.removeEventListener('pointercancel', forgetPress, true);\n doc.removeEventListener('contextmenu', forgetPress, true);\n doc.removeEventListener('click', handleClick);\n doc.removeEventListener('focusin', handleFocusIn, true);\n },\n };\n}\n\nfunction removeListeners(state: LayerState): void {\n state.listeners?.remove();\n state.listeners = null;\n state.press = null;\n}\n"],"mappings":";;AAcA,IAAaA,IAAU;CACrB,SAAS;CACT,OAAO;CACP,SAAS;AACX,GAuCaC,IAAyB;AA6BtC,SAASC,IAAuB;CAC9B,IAAMC,IAAQC,EAA8B,iBAAiB;EAC3D,OAAO,CAAC;EACR,0BAAU,IAAI,IAAI;EAClB,SAAS;EACT,OAAO;EACP,WAAW;EACX,6BAAa,IAAI,IAAI;EACrB,0BAAU,IAAI,IAAI;CACpB,EAAE;CAIF,OAFA,EAAM,gCAAgB,IAAI,IAAI,GAC9B,EAAM,6BAAa,IAAI,IAAI,GACpBD;AACT;AAEA,SAASE,EAAkB,GAAyB;CAClD,KAAK,IAAMC,KAAc,MAAM,KAAKH,EAAM,WAAW,GAAG,EAAW;AACrE;AAEA,IAAMI,IAAe;AAErB,SAASC,EAAU,GAAmB,GAA4C;CAChF,IAAIC,MAAO,MACX,OAAON,EAAM,MAAM,MAAM,M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BAAoB,eAAeZ,GAAmB,EAAI,GAC9DY,EAAI,oBAAoB,aAAaT,GAAiB,EAAI,GAC1DS,EAAI,oBAAoB,iBAAiBN,GAAa,EAAI,GAC1DM,EAAI,oBAAoB,eAAeN,GAAa,EAAI,GACxDM,EAAI,oBAAoB,SAASL,CAAW,GAC5CK,EAAI,oBAAoB,WAAWH,GAAe,EAAI;CACxD,EACF;AACF;AAEA,SAASvB,EAAgB,GAAyB;CAGhD,AAFAzD,EAAM,WAAW,OAAO,GACxB,EAAM,YAAY,MAClB,EAAM,QAAQ;AAChB"}
@@ -0,0 +1,2 @@
1
+ const e=require("./cn.cjs"),t=require("./composeEventHandlers.cjs"),n=require("./mergeRefs.cjs"),r=require("./aria.cjs");var i=/^on[A-Z]/,a=new Set([`aria-describedby`,`aria-labelledby`]);function o(o,s,c){let l=o??{},u=s??{},d=c?.oursWin??[],f={...l};for(let o of Object.keys(u)){let s=u[o],c=l[o];Object.prototype.hasOwnProperty.call(l,o)&&d.includes(o)||(i.test(o)&&typeof c==`function`&&typeof s==`function`?f[o]=t.composeEventHandlers(s,c):o===`className`?s!==void 0&&(f[o]=e.cn(c,s)):o===`style`?s!==void 0&&(f[o]=c&&typeof c==`object`?{...c,...s}:s):a.has(o)?s!==void 0&&(f[o]=r.joinIds(s,c)):o===`ref`?s!=null&&(f[o]=c==null?s:n.mergeRefs(c,s)):s!==void 0&&(f[o]=s))}return f}exports.mergeProps=o;
2
+ //# sourceMappingURL=mergeProps.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeProps.cjs","names":["composeEventHandlers","cn","joinIds","mergeRefs","require_cn","require_composeEventHandlers","require_mergeRefs","require_aria","HANDLER_KEY","ID_LIST_KEYS","mergeProps","ourProps","ours","theirProps","theirs","oursWin","options","result","key","theirValue","ourValue"],"sources":["../../src/lib/mergeProps.ts"],"sourcesContent":["import type * as React from 'react';\nimport { cn } from './cn';\nimport { composeEventHandlers } from './composeEventHandlers';\nimport { mergeRefs } from './mergeRefs';\nimport { joinIds } from './aria';\n\n/** Options of {@link mergeProps}. */\nexport interface MergePropsOptions {\n /**\n * Keys for which our value is kept whenever `ours` defines the key (even as `undefined`).\n * Triggers pass `['aria-expanded', 'aria-controls', 'aria-haspopup']` so a child's static\n * attribute never overrides live state.\n */\n oursWin?: readonly string[];\n}\n\ntype AnyHandler = (event: { defaultPrevented: boolean }) => void;\ntype UnknownProps = Record<string, unknown>;\n\nconst HANDLER_KEY = /^on[A-Z]/;\nconst ID_LIST_KEYS = new Set(['aria-describedby', 'aria-labelledby']);\n\n/**\n * Merges the props a component wants to put on an element (`ours`) with the props the consumer or\n * a cloned child already has (`theirs`). Pure: returns a new object and never mutates its inputs.\n *\n * - `on*` handlers present on both sides are composed with `composeEventHandlers` (theirs first;\n * ours is skipped when theirs calls `preventDefault()`).\n * - `className` = `cn(ours, theirs)` (theirs win Tailwind conflicts); `style` = `{ ...ours, ...theirs }`.\n * - `aria-describedby` / `aria-labelledby` are joined with `joinIds(theirs, ours)`.\n * - `ref`s are merged with `mergeRefs` (a new callback per call: components that clone on every\n * render use `useTriggerElement`/`useMergedRefs`, which memoise the merged ref).\n * - keys listed in `options.oursWin` keep our value whenever `ours` defines them.\n * - any other key: theirs wins unless it is `undefined`.\n */\nexport function mergeProps<A, B>(ours: A, theirs: B, options?: MergePropsOptions): A & B {\n const ourProps = (ours ?? {}) as UnknownProps;\n const theirProps = (theirs ?? {}) as UnknownProps;\n const oursWin = options?.oursWin ?? [];\n const result: UnknownProps = { ...ourProps };\n\n for (const key of Object.keys(theirProps)) {\n const theirValue = theirProps[key];\n const ourValue = ourProps[key];\n const ourHasKey = Object.prototype.hasOwnProperty.call(ourProps, key);\n\n if (ourHasKey && oursWin.includes(key)) continue;\n\n if (\n HANDLER_KEY.test(key) &&\n typeof ourValue === 'function' &&\n typeof theirValue === 'function'\n ) {\n result[key] = composeEventHandlers(theirValue as AnyHandler, ourValue as AnyHandler);\n } else if (key === 'className') {\n if (theirValue !== undefined) {\n result[key] = cn(ourValue as string | undefined, theirValue as string | undefined);\n }\n } else if (key === 'style') {\n if (theirValue !== undefined) {\n result[key] =\n ourValue && typeof ourValue === 'object'\n ? { ...(ourValue as React.CSSProperties), ...(theirValue as React.CSSProperties) }\n : theirValue;\n }\n } else if (ID_LIST_KEYS.has(key)) {\n if (theirValue !== undefined) {\n result[key] = joinIds(theirValue as string | undefined, ourValue as string | undefined);\n }\n } else if (key === 'ref') {\n if (theirValue != null) {\n result[key] =\n ourValue != null\n ? mergeRefs(ourValue as React.Ref<unknown>, theirValue as React.Ref<unknown>)\n : theirValue;\n }\n } else if (theirValue !== undefined) {\n result[key] = theirValue;\n }\n }\n\n return result as A & B;\n}\n"],"mappings":"yHAmBA,IAAMQ,EAAc,WACdC,EAAe,IAAI,IAAI,CAAC,mBAAoB,iBAAiB,CAAC,EAepE,SAAgBC,EAAiB,EAAS,EAAW,EAAoC,CACvF,IAAMC,EAAYC,GAAQ,CAAC,EACrBC,EAAcC,GAAU,CAAC,EACzBC,EAAUC,GAAS,SAAW,CAAC,EAC/BC,EAAuB,CAAE,GAAGN,CAAS,EAE3C,IAAK,IAAMO,KAAO,OAAO,KAAKL,CAAU,EAAG,CACzC,IAAMM,EAAaN,EAAWK,GACxBE,EAAWT,EAASO,GACR,OAAO,UAAU,eAAe,KAAKP,EAAUO,CAE7D,GAAaH,EAAQ,SAASG,CAAG,IAGnCV,EAAY,KAAKU,CAAG,GACpB,OAAOE,GAAa,YACpB,OAAOD,GAAe,WAEtB,EAAOD,GAAOlB,EAAAA,qBAAqBmB,EAA0BC,CAAsB,EAC1EF,IAAQ,YACbC,IAAe,IAAA,KACjB,EAAOD,GAAOjB,EAAAA,GAAGmB,EAAgCD,CAAgC,GAE1ED,IAAQ,QACbC,IAAe,IAAA,KACjB,EAAOD,GACLE,GAAY,OAAOA,GAAa,SAC5B,CAAE,GAAIA,EAAkC,GAAID,CAAmC,EAC/EA,GAECV,EAAa,IAAIS,CAAG,EACzBC,IAAe,IAAA,KACjB,EAAOD,GAAOhB,EAAAA,QAAQiB,EAAkCC,CAA8B,GAE/EF,IAAQ,MACbC,GAAc,OAChB,EAAOD,GACLE,GAAY,KAERD,EADAhB,EAAAA,UAAUiB,EAAgCD,CAAgC,GAGzEA,IAAe,IAAA,KACxB,EAAOD,GAAOC,GAElB,CAEA,OAAOF,CACT"}
@@ -0,0 +1,21 @@
1
+ import { cn as e } from "./cn.mjs";
2
+ import { composeEventHandlers as t } from "./composeEventHandlers.mjs";
3
+ import { mergeRefs as n } from "./mergeRefs.mjs";
4
+ import { joinIds as r } from "./aria.mjs";
5
+ //#region src/lib/mergeProps.ts
6
+ var i = /^on[A-Z]/, a = /* @__PURE__ */ new Set(["aria-describedby", "aria-labelledby"]);
7
+ function o(o, s, c) {
8
+ let l = o ?? {}, u = s ?? {}, d = c?.oursWin ?? [], f = { ...l };
9
+ for (let o of Object.keys(u)) {
10
+ let s = u[o], c = l[o];
11
+ Object.prototype.hasOwnProperty.call(l, o) && d.includes(o) || (i.test(o) && typeof c == "function" && typeof s == "function" ? f[o] = t(s, c) : o === "className" ? s !== void 0 && (f[o] = e(c, s)) : o === "style" ? s !== void 0 && (f[o] = c && typeof c == "object" ? {
12
+ ...c,
13
+ ...s
14
+ } : s) : a.has(o) ? s !== void 0 && (f[o] = r(s, c)) : o === "ref" ? s != null && (f[o] = c == null ? s : n(c, s)) : s !== void 0 && (f[o] = s));
15
+ }
16
+ return f;
17
+ }
18
+ //#endregion
19
+ export { o as mergeProps };
20
+
21
+ //# sourceMappingURL=mergeProps.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeProps.mjs","names":["HANDLER_KEY","ID_LIST_KEYS","mergeProps","ourProps","ours","theirProps","theirs","oursWin","options","result","key","theirValue","ourValue","composeEventHandlers","cn","joinIds","mergeRefs"],"sources":["../../src/lib/mergeProps.ts"],"sourcesContent":["import type * as React from 'react';\nimport { cn } from './cn';\nimport { composeEventHandlers } from './composeEventHandlers';\nimport { mergeRefs } from './mergeRefs';\nimport { joinIds } from './aria';\n\n/** Options of {@link mergeProps}. */\nexport interface MergePropsOptions {\n /**\n * Keys for which our value is kept whenever `ours` defines the key (even as `undefined`).\n * Triggers pass `['aria-expanded', 'aria-controls', 'aria-haspopup']` so a child's static\n * attribute never overrides live state.\n */\n oursWin?: readonly string[];\n}\n\ntype AnyHandler = (event: { defaultPrevented: boolean }) => void;\ntype UnknownProps = Record<string, unknown>;\n\nconst HANDLER_KEY = /^on[A-Z]/;\nconst ID_LIST_KEYS = new Set(['aria-describedby', 'aria-labelledby']);\n\n/**\n * Merges the props a component wants to put on an element (`ours`) with the props the consumer or\n * a cloned child already has (`theirs`). Pure: returns a new object and never mutates its inputs.\n *\n * - `on*` handlers present on both sides are composed with `composeEventHandlers` (theirs first;\n * ours is skipped when theirs calls `preventDefault()`).\n * - `className` = `cn(ours, theirs)` (theirs win Tailwind conflicts); `style` = `{ ...ours, ...theirs }`.\n * - `aria-describedby` / `aria-labelledby` are joined with `joinIds(theirs, ours)`.\n * - `ref`s are merged with `mergeRefs` (a new callback per call: components that clone on every\n * render use `useTriggerElement`/`useMergedRefs`, which memoise the merged ref).\n * - keys listed in `options.oursWin` keep our value whenever `ours` defines them.\n * - any other key: theirs wins unless it is `undefined`.\n */\nexport function mergeProps<A, B>(ours: A, theirs: B, options?: MergePropsOptions): A & B {\n const ourProps = (ours ?? {}) as UnknownProps;\n const theirProps = (theirs ?? {}) as UnknownProps;\n const oursWin = options?.oursWin ?? [];\n const result: UnknownProps = { ...ourProps };\n\n for (const key of Object.keys(theirProps)) {\n const theirValue = theirProps[key];\n const ourValue = ourProps[key];\n const ourHasKey = Object.prototype.hasOwnProperty.call(ourProps, key);\n\n if (ourHasKey && oursWin.includes(key)) continue;\n\n if (\n HANDLER_KEY.test(key) &&\n typeof ourValue === 'function' &&\n typeof theirValue === 'function'\n ) {\n result[key] = composeEventHandlers(theirValue as AnyHandler, ourValue as AnyHandler);\n } else if (key === 'className') {\n if (theirValue !== undefined) {\n result[key] = cn(ourValue as string | undefined, theirValue as string | undefined);\n }\n } else if (key === 'style') {\n if (theirValue !== undefined) {\n result[key] =\n ourValue && typeof ourValue === 'object'\n ? { ...(ourValue as React.CSSProperties), ...(theirValue as React.CSSProperties) }\n : theirValue;\n }\n } else if (ID_LIST_KEYS.has(key)) {\n if (theirValue !== undefined) {\n result[key] = joinIds(theirValue as string | undefined, ourValue as string | undefined);\n }\n } else if (key === 'ref') {\n if (theirValue != null) {\n result[key] =\n ourValue != null\n ? mergeRefs(ourValue as React.Ref<unknown>, theirValue as React.Ref<unknown>)\n : theirValue;\n }\n } else if (theirValue !== undefined) {\n result[key] = theirValue;\n }\n }\n\n return result as A & B;\n}\n"],"mappings":";;;;;AAmBA,IAAMA,IAAc,YACdC,oBAAe,IAAI,IAAI,CAAC,oBAAoB,iBAAiB,CAAC;AAepE,SAAgBC,EAAiB,GAAS,GAAW,GAAoC;CACvF,IAAMC,IAAYC,KAAQ,CAAC,GACrBC,IAAcC,KAAU,CAAC,GACzBC,IAAUC,GAAS,WAAW,CAAC,GAC/BC,IAAuB,EAAE,GAAGN,EAAS;CAE3C,KAAK,IAAMO,KAAO,OAAO,KAAKL,CAAU,GAAG;EACzC,IAAMM,IAAaN,EAAWK,IACxBE,IAAWT,EAASO;EAG1B,AAFkB,OAAO,UAAU,eAAe,KAAKP,GAAUO,CAE7D,KAAaH,EAAQ,SAASG,CAAG,MAGnCV,EAAY,KAAKU,CAAG,KACpB,OAAOE,KAAa,cACpB,OAAOD,KAAe,aAEtB,EAAOD,KAAOG,EAAqBF,GAA0BC,CAAsB,IAC1EF,MAAQ,cACbC,MAAe,KAAA,MACjB,EAAOD,KAAOI,EAAGF,GAAgCD,CAAgC,KAE1ED,MAAQ,UACbC,MAAe,KAAA,MACjB,EAAOD,KACLE,KAAY,OAAOA,KAAa,WAC5B;GAAE,GAAIA;GAAkC,GAAID;EAAmC,IAC/EA,KAECV,EAAa,IAAIS,CAAG,IACzBC,MAAe,KAAA,MACjB,EAAOD,KAAOK,EAAQJ,GAAkCC,CAA8B,KAE/EF,MAAQ,QACbC,KAAc,SAChB,EAAOD,KACLE,KAAY,OAERD,IADAK,EAAUJ,GAAgCD,CAAgC,KAGzEA,MAAe,KAAA,MACxB,EAAOD,KAAOC;CAElB;CAEA,OAAOF;AACT"}
@@ -0,0 +1,2 @@
1
+ function e(e,t){if(typeof e==`function`){let n=e(t);return typeof n==`function`?n:void 0}e&&(e.current=t)}function t(...t){return n=>{let r=[];for(let i of t){if(!i)continue;let t=e(i,n);t?r.push(t):typeof i==`function`?r.push(()=>{i(null)}):r.push(()=>{e(i,null)})}return()=>{for(let e of r)e()}}}exports.mergeRefs=t,exports.setRef=e;
2
+ //# sourceMappingURL=mergeRefs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeRefs.cjs","names":["setRef","ref","cleanup","value","mergeRefs","refs","cleanups","node"],"sources":["../../src/lib/mergeRefs.ts"],"sourcesContent":["import type * as React from 'react';\n\ntype RefCleanup = () => void;\n\n/**\n * Writes `value` into a ref: calls a callback ref (returning its React 19 cleanup, if any) or\n * assigns `current` on an object ref. `null`/`undefined` refs are ignored.\n */\nexport function setRef<T>(\n ref: React.Ref<T> | undefined | null,\n value: T | null,\n): void | RefCleanup {\n if (typeof ref === 'function') {\n const cleanup: unknown = ref(value);\n return typeof cleanup === 'function' ? (cleanup as RefCleanup) : undefined;\n }\n if (ref) {\n (ref as React.RefObject<T | null>).current = value;\n }\n}\n\n/**\n * Merges several refs into one callback ref (React 19 cleanup-aware).\n *\n * On attach every ref receives the node. The merged callback returns a single cleanup, so React 19\n * calls it on detach instead of calling the ref with `null`; that cleanup runs each callback ref's\n * own cleanup, calls callback refs without a cleanup with `null`, and resets object refs to `null`.\n *\n * The result is a new function on every call: inside components use the `useMergedRefs` hook\n * (also exported from this package), which memoises it, so the refs are not detached and\n * re-attached on every render.\n */\nexport function mergeRefs<T>(\n ...refs: Array<React.Ref<T> | undefined | null>\n): React.RefCallback<T> {\n return (node: T | null) => {\n const cleanups: RefCleanup[] = [];\n for (const ref of refs) {\n if (!ref) continue;\n const cleanup = setRef(ref, node);\n if (cleanup) {\n cleanups.push(cleanup);\n } else if (typeof ref === 'function') {\n cleanups.push(() => {\n ref(null);\n });\n } else {\n cleanups.push(() => {\n setRef(ref, null);\n });\n }\n }\n return () => {\n for (const cleanup of cleanups) cleanup();\n };\n };\n}\n"],"mappings":"AAQA,SAAgBA,EACd,EACA,EACmB,CACnB,GAAI,OAAOC,GAAQ,WAAY,CAC7B,IAAMC,EAAmBD,EAAIE,CAAK,EAClC,OAAO,OAAOD,GAAY,WAAcA,EAAyB,IAAA,EACnE,CACID,IACF,EAAmC,QAAUE,EAEjD,CAaA,SAAgBC,EACd,GAAGC,EACmB,CACtB,MAAQ,IAAmB,CACzB,IAAMC,EAAyB,CAAC,EAChC,IAAK,IAAML,KAAOI,EAAM,CACtB,GAAI,CAACJ,EAAK,SACV,IAAMC,EAAUF,EAAOC,EAAKM,CAAI,EAC5BL,EACFI,EAAS,KAAKJ,CAAO,EACZ,OAAOD,GAAQ,WACxBK,EAAS,SAAW,CAClBL,EAAI,IAAI,CACV,CAAC,EAEDK,EAAS,SAAW,CAClBN,EAAOC,EAAK,IAAI,CAClB,CAAC,CAEL,CACA,UAAa,CACX,IAAK,IAAMC,KAAWI,EAAUJ,EAAQ,CAC1C,CACF,CACF"}
@@ -0,0 +1,29 @@
1
+ //#region src/lib/mergeRefs.ts
2
+ function e(e, t) {
3
+ if (typeof e == "function") {
4
+ let n = e(t);
5
+ return typeof n == "function" ? n : void 0;
6
+ }
7
+ e && (e.current = t);
8
+ }
9
+ function t(...t) {
10
+ return (n) => {
11
+ let r = [];
12
+ for (let i of t) {
13
+ if (!i) continue;
14
+ let t = e(i, n);
15
+ t ? r.push(t) : typeof i == "function" ? r.push(() => {
16
+ i(null);
17
+ }) : r.push(() => {
18
+ e(i, null);
19
+ });
20
+ }
21
+ return () => {
22
+ for (let e of r) e();
23
+ };
24
+ };
25
+ }
26
+ //#endregion
27
+ export { t as mergeRefs, e as setRef };
28
+
29
+ //# sourceMappingURL=mergeRefs.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeRefs.mjs","names":["setRef","ref","cleanup","value","mergeRefs","refs","cleanups","node"],"sources":["../../src/lib/mergeRefs.ts"],"sourcesContent":["import type * as React from 'react';\n\ntype RefCleanup = () => void;\n\n/**\n * Writes `value` into a ref: calls a callback ref (returning its React 19 cleanup, if any) or\n * assigns `current` on an object ref. `null`/`undefined` refs are ignored.\n */\nexport function setRef<T>(\n ref: React.Ref<T> | undefined | null,\n value: T | null,\n): void | RefCleanup {\n if (typeof ref === 'function') {\n const cleanup: unknown = ref(value);\n return typeof cleanup === 'function' ? (cleanup as RefCleanup) : undefined;\n }\n if (ref) {\n (ref as React.RefObject<T | null>).current = value;\n }\n}\n\n/**\n * Merges several refs into one callback ref (React 19 cleanup-aware).\n *\n * On attach every ref receives the node. The merged callback returns a single cleanup, so React 19\n * calls it on detach instead of calling the ref with `null`; that cleanup runs each callback ref's\n * own cleanup, calls callback refs without a cleanup with `null`, and resets object refs to `null`.\n *\n * The result is a new function on every call: inside components use the `useMergedRefs` hook\n * (also exported from this package), which memoises it, so the refs are not detached and\n * re-attached on every render.\n */\nexport function mergeRefs<T>(\n ...refs: Array<React.Ref<T> | undefined | null>\n): React.RefCallback<T> {\n return (node: T | null) => {\n const cleanups: RefCleanup[] = [];\n for (const ref of refs) {\n if (!ref) continue;\n const cleanup = setRef(ref, node);\n if (cleanup) {\n cleanups.push(cleanup);\n } else if (typeof ref === 'function') {\n cleanups.push(() => {\n ref(null);\n });\n } else {\n cleanups.push(() => {\n setRef(ref, null);\n });\n }\n }\n return () => {\n for (const cleanup of cleanups) cleanup();\n };\n };\n}\n"],"mappings":";AAQA,SAAgBA,EACd,GACA,GACmB;CACnB,IAAI,OAAOC,KAAQ,YAAY;EAC7B,IAAMC,IAAmBD,EAAIE,CAAK;EAClC,OAAO,OAAOD,KAAY,aAAcA,IAAyB,KAAA;CACnE;CACA,AAAID,MACF,EAAmC,UAAUE;AAEjD;AAaA,SAAgBC,EACd,GAAGC,GACmB;CACtB,QAAQ,MAAmB;EACzB,IAAMC,IAAyB,CAAC;EAChC,KAAK,IAAML,KAAOI,GAAM;GACtB,IAAI,CAACJ,GAAK;GACV,IAAMC,IAAUF,EAAOC,GAAKM,CAAI;GAChC,AAAIL,IACFI,EAAS,KAAKJ,CAAO,IACZ,OAAOD,KAAQ,aACxBK,EAAS,WAAW;IAClB,EAAI,IAAI;GACV,CAAC,IAEDA,EAAS,WAAW;IAClB,EAAOL,GAAK,IAAI;GAClB,CAAC;EAEL;EACA,aAAa;GACX,KAAK,IAAMC,KAAWI,GAAU,EAAQ;EAC1C;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./dev.cjs"),n=require("./mergeProps.cjs");let r=require("react");r=e.__toESM(r,1);var i=[`aria-expanded`,`aria-controls`,`aria-haspopup`];function a(e){return r.isValidElement(e)&&e.type!==r.Fragment}function o(e){if(!r.isValidElement(e)||e.type!==r.Fragment)return e;let t=e.props.children;return r.isValidElement(t)?o(t):e}function s(e,o,s){if(typeof e==`function`)return e(o);let c=s.asChild!==!1;if(c&&a(e))return r.cloneElement(e,n.mergeProps(o,e.props,{oursWin:i}));c&&e!=null&&typeof e!=`boolean`&&t.warnOnce(`trigger-children:${s.componentName}`,`${s.componentName}: expected a single React element child (not text, a Fragment or several elements); the children are rendered inside a <${s.fallback??`span`}> wrapper instead.`);let l=s.fallback??`span`,u={...o};return l===`button`&&u.type===void 0&&(u.type=`button`),r.createElement(l,u,e)}exports.STATE_ARIA=i,exports.isCloneableElement=a,exports.renderTrigger=s,exports.unwrapFragment=o;
2
+ //# sourceMappingURL=renderTrigger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTrigger.cjs","names":["React","mergeProps","require_runtime","require_dev","require_mergeProps","react","STATE_ARIA","isCloneableElement","node","unwrapFragment","children","inner","renderTrigger","triggerProps","asChild","options","fallback","wrapperProps"],"sources":["../../src/lib/renderTrigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeProps } from './mergeProps';\nimport { warnOnce } from './dev';\n\n/** A trigger's child: a single element (props are merged onto it) or a render function. */\nexport type TriggerChildren<P> = React.ReactElement | ((props: P) => React.ReactNode);\n\n/** Trigger state attributes that always win over a cloned child's own values. */\nexport const STATE_ARIA = ['aria-expanded', 'aria-controls', 'aria-haspopup'] as const;\n\n/** Options of {@link renderTrigger}. */\nexport interface RenderTriggerOptions {\n /** Public name used in development warnings, e.g. `'Popover.Trigger'`. */\n componentName: string;\n /** Wrapper element for `asChild={false}` and for children that cannot be cloned. @default 'span' */\n fallback?: 'span' | 'button';\n /** `false` renders the wrapper element (the 0.4 behaviour) instead of cloning the child. @default true */\n asChild?: boolean;\n}\n\ntype UnknownProps = Record<string, unknown>;\n\n/**\n * Whether a trigger's child can take the trigger props by cloning: a valid element other than a\n * Fragment. Internal (shared by `renderTrigger`, `useTriggerElement` and Tooltip).\n */\nexport function isCloneableElement(node: unknown): node is React.ReactElement<UnknownProps> {\n return React.isValidElement(node) && node.type !== React.Fragment;\n}\n\n/**\n * The element of a single-element Fragment (`<><Button /></>`, children of a conditional\n * expression), unwrapped at any depth; other children as given. Internal (shared by\n * `useTriggerElement` and Tooltip).\n */\nexport function unwrapFragment(children: React.ReactNode): React.ReactNode {\n if (!React.isValidElement(children) || children.type !== React.Fragment) return children;\n const inner = (children.props as { children?: React.ReactNode }).children;\n return React.isValidElement(inner) ? unwrapFragment(inner) : children;\n}\n\n/**\n * Pure core of every trigger (`Dialog.Trigger`, `Popover.Trigger`, `Menu.Trigger`, `.Close`,\n * Tooltip). `useTriggerElement` builds on it and adds the memoised ref and the automatic\n * wrapper fallback.\n *\n * - Function child → `children(triggerProps)`.\n * - `asChild !== false` and a single valid non-Fragment element → the element cloned with\n * `mergeProps(triggerProps, child.props, { oursWin: STATE_ARIA })`: handlers composed (the\n * child's run first), classes/styles merged, refs merged (React 19 keeps `ref` in props), the\n * child's own `id` wins, and live `aria-expanded`/`aria-controls`/`aria-haspopup` always win.\n * - `asChild === false`, or any other child shape (text, Fragment, several elements) → the children\n * rendered inside `fallback` (default `<span>`) carrying the trigger props. The non-element case\n * warns once in development; it never returns `null` and never clones a Fragment.\n *\n * @param children The trigger's children.\n * @param triggerProps Props the trigger puts on its element (ids, state ARIA, handlers, ref).\n * @param options See {@link RenderTriggerOptions}.\n */\nexport function renderTrigger<P>(\n children: TriggerChildren<P> | React.ReactNode,\n triggerProps: P,\n options: RenderTriggerOptions,\n): React.ReactNode {\n if (typeof children === 'function') {\n return (children as (props: P) => React.ReactNode)(triggerProps);\n }\n\n const asChild = options.asChild !== false;\n if (asChild && isCloneableElement(children)) {\n return React.cloneElement(\n children,\n mergeProps(triggerProps, children.props, { oursWin: STATE_ARIA }) as UnknownProps,\n );\n }\n\n const isEmpty = children === null || children === undefined || typeof children === 'boolean';\n if (asChild && !isEmpty) {\n warnOnce(\n `trigger-children:${options.componentName}`,\n `${options.componentName}: expected a single React element child (not text, a Fragment or several elements); the children are rendered inside a <${options.fallback ?? 'span'}> wrapper instead.`,\n );\n }\n\n const fallback = options.fallback ?? 'span';\n const wrapperProps: UnknownProps = { ...(triggerProps as UnknownProps) };\n if (fallback === 'button' && wrapperProps.type === undefined) {\n wrapperProps.type = 'button';\n }\n return React.createElement(fallback, wrapperProps, children as React.ReactNode);\n}\n"],"mappings":"kJAQA,IAAaM,EAAa,CAAC,gBAAiB,gBAAiB,eAAe,EAkB5E,SAAgBC,EAAmB,EAAyD,CAC1F,OAAOP,EAAM,eAAeQ,CAAI,GAAKA,EAAK,OAASR,EAAM,QAC3D,CAOA,SAAgBS,EAAe,EAA4C,CACzE,GAAI,CAACT,EAAM,eAAeU,CAAQ,GAAKA,EAAS,OAASV,EAAM,SAAU,OAAOU,EAChF,IAAMC,EAASD,EAAS,MAAyC,SACjE,OAAOV,EAAM,eAAeW,CAAK,EAAIF,EAAeE,CAAK,EAAID,CAC/D,CAoBA,SAAgBE,EACd,EACA,EACA,EACiB,CACjB,GAAI,OAAOF,GAAa,WACtB,OAAQA,EAA2CG,CAAY,EAGjE,IAAMC,EAAUC,EAAQ,UAAY,GACpC,GAAID,GAAWP,EAAmBG,CAAQ,EACxC,OAAOV,EAAM,aACXU,EACAT,EAAAA,WAAWY,EAAcH,EAAS,MAAO,CAAE,QAASJ,CAAW,CAAC,CAClE,EAIEQ,GADYJ,GAAa,MAAkC,OAAOA,GAAa,WAEjFP,EAAA,SACE,oBAAoBY,EAAQ,gBAC5B,GAAGA,EAAQ,cAAc,0HAA0HA,EAAQ,UAAY,OAAO,mBAChL,EAGF,IAAMC,EAAWD,EAAQ,UAAY,OAC/BE,EAA6B,CAAE,GAAIJ,CAA8B,EAIvE,OAHIG,IAAa,UAAYC,EAAa,OAAS,IAAA,KACjD,EAAa,KAAO,UAEfjB,EAAM,cAAcgB,EAAUC,EAAcP,CAA2B,CAChF"}
@@ -0,0 +1,29 @@
1
+ import { warnOnce as e } from "./dev.mjs";
2
+ import { mergeProps as t } from "./mergeProps.mjs";
3
+ import * as n from "react";
4
+ //#region src/lib/renderTrigger.tsx
5
+ var r = [
6
+ "aria-expanded",
7
+ "aria-controls",
8
+ "aria-haspopup"
9
+ ];
10
+ function i(e) {
11
+ return n.isValidElement(e) && e.type !== n.Fragment;
12
+ }
13
+ function a(e) {
14
+ if (!n.isValidElement(e) || e.type !== n.Fragment) return e;
15
+ let t = e.props.children;
16
+ return n.isValidElement(t) ? a(t) : e;
17
+ }
18
+ function o(a, o, s) {
19
+ if (typeof a == "function") return a(o);
20
+ let c = s.asChild !== !1;
21
+ if (c && i(a)) return n.cloneElement(a, t(o, a.props, { oursWin: r }));
22
+ c && a != null && typeof a != "boolean" && e(`trigger-children:${s.componentName}`, `${s.componentName}: expected a single React element child (not text, a Fragment or several elements); the children are rendered inside a <${s.fallback ?? "span"}> wrapper instead.`);
23
+ let l = s.fallback ?? "span", u = { ...o };
24
+ return l === "button" && u.type === void 0 && (u.type = "button"), n.createElement(l, u, a);
25
+ }
26
+ //#endregion
27
+ export { r as STATE_ARIA, i as isCloneableElement, o as renderTrigger, a as unwrapFragment };
28
+
29
+ //# sourceMappingURL=renderTrigger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderTrigger.mjs","names":["React","STATE_ARIA","isCloneableElement","node","unwrapFragment","children","inner","renderTrigger","triggerProps","asChild","options","mergeProps","warnOnce","fallback","wrapperProps"],"sources":["../../src/lib/renderTrigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeProps } from './mergeProps';\nimport { warnOnce } from './dev';\n\n/** A trigger's child: a single element (props are merged onto it) or a render function. */\nexport type TriggerChildren<P> = React.ReactElement | ((props: P) => React.ReactNode);\n\n/** Trigger state attributes that always win over a cloned child's own values. */\nexport const STATE_ARIA = ['aria-expanded', 'aria-controls', 'aria-haspopup'] as const;\n\n/** Options of {@link renderTrigger}. */\nexport interface RenderTriggerOptions {\n /** Public name used in development warnings, e.g. `'Popover.Trigger'`. */\n componentName: string;\n /** Wrapper element for `asChild={false}` and for children that cannot be cloned. @default 'span' */\n fallback?: 'span' | 'button';\n /** `false` renders the wrapper element (the 0.4 behaviour) instead of cloning the child. @default true */\n asChild?: boolean;\n}\n\ntype UnknownProps = Record<string, unknown>;\n\n/**\n * Whether a trigger's child can take the trigger props by cloning: a valid element other than a\n * Fragment. Internal (shared by `renderTrigger`, `useTriggerElement` and Tooltip).\n */\nexport function isCloneableElement(node: unknown): node is React.ReactElement<UnknownProps> {\n return React.isValidElement(node) && node.type !== React.Fragment;\n}\n\n/**\n * The element of a single-element Fragment (`<><Button /></>`, children of a conditional\n * expression), unwrapped at any depth; other children as given. Internal (shared by\n * `useTriggerElement` and Tooltip).\n */\nexport function unwrapFragment(children: React.ReactNode): React.ReactNode {\n if (!React.isValidElement(children) || children.type !== React.Fragment) return children;\n const inner = (children.props as { children?: React.ReactNode }).children;\n return React.isValidElement(inner) ? unwrapFragment(inner) : children;\n}\n\n/**\n * Pure core of every trigger (`Dialog.Trigger`, `Popover.Trigger`, `Menu.Trigger`, `.Close`,\n * Tooltip). `useTriggerElement` builds on it and adds the memoised ref and the automatic\n * wrapper fallback.\n *\n * - Function child → `children(triggerProps)`.\n * - `asChild !== false` and a single valid non-Fragment element → the element cloned with\n * `mergeProps(triggerProps, child.props, { oursWin: STATE_ARIA })`: handlers composed (the\n * child's run first), classes/styles merged, refs merged (React 19 keeps `ref` in props), the\n * child's own `id` wins, and live `aria-expanded`/`aria-controls`/`aria-haspopup` always win.\n * - `asChild === false`, or any other child shape (text, Fragment, several elements) → the children\n * rendered inside `fallback` (default `<span>`) carrying the trigger props. The non-element case\n * warns once in development; it never returns `null` and never clones a Fragment.\n *\n * @param children The trigger's children.\n * @param triggerProps Props the trigger puts on its element (ids, state ARIA, handlers, ref).\n * @param options See {@link RenderTriggerOptions}.\n */\nexport function renderTrigger<P>(\n children: TriggerChildren<P> | React.ReactNode,\n triggerProps: P,\n options: RenderTriggerOptions,\n): React.ReactNode {\n if (typeof children === 'function') {\n return (children as (props: P) => React.ReactNode)(triggerProps);\n }\n\n const asChild = options.asChild !== false;\n if (asChild && isCloneableElement(children)) {\n return React.cloneElement(\n children,\n mergeProps(triggerProps, children.props, { oursWin: STATE_ARIA }) as UnknownProps,\n );\n }\n\n const isEmpty = children === null || children === undefined || typeof children === 'boolean';\n if (asChild && !isEmpty) {\n warnOnce(\n `trigger-children:${options.componentName}`,\n `${options.componentName}: expected a single React element child (not text, a Fragment or several elements); the children are rendered inside a <${options.fallback ?? 'span'}> wrapper instead.`,\n );\n }\n\n const fallback = options.fallback ?? 'span';\n const wrapperProps: UnknownProps = { ...(triggerProps as UnknownProps) };\n if (fallback === 'button' && wrapperProps.type === undefined) {\n wrapperProps.type = 'button';\n }\n return React.createElement(fallback, wrapperProps, children as React.ReactNode);\n}\n"],"mappings":";;;;AAQA,IAAaC,IAAa;CAAC;CAAiB;CAAiB;AAAe;AAkB5E,SAAgBC,EAAmB,GAAyD;CAC1F,OAAOF,EAAM,eAAeG,CAAI,KAAKA,EAAK,SAASH,EAAM;AAC3D;AAOA,SAAgBI,EAAe,GAA4C;CACzE,IAAI,CAACJ,EAAM,eAAeK,CAAQ,KAAKA,EAAS,SAASL,EAAM,UAAU,OAAOK;CAChF,IAAMC,IAASD,EAAS,MAAyC;CACjE,OAAOL,EAAM,eAAeM,CAAK,IAAIF,EAAeE,CAAK,IAAID;AAC/D;AAoBA,SAAgBE,EACd,GACA,GACA,GACiB;CACjB,IAAI,OAAOF,KAAa,YACtB,OAAQA,EAA2CG,CAAY;CAGjE,IAAMC,IAAUC,EAAQ,YAAY;CACpC,IAAID,KAAWP,EAAmBG,CAAQ,GACxC,OAAOL,EAAM,aACXK,GACAM,EAAWH,GAAcH,EAAS,OAAO,EAAE,SAASJ,EAAW,CAAC,CAClE;CAIF,AAAIQ,KADYJ,KAAa,QAAkC,OAAOA,KAAa,aAEjFO,EACE,oBAAoBF,EAAQ,iBAC5B,GAAGA,EAAQ,cAAc,0HAA0HA,EAAQ,YAAY,OAAO,mBAChL;CAGF,IAAMG,IAAWH,EAAQ,YAAY,QAC/BI,IAA6B,EAAE,GAAIN,EAA8B;CAIvE,OAHIK,MAAa,YAAYC,EAAa,SAAS,KAAA,MACjD,EAAa,OAAO,WAEfd,EAAM,cAAca,GAAUC,GAAcT,CAA2B;AAChF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./cn.cjs"),n=require("./children.cjs"),r=require("./dev.cjs");let i=require("react");i=e.__toESM(i,1);var a=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function o(e){let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null}function s(e){return typeof e!=`object`||!e||i.isValidElement(e)||`$$typeof`in e||Symbol.iterator in e||typeof e.then==`function`?!1:o(e)}function c(e){return typeof e==`string`&&a.has(e)}var l=new WeakMap;function u(e){if(Array.isArray(e)||!(Symbol.iterator in e))return!1;let t=e;return t[Symbol.iterator]()===t}function d(e,t,r){if(e==null||typeof e==`boolean`||e===``)return!1;if(typeof e!=`object`)return!0;if(i.isValidElement(e))return!n.isElementOfType(e,i.Fragment)||d(e.props.children,t,!0);if(!(Symbol.iterator in e)||r&&u(e))return!0;if(t.has(e))return!1;t.add(e);try{for(let n of h(e))if(d(n,t,!0))return!0;return!1}finally{t.delete(e)}}function f(e){return d(e,new Set,!1)}function p(e){return h(e)}function m(e,t){return typeof e!=`string`||a.has(e)?!1:t.dangerouslySetInnerHTML==null&&!f(t.children)}function h(e){if(typeof e==`object`&&e&&u(e)){let t=e,n=l.get(t);return n||(n=Array.from(t),l.set(t,n)),n}return e}function g(e){return typeof e==`string`?`<${e}>`:`a void element`}function _(e,n){return t.cn(e,n)||void 0}function v(e,t,n,a){if(e==null||typeof e==`boolean`)return null;let o=t??`span`,l=a??{};if(s(e)){let{as:t,children:i,className:a,...s}=e,u=t??o,d=h(i);return c(u)&&(f(d)&&r.warnOnce(`slot:void-children:${String(u)}`,`A slot rendered as ${g(u)} cannot have children; its \`children\` were ignored.`),d=void 0),{Component:u,props:{...l,...s,className:_(n,a)},children:d}}if(c(o)){if(i.isValidElement(e)&&e.type!==i.Fragment){let{children:t,className:r,...i}=e.props;return{Component:e.type,props:{...l,...i,className:_(n,r)},children:t}}return i.isValidElement(e)?(f(e)&&r.warnOnce(`slot:void-fragment:${String(o)}`,`A Fragment cannot stand in for ${g(o)} (a void element): it cannot take the slot's className or attributes. Pass the element itself or an object slot instead; the slot was not rendered.`),null):(f(e)&&r.warnOnce(`slot:void-content:${String(o)}`,`Slot content cannot be rendered inside ${g(o)} (a void element). Pass an element or an object slot instead; the slot was not rendered.`),null)}return{Component:o,props:{...l,className:n||void 0},children:h(e)}}function y(e,t,n,r){let a=v(e,t,n,r);if(!a)return null;let{Component:o,props:s,children:c}=a;return c===void 0?i.createElement(o,s):i.createElement(o,s,c)}exports.VOID_ELEMENTS=a,exports.materialiseSlotContent=p,exports.renderSlot=y,exports.resolveSlot=v,exports.slotRendersContent=f,exports.slotWrapsDefaultContent=m;
2
+ //# sourceMappingURL=slot.cjs.map