@sprawlify/primitives 0.0.1

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 (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,496 @@
1
+ const require_dom_query = require('./dom-query-CWZdWUGp.cjs');
2
+ const require_defineProperty = require('./defineProperty-BoUOT9Ie.cjs');
3
+
4
+ //#region src/shared/focus-trap/focus-trap.ts
5
+ const activeFocusTraps = {
6
+ activateTrap(trapStack, trap) {
7
+ if (trapStack.length > 0) {
8
+ const activeTrap = trapStack[trapStack.length - 1];
9
+ if (activeTrap !== trap) activeTrap.pause();
10
+ }
11
+ const trapIndex = trapStack.indexOf(trap);
12
+ if (trapIndex === -1) trapStack.push(trap);
13
+ else {
14
+ trapStack.splice(trapIndex, 1);
15
+ trapStack.push(trap);
16
+ }
17
+ },
18
+ deactivateTrap(trapStack, trap) {
19
+ const trapIndex = trapStack.indexOf(trap);
20
+ if (trapIndex !== -1) trapStack.splice(trapIndex, 1);
21
+ if (trapStack.length > 0) trapStack[trapStack.length - 1].unpause();
22
+ }
23
+ };
24
+ const sharedTrapStack = [];
25
+ var FocusTrap = class {
26
+ addPortalContainer(controlledElement) {
27
+ const portalContainer = controlledElement.parentElement;
28
+ if (portalContainer && !this.portalContainers.has(portalContainer)) {
29
+ this.portalContainers.add(portalContainer);
30
+ if (this.state.active && !this.state.paused) this.observePortalContainer(portalContainer);
31
+ }
32
+ }
33
+ observePortalContainer(portalContainer) {
34
+ this._mutationObserver?.observe(portalContainer, {
35
+ subtree: true,
36
+ childList: true,
37
+ attributes: true,
38
+ attributeFilter: ["aria-controls", "aria-expanded"]
39
+ });
40
+ }
41
+ updatePortalContainers() {
42
+ if (!this.config.followControlledElements) return;
43
+ this.state.containers.forEach((container) => {
44
+ require_dom_query.getControlledElements(container).forEach((controlledElement) => {
45
+ this.addPortalContainer(controlledElement);
46
+ });
47
+ });
48
+ }
49
+ get active() {
50
+ return this.state.active;
51
+ }
52
+ get paused() {
53
+ return this.state.paused;
54
+ }
55
+ constructor(elements, options) {
56
+ require_defineProperty._defineProperty(this, "trapStack", void 0);
57
+ require_defineProperty._defineProperty(this, "config", void 0);
58
+ require_defineProperty._defineProperty(this, "doc", void 0);
59
+ require_defineProperty._defineProperty(this, "state", {
60
+ containers: [],
61
+ containerGroups: [],
62
+ tabbableGroups: [],
63
+ nodeFocusedBeforeActivation: null,
64
+ mostRecentlyFocusedNode: null,
65
+ active: false,
66
+ paused: false,
67
+ delayInitialFocusTimer: void 0,
68
+ recentNavEvent: void 0
69
+ });
70
+ require_defineProperty._defineProperty(this, "portalContainers", /* @__PURE__ */ new Set());
71
+ require_defineProperty._defineProperty(this, "listenerCleanups", []);
72
+ require_defineProperty._defineProperty(this, "handleFocus", (event) => {
73
+ const target = require_dom_query.getEventTarget(event);
74
+ const targetContained = this.findContainerIndex(target, event) >= 0;
75
+ if (targetContained || require_dom_query.isDocument(target)) {
76
+ if (targetContained) this.state.mostRecentlyFocusedNode = target;
77
+ } else {
78
+ event.stopImmediatePropagation();
79
+ let nextNode;
80
+ let navAcrossContainers = true;
81
+ if (this.state.mostRecentlyFocusedNode) {
82
+ if (require_dom_query.getTabIndex(this.state.mostRecentlyFocusedNode) > 0) {
83
+ const mruContainerIdx = this.findContainerIndex(this.state.mostRecentlyFocusedNode);
84
+ const { tabbableNodes } = this.state.containerGroups[mruContainerIdx];
85
+ if (tabbableNodes.length > 0) {
86
+ const mruTabIdx = tabbableNodes.findIndex((node) => node === this.state.mostRecentlyFocusedNode);
87
+ if (mruTabIdx >= 0) {
88
+ if (this.config.isKeyForward(this.state.recentNavEvent)) {
89
+ if (mruTabIdx + 1 < tabbableNodes.length) {
90
+ nextNode = tabbableNodes[mruTabIdx + 1];
91
+ navAcrossContainers = false;
92
+ }
93
+ } else if (mruTabIdx - 1 >= 0) {
94
+ nextNode = tabbableNodes[mruTabIdx - 1];
95
+ navAcrossContainers = false;
96
+ }
97
+ }
98
+ }
99
+ } else if (!this.state.containerGroups.some((g) => g.tabbableNodes.some((n) => require_dom_query.getTabIndex(n) > 0))) navAcrossContainers = false;
100
+ } else navAcrossContainers = false;
101
+ if (navAcrossContainers) nextNode = this.findNextNavNode({
102
+ target: this.state.mostRecentlyFocusedNode,
103
+ isBackward: this.config.isKeyBackward(this.state.recentNavEvent)
104
+ });
105
+ if (nextNode) this.tryFocus(nextNode);
106
+ else this.tryFocus(this.state.mostRecentlyFocusedNode || this.getInitialFocusNode());
107
+ }
108
+ this.state.recentNavEvent = void 0;
109
+ });
110
+ require_defineProperty._defineProperty(this, "handlePointerDown", (event) => {
111
+ const target = require_dom_query.getEventTarget(event);
112
+ if (this.findContainerIndex(target, event) >= 0) return;
113
+ if (valueOrHandler(this.config.clickOutsideDeactivates, event)) {
114
+ this.deactivate({ returnFocus: this.config.returnFocusOnDeactivate });
115
+ return;
116
+ }
117
+ if (valueOrHandler(this.config.allowOutsideClick, event)) return;
118
+ event.preventDefault();
119
+ });
120
+ require_defineProperty._defineProperty(this, "handleClick", (event) => {
121
+ const target = require_dom_query.getEventTarget(event);
122
+ if (this.findContainerIndex(target, event) >= 0) return;
123
+ if (valueOrHandler(this.config.clickOutsideDeactivates, event)) return;
124
+ if (valueOrHandler(this.config.allowOutsideClick, event)) return;
125
+ event.preventDefault();
126
+ event.stopImmediatePropagation();
127
+ });
128
+ require_defineProperty._defineProperty(this, "handleTabKey", (event) => {
129
+ if (this.config.isKeyForward(event) || this.config.isKeyBackward(event)) {
130
+ this.state.recentNavEvent = event;
131
+ const isBackward = this.config.isKeyBackward(event);
132
+ const destinationNode = this.findNextNavNode({
133
+ event,
134
+ isBackward
135
+ });
136
+ if (!destinationNode) return;
137
+ if (isTabEvent(event)) event.preventDefault();
138
+ this.tryFocus(destinationNode);
139
+ }
140
+ });
141
+ require_defineProperty._defineProperty(this, "handleEscapeKey", (event) => {
142
+ if (isEscapeEvent(event) && valueOrHandler(this.config.escapeDeactivates, event) !== false) {
143
+ event.preventDefault();
144
+ this.deactivate();
145
+ }
146
+ });
147
+ require_defineProperty._defineProperty(this, "_mutationObserver", void 0);
148
+ require_defineProperty._defineProperty(this, "setupMutationObserver", () => {
149
+ this._mutationObserver = new (this.doc.defaultView || window).MutationObserver((mutations) => {
150
+ if (mutations.some((mutation) => {
151
+ return Array.from(mutation.removedNodes).some((node) => node === this.state.mostRecentlyFocusedNode);
152
+ })) this.tryFocus(this.getInitialFocusNode());
153
+ if (mutations.some((mutation) => {
154
+ if (mutation.type === "attributes" && (mutation.attributeName === "aria-controls" || mutation.attributeName === "aria-expanded")) return true;
155
+ if (mutation.type === "childList" && mutation.addedNodes.length > 0) return Array.from(mutation.addedNodes).some((node) => {
156
+ if (node.nodeType !== Node.ELEMENT_NODE) return false;
157
+ const element = node;
158
+ if (require_dom_query.hasControllerElements(element)) return true;
159
+ if (element.id && !this.state.containers.some((c) => c.contains(element))) return require_dom_query.isControlledByExpandedController(element);
160
+ return false;
161
+ });
162
+ return false;
163
+ }) && this.state.active && !this.state.paused) {
164
+ this.updateTabbableNodes();
165
+ this.updatePortalContainers();
166
+ }
167
+ });
168
+ });
169
+ require_defineProperty._defineProperty(this, "updateObservedNodes", () => {
170
+ this._mutationObserver?.disconnect();
171
+ if (this.state.active && !this.state.paused) {
172
+ this.state.containers.map((container) => {
173
+ this._mutationObserver?.observe(container, {
174
+ subtree: true,
175
+ childList: true,
176
+ attributes: true,
177
+ attributeFilter: ["aria-controls", "aria-expanded"]
178
+ });
179
+ });
180
+ this.portalContainers.forEach((portalContainer) => {
181
+ this.observePortalContainer(portalContainer);
182
+ });
183
+ }
184
+ });
185
+ require_defineProperty._defineProperty(this, "getInitialFocusNode", () => {
186
+ let node = this.getNodeForOption("initialFocus", { hasFallback: true });
187
+ if (node === false) return false;
188
+ if (node === void 0 || node && !require_dom_query.isFocusable(node)) {
189
+ const activeElement = require_dom_query.getActiveElement(this.doc);
190
+ if (activeElement && this.findContainerIndex(activeElement) >= 0) node = activeElement;
191
+ else {
192
+ const firstTabbableGroup = this.state.tabbableGroups[0];
193
+ node = firstTabbableGroup && firstTabbableGroup.firstTabbableNode || this.getNodeForOption("fallbackFocus");
194
+ }
195
+ } else if (node === null) node = this.getNodeForOption("fallbackFocus");
196
+ if (!node) throw new Error("Your focus-trap needs to have at least one focusable element");
197
+ if (!node.isConnected) node = this.getNodeForOption("fallbackFocus");
198
+ return node;
199
+ });
200
+ require_defineProperty._defineProperty(this, "tryFocus", (node) => {
201
+ if (node === false) return;
202
+ if (node === require_dom_query.getActiveElement(this.doc)) return;
203
+ if (!node || !node.focus) {
204
+ this.tryFocus(this.getInitialFocusNode());
205
+ return;
206
+ }
207
+ node.focus({ preventScroll: !!this.config.preventScroll });
208
+ this.state.mostRecentlyFocusedNode = node;
209
+ if (isSelectableInput(node)) node.select();
210
+ });
211
+ require_defineProperty._defineProperty(this, "deactivate", (deactivateOptions) => {
212
+ if (!this.state.active) return this;
213
+ const options$1 = {
214
+ onDeactivate: this.config.onDeactivate,
215
+ onPostDeactivate: this.config.onPostDeactivate,
216
+ checkCanReturnFocus: this.config.checkCanReturnFocus,
217
+ ...deactivateOptions
218
+ };
219
+ clearTimeout(this.state.delayInitialFocusTimer);
220
+ this.state.delayInitialFocusTimer = void 0;
221
+ this.removeListeners();
222
+ this.state.active = false;
223
+ this.state.paused = false;
224
+ this.updateObservedNodes();
225
+ activeFocusTraps.deactivateTrap(this.trapStack, this);
226
+ this.portalContainers.clear();
227
+ const onDeactivate = this.getOption(options$1, "onDeactivate");
228
+ const onPostDeactivate = this.getOption(options$1, "onPostDeactivate");
229
+ const checkCanReturnFocus = this.getOption(options$1, "checkCanReturnFocus");
230
+ const returnFocus = this.getOption(options$1, "returnFocus", "returnFocusOnDeactivate");
231
+ onDeactivate?.();
232
+ const finishDeactivation = () => {
233
+ delay(() => {
234
+ if (returnFocus) {
235
+ const returnFocusNode = this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);
236
+ this.tryFocus(returnFocusNode);
237
+ }
238
+ onPostDeactivate?.();
239
+ });
240
+ };
241
+ if (returnFocus && checkCanReturnFocus) {
242
+ checkCanReturnFocus(this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
243
+ return this;
244
+ }
245
+ finishDeactivation();
246
+ return this;
247
+ });
248
+ require_defineProperty._defineProperty(this, "pause", (pauseOptions) => {
249
+ if (this.state.paused || !this.state.active) return this;
250
+ const onPause = this.getOption(pauseOptions, "onPause");
251
+ const onPostPause = this.getOption(pauseOptions, "onPostPause");
252
+ this.state.paused = true;
253
+ onPause?.();
254
+ this.removeListeners();
255
+ this.updateObservedNodes();
256
+ onPostPause?.();
257
+ return this;
258
+ });
259
+ require_defineProperty._defineProperty(this, "unpause", (unpauseOptions) => {
260
+ if (!this.state.paused || !this.state.active) return this;
261
+ const onUnpause = this.getOption(unpauseOptions, "onUnpause");
262
+ const onPostUnpause = this.getOption(unpauseOptions, "onPostUnpause");
263
+ this.state.paused = false;
264
+ onUnpause?.();
265
+ this.updateTabbableNodes();
266
+ this.addListeners();
267
+ this.updateObservedNodes();
268
+ onPostUnpause?.();
269
+ return this;
270
+ });
271
+ require_defineProperty._defineProperty(this, "updateContainerElements", (containerElements) => {
272
+ this.state.containers = Array.isArray(containerElements) ? containerElements.filter(Boolean) : [containerElements].filter(Boolean);
273
+ if (this.state.active) this.updateTabbableNodes();
274
+ this.updateObservedNodes();
275
+ return this;
276
+ });
277
+ require_defineProperty._defineProperty(this, "getReturnFocusNode", (previousActiveElement) => {
278
+ const node = this.getNodeForOption("setReturnFocus", { params: [previousActiveElement] });
279
+ return node ? node : node === false ? false : previousActiveElement;
280
+ });
281
+ require_defineProperty._defineProperty(this, "getOption", (configOverrideOptions, optionName, configOptionName) => {
282
+ return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : this.config[configOptionName || optionName];
283
+ });
284
+ require_defineProperty._defineProperty(this, "getNodeForOption", (optionName, { hasFallback = false, params = [] } = {}) => {
285
+ let optionValue = this.config[optionName];
286
+ if (typeof optionValue === "function") optionValue = optionValue(...params);
287
+ if (optionValue === true) optionValue = void 0;
288
+ if (!optionValue) {
289
+ if (optionValue === void 0 || optionValue === false) return optionValue;
290
+ throw new Error(`\`${optionName}\` was specified but was not a node, or did not return a node`);
291
+ }
292
+ let node = optionValue;
293
+ if (typeof optionValue === "string") {
294
+ try {
295
+ node = this.doc.querySelector(optionValue);
296
+ } catch (err) {
297
+ throw new Error(`\`${optionName}\` appears to be an invalid selector; error="${err.message}"`);
298
+ }
299
+ if (!node) {
300
+ if (!hasFallback) throw new Error(`\`${optionName}\` as selector refers to no known node`);
301
+ }
302
+ }
303
+ return node;
304
+ });
305
+ require_defineProperty._defineProperty(this, "findNextNavNode", (opts) => {
306
+ const { event, isBackward = false } = opts;
307
+ const target = opts.target || require_dom_query.getEventTarget(event);
308
+ this.updateTabbableNodes();
309
+ let destinationNode = null;
310
+ if (this.state.tabbableGroups.length > 0) {
311
+ const containerIndex = this.findContainerIndex(target, event);
312
+ const containerGroup = containerIndex >= 0 ? this.state.containerGroups[containerIndex] : void 0;
313
+ if (containerIndex < 0) if (isBackward) destinationNode = this.state.tabbableGroups[this.state.tabbableGroups.length - 1].lastTabbableNode;
314
+ else destinationNode = this.state.tabbableGroups[0].firstTabbableNode;
315
+ else if (isBackward) {
316
+ let startOfGroupIndex = this.state.tabbableGroups.findIndex(({ firstTabbableNode }) => target === firstTabbableNode);
317
+ if (startOfGroupIndex < 0 && (containerGroup?.container === target || require_dom_query.isFocusable(target) && !require_dom_query.isTabbable(target) && !containerGroup?.nextTabbableNode(target, false))) startOfGroupIndex = containerIndex;
318
+ if (startOfGroupIndex >= 0) {
319
+ const destinationGroupIndex = startOfGroupIndex === 0 ? this.state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
320
+ const destinationGroup = this.state.tabbableGroups[destinationGroupIndex];
321
+ destinationNode = require_dom_query.getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
322
+ } else if (!isTabEvent(event)) destinationNode = containerGroup?.nextTabbableNode(target, false);
323
+ } else {
324
+ let lastOfGroupIndex = this.state.tabbableGroups.findIndex(({ lastTabbableNode }) => target === lastTabbableNode);
325
+ if (lastOfGroupIndex < 0 && (containerGroup?.container === target || require_dom_query.isFocusable(target) && !require_dom_query.isTabbable(target) && !containerGroup?.nextTabbableNode(target))) lastOfGroupIndex = containerIndex;
326
+ if (lastOfGroupIndex >= 0) {
327
+ const destinationGroupIndex = lastOfGroupIndex === this.state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
328
+ const destinationGroup = this.state.tabbableGroups[destinationGroupIndex];
329
+ destinationNode = require_dom_query.getTabIndex(target) >= 0 ? destinationGroup.firstTabbableNode : destinationGroup.firstDomTabbableNode;
330
+ } else if (!isTabEvent(event)) destinationNode = containerGroup?.nextTabbableNode(target);
331
+ }
332
+ } else destinationNode = this.getNodeForOption("fallbackFocus");
333
+ return destinationNode;
334
+ });
335
+ this.trapStack = options.trapStack || sharedTrapStack;
336
+ const config = {
337
+ returnFocusOnDeactivate: true,
338
+ escapeDeactivates: true,
339
+ delayInitialFocus: true,
340
+ followControlledElements: true,
341
+ isKeyForward(e) {
342
+ return isTabEvent(e) && !e.shiftKey;
343
+ },
344
+ isKeyBackward(e) {
345
+ return isTabEvent(e) && e.shiftKey;
346
+ },
347
+ ...options
348
+ };
349
+ this.doc = config.document || require_dom_query.getDocument(Array.isArray(elements) ? elements[0] : elements);
350
+ this.config = config;
351
+ this.updateContainerElements(elements);
352
+ this.setupMutationObserver();
353
+ }
354
+ findContainerIndex(element, event) {
355
+ const composedPath = typeof event?.composedPath === "function" ? event.composedPath() : void 0;
356
+ return this.state.containerGroups.findIndex(({ container, tabbableNodes }) => container.contains(element) || composedPath?.includes(container) || tabbableNodes.find((node) => node === element) || this.isControlledElement(container, element));
357
+ }
358
+ isControlledElement(container, element) {
359
+ if (!this.config.followControlledElements) return false;
360
+ return require_dom_query.isControlledElement(container, element);
361
+ }
362
+ updateTabbableNodes() {
363
+ this.state.containerGroups = this.state.containers.map((container) => {
364
+ const tabbableNodes = require_dom_query.getTabbables(container, { getShadowRoot: this.config.getShadowRoot });
365
+ const focusableNodes = require_dom_query.getFocusables(container, { getShadowRoot: this.config.getShadowRoot });
366
+ const firstTabbableNode = tabbableNodes[0];
367
+ const lastTabbableNode = tabbableNodes[tabbableNodes.length - 1];
368
+ const firstDomTabbableNode = firstTabbableNode;
369
+ const lastDomTabbableNode = lastTabbableNode;
370
+ let posTabIndexesFound = false;
371
+ for (let i = 0; i < tabbableNodes.length; i++) if (require_dom_query.getTabIndex(tabbableNodes[i]) > 0) {
372
+ posTabIndexesFound = true;
373
+ break;
374
+ }
375
+ function nextTabbableNode(node, forward = true) {
376
+ const nodeIdx = tabbableNodes.indexOf(node);
377
+ if (nodeIdx >= 0) return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
378
+ const focusableIdx = focusableNodes.indexOf(node);
379
+ if (focusableIdx < 0) return void 0;
380
+ if (forward) {
381
+ for (let i = focusableIdx + 1; i < focusableNodes.length; i++) if (require_dom_query.isTabbable(focusableNodes[i])) return focusableNodes[i];
382
+ } else for (let i = focusableIdx - 1; i >= 0; i--) if (require_dom_query.isTabbable(focusableNodes[i])) return focusableNodes[i];
383
+ }
384
+ return {
385
+ container,
386
+ tabbableNodes,
387
+ focusableNodes,
388
+ posTabIndexesFound,
389
+ firstTabbableNode,
390
+ lastTabbableNode,
391
+ firstDomTabbableNode,
392
+ lastDomTabbableNode,
393
+ nextTabbableNode
394
+ };
395
+ });
396
+ this.state.tabbableGroups = this.state.containerGroups.filter((group) => group.tabbableNodes.length > 0);
397
+ if (this.state.tabbableGroups.length <= 0 && !this.getNodeForOption("fallbackFocus")) throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
398
+ if (this.state.containerGroups.find((g) => g.posTabIndexesFound) && this.state.containerGroups.length > 1) throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
399
+ }
400
+ addListeners() {
401
+ if (!this.state.active) return;
402
+ activeFocusTraps.activateTrap(this.trapStack, this);
403
+ this.state.delayInitialFocusTimer = this.config.delayInitialFocus ? delay(() => {
404
+ this.tryFocus(this.getInitialFocusNode());
405
+ }) : this.tryFocus(this.getInitialFocusNode());
406
+ this.listenerCleanups.push(require_dom_query.addDomEvent(this.doc, "focusin", this.handleFocus, true), require_dom_query.addDomEvent(this.doc, "mousedown", this.handlePointerDown, {
407
+ capture: true,
408
+ passive: false
409
+ }), require_dom_query.addDomEvent(this.doc, "touchstart", this.handlePointerDown, {
410
+ capture: true,
411
+ passive: false
412
+ }), require_dom_query.addDomEvent(this.doc, "click", this.handleClick, {
413
+ capture: true,
414
+ passive: false
415
+ }), require_dom_query.addDomEvent(this.doc, "keydown", this.handleTabKey, {
416
+ capture: true,
417
+ passive: false
418
+ }), require_dom_query.addDomEvent(this.doc, "keydown", this.handleEscapeKey));
419
+ return this;
420
+ }
421
+ removeListeners() {
422
+ if (!this.state.active) return;
423
+ this.listenerCleanups.forEach((cleanup) => cleanup());
424
+ this.listenerCleanups = [];
425
+ return this;
426
+ }
427
+ activate(activateOptions) {
428
+ if (this.state.active) return this;
429
+ const onActivate = this.getOption(activateOptions, "onActivate");
430
+ const onPostActivate = this.getOption(activateOptions, "onPostActivate");
431
+ const checkCanFocusTrap = this.getOption(activateOptions, "checkCanFocusTrap");
432
+ if (!checkCanFocusTrap) this.updateTabbableNodes();
433
+ this.state.active = true;
434
+ this.state.paused = false;
435
+ this.state.nodeFocusedBeforeActivation = require_dom_query.getActiveElement(this.doc);
436
+ onActivate?.();
437
+ const finishActivation = () => {
438
+ if (checkCanFocusTrap) this.updateTabbableNodes();
439
+ this.addListeners();
440
+ this.updateObservedNodes();
441
+ onPostActivate?.();
442
+ };
443
+ if (checkCanFocusTrap) {
444
+ checkCanFocusTrap(this.state.containers.concat()).then(finishActivation, finishActivation);
445
+ return this;
446
+ }
447
+ finishActivation();
448
+ return this;
449
+ }
450
+ };
451
+ const isTabEvent = (event) => event.key === "Tab";
452
+ const valueOrHandler = (value, ...params) => typeof value === "function" ? value(...params) : value;
453
+ const isEscapeEvent = (event) => !event.isComposing && event.key === "Escape";
454
+ const delay = (fn) => setTimeout(fn, 0);
455
+ const isSelectableInput = (node) => node.localName === "input" && "select" in node && typeof node.select === "function";
456
+
457
+ //#endregion
458
+ //#region src/shared/focus-trap/index.ts
459
+ function trapFocus(el, options = {}) {
460
+ let trap;
461
+ const cleanup = require_dom_query.raf(() => {
462
+ const contentEl = typeof el === "function" ? el() : el;
463
+ if (!contentEl) return;
464
+ trap = new FocusTrap(contentEl, {
465
+ escapeDeactivates: false,
466
+ allowOutsideClick: true,
467
+ preventScroll: true,
468
+ returnFocusOnDeactivate: true,
469
+ delayInitialFocus: false,
470
+ fallbackFocus: contentEl,
471
+ ...options,
472
+ document: require_dom_query.getDocument(contentEl)
473
+ });
474
+ try {
475
+ trap.activate();
476
+ } catch {}
477
+ });
478
+ return function destroy() {
479
+ trap?.deactivate();
480
+ cleanup();
481
+ };
482
+ }
483
+
484
+ //#endregion
485
+ Object.defineProperty(exports, 'FocusTrap', {
486
+ enumerable: true,
487
+ get: function () {
488
+ return FocusTrap;
489
+ }
490
+ });
491
+ Object.defineProperty(exports, 'trapFocus', {
492
+ enumerable: true,
493
+ get: function () {
494
+ return trapFocus;
495
+ }
496
+ });
@@ -0,0 +1,5 @@
1
+ require('./dom-query-CWZdWUGp.cjs');
2
+ const require_focus_trap = require('./focus-trap-D4i52S9A.cjs');
3
+
4
+ exports.FocusTrap = require_focus_trap.FocusTrap;
5
+ exports.trapFocus = require_focus_trap.trapFocus;
@@ -0,0 +1,88 @@
1
+ //#region src/shared/focus-trap/types.d.ts
2
+ type FocusableElement = HTMLElement | SVGElement;
3
+ type FocusTargetValue = FocusableElement | string;
4
+ type FocusTargetValueOrFalse = FocusTargetValue | false;
5
+ type FocusTarget = FocusTargetValue | (() => FocusTargetValue);
6
+ type FocusTargetOrFalse = FocusTargetValueOrFalse | (() => FocusTargetValueOrFalse);
7
+ type MouseEventToBoolean = (event: MouseEvent | TouchEvent) => boolean;
8
+ type KeyboardEventToBoolean = (event: KeyboardEvent) => boolean;
9
+ interface FocusTrapOptions {
10
+ onActivate?: VoidFunction | undefined;
11
+ onPostActivate?: VoidFunction | undefined;
12
+ onPause?: VoidFunction | undefined;
13
+ onPostPause?: VoidFunction | undefined;
14
+ onUnpause?: VoidFunction | undefined;
15
+ onPostUnpause?: VoidFunction | undefined;
16
+ checkCanFocusTrap?: ((containers: Array<HTMLElement | SVGElement>) => Promise<void>) | undefined;
17
+ onDeactivate?: VoidFunction | undefined;
18
+ onPostDeactivate?: VoidFunction | undefined;
19
+ checkCanReturnFocus?: ((trigger: HTMLElement | SVGElement) => Promise<void>) | undefined;
20
+ initialFocus?: FocusTargetOrFalse | undefined | VoidFunction;
21
+ fallbackFocus?: FocusTarget | undefined;
22
+ returnFocusOnDeactivate?: boolean | undefined;
23
+ setReturnFocus?: FocusTargetValueOrFalse | ((nodeFocusedBeforeActivation: HTMLElement | SVGElement) => FocusTargetValueOrFalse) | undefined;
24
+ escapeDeactivates?: boolean | KeyboardEventToBoolean | undefined;
25
+ clickOutsideDeactivates?: boolean | MouseEventToBoolean | undefined;
26
+ allowOutsideClick?: boolean | MouseEventToBoolean | undefined;
27
+ preventScroll?: boolean | undefined;
28
+ delayInitialFocus?: boolean | undefined;
29
+ document?: Document | undefined;
30
+ isKeyForward?: KeyboardEventToBoolean | undefined;
31
+ isKeyBackward?: KeyboardEventToBoolean | undefined;
32
+ trapStack?: any[] | undefined;
33
+ followControlledElements?: boolean | undefined;
34
+ getShadowRoot?: boolean | ((node: FocusableElement) => ShadowRoot | boolean | undefined) | undefined;
35
+ }
36
+ interface DeactivateOptions extends Pick<FocusTrapOptions, "onDeactivate" | "onPostDeactivate" | "checkCanReturnFocus"> {
37
+ returnFocus?: boolean | undefined;
38
+ }
39
+ type ActivateOptions = Pick<FocusTrapOptions, "onActivate" | "onPostActivate" | "checkCanFocusTrap">;
40
+ type PauseOptions = Pick<FocusTrapOptions, "onPause" | "onPostPause">;
41
+ type UnpauseOptions = Pick<FocusTrapOptions, "onUnpause" | "onPostUnpause">;
42
+ //#endregion
43
+ //#region src/shared/focus-trap/focus-trap.d.ts
44
+ declare class FocusTrap {
45
+ private trapStack;
46
+ private config;
47
+ private doc;
48
+ private state;
49
+ private portalContainers;
50
+ private addPortalContainer;
51
+ private observePortalContainer;
52
+ private updatePortalContainers;
53
+ get active(): boolean;
54
+ get paused(): boolean;
55
+ constructor(elements: HTMLElement | HTMLElement[], options: FocusTrapOptions);
56
+ private findContainerIndex;
57
+ private isControlledElement;
58
+ private updateTabbableNodes;
59
+ private listenerCleanups;
60
+ private addListeners;
61
+ private removeListeners;
62
+ private handleFocus;
63
+ private handlePointerDown;
64
+ private handleClick;
65
+ private handleTabKey;
66
+ private handleEscapeKey;
67
+ private _mutationObserver?;
68
+ private setupMutationObserver;
69
+ private updateObservedNodes;
70
+ private getInitialFocusNode;
71
+ private tryFocus;
72
+ activate(activateOptions?: ActivateOptions): this;
73
+ deactivate: (deactivateOptions?: DeactivateOptions) => this;
74
+ pause: (pauseOptions?: PauseOptions) => this;
75
+ unpause: (unpauseOptions?: UnpauseOptions) => this;
76
+ updateContainerElements: (containerElements: HTMLElement | HTMLElement[]) => this;
77
+ private getReturnFocusNode;
78
+ private getOption;
79
+ private getNodeForOption;
80
+ private findNextNavNode;
81
+ }
82
+ //#endregion
83
+ //#region src/shared/focus-trap/index.d.ts
84
+ type ElementOrGetter = HTMLElement | null | (() => HTMLElement | null);
85
+ interface TrapFocusOptions extends Omit<FocusTrapOptions, "document"> {}
86
+ declare function trapFocus(el: ElementOrGetter, options?: TrapFocusOptions): () => void;
87
+ //#endregion
88
+ export { FocusTrap, type FocusTrapOptions, TrapFocusOptions, trapFocus };
@@ -0,0 +1,88 @@
1
+ //#region src/shared/focus-trap/types.d.ts
2
+ type FocusableElement = HTMLElement | SVGElement;
3
+ type FocusTargetValue = FocusableElement | string;
4
+ type FocusTargetValueOrFalse = FocusTargetValue | false;
5
+ type FocusTarget = FocusTargetValue | (() => FocusTargetValue);
6
+ type FocusTargetOrFalse = FocusTargetValueOrFalse | (() => FocusTargetValueOrFalse);
7
+ type MouseEventToBoolean = (event: MouseEvent | TouchEvent) => boolean;
8
+ type KeyboardEventToBoolean = (event: KeyboardEvent) => boolean;
9
+ interface FocusTrapOptions {
10
+ onActivate?: VoidFunction | undefined;
11
+ onPostActivate?: VoidFunction | undefined;
12
+ onPause?: VoidFunction | undefined;
13
+ onPostPause?: VoidFunction | undefined;
14
+ onUnpause?: VoidFunction | undefined;
15
+ onPostUnpause?: VoidFunction | undefined;
16
+ checkCanFocusTrap?: ((containers: Array<HTMLElement | SVGElement>) => Promise<void>) | undefined;
17
+ onDeactivate?: VoidFunction | undefined;
18
+ onPostDeactivate?: VoidFunction | undefined;
19
+ checkCanReturnFocus?: ((trigger: HTMLElement | SVGElement) => Promise<void>) | undefined;
20
+ initialFocus?: FocusTargetOrFalse | undefined | VoidFunction;
21
+ fallbackFocus?: FocusTarget | undefined;
22
+ returnFocusOnDeactivate?: boolean | undefined;
23
+ setReturnFocus?: FocusTargetValueOrFalse | ((nodeFocusedBeforeActivation: HTMLElement | SVGElement) => FocusTargetValueOrFalse) | undefined;
24
+ escapeDeactivates?: boolean | KeyboardEventToBoolean | undefined;
25
+ clickOutsideDeactivates?: boolean | MouseEventToBoolean | undefined;
26
+ allowOutsideClick?: boolean | MouseEventToBoolean | undefined;
27
+ preventScroll?: boolean | undefined;
28
+ delayInitialFocus?: boolean | undefined;
29
+ document?: Document | undefined;
30
+ isKeyForward?: KeyboardEventToBoolean | undefined;
31
+ isKeyBackward?: KeyboardEventToBoolean | undefined;
32
+ trapStack?: any[] | undefined;
33
+ followControlledElements?: boolean | undefined;
34
+ getShadowRoot?: boolean | ((node: FocusableElement) => ShadowRoot | boolean | undefined) | undefined;
35
+ }
36
+ interface DeactivateOptions extends Pick<FocusTrapOptions, "onDeactivate" | "onPostDeactivate" | "checkCanReturnFocus"> {
37
+ returnFocus?: boolean | undefined;
38
+ }
39
+ type ActivateOptions = Pick<FocusTrapOptions, "onActivate" | "onPostActivate" | "checkCanFocusTrap">;
40
+ type PauseOptions = Pick<FocusTrapOptions, "onPause" | "onPostPause">;
41
+ type UnpauseOptions = Pick<FocusTrapOptions, "onUnpause" | "onPostUnpause">;
42
+ //#endregion
43
+ //#region src/shared/focus-trap/focus-trap.d.ts
44
+ declare class FocusTrap {
45
+ private trapStack;
46
+ private config;
47
+ private doc;
48
+ private state;
49
+ private portalContainers;
50
+ private addPortalContainer;
51
+ private observePortalContainer;
52
+ private updatePortalContainers;
53
+ get active(): boolean;
54
+ get paused(): boolean;
55
+ constructor(elements: HTMLElement | HTMLElement[], options: FocusTrapOptions);
56
+ private findContainerIndex;
57
+ private isControlledElement;
58
+ private updateTabbableNodes;
59
+ private listenerCleanups;
60
+ private addListeners;
61
+ private removeListeners;
62
+ private handleFocus;
63
+ private handlePointerDown;
64
+ private handleClick;
65
+ private handleTabKey;
66
+ private handleEscapeKey;
67
+ private _mutationObserver?;
68
+ private setupMutationObserver;
69
+ private updateObservedNodes;
70
+ private getInitialFocusNode;
71
+ private tryFocus;
72
+ activate(activateOptions?: ActivateOptions): this;
73
+ deactivate: (deactivateOptions?: DeactivateOptions) => this;
74
+ pause: (pauseOptions?: PauseOptions) => this;
75
+ unpause: (unpauseOptions?: UnpauseOptions) => this;
76
+ updateContainerElements: (containerElements: HTMLElement | HTMLElement[]) => this;
77
+ private getReturnFocusNode;
78
+ private getOption;
79
+ private getNodeForOption;
80
+ private findNextNavNode;
81
+ }
82
+ //#endregion
83
+ //#region src/shared/focus-trap/index.d.ts
84
+ type ElementOrGetter = HTMLElement | null | (() => HTMLElement | null);
85
+ interface TrapFocusOptions extends Omit<FocusTrapOptions, "document"> {}
86
+ declare function trapFocus(el: ElementOrGetter, options?: TrapFocusOptions): () => void;
87
+ //#endregion
88
+ export { FocusTrap, type FocusTrapOptions, TrapFocusOptions, trapFocus };
@@ -0,0 +1,4 @@
1
+ import "./dom-query-DFCRhyj1.mjs";
2
+ import { n as FocusTrap, t as trapFocus } from "./focus-trap-D-bypQEJ.mjs";
3
+
4
+ export { FocusTrap, trapFocus };