@content-blocks/js 0.7.6 → 0.8.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 (380) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +111 -3
  3. package/THIRD-PARTY-NOTICES.md +21 -0
  4. package/dist/cjs/{app-globals-3a1e7e63.js → app-globals-V2Kpy_OQ.js} +0 -2
  5. package/dist/cjs/content-accordion.cjs.entry.js +87 -0
  6. package/dist/cjs/content-blocks.cjs.js +35 -11
  7. package/dist/cjs/content-button.cjs.entry.js +113 -0
  8. package/dist/cjs/content-carousel.cjs.entry.js +153 -47
  9. package/dist/cjs/content-grid-formatter.cjs.entry.js +102 -0
  10. package/dist/cjs/content-hero-block.cjs.entry.js +45 -0
  11. package/dist/cjs/content-image.cjs.entry.js +153 -0
  12. package/dist/cjs/content-line.cjs.entry.js +61 -0
  13. package/dist/cjs/content-navigation-block.cjs.entry.js +51 -34
  14. package/dist/cjs/content-overlay.cjs.entry.js +641 -0
  15. package/dist/cjs/content-spacer.cjs.entry.js +75 -0
  16. package/dist/cjs/content-split-block.cjs.entry.js +22 -19
  17. package/dist/cjs/content-tabs.cjs.entry.js +38 -21
  18. package/dist/cjs/content-text-block.cjs.entry.js +63 -0
  19. package/dist/cjs/content-tout-block.cjs.entry.js +34 -0
  20. package/dist/cjs/{content-accordion_11.cjs.entry.js → content-video.cjs.entry.js} +14560 -12927
  21. package/dist/cjs/{focus-trap.esm-7bc384a0.js → focus-trap.esm-ZwN-anf1.js} +484 -190
  22. package/dist/cjs/{index-2e0ce692.js → index-B1U6Gweq.js} +348 -246
  23. package/dist/cjs/index-ClnpH9XB.js +2170 -0
  24. package/dist/cjs/index-CyalvZJn.js +1719 -0
  25. package/dist/cjs/index-DUvWvBDN.js +290 -0
  26. package/dist/cjs/index-voGY4Tkl.js +4705 -0
  27. package/dist/cjs/index.cjs.js +2 -5
  28. package/dist/cjs/loader.cjs.js +3 -8
  29. package/dist/cjs/responsive-component-C5eJS82z.js +171 -0
  30. package/dist/cjs/responsive-component-DMdnQIPV.js +171 -0
  31. package/dist/cjs/swiper-KLYbvU1K.js +3931 -0
  32. package/dist/cjs/{swiper-8221f4e8.js → swiper-_Z8Y4IJI.js} +269 -236
  33. package/dist/cjs/utils-BCHaRGm_.js +462 -0
  34. package/dist/cjs/{utils-df044337.js → utils-C3gXIS2t.js} +51 -49
  35. package/dist/cjs/utils-DUvWvBDN.js +290 -0
  36. package/dist/collection/blocks/content-hero-block/content-hero-block.css +1 -1
  37. package/dist/collection/blocks/content-hero-block/content-hero-block.js +33 -48
  38. package/dist/collection/blocks/content-split-block/content-split-block.css +16 -5
  39. package/dist/collection/blocks/content-split-block/content-split-block.js +29 -48
  40. package/dist/collection/blocks/content-text-block/content-text-block.js +65 -59
  41. package/dist/collection/blocks/content-tout-block/content-tout-block.css +3 -0
  42. package/dist/collection/blocks/content-tout-block/content-tout-block.js +22 -47
  43. package/dist/collection/collection-manifest.json +8 -5
  44. package/dist/collection/components/content-accordion/content-accordion.css +20 -1
  45. package/dist/collection/components/content-accordion/content-accordion.js +67 -33
  46. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js +0 -1
  47. package/dist/collection/components/content-carousel/content-carousel.css +60 -4
  48. package/dist/collection/components/content-carousel/content-carousel.js +294 -44
  49. package/dist/collection/components/content-navigation-block/content-navigation-block.css +15 -1
  50. package/dist/collection/components/content-navigation-block/content-navigation-block.js +86 -42
  51. package/dist/collection/components/content-overlay/content-overlay.css +36 -5
  52. package/dist/collection/components/content-overlay/content-overlay.js +181 -120
  53. package/dist/collection/components/content-overlay/libraries/aria-dialog.js +0 -1
  54. package/dist/collection/components/content-overlay/libraries/aria-utilities.js +0 -1
  55. package/dist/collection/components/content-tabs/content-tabs.js +7 -49
  56. package/dist/collection/components/content-tabs/libraries/w3_tabs.js +0 -1
  57. package/dist/collection/elements/content-button/content-button.css +8 -7
  58. package/dist/collection/elements/content-button/content-button.js +103 -84
  59. package/dist/collection/elements/content-image/content-image.css +3 -1
  60. package/dist/collection/elements/content-image/content-image.js +176 -95
  61. package/dist/collection/elements/content-line/content-line.js +63 -54
  62. package/dist/collection/elements/content-video/content-video.css +1 -1
  63. package/dist/collection/elements/content-video/content-video.js +165 -92
  64. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +8 -2
  65. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +167 -89
  66. package/dist/collection/formatters/content-spacer/content-spacer.js +86 -209
  67. package/dist/collection/global/content-blocks-reset.css +77 -0
  68. package/dist/collection/index.js +1 -1
  69. package/dist/collection/sass/_mixins.scss +21 -5
  70. package/dist/collection/sass/_variables.scss +15 -15
  71. package/dist/collection/setupFiles.js +0 -1
  72. package/dist/collection/site/site.js +67 -0
  73. package/dist/collection/utils/breakpoints.js +162 -0
  74. package/dist/collection/utils/responsive-component.js +249 -0
  75. package/dist/collection/utils/utils.js +32 -42
  76. package/dist/components/content-accordion.js +65 -44
  77. package/dist/components/content-button.js +89 -43
  78. package/dist/components/content-carousel.js +172 -55
  79. package/dist/components/content-grid-formatter.js +127 -3
  80. package/dist/components/content-hero-block.js +33 -26
  81. package/dist/components/content-image.js +127 -71
  82. package/dist/components/content-line.js +56 -35
  83. package/dist/components/content-navigation-block.js +62 -39
  84. package/dist/components/content-overlay.js +128 -67
  85. package/dist/components/content-spacer.js +70 -54
  86. package/dist/components/content-split-block.js +33 -32
  87. package/dist/components/content-tabs.js +46 -25
  88. package/dist/components/content-text-block.js +55 -35
  89. package/dist/components/content-tout-block.js +29 -27
  90. package/dist/components/content-video.js +14624 -11972
  91. package/dist/{esm/focus-trap.esm-8fb54175.js → components/focus-trap.esm.js} +484 -190
  92. package/dist/components/index.d.ts +2 -0
  93. package/dist/components/index.js +3 -3
  94. package/dist/components/{p-5a91aa1b.js → index2.js} +348 -246
  95. package/dist/components/p-BWRCeMvO.js +1 -0
  96. package/dist/components/p-CYF5GU_q.js +1 -0
  97. package/dist/components/p-DXUoPIwl.js +10 -0
  98. package/dist/components/p-D_Ll4QNj.js +1 -0
  99. package/dist/components/p-DhIoW7H3.js +1 -0
  100. package/dist/components/responsive-component.js +168 -0
  101. package/dist/components/{p-e5dc4ea4.js → swiper.js} +268 -235
  102. package/dist/components/utils.js +4969 -0
  103. package/dist/{esm/utils-1c9f0ec1.js → components/utils2.js} +51 -50
  104. package/dist/content-blocks/content-accordion.entry.js +85 -0
  105. package/dist/content-blocks/content-blocks.esm.js +47 -2
  106. package/dist/content-blocks/content-button.entry.js +111 -0
  107. package/dist/content-blocks/content-carousel.entry.js +188 -0
  108. package/dist/content-blocks/content-grid-formatter.entry.js +100 -0
  109. package/dist/content-blocks/content-hero-block.entry.js +43 -0
  110. package/dist/content-blocks/content-image.entry.js +151 -0
  111. package/dist/content-blocks/content-line.entry.js +59 -0
  112. package/dist/content-blocks/content-navigation-block.entry.js +105 -0
  113. package/dist/content-blocks/content-overlay.entry.js +639 -0
  114. package/dist/content-blocks/content-spacer.entry.js +73 -0
  115. package/dist/content-blocks/content-split-block.entry.js +34 -0
  116. package/dist/content-blocks/content-tabs.entry.js +245 -0
  117. package/dist/content-blocks/content-text-block.entry.js +61 -0
  118. package/dist/content-blocks/content-tout-block.entry.js +32 -0
  119. package/dist/{esm/content-accordion_11.entry.js → content-blocks/content-video.entry.js} +14535 -12890
  120. package/dist/{components/p-a2fedf8a.js → content-blocks/focus-trap.esm-DXUoPIwl.js} +484 -190
  121. package/dist/content-blocks/global/content-blocks-reset.css +77 -0
  122. package/dist/content-blocks/index-BFDJMblF.js +4690 -0
  123. package/dist/{esm/index-f45a9c45.js → content-blocks/index-P1YnSd-O.js} +348 -246
  124. package/dist/content-blocks/index.esm.js +1 -2
  125. package/dist/content-blocks/p-008457f0.entry.js +1 -0
  126. package/dist/content-blocks/p-052692f1.entry.js +1 -0
  127. package/dist/content-blocks/p-0f71bd32.entry.js +1 -0
  128. package/dist/content-blocks/p-1f154617.entry.js +1 -0
  129. package/dist/content-blocks/p-2554ebd8.entry.js +1 -0
  130. package/dist/content-blocks/p-4afd6511.entry.js +1 -0
  131. package/dist/content-blocks/p-78d5de9f.entry.js +1 -0
  132. package/dist/content-blocks/p-7bcf7e7e.entry.js +1 -0
  133. package/dist/content-blocks/p-9058031c.entry.js +1 -0
  134. package/dist/content-blocks/p-9c41ac23.entry.js +17 -0
  135. package/dist/content-blocks/p-CLwOzPEO.js +3 -0
  136. package/dist/content-blocks/p-CYF5GU_q.js +1 -0
  137. package/dist/content-blocks/p-CjR_4mPu.js +1 -0
  138. package/dist/content-blocks/p-DQuL1Twl.js +1 -0
  139. package/dist/content-blocks/p-DXUoPIwl.js +10 -0
  140. package/dist/content-blocks/p-D_Ll4QNj.js +1 -0
  141. package/dist/content-blocks/p-DhIoW7H3.js +1 -0
  142. package/dist/content-blocks/p-DzYwy_62.js +1 -0
  143. package/dist/content-blocks/p-b2e6358a.entry.js +1 -0
  144. package/dist/content-blocks/p-c783bc68.entry.js +1 -0
  145. package/dist/content-blocks/p-e3d81e15.entry.js +1 -0
  146. package/dist/content-blocks/p-f23b4aae.entry.js +1 -0
  147. package/dist/content-blocks/p-f75c9094.entry.js +1 -0
  148. package/dist/content-blocks/responsive-component-BsLrcKbS.js +169 -0
  149. package/dist/content-blocks/sass/_mixins.scss +21 -5
  150. package/dist/content-blocks/sass/_variables.scss +15 -15
  151. package/dist/{esm/swiper-e9621adb.js → content-blocks/swiper-nBv069TB.js} +268 -235
  152. package/dist/{components/p-b85cfa86.js → content-blocks/utils--SDsQnWS.js} +51 -50
  153. package/dist/content-blocks/utils-Bak__24s.js +280 -0
  154. package/dist/docs.d.ts +480 -0
  155. package/dist/docs.json +5312 -0
  156. package/dist/esm/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -2
  157. package/dist/esm/content-accordion.entry.js +85 -0
  158. package/dist/esm/content-blocks.js +33 -8
  159. package/dist/esm/content-button.entry.js +111 -0
  160. package/dist/esm/content-carousel.entry.js +153 -45
  161. package/dist/esm/content-grid-formatter.entry.js +100 -0
  162. package/dist/esm/content-hero-block.entry.js +43 -0
  163. package/dist/esm/content-image.entry.js +151 -0
  164. package/dist/esm/content-line.entry.js +59 -0
  165. package/dist/esm/content-navigation-block.entry.js +51 -32
  166. package/dist/esm/content-overlay.entry.js +639 -0
  167. package/dist/esm/content-spacer.entry.js +73 -0
  168. package/dist/esm/content-split-block.entry.js +22 -17
  169. package/dist/esm/content-tabs.entry.js +38 -19
  170. package/dist/esm/content-text-block.entry.js +61 -0
  171. package/dist/esm/content-tout-block.entry.js +32 -0
  172. package/dist/esm/content-video.entry.js +72033 -0
  173. package/dist/esm/focus-trap.esm-DXUoPIwl.js +1801 -0
  174. package/dist/esm/index-BASCLGuP.js +1713 -0
  175. package/dist/esm/index-BFDJMblF.js +4690 -0
  176. package/dist/esm/index-CLwOzPEO.js +2161 -0
  177. package/dist/esm/index-CjR_4mPu.js +280 -0
  178. package/dist/esm/index-P1YnSd-O.js +5397 -0
  179. package/dist/esm/index.js +1 -3
  180. package/dist/esm/loader.js +3 -6
  181. package/dist/esm/responsive-component-BsLrcKbS.js +169 -0
  182. package/dist/esm/responsive-component-D7dJHMp0.js +169 -0
  183. package/dist/esm/swiper-CtypHPwF.js +3928 -0
  184. package/dist/esm/swiper-nBv069TB.js +3941 -0
  185. package/dist/esm/utils--SDsQnWS.js +460 -0
  186. package/dist/esm/utils-Bak__24s.js +280 -0
  187. package/dist/esm/utils-CYF5GU_q.js +438 -0
  188. package/dist/node_modules/video.js/dist/video-js.min.css +1 -0
  189. package/dist/test/axe.js +60 -0
  190. package/dist/types/Users/shahrukceo/Developer/content-blocks/packages/js/.stencil/test/axe.d.ts +16 -0
  191. package/dist/types/blocks/content-hero-block/content-hero-block.d.ts +7 -11
  192. package/dist/types/blocks/content-split-block/content-split-block.d.ts +5 -9
  193. package/dist/types/blocks/content-text-block/content-text-block.d.ts +4 -9
  194. package/dist/types/blocks/content-tout-block/content-tout-block.d.ts +5 -10
  195. package/dist/types/components/content-accordion/content-accordion.d.ts +4 -3
  196. package/dist/types/components/content-accordion/libraries/w3_disclosure_button.d.ts +0 -1
  197. package/dist/types/components/content-carousel/content-carousel.d.ts +44 -7
  198. package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +14 -8
  199. package/dist/types/components/content-overlay/content-overlay.d.ts +15 -16
  200. package/dist/types/components/content-overlay/libraries/aria-dialog.d.ts +0 -1
  201. package/dist/types/components/content-overlay/libraries/aria-utilities.d.ts +0 -1
  202. package/dist/types/components/content-tabs/content-tabs.d.ts +4 -10
  203. package/dist/types/components/content-tabs/libraries/w3_tabs.d.ts +0 -1
  204. package/dist/types/components.d.ts +900 -196
  205. package/dist/types/elements/content-button/content-button.d.ts +8 -13
  206. package/dist/types/elements/content-image/content-image.d.ts +15 -9
  207. package/dist/types/elements/content-line/content-line.d.ts +5 -12
  208. package/dist/types/elements/content-video/content-video.d.ts +12 -11
  209. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +14 -9
  210. package/dist/types/formatters/content-spacer/content-spacer.d.ts +4 -36
  211. package/dist/types/index.d.ts +3 -1
  212. package/dist/types/setupFiles.d.ts +0 -1
  213. package/dist/types/stencil-public-runtime.d.ts +265 -60
  214. package/dist/types/typings.d.ts +10 -0
  215. package/dist/types/utils/breakpoints.d.ts +57 -0
  216. package/dist/types/utils/responsive-component.d.ts +49 -0
  217. package/dist/types/utils/utils.d.ts +11 -8
  218. package/loader/cdn.js +1 -0
  219. package/loader/index.cjs.js +1 -0
  220. package/loader/index.d.ts +24 -0
  221. package/loader/index.es2017.js +1 -0
  222. package/loader/index.js +2 -0
  223. package/package.json +75 -65
  224. package/dist/cjs/BehaviorSubject-12116537.js +0 -655
  225. package/dist/cjs/BehaviorSubject-12116537.js.map +0 -1
  226. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  227. package/dist/cjs/content-accordion_11.cjs.entry.js.map +0 -1
  228. package/dist/cjs/content-blocks.cjs.js.map +0 -1
  229. package/dist/cjs/content-carousel.cjs.entry.js.map +0 -1
  230. package/dist/cjs/content-navigation-block.cjs.entry.js.map +0 -1
  231. package/dist/cjs/content-split-block.cjs.entry.js.map +0 -1
  232. package/dist/cjs/content-tabs.cjs.entry.js.map +0 -1
  233. package/dist/cjs/focus-trap.esm-7bc384a0.js.map +0 -1
  234. package/dist/cjs/index-2e0ce692.js.map +0 -1
  235. package/dist/cjs/index-8af2820a.js +0 -1650
  236. package/dist/cjs/index-8af2820a.js.map +0 -1
  237. package/dist/cjs/index.cjs.js.map +0 -1
  238. package/dist/cjs/loader.cjs.js.map +0 -1
  239. package/dist/cjs/swiper-8221f4e8.js.map +0 -1
  240. package/dist/cjs/utils-df044337.js.map +0 -1
  241. package/dist/cjs/utils-f8ccab0a.js +0 -126
  242. package/dist/cjs/utils-f8ccab0a.js.map +0 -1
  243. package/dist/cjs/window-resize-service-65a5a370.js +0 -37
  244. package/dist/cjs/window-resize-service-65a5a370.js.map +0 -1
  245. package/dist/collection/blocks/content-hero-block/content-hero-block.js.map +0 -1
  246. package/dist/collection/blocks/content-split-block/content-split-block.js.map +0 -1
  247. package/dist/collection/blocks/content-text-block/content-text-block.js.map +0 -1
  248. package/dist/collection/blocks/content-tout-block/content-tout-block.js.map +0 -1
  249. package/dist/collection/components/content-accordion/content-accordion.js.map +0 -1
  250. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js.map +0 -1
  251. package/dist/collection/components/content-carousel/content-carousel.js.map +0 -1
  252. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +0 -1
  253. package/dist/collection/components/content-overlay/content-overlay.js.map +0 -1
  254. package/dist/collection/components/content-overlay/libraries/aria-dialog.js.map +0 -1
  255. package/dist/collection/components/content-overlay/libraries/aria-utilities.js.map +0 -1
  256. package/dist/collection/components/content-tabs/content-tabs.js.map +0 -1
  257. package/dist/collection/components/content-tabs/libraries/w3_tabs.js.map +0 -1
  258. package/dist/collection/elements/content-button/content-button.js.map +0 -1
  259. package/dist/collection/elements/content-image/content-image.js.map +0 -1
  260. package/dist/collection/elements/content-line/content-line.js.map +0 -1
  261. package/dist/collection/elements/content-video/content-video.js.map +0 -1
  262. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +0 -1
  263. package/dist/collection/formatters/content-spacer/content-spacer.js.map +0 -1
  264. package/dist/collection/globalScript.js +0 -15
  265. package/dist/collection/globalScript.js.map +0 -1
  266. package/dist/collection/index.js.map +0 -1
  267. package/dist/collection/services/content-events-service.js +0 -23
  268. package/dist/collection/services/content-events-service.js.map +0 -1
  269. package/dist/collection/services/window-resize-service.js +0 -31
  270. package/dist/collection/services/window-resize-service.js.map +0 -1
  271. package/dist/collection/setupFiles.js.map +0 -1
  272. package/dist/collection/stories/ContentHeroBlock.stories.js +0 -51
  273. package/dist/collection/stories/ContentHeroBlock.stories.js.map +0 -1
  274. package/dist/collection/stories/ContentNavigationBlock.stories.js +0 -33
  275. package/dist/collection/stories/ContentNavigationBlock.stories.js.map +0 -1
  276. package/dist/collection/stories/ContentSpacer.stories.js +0 -20
  277. package/dist/collection/stories/ContentSpacer.stories.js.map +0 -1
  278. package/dist/collection/stories/ContentTextBlock.stories.js +0 -17
  279. package/dist/collection/stories/ContentTextBlock.stories.js.map +0 -1
  280. package/dist/collection/stories/ContentToutBlock.stories.js +0 -17
  281. package/dist/collection/stories/ContentToutBlock.stories.js.map +0 -1
  282. package/dist/collection/stories/FullPageExample.stories.js +0 -432
  283. package/dist/collection/stories/FullPageExample.stories.js.map +0 -1
  284. package/dist/collection/stories/assets/accessibility.svg +0 -5
  285. package/dist/collection/stories/assets/discord.svg +0 -15
  286. package/dist/collection/stories/assets/github.svg +0 -3
  287. package/dist/collection/stories/assets/tutorials.svg +0 -12
  288. package/dist/collection/stories/assets/youtube.svg +0 -4
  289. package/dist/collection/utils/utils.js.map +0 -1
  290. package/dist/components/content-accordion.js.map +0 -1
  291. package/dist/components/content-button.js.map +0 -1
  292. package/dist/components/content-carousel.js.map +0 -1
  293. package/dist/components/content-grid-formatter.js.map +0 -1
  294. package/dist/components/content-hero-block.js.map +0 -1
  295. package/dist/components/content-image.js.map +0 -1
  296. package/dist/components/content-line.js.map +0 -1
  297. package/dist/components/content-navigation-block.js.map +0 -1
  298. package/dist/components/content-overlay.js.map +0 -1
  299. package/dist/components/content-spacer.js.map +0 -1
  300. package/dist/components/content-split-block.js.map +0 -1
  301. package/dist/components/content-tabs.js.map +0 -1
  302. package/dist/components/content-text-block.js.map +0 -1
  303. package/dist/components/content-tout-block.js.map +0 -1
  304. package/dist/components/content-video.js.map +0 -1
  305. package/dist/components/index.js.map +0 -1
  306. package/dist/components/p-26483b46.js +0 -35
  307. package/dist/components/p-26483b46.js.map +0 -1
  308. package/dist/components/p-5a91aa1b.js.map +0 -1
  309. package/dist/components/p-74be971f.js +0 -652
  310. package/dist/components/p-74be971f.js.map +0 -1
  311. package/dist/components/p-7a436263.js +0 -122
  312. package/dist/components/p-7a436263.js.map +0 -1
  313. package/dist/components/p-a2fedf8a.js.map +0 -1
  314. package/dist/components/p-b85cfa86.js.map +0 -1
  315. package/dist/components/p-e28db040.js +0 -1452
  316. package/dist/components/p-e28db040.js.map +0 -1
  317. package/dist/components/p-e5dc4ea4.js.map +0 -1
  318. package/dist/components/p-e9bce2ab.js +0 -88
  319. package/dist/components/p-e9bce2ab.js.map +0 -1
  320. package/dist/content-blocks/content-blocks.esm.js.map +0 -1
  321. package/dist/content-blocks/index.esm.js.map +0 -1
  322. package/dist/content-blocks/p-13c3cc4f.js +0 -3
  323. package/dist/content-blocks/p-13c3cc4f.js.map +0 -1
  324. package/dist/content-blocks/p-5422c25b.entry.js +0 -2
  325. package/dist/content-blocks/p-5422c25b.entry.js.map +0 -1
  326. package/dist/content-blocks/p-5a91aa1b.js +0 -2
  327. package/dist/content-blocks/p-5a91aa1b.js.map +0 -1
  328. package/dist/content-blocks/p-650d1757.js +0 -2
  329. package/dist/content-blocks/p-650d1757.js.map +0 -1
  330. package/dist/content-blocks/p-74be971f.js +0 -2
  331. package/dist/content-blocks/p-74be971f.js.map +0 -1
  332. package/dist/content-blocks/p-8deb755c.entry.js +0 -26
  333. package/dist/content-blocks/p-8deb755c.entry.js.map +0 -1
  334. package/dist/content-blocks/p-a2fedf8a.js +0 -10
  335. package/dist/content-blocks/p-a2fedf8a.js.map +0 -1
  336. package/dist/content-blocks/p-b305392e.entry.js +0 -2
  337. package/dist/content-blocks/p-b305392e.entry.js.map +0 -1
  338. package/dist/content-blocks/p-b85cfa86.js +0 -2
  339. package/dist/content-blocks/p-b85cfa86.js.map +0 -1
  340. package/dist/content-blocks/p-cc7397cf.js +0 -2
  341. package/dist/content-blocks/p-cc7397cf.js.map +0 -1
  342. package/dist/content-blocks/p-d62775d7.entry.js +0 -2
  343. package/dist/content-blocks/p-d62775d7.entry.js.map +0 -1
  344. package/dist/content-blocks/p-e1255160.js +0 -2
  345. package/dist/content-blocks/p-e1255160.js.map +0 -1
  346. package/dist/content-blocks/p-e5dc4ea4.js +0 -2
  347. package/dist/content-blocks/p-e5dc4ea4.js.map +0 -1
  348. package/dist/content-blocks/p-f73f934a.entry.js +0 -2
  349. package/dist/content-blocks/p-f73f934a.entry.js.map +0 -1
  350. package/dist/esm/BehaviorSubject-f7a12fd8.js +0 -652
  351. package/dist/esm/BehaviorSubject-f7a12fd8.js.map +0 -1
  352. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  353. package/dist/esm/content-accordion_11.entry.js.map +0 -1
  354. package/dist/esm/content-blocks.js.map +0 -1
  355. package/dist/esm/content-carousel.entry.js.map +0 -1
  356. package/dist/esm/content-navigation-block.entry.js.map +0 -1
  357. package/dist/esm/content-split-block.entry.js.map +0 -1
  358. package/dist/esm/content-tabs.entry.js.map +0 -1
  359. package/dist/esm/focus-trap.esm-8fb54175.js.map +0 -1
  360. package/dist/esm/index-ec24af7a.js +0 -1621
  361. package/dist/esm/index-ec24af7a.js.map +0 -1
  362. package/dist/esm/index-f45a9c45.js.map +0 -1
  363. package/dist/esm/index.js.map +0 -1
  364. package/dist/esm/loader.js.map +0 -1
  365. package/dist/esm/swiper-e9621adb.js.map +0 -1
  366. package/dist/esm/utils-1c9f0ec1.js.map +0 -1
  367. package/dist/esm/utils-9a901aa9.js +0 -122
  368. package/dist/esm/utils-9a901aa9.js.map +0 -1
  369. package/dist/esm/window-resize-service-354f2ac5.js +0 -35
  370. package/dist/esm/window-resize-service-354f2ac5.js.map +0 -1
  371. package/dist/types/globalScript.d.ts +0 -1
  372. package/dist/types/old-components.d.ts +0 -1239
  373. package/dist/types/services/content-events-service.d.ts +0 -11
  374. package/dist/types/services/window-resize-service.d.ts +0 -11
  375. package/dist/types/stories/ContentHeroBlock.stories.d.ts +0 -11
  376. package/dist/types/stories/ContentNavigationBlock.stories.d.ts +0 -9
  377. package/dist/types/stories/ContentSpacer.stories.d.ts +0 -15
  378. package/dist/types/stories/ContentTextBlock.stories.d.ts +0 -9
  379. package/dist/types/stories/ContentToutBlock.stories.d.ts +0 -9
  380. package/dist/types/stories/FullPageExample.stories.d.ts +0 -10
@@ -0,0 +1,1801 @@
1
+ /*!
2
+ * tabbable 6.5.1
3
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
4
+ */
5
+ // NOTE: separate `:not()` selectors has broader browser support than the newer
6
+ // `:not([inert], [inert] *)` (Feb 2023)
7
+ var candidateSelectors = ['input:not([inert]):not([inert] *)', 'select:not([inert]):not([inert] *)', 'textarea:not([inert]):not([inert] *)', 'a[href]:not([inert]):not([inert] *)', 'area[href]:not([inert]):not([inert] *)', 'button:not([inert]):not([inert] *)', '[tabindex]:not(slot):not([inert]):not([inert] *)', 'audio[controls]:not([inert]):not([inert] *)', 'video[controls]:not([inert]):not([inert] *)', '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', 'details>summary:first-of-type:not([inert]):not([inert] *)', 'details:not([inert]):not([inert] *)'];
8
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
9
+ var NoElement = typeof Element === 'undefined';
10
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
11
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
12
+ return element == null || element.getRootNode == null ? void 0 : element.getRootNode();
13
+ } : function (element) {
14
+ return element == null ? void 0 : element.ownerDocument;
15
+ };
16
+
17
+ /**
18
+ * Determines if a node is inert or in an inert ancestor.
19
+ * @param {Node} [node]
20
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
21
+ * see if any of them are inert. If false, only `node` itself is considered.
22
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
23
+ * False if `node` is falsy.
24
+ */
25
+ var _isInert = function isInert(node, lookUp) {
26
+ if (lookUp === void 0) {
27
+ lookUp = true;
28
+ }
29
+ // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
30
+ // JS API property; we have to check the attribute, which can either be empty or 'true';
31
+ // if it's `null` (not specified) or 'false', it's an active element
32
+ var inertAtt = node == null || node.getAttribute == null ? void 0 : node.getAttribute('inert');
33
+ var inert = inertAtt === '' || inertAtt === 'true';
34
+
35
+ // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
36
+ // if it weren't for `matches()` not being a function on shadow roots; the following
37
+ // code works for any kind of node
38
+ var result = inert || lookUp && node && (
39
+ // closest does not exist on shadow roots, so we fall back to a manual
40
+ // lookup upward, in case it is not defined.
41
+ typeof node.closest === 'function' ? node.closest('[inert]') : _isInert(node.parentNode));
42
+ return result;
43
+ };
44
+
45
+ /**
46
+ * Determines if a node's content is editable.
47
+ * @param {Element} [node]
48
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
49
+ */
50
+ var isContentEditable = function isContentEditable(node) {
51
+ var _node$getAttribute;
52
+ // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
53
+ // to use the case-insensitive attribute directly: empty, 'true', and 'plaintext-only'
54
+ // are editable states; `null` (not specified) and 'false' are not.
55
+ var attValue = node == null || node.getAttribute == null || (_node$getAttribute = node.getAttribute('contenteditable')) == null ? void 0 : _node$getAttribute.toLowerCase();
56
+ return attValue === '' || attValue === 'true' || attValue === 'plaintext-only';
57
+ };
58
+
59
+ /**
60
+ * @param {Element} el container to check in
61
+ * @param {boolean} includeContainer add container to check
62
+ * @param {(node: Element) => boolean} filter filter candidates
63
+ * @returns {Element[]}
64
+ */
65
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
66
+ // even if `includeContainer=false`, we still have to check it for inertness because
67
+ // if it's inert (either by itself or via its parent), then all its children are inert
68
+ if (_isInert(el)) {
69
+ return [];
70
+ }
71
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
72
+ if (includeContainer && matches.call(el, candidateSelector)) {
73
+ candidates.unshift(el);
74
+ }
75
+ candidates = candidates.filter(filter);
76
+ return candidates;
77
+ };
78
+
79
+ /**
80
+ * @callback GetShadowRoot
81
+ * @param {Element} element to check for shadow root
82
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
83
+ */
84
+
85
+ /**
86
+ * @callback ShadowRootFilter
87
+ * @param {Element} shadowHostNode the element which contains shadow content
88
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
89
+ */
90
+
91
+ /**
92
+ * @typedef {Object} CandidateScope
93
+ * @property {Element} scopeParent contains inner candidates
94
+ * @property {Element[]} candidates list of candidates found in the scope parent
95
+ */
96
+
97
+ /**
98
+ * @typedef {Object} IterativeOptions
99
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
100
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
101
+ * or a boolean stating if it has an undisclosed shadow root
102
+ * @property {(node: Element) => boolean} filter filter candidates
103
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
104
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
105
+ */
106
+
107
+ /**
108
+ * @param {Element[]} elements list of element containers to match candidates from
109
+ * @param {boolean} includeContainer add container list to check
110
+ * @param {IterativeOptions} options
111
+ * @returns {Array.<Element|CandidateScope>}
112
+ */
113
+ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
114
+ var candidates = [];
115
+ var elementsToCheck = Array.from(elements);
116
+ while (elementsToCheck.length) {
117
+ var element = elementsToCheck.shift();
118
+ if (_isInert(element, false)) {
119
+ // no need to look up since we're drilling down
120
+ // anything inside this container will also be inert
121
+ continue;
122
+ }
123
+ if (element.tagName === 'SLOT') {
124
+ // add shadow dom slot scope (slot itself cannot be focusable)
125
+ var assigned = element.assignedElements();
126
+ var content = assigned.length ? assigned : element.children;
127
+ var nestedCandidates = _getCandidatesIteratively(content, true, options);
128
+ if (options.flatten) {
129
+ candidates.push.apply(candidates, nestedCandidates);
130
+ } else {
131
+ candidates.push({
132
+ scopeParent: element,
133
+ candidates: nestedCandidates
134
+ });
135
+ }
136
+ } else {
137
+ // check candidate element
138
+ var validCandidate = matches.call(element, candidateSelector);
139
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
140
+ candidates.push(element);
141
+ }
142
+
143
+ // iterate over shadow content if possible
144
+ var shadowRoot = element.shadowRoot ||
145
+ // check for an undisclosed shadow
146
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
147
+
148
+ // no inert look up because we're already drilling down and checking for inertness
149
+ // on the way down, so all containers to this root node should have already been
150
+ // vetted as non-inert
151
+ var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
152
+ if (shadowRoot && validShadowRoot) {
153
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
154
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
155
+ // child candidates found because they're likely slotted elements (elements that are
156
+ // children of the web component element (which has the shadow), in the light dom, but
157
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
158
+ // _after_ we return from this recursive call
159
+ var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
160
+ if (options.flatten) {
161
+ candidates.push.apply(candidates, _nestedCandidates);
162
+ } else {
163
+ candidates.push({
164
+ scopeParent: element,
165
+ candidates: _nestedCandidates
166
+ });
167
+ }
168
+ } else {
169
+ // there's not shadow so just dig into the element's (light dom) children
170
+ // __without__ giving the element special scope treatment
171
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
172
+ }
173
+ }
174
+ }
175
+ return candidates;
176
+ };
177
+
178
+ /**
179
+ * @private
180
+ * Determines if the node has an explicitly specified `tabindex` attribute.
181
+ * @param {HTMLElement} node
182
+ * @returns {boolean} True if so; false if not.
183
+ */
184
+ var hasTabIndex = function hasTabIndex(node) {
185
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
186
+ };
187
+
188
+ /**
189
+ * Determine the tab index of a given node.
190
+ * @param {HTMLElement} node
191
+ * @returns {number} Tab order (negative, 0, or positive number).
192
+ * @throws {Error} If `node` is falsy.
193
+ */
194
+ var getTabIndex = function getTabIndex(node) {
195
+ if (!node) {
196
+ throw new Error('No node provided');
197
+ }
198
+ if (node.tabIndex < 0) {
199
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
200
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
201
+ // yet they are still part of the regular tab order; in FF, they get a default
202
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
203
+ // order, consider their tab index to be 0.
204
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
205
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
206
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
207
+ return 0;
208
+ }
209
+ }
210
+ return node.tabIndex;
211
+ };
212
+
213
+ /**
214
+ * Determine the tab index of a given node __for sort order purposes__.
215
+ * @param {HTMLElement} node
216
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
217
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
218
+ * inserted into the correct sort position.
219
+ * @returns {number} Tab order (negative, 0, or positive number).
220
+ */
221
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
222
+ var tabIndex = getTabIndex(node);
223
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
224
+ return 0;
225
+ }
226
+ return tabIndex;
227
+ };
228
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
229
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
230
+ };
231
+ var isInput = function isInput(node) {
232
+ return node.tagName === 'INPUT';
233
+ };
234
+ var isHiddenInput = function isHiddenInput(node) {
235
+ return isInput(node) && node.type === 'hidden';
236
+ };
237
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
238
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
239
+ return child.tagName === 'SUMMARY';
240
+ });
241
+ return r;
242
+ };
243
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
244
+ for (var i = 0; i < nodes.length; i++) {
245
+ if (nodes[i].checked && nodes[i].form === form) {
246
+ return nodes[i];
247
+ }
248
+ }
249
+ };
250
+ var isTabbableRadio = function isTabbableRadio(node) {
251
+ if (!node.name) {
252
+ return true;
253
+ }
254
+ var radioScope = node.form || getRootNode(node);
255
+ var queryRadios = function queryRadios(name) {
256
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
257
+ };
258
+ var radioSet;
259
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
260
+ radioSet = queryRadios(window.CSS.escape(node.name));
261
+ } else {
262
+ try {
263
+ radioSet = queryRadios(node.name);
264
+ } catch (err) {
265
+ // eslint-disable-next-line no-console
266
+ console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
267
+ return false;
268
+ }
269
+ }
270
+ var checked = getCheckedRadio(radioSet, node.form);
271
+ return !checked || checked === node;
272
+ };
273
+ var isRadio = function isRadio(node) {
274
+ return isInput(node) && node.type === 'radio';
275
+ };
276
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
277
+ return isRadio(node) && !isTabbableRadio(node);
278
+ };
279
+
280
+ // determines if a node is ultimately attached to the window's document
281
+ var isNodeAttached = function isNodeAttached(node) {
282
+ var _nodeRoot;
283
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
284
+ // (but NOT _the_ document; see second 'If' comment below for more).
285
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
286
+ // is attached, and the one we need to check if it's in the document or not (because the
287
+ // shadow, and all nodes it contains, is never considered in the document since shadows
288
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
289
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
290
+ // visibility, including all the nodes it contains). The host could be any normal node,
291
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
292
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
293
+ // tested).
294
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
295
+ // that is attached (or find none) because the node might be in nested shadows...
296
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
297
+ // document (per the docs) and while it's a Document-type object, that document does not
298
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
299
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
300
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
301
+ // node is actually detached.
302
+ // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
303
+ // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
304
+ // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
305
+ // `ownerDocument` will be `null`, hence the optional chaining on it.
306
+ var nodeRoot = node && getRootNode(node);
307
+ var nodeRootHost = (_nodeRoot = nodeRoot) == null ? void 0 : _nodeRoot.host;
308
+
309
+ // in some cases, a detached node will return itself as the root instead of a document or
310
+ // shadow root object, in which case, we shouldn't try to look further up the host chain
311
+ var attached = false;
312
+ if (nodeRoot && nodeRoot !== node) {
313
+ var _nodeRootHost, _node$ownerDocument;
314
+ attached = !!((_nodeRootHost = nodeRootHost) != null && (_nodeRootHost = _nodeRootHost.ownerDocument) != null && _nodeRootHost.contains(nodeRootHost) || node != null && (_node$ownerDocument = node.ownerDocument) != null && _node$ownerDocument.contains(node));
315
+ while (!attached && nodeRootHost) {
316
+ var _nodeRoot2, _nodeRootHost2;
317
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
318
+ // which means we need to get the host's host and check if that parent host is contained
319
+ // in (i.e. attached to) the document
320
+ nodeRoot = getRootNode(nodeRootHost);
321
+ nodeRootHost = (_nodeRoot2 = nodeRoot) == null ? void 0 : _nodeRoot2.host;
322
+ attached = !!((_nodeRootHost2 = nodeRootHost) != null && (_nodeRootHost2 = _nodeRootHost2.ownerDocument) != null && _nodeRootHost2.contains(nodeRootHost));
323
+ }
324
+ }
325
+ return attached;
326
+ };
327
+ var isZeroArea = function isZeroArea(node) {
328
+ var _node$getBoundingClie = node.getBoundingClientRect(),
329
+ width = _node$getBoundingClie.width,
330
+ height = _node$getBoundingClie.height;
331
+ return width === 0 && height === 0;
332
+ };
333
+ var isHidden = function isHidden(node, _ref) {
334
+ var displayCheck = _ref.displayCheck,
335
+ getShadowRoot = _ref.getShadowRoot;
336
+ if (displayCheck === 'full-native') {
337
+ if ('checkVisibility' in node) {
338
+ // Chrome >= 105, Edge >= 105, Firefox >= 106, Safari >= 17.4
339
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility
340
+ var visible = node.checkVisibility({
341
+ // Checking opacity might be desirable for some use cases, but natively,
342
+ // opacity zero elements _are_ focusable and tabbable.
343
+ checkOpacity: false,
344
+ opacityProperty: false,
345
+ contentVisibilityAuto: true,
346
+ visibilityProperty: true,
347
+ // This is an alias for `visibilityProperty`. Contemporary browsers
348
+ // support both. However, this alias has wider browser support (Chrome
349
+ // >= 105 and Firefox >= 106, vs. Chrome >= 121 and Firefox >= 122), so
350
+ // we include it anyway.
351
+ checkVisibilityCSS: true
352
+ });
353
+ return !visible;
354
+ }
355
+ // Fall through to manual visibility checks
356
+ }
357
+
358
+ // NOTE: visibility will be `undefined` if node is detached from the document
359
+ // (see notes about this further down), which means we will consider it visible
360
+ // (this is legacy behavior from a very long way back)
361
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
362
+ // _visibility_ check, not a _display_ check
363
+ var _getComputedStyle = getComputedStyle(node),
364
+ visibility = _getComputedStyle.visibility;
365
+ if (visibility === 'hidden' || visibility === 'collapse') {
366
+ return true;
367
+ }
368
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
369
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
370
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
371
+ return true;
372
+ }
373
+ if (!displayCheck || displayCheck === 'full' ||
374
+ // full-native can run this branch when it falls through in case
375
+ // Element#checkVisibility is unsupported
376
+ displayCheck === 'full-native' || displayCheck === 'legacy-full') {
377
+ if (typeof getShadowRoot === 'function') {
378
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
379
+ // 'non-zero-area' fallback
380
+ var originalNode = node;
381
+ while (node) {
382
+ var parentElement = node.parentElement;
383
+ var rootNode = getRootNode(node);
384
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
385
+ ) {
386
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
387
+ // fall back to a non-zero-area test
388
+ return isZeroArea(node);
389
+ } else if (node.assignedSlot) {
390
+ // iterate up slot
391
+ node = node.assignedSlot;
392
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
393
+ // cross shadow boundary
394
+ node = rootNode.host;
395
+ } else {
396
+ // iterate up normal dom
397
+ node = parentElement;
398
+ }
399
+ }
400
+ node = originalNode;
401
+ }
402
+ // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
403
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
404
+ // it might be a falsy value, which means shadow DOM support is disabled
405
+
406
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
407
+ // now we can just test to see if it would normally be visible or not, provided it's
408
+ // attached to the main document.
409
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
410
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
411
+
412
+ if (isNodeAttached(node)) {
413
+ // this works wherever the node is: if there's at least one client rect, it's
414
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
415
+ // node itself is hidden in place of its contents; and there's no need to search
416
+ // up the hierarchy either
417
+ return !node.getClientRects().length;
418
+ }
419
+
420
+ // Else, the node isn't attached to the document, which means the `getClientRects()`
421
+ // API will __always__ return zero rects (this can happen, for example, if React
422
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
423
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
424
+ //
425
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
426
+ // because styles are only computed for nodes that are in the document.
427
+ //
428
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
429
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
430
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
431
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
432
+ // considering __everything__ to be visible because of the innability to determine styles.
433
+ //
434
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
435
+ // nodes as visible with the 'none' fallback.__
436
+ if (displayCheck !== 'legacy-full') {
437
+ return true; // hidden
438
+ }
439
+ // else, fallback to 'none' mode and consider the node visible
440
+ } else if (displayCheck === 'non-zero-area') {
441
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
442
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
443
+ // client rect, we don't special-case for whether the node is attached or not. In
444
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
445
+ // times, and that includes attached or not.
446
+ return isZeroArea(node);
447
+ }
448
+
449
+ // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
450
+ // it's visible
451
+ return false;
452
+ };
453
+
454
+ // form fields (nested) inside a disabled fieldset are not focusable/tabbable
455
+ // unless they are in the _first_ <legend> element of the top-most disabled
456
+ // fieldset
457
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
458
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
459
+ var parentNode = node.parentElement;
460
+ // check if `node` is contained in a disabled <fieldset>
461
+ while (parentNode) {
462
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
463
+ // look for the first <legend> among the children of the disabled <fieldset>
464
+ for (var i = 0; i < parentNode.children.length; i++) {
465
+ var child = parentNode.children.item(i);
466
+ // when the first <legend> (in document order) is found
467
+ if (child.tagName === 'LEGEND') {
468
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
469
+ // return whether `node` is a descendant of its first <legend>
470
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
471
+ }
472
+ }
473
+ // the disabled <fieldset> containing `node` has no <legend>
474
+ return true;
475
+ }
476
+ parentNode = parentNode.parentElement;
477
+ }
478
+ }
479
+
480
+ // else, node's tabbable/focusable state should not be affected by a fieldset's
481
+ // enabled/disabled state
482
+ return false;
483
+ };
484
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
485
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) ||
486
+ // For a details element with a summary, the summary element gets the focus
487
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
488
+ return false;
489
+ }
490
+ return true;
491
+ };
492
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
493
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
494
+ return false;
495
+ }
496
+ return true;
497
+ };
498
+ var isShadowRootTabbable = function isShadowRootTabbable(shadowHostNode) {
499
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
500
+ if (isNaN(tabIndex) || tabIndex >= 0) {
501
+ return true;
502
+ }
503
+ // If a custom element has an explicit negative tabindex,
504
+ // browsers will not allow tab targeting said element's children.
505
+ return false;
506
+ };
507
+
508
+ /**
509
+ * @param {Array.<Element|CandidateScope>} candidates
510
+ * @returns Element[]
511
+ */
512
+ var _sortByOrder = function sortByOrder(candidates) {
513
+ var regularTabbables = [];
514
+ var orderedTabbables = [];
515
+ candidates.forEach(function (item, i) {
516
+ var isScope = !!item.scopeParent;
517
+ var element = isScope ? item.scopeParent : item;
518
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
519
+ var elements = isScope ? _sortByOrder(item.candidates) : element;
520
+ if (candidateTabindex === 0) {
521
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
522
+ } else {
523
+ orderedTabbables.push({
524
+ documentOrder: i,
525
+ tabIndex: candidateTabindex,
526
+ item: item,
527
+ isScope: isScope,
528
+ content: elements
529
+ });
530
+ }
531
+ });
532
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
533
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
534
+ return acc;
535
+ }, []).concat(regularTabbables);
536
+ };
537
+ var tabbable = function tabbable(container, options) {
538
+ options = options || {};
539
+ var candidates;
540
+ if (options.getShadowRoot) {
541
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
542
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
543
+ flatten: false,
544
+ getShadowRoot: options.getShadowRoot,
545
+ shadowRootFilter: isShadowRootTabbable
546
+ });
547
+ } else {
548
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
549
+ }
550
+ return _sortByOrder(candidates);
551
+ };
552
+ var focusable = function focusable(container, options) {
553
+ options = options || {};
554
+ var candidates;
555
+ if (options.getShadowRoot) {
556
+ candidates = _getCandidatesIteratively([container], options.includeContainer, {
557
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
558
+ flatten: true,
559
+ getShadowRoot: options.getShadowRoot
560
+ });
561
+ } else {
562
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
563
+ }
564
+ return candidates;
565
+ };
566
+ var isTabbable = function isTabbable(node, options) {
567
+ options = options || {};
568
+ if (!node) {
569
+ throw new Error('No node provided');
570
+ }
571
+ if (matches.call(node, candidateSelector) === false) {
572
+ return false;
573
+ }
574
+ return isNodeMatchingSelectorTabbable(options, node);
575
+ };
576
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe:not([inert]):not([inert] *)').join(',');
577
+ var isFocusable = function isFocusable(node, options) {
578
+ options = options || {};
579
+ if (!node) {
580
+ throw new Error('No node provided');
581
+ }
582
+ if (matches.call(node, focusableCandidateSelector) === false) {
583
+ return false;
584
+ }
585
+ return isNodeMatchingSelectorFocusable(options, node);
586
+ };
587
+
588
+ /*!
589
+ * focus-trap 7.8.0
590
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
591
+ */
592
+
593
+ function _arrayLikeToArray(r, a) {
594
+ (null == a || a > r.length) && (a = r.length);
595
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
596
+ return n;
597
+ }
598
+ function _arrayWithoutHoles(r) {
599
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
600
+ }
601
+ function _createForOfIteratorHelper(r, e) {
602
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
603
+ if (!t) {
604
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
605
+ t && (r = t);
606
+ var n = 0,
607
+ F = function () {};
608
+ return {
609
+ s: F,
610
+ n: function () {
611
+ return n >= r.length ? {
612
+ done: true
613
+ } : {
614
+ done: false,
615
+ value: r[n++]
616
+ };
617
+ },
618
+ e: function (r) {
619
+ throw r;
620
+ },
621
+ f: F
622
+ };
623
+ }
624
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
625
+ }
626
+ var o,
627
+ a = true,
628
+ u = false;
629
+ return {
630
+ s: function () {
631
+ t = t.call(r);
632
+ },
633
+ n: function () {
634
+ var r = t.next();
635
+ return a = r.done, r;
636
+ },
637
+ e: function (r) {
638
+ u = true, o = r;
639
+ },
640
+ f: function () {
641
+ try {
642
+ a || null == t.return || t.return();
643
+ } finally {
644
+ if (u) throw o;
645
+ }
646
+ }
647
+ };
648
+ }
649
+ function _defineProperty(e, r, t) {
650
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
651
+ value: t,
652
+ enumerable: true,
653
+ configurable: true,
654
+ writable: true
655
+ }) : e[r] = t, e;
656
+ }
657
+ function _iterableToArray(r) {
658
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
659
+ }
660
+ function _nonIterableSpread() {
661
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
662
+ }
663
+ function ownKeys(e, r) {
664
+ var t = Object.keys(e);
665
+ if (Object.getOwnPropertySymbols) {
666
+ var o = Object.getOwnPropertySymbols(e);
667
+ r && (o = o.filter(function (r) {
668
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
669
+ })), t.push.apply(t, o);
670
+ }
671
+ return t;
672
+ }
673
+ function _objectSpread2(e) {
674
+ for (var r = 1; r < arguments.length; r++) {
675
+ var t = null != arguments[r] ? arguments[r] : {};
676
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
677
+ _defineProperty(e, r, t[r]);
678
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
679
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
680
+ });
681
+ }
682
+ return e;
683
+ }
684
+ function _toConsumableArray(r) {
685
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
686
+ }
687
+ function _toPrimitive(t, r) {
688
+ if ("object" != typeof t || !t) return t;
689
+ var e = t[Symbol.toPrimitive];
690
+ if (void 0 !== e) {
691
+ var i = e.call(t, r);
692
+ if ("object" != typeof i) return i;
693
+ throw new TypeError("@@toPrimitive must return a primitive value.");
694
+ }
695
+ return ("string" === r ? String : Number)(t);
696
+ }
697
+ function _toPropertyKey(t) {
698
+ var i = _toPrimitive(t, "string");
699
+ return "symbol" == typeof i ? i : i + "";
700
+ }
701
+ function _unsupportedIterableToArray(r, a) {
702
+ if (r) {
703
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
704
+ var t = {}.toString.call(r).slice(8, -1);
705
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
706
+ }
707
+ }
708
+
709
+ var activeFocusTraps = {
710
+ // Returns the trap from the top of the stack.
711
+ getActiveTrap: function getActiveTrap(trapStack) {
712
+ if ((trapStack === null || trapStack === void 0 ? void 0 : trapStack.length) > 0) {
713
+ return trapStack[trapStack.length - 1];
714
+ }
715
+ return null;
716
+ },
717
+ // Pauses the currently active trap, then adds a new trap to the stack.
718
+ activateTrap: function activateTrap(trapStack, trap) {
719
+ var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
720
+ if (trap !== activeTrap) {
721
+ activeFocusTraps.pauseTrap(trapStack);
722
+ }
723
+ var trapIndex = trapStack.indexOf(trap);
724
+ if (trapIndex === -1) {
725
+ trapStack.push(trap);
726
+ } else {
727
+ // move this existing trap to the front of the queue
728
+ trapStack.splice(trapIndex, 1);
729
+ trapStack.push(trap);
730
+ }
731
+ },
732
+ // Removes the trap from the top of the stack, then unpauses the next trap down.
733
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
734
+ var trapIndex = trapStack.indexOf(trap);
735
+ if (trapIndex !== -1) {
736
+ trapStack.splice(trapIndex, 1);
737
+ }
738
+ activeFocusTraps.unpauseTrap(trapStack);
739
+ },
740
+ // Pauses the trap at the top of the stack.
741
+ pauseTrap: function pauseTrap(trapStack) {
742
+ var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
743
+ activeTrap === null || activeTrap === void 0 || activeTrap._setPausedState(true);
744
+ },
745
+ // Unpauses the trap at the top of the stack.
746
+ unpauseTrap: function unpauseTrap(trapStack) {
747
+ var activeTrap = activeFocusTraps.getActiveTrap(trapStack);
748
+ if (activeTrap && !activeTrap._isManuallyPaused()) {
749
+ activeTrap._setPausedState(false);
750
+ }
751
+ }
752
+ };
753
+ var isSelectableInput = function isSelectableInput(node) {
754
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
755
+ };
756
+ var isEscapeEvent = function isEscapeEvent(e) {
757
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
758
+ };
759
+ var isTabEvent = function isTabEvent(e) {
760
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
761
+ };
762
+
763
+ // checks for TAB by default
764
+ var isKeyForward = function isKeyForward(e) {
765
+ return isTabEvent(e) && !e.shiftKey;
766
+ };
767
+
768
+ // checks for SHIFT+TAB by default
769
+ var isKeyBackward = function isKeyBackward(e) {
770
+ return isTabEvent(e) && e.shiftKey;
771
+ };
772
+ var delay = function delay(fn) {
773
+ return setTimeout(fn, 0);
774
+ };
775
+
776
+ /**
777
+ * Get an option's value when it could be a plain value, or a handler that provides
778
+ * the value.
779
+ * @param {*} value Option's value to check.
780
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
781
+ * @returns {*} The `value`, or the handler's returned value.
782
+ */
783
+ var valueOrHandler = function valueOrHandler(value) {
784
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
785
+ params[_key - 1] = arguments[_key];
786
+ }
787
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
788
+ };
789
+ var getActualTarget = function getActualTarget(event) {
790
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
791
+ // shadow host. However, event.target.composedPath() will be an array of
792
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
793
+ // outer-most (the host HTML document). If we have access to composedPath(),
794
+ // then use its first element; otherwise, fall back to event.target (and
795
+ // this only works for an _open_ shadow DOM; otherwise,
796
+ // composedPath()[0] === event.target always).
797
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
798
+ };
799
+
800
+ // NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
801
+ // current instance use the same stack if `userOptions.trapStack` isn't specified
802
+ var internalTrapStack = [];
803
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
804
+ // SSR: a live trap shouldn't be created in this type of environment so this
805
+ // should be safe code to execute if the `document` option isn't specified
806
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
807
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
808
+ var config = _objectSpread2({
809
+ returnFocusOnDeactivate: true,
810
+ escapeDeactivates: true,
811
+ delayInitialFocus: true,
812
+ isolateSubtrees: false,
813
+ isKeyForward: isKeyForward,
814
+ isKeyBackward: isKeyBackward
815
+ }, userOptions);
816
+ var state = {
817
+ // containers given to createFocusTrap()
818
+ /** @type {Array<HTMLElement>} */
819
+ containers: [],
820
+ // list of objects identifying tabbable nodes in `containers` in the trap
821
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
822
+ // is active, but the trap should never get to a state where there isn't at least one group
823
+ // with at least one tabbable node in it (that would lead to an error condition that would
824
+ // result in an error being thrown)
825
+ /** @type {Array<{
826
+ * container: HTMLElement,
827
+ * tabbableNodes: Array<HTMLElement>, // empty if none
828
+ * focusableNodes: Array<HTMLElement>, // empty if none
829
+ * posTabIndexesFound: boolean,
830
+ * firstTabbableNode: HTMLElement|undefined,
831
+ * lastTabbableNode: HTMLElement|undefined,
832
+ * firstDomTabbableNode: HTMLElement|undefined,
833
+ * lastDomTabbableNode: HTMLElement|undefined,
834
+ * nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
835
+ * }>}
836
+ */
837
+ containerGroups: [],
838
+ // same order/length as `containers` list
839
+
840
+ // references to objects in `containerGroups`, but only those that actually have
841
+ // tabbable nodes in them
842
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
843
+ // the same length
844
+ tabbableGroups: [],
845
+ // references to nodes that are siblings to the ancestors of this trap's containers.
846
+ /** @type {Set<HTMLElement>} */
847
+ adjacentElements: new Set(),
848
+ // references to nodes that were inert or aria-hidden before the trap was activated.
849
+ /** @type {Set<HTMLElement>} */
850
+ alreadySilent: new Set(),
851
+ nodeFocusedBeforeActivation: null,
852
+ mostRecentlyFocusedNode: null,
853
+ active: false,
854
+ paused: false,
855
+ manuallyPaused: false,
856
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
857
+ // has been delayed during activation
858
+ delayInitialFocusTimer: undefined,
859
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
860
+ recentNavEvent: undefined
861
+ };
862
+ var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
863
+
864
+ /**
865
+ * Gets a configuration option value.
866
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
867
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
868
+ * @param {string} optionName Name of the option whose value is sought.
869
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
870
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
871
+ */
872
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
873
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
874
+ };
875
+
876
+ /**
877
+ * Finds the index of the container that contains the element.
878
+ * @param {HTMLElement} element
879
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
880
+ * the event's composed path is used to see if includes any known trap containers in the
881
+ * case where the element is inside a Shadow DOM.
882
+ * @returns {number} Index of the container in either `state.containers` or
883
+ * `state.containerGroups` (the order/length of these lists are the same); -1
884
+ * if the element isn't found.
885
+ */
886
+ var findContainerIndex = function findContainerIndex(element, event) {
887
+ var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
888
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
889
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
890
+ // and we still need to find the element in there
891
+ return state.containerGroups.findIndex(function (_ref) {
892
+ var container = _ref.container,
893
+ tabbableNodes = _ref.tabbableNodes;
894
+ return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any
895
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
896
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
897
+ // look inside web components even if open)
898
+ composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
899
+ return node === element;
900
+ });
901
+ });
902
+ };
903
+
904
+ /**
905
+ * Gets the node for the given option, which is expected to be an option that
906
+ * can be either a DOM node, a string that is a selector to get a node, `false`
907
+ * (if a node is explicitly NOT given), or a function that returns any of these
908
+ * values.
909
+ * @param {string} optionName
910
+ * @param {Object} options
911
+ * @param {boolean} [options.hasFallback] True if the option could be a selector string
912
+ * and the option allows for a fallback scenario in the case where the selector is
913
+ * valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
914
+ * @param {Array} [options.params] Params to pass to the option if it's a function.
915
+ * @returns {undefined | null | false | HTMLElement | SVGElement} Returns
916
+ * `undefined` if the option is not specified; `null` if the option didn't resolve
917
+ * to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
918
+ * (node explicitly not given); otherwise, the resolved DOM node.
919
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
920
+ * resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
921
+ */
922
+ var getNodeForOption = function getNodeForOption(optionName) {
923
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
924
+ _ref2$hasFallback = _ref2.hasFallback,
925
+ hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback,
926
+ _ref2$params = _ref2.params,
927
+ params = _ref2$params === void 0 ? [] : _ref2$params;
928
+ var optionValue = config[optionName];
929
+ if (typeof optionValue === 'function') {
930
+ optionValue = optionValue.apply(void 0, _toConsumableArray(params));
931
+ }
932
+ if (optionValue === true) {
933
+ optionValue = undefined; // use default value
934
+ }
935
+ if (!optionValue) {
936
+ if (optionValue === undefined || optionValue === false) {
937
+ return optionValue;
938
+ }
939
+ // else, empty string (invalid), null (invalid), 0 (invalid)
940
+
941
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
942
+ }
943
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
944
+
945
+ if (typeof optionValue === 'string') {
946
+ try {
947
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
948
+ } catch (err) {
949
+ throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
950
+ }
951
+ if (!node) {
952
+ if (!hasFallback) {
953
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
954
+ }
955
+ // else, `node` MUST be `null` because that's what `Document.querySelector()` returns
956
+ // if the selector is valid but doesn't match anything
957
+ }
958
+ }
959
+ return node;
960
+ };
961
+ var getInitialFocusNode = function getInitialFocusNode() {
962
+ var node = getNodeForOption('initialFocus', {
963
+ hasFallback: true
964
+ });
965
+
966
+ // false explicitly indicates we want no initialFocus at all
967
+ if (node === false) {
968
+ return false;
969
+ }
970
+ if (node === undefined || node && !isFocusable(node, config.tabbableOptions)) {
971
+ // option not specified nor focusable: use fallback options
972
+ if (findContainerIndex(doc.activeElement) >= 0) {
973
+ node = doc.activeElement;
974
+ } else {
975
+ var firstTabbableGroup = state.tabbableGroups[0];
976
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
977
+
978
+ // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
979
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
980
+ }
981
+ } else if (node === null) {
982
+ // option is a VALID selector string that doesn't yield a node: use the `fallbackFocus`
983
+ // option instead of the default behavior when the option isn't specified at all
984
+ node = getNodeForOption('fallbackFocus');
985
+ }
986
+ if (!node) {
987
+ throw new Error('Your focus-trap needs to have at least one focusable element');
988
+ }
989
+ return node;
990
+ };
991
+ var updateTabbableNodes = function updateTabbableNodes() {
992
+ state.containerGroups = state.containers.map(function (container) {
993
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
994
+
995
+ // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
996
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
997
+ // are focusable but not tabbable
998
+ var focusableNodes = focusable(container, config.tabbableOptions);
999
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
1000
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
1001
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
1002
+ return isTabbable(node);
1003
+ });
1004
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
1005
+ return isTabbable(node);
1006
+ });
1007
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
1008
+ return getTabIndex(node) > 0;
1009
+ });
1010
+ return {
1011
+ container: container,
1012
+ tabbableNodes: tabbableNodes,
1013
+ focusableNodes: focusableNodes,
1014
+ /** True if at least one node with positive `tabindex` was found in this container. */
1015
+ posTabIndexesFound: posTabIndexesFound,
1016
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
1017
+ firstTabbableNode: firstTabbableNode,
1018
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
1019
+ lastTabbableNode: lastTabbableNode,
1020
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
1021
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
1022
+ // because that API doesn't work with Shadow DOM as well as it should (@see
1023
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
1024
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
1025
+ // "close enough most of the time" alternative for positive tabindexes which should generally
1026
+ // be avoided anyway...
1027
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
1028
+ firstDomTabbableNode: firstDomTabbableNode,
1029
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
1030
+ lastDomTabbableNode: lastDomTabbableNode,
1031
+ /**
1032
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
1033
+ * in this container, if any.
1034
+ * @param {HTMLElement} node
1035
+ * @param {boolean} [forward] True if going in forward tab order; false if going
1036
+ * in reverse.
1037
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
1038
+ */
1039
+ nextTabbableNode: function nextTabbableNode(node) {
1040
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1041
+ var nodeIdx = tabbableNodes.indexOf(node);
1042
+ if (nodeIdx < 0) {
1043
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
1044
+ // since `node` should at least have been focusable, we assume that's the case and mimic
1045
+ // what browsers do, which is set focus to the next node in __document position order__,
1046
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
1047
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
1048
+ // basic DOM order
1049
+ if (forward) {
1050
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
1051
+ return isTabbable(el);
1052
+ });
1053
+ }
1054
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
1055
+ return isTabbable(el);
1056
+ });
1057
+ }
1058
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
1059
+ }
1060
+ };
1061
+ });
1062
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
1063
+ return group.tabbableNodes.length > 0;
1064
+ });
1065
+
1066
+ // throw if no groups have tabbable nodes and we don't have a fallback focus node either
1067
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
1068
+ ) {
1069
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
1070
+ }
1071
+
1072
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
1073
+ // doing it across multiple containers where tabindexes could be all over the place
1074
+ // would require Tabbable to support multiple containers, would require additional
1075
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
1076
+ // to look at those containers in document position order rather than user-provided
1077
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
1078
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
1079
+ if (state.containerGroups.find(function (g) {
1080
+ return g.posTabIndexesFound;
1081
+ }) && state.containerGroups.length > 1) {
1082
+ 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.");
1083
+ }
1084
+ };
1085
+
1086
+ /**
1087
+ * Gets the current activeElement. If it's a web-component and has open shadow-root
1088
+ * it will recursively search inside shadow roots for the "true" activeElement.
1089
+ *
1090
+ * @param {Document | ShadowRoot} el
1091
+ *
1092
+ * @returns {HTMLElement} The element that currently has the focus
1093
+ **/
1094
+ var _getActiveElement = function getActiveElement(el) {
1095
+ var activeElement = el.activeElement;
1096
+ if (!activeElement) {
1097
+ return;
1098
+ }
1099
+ if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
1100
+ return _getActiveElement(activeElement.shadowRoot);
1101
+ }
1102
+ return activeElement;
1103
+ };
1104
+ var _tryFocus = function tryFocus(node) {
1105
+ if (node === false) {
1106
+ return;
1107
+ }
1108
+ if (node === _getActiveElement(document)) {
1109
+ return;
1110
+ }
1111
+ if (!node || !node.focus) {
1112
+ _tryFocus(getInitialFocusNode());
1113
+ return;
1114
+ }
1115
+ node.focus({
1116
+ preventScroll: !!config.preventScroll
1117
+ });
1118
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
1119
+ state.mostRecentlyFocusedNode = node;
1120
+ if (isSelectableInput(node)) {
1121
+ node.select();
1122
+ }
1123
+ };
1124
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
1125
+ var node = getNodeForOption('setReturnFocus', {
1126
+ params: [previousActiveElement]
1127
+ });
1128
+ return node ? node : node === false ? false : previousActiveElement;
1129
+ };
1130
+
1131
+ /**
1132
+ * Finds the next node (in either direction) where focus should move according to a
1133
+ * keyboard focus-in event.
1134
+ * @param {Object} params
1135
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
1136
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
1137
+ * will be used to determine the `target`). Ignored if `target` is specified.
1138
+ * @param {boolean} [params.isBackward] True if focus should move backward.
1139
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
1140
+ * determined given the current state of the trap.
1141
+ */
1142
+ var findNextNavNode = function findNextNavNode(_ref3) {
1143
+ var target = _ref3.target,
1144
+ event = _ref3.event,
1145
+ _ref3$isBackward = _ref3.isBackward,
1146
+ isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
1147
+ target = target || getActualTarget(event);
1148
+ updateTabbableNodes();
1149
+ var destinationNode = null;
1150
+ if (state.tabbableGroups.length > 0) {
1151
+ // make sure the target is actually contained in a group
1152
+ // NOTE: the target may also be the container itself if it's focusable
1153
+ // with tabIndex='-1' and was given initial focus
1154
+ var containerIndex = findContainerIndex(target, event);
1155
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
1156
+ if (containerIndex < 0) {
1157
+ // target not found in any group: quite possible focus has escaped the trap,
1158
+ // so bring it back into...
1159
+ if (isBackward) {
1160
+ // ...the last node in the last group
1161
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
1162
+ } else {
1163
+ // ...the first node in the first group
1164
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
1165
+ }
1166
+ } else if (isBackward) {
1167
+ // REVERSE
1168
+
1169
+ // is the target the first tabbable node in a group?
1170
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
1171
+ var firstTabbableNode = _ref4.firstTabbableNode;
1172
+ return target === firstTabbableNode;
1173
+ });
1174
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
1175
+ // an exception case where the target is either the container itself, or
1176
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1177
+ // and user clicked on it or node was programmatically given focus)
1178
+ // and is not followed by any other tabbable node, in which
1179
+ // case, we should handle shift+tab as if focus were on the container's
1180
+ // first tabbable node, and go to the last tabbable node of the LAST group
1181
+ startOfGroupIndex = containerIndex;
1182
+ }
1183
+ if (startOfGroupIndex >= 0) {
1184
+ // YES: then shift+tab should go to the last tabbable node in the
1185
+ // previous group (and wrap around to the last tabbable node of
1186
+ // the LAST group if it's the first tabbable node of the FIRST group)
1187
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
1188
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
1189
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
1190
+ } else if (!isTabEvent(event)) {
1191
+ // user must have customized the nav keys so we have to move focus manually _within_
1192
+ // the active group: do this based on the order determined by tabbable()
1193
+ destinationNode = containerGroup.nextTabbableNode(target, false);
1194
+ }
1195
+ } else {
1196
+ // FORWARD
1197
+
1198
+ // is the target the last tabbable node in a group?
1199
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
1200
+ var lastTabbableNode = _ref5.lastTabbableNode;
1201
+ return target === lastTabbableNode;
1202
+ });
1203
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
1204
+ // an exception case where the target is the container itself, or
1205
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1206
+ // and user clicked on it or node was programmatically given focus)
1207
+ // and is not followed by any other tabbable node, in which
1208
+ // case, we should handle tab as if focus were on the container's
1209
+ // last tabbable node, and go to the first tabbable node of the FIRST group
1210
+ lastOfGroupIndex = containerIndex;
1211
+ }
1212
+ if (lastOfGroupIndex >= 0) {
1213
+ // YES: then tab should go to the first tabbable node in the next
1214
+ // group (and wrap around to the first tabbable node of the FIRST
1215
+ // group if it's the last tabbable node of the LAST group)
1216
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
1217
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
1218
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
1219
+ } else if (!isTabEvent(event)) {
1220
+ // user must have customized the nav keys so we have to move focus manually _within_
1221
+ // the active group: do this based on the order determined by tabbable()
1222
+ destinationNode = containerGroup.nextTabbableNode(target);
1223
+ }
1224
+ }
1225
+ } else {
1226
+ // no groups available
1227
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
1228
+ destinationNode = getNodeForOption('fallbackFocus');
1229
+ }
1230
+ return destinationNode;
1231
+ };
1232
+
1233
+ // This needs to be done on mousedown and touchstart instead of click
1234
+ // so that it precedes the focus event.
1235
+ var checkPointerDown = function checkPointerDown(e) {
1236
+ var target = getActualTarget(e);
1237
+ if (findContainerIndex(target, e) >= 0) {
1238
+ // allow the click since it ocurred inside the trap
1239
+ return;
1240
+ }
1241
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1242
+ // immediately deactivate the trap
1243
+ trap.deactivate({
1244
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
1245
+ // which will result in the outside click setting focus to the node
1246
+ // that was clicked (and if not focusable, to "nothing"); by setting
1247
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
1248
+ // on activation (or the configured `setReturnFocus` node), whether the
1249
+ // outside click was on a focusable node or not
1250
+ returnFocus: config.returnFocusOnDeactivate
1251
+ });
1252
+ return;
1253
+ }
1254
+
1255
+ // This is needed for mobile devices.
1256
+ // (If we'll only let `click` events through,
1257
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
1258
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1259
+ // allow the click outside the trap to take place
1260
+ return;
1261
+ }
1262
+
1263
+ // otherwise, prevent the click
1264
+ e.preventDefault();
1265
+ };
1266
+
1267
+ // In case focus escapes the trap for some strange reason, pull it back in.
1268
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
1269
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
1270
+ // prevent that from happening by the time we discover that focus escaped
1271
+ var checkFocusIn = function checkFocusIn(event) {
1272
+ var target = getActualTarget(event);
1273
+ var targetContained = findContainerIndex(target, event) >= 0;
1274
+
1275
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
1276
+ if (targetContained || target instanceof Document) {
1277
+ if (targetContained) {
1278
+ state.mostRecentlyFocusedNode = target;
1279
+ }
1280
+ } else {
1281
+ // escaped! pull it back in to where it just left
1282
+ event.stopImmediatePropagation();
1283
+
1284
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
1285
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
1286
+ // toward a node with a positive tab index
1287
+ var nextNode; // next node to focus, if we find one
1288
+ var navAcrossContainers = true;
1289
+ if (state.mostRecentlyFocusedNode) {
1290
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
1291
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
1292
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
1293
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
1294
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
1295
+ // with at least one tabbable node in order to function, so this could be the other container
1296
+ // with nothing tabbable in it)
1297
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
1298
+ if (tabbableNodes.length > 0) {
1299
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
1300
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
1301
+ return node === state.mostRecentlyFocusedNode;
1302
+ });
1303
+ if (mruTabIdx >= 0) {
1304
+ if (config.isKeyForward(state.recentNavEvent)) {
1305
+ if (mruTabIdx + 1 < tabbableNodes.length) {
1306
+ nextNode = tabbableNodes[mruTabIdx + 1];
1307
+ navAcrossContainers = false;
1308
+ }
1309
+ // else, don't wrap within the container as focus should move to next/previous
1310
+ // container
1311
+ } else {
1312
+ if (mruTabIdx - 1 >= 0) {
1313
+ nextNode = tabbableNodes[mruTabIdx - 1];
1314
+ navAcrossContainers = false;
1315
+ }
1316
+ // else, don't wrap within the container as focus should move to next/previous
1317
+ // container
1318
+ }
1319
+ // else, don't find in container order without considering direction too
1320
+ }
1321
+ }
1322
+ // else, no tabbable nodes in that container (which means we must have at least one other
1323
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
1324
+ // an error the last time updateTabbableNodes() was run): find next node among all known
1325
+ // containers
1326
+ } else {
1327
+ // check to see if there's at least one tabbable node with a positive tab index inside
1328
+ // the trap because focus seems to escape when navigating backward from a tabbable node
1329
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
1330
+ // the greatest positive tab index like it should)
1331
+ if (!state.containerGroups.some(function (g) {
1332
+ return g.tabbableNodes.some(function (n) {
1333
+ return getTabIndex(n) > 0;
1334
+ });
1335
+ })) {
1336
+ // no containers with tabbable nodes with positive tab indexes which means the focus
1337
+ // escaped for some other reason and we should just execute the fallback to the
1338
+ // MRU node or initial focus node, if any
1339
+ navAcrossContainers = false;
1340
+ }
1341
+ }
1342
+ } else {
1343
+ // no MRU node means we're likely in some initial condition when the trap has just
1344
+ // been activated and initial focus hasn't been given yet, in which case we should
1345
+ // fall through to trying to focus the initial focus node, which is what should
1346
+ // happen below at this point in the logic
1347
+ navAcrossContainers = false;
1348
+ }
1349
+ if (navAcrossContainers) {
1350
+ nextNode = findNextNavNode({
1351
+ // move FROM the MRU node, not event-related node (which will be the node that is
1352
+ // outside the trap causing the focus escape we're trying to fix)
1353
+ target: state.mostRecentlyFocusedNode,
1354
+ isBackward: config.isKeyBackward(state.recentNavEvent)
1355
+ });
1356
+ }
1357
+ if (nextNode) {
1358
+ _tryFocus(nextNode);
1359
+ } else {
1360
+ _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
1361
+ }
1362
+ }
1363
+ state.recentNavEvent = undefined; // clear
1364
+ };
1365
+
1366
+ // Hijack key nav events on the first and last focusable nodes of the trap,
1367
+ // in order to prevent focus from escaping. If it escapes for even a
1368
+ // moment it can end up scrolling the page and causing confusion so we
1369
+ // kind of need to capture the action at the keydown phase.
1370
+ var checkKeyNav = function checkKeyNav(event) {
1371
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1372
+ state.recentNavEvent = event;
1373
+ var destinationNode = findNextNavNode({
1374
+ event: event,
1375
+ isBackward: isBackward
1376
+ });
1377
+ if (destinationNode) {
1378
+ if (isTabEvent(event)) {
1379
+ // since tab natively moves focus, we wouldn't have a destination node unless we
1380
+ // were on the edge of a container and had to move to the next/previous edge, in
1381
+ // which case we want to prevent default to keep the browser from moving focus
1382
+ // to where it normally would
1383
+ event.preventDefault();
1384
+ }
1385
+ _tryFocus(destinationNode);
1386
+ }
1387
+ // else, let the browser take care of [shift+]tab and move the focus
1388
+ };
1389
+ var checkTabKey = function checkTabKey(event) {
1390
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
1391
+ checkKeyNav(event, config.isKeyBackward(event));
1392
+ }
1393
+ };
1394
+
1395
+ // we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates
1396
+ var checkEscapeKey = function checkEscapeKey(event) {
1397
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
1398
+ event.preventDefault();
1399
+ trap.deactivate();
1400
+ }
1401
+ };
1402
+ var checkClick = function checkClick(e) {
1403
+ var target = getActualTarget(e);
1404
+ if (findContainerIndex(target, e) >= 0) {
1405
+ return;
1406
+ }
1407
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1408
+ return;
1409
+ }
1410
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1411
+ return;
1412
+ }
1413
+ e.preventDefault();
1414
+ e.stopImmediatePropagation();
1415
+ };
1416
+
1417
+ //
1418
+ // EVENT LISTENERS
1419
+ //
1420
+
1421
+ var addListeners = function addListeners() {
1422
+ if (!state.active) {
1423
+ return;
1424
+ }
1425
+
1426
+ // There can be only one listening focus trap at a time
1427
+ activeFocusTraps.activateTrap(trapStack, trap);
1428
+
1429
+ // Delay ensures that the focused element doesn't capture the event
1430
+ // that caused the focus trap activation.
1431
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
1432
+ _tryFocus(getInitialFocusNode());
1433
+ }) : _tryFocus(getInitialFocusNode());
1434
+ doc.addEventListener('focusin', checkFocusIn, true);
1435
+ doc.addEventListener('mousedown', checkPointerDown, {
1436
+ capture: true,
1437
+ passive: false
1438
+ });
1439
+ doc.addEventListener('touchstart', checkPointerDown, {
1440
+ capture: true,
1441
+ passive: false
1442
+ });
1443
+ doc.addEventListener('click', checkClick, {
1444
+ capture: true,
1445
+ passive: false
1446
+ });
1447
+ doc.addEventListener('keydown', checkTabKey, {
1448
+ capture: true,
1449
+ passive: false
1450
+ });
1451
+ doc.addEventListener('keydown', checkEscapeKey);
1452
+ return trap;
1453
+ };
1454
+
1455
+ /**
1456
+ * Traverses up the DOM from each of `containers`, collecting references to
1457
+ * the elements that are siblings to `container` or an ancestor of `container`.
1458
+ * @param {Array<HTMLElement>} containers
1459
+ */
1460
+ var collectAdjacentElements = function collectAdjacentElements(containers) {
1461
+ // Re-activate all adjacent elements & clear previous collection.
1462
+ if (state.active && !state.paused) {
1463
+ trap._setSubtreeIsolation(false);
1464
+ }
1465
+ state.adjacentElements.clear();
1466
+ state.alreadySilent.clear();
1467
+
1468
+ // Collect all ancestors of all containers to avoid redundant processing.
1469
+ var containerAncestors = new Set();
1470
+ var adjacentElements = new Set();
1471
+
1472
+ // Compile all elements adjacent to the focus trap containers & lineage.
1473
+ var _iterator = _createForOfIteratorHelper(containers),
1474
+ _step;
1475
+ try {
1476
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1477
+ var container = _step.value;
1478
+ containerAncestors.add(container);
1479
+ var insideShadowRoot = typeof ShadowRoot !== 'undefined' && container.getRootNode() instanceof ShadowRoot;
1480
+ var current = container;
1481
+ while (current) {
1482
+ containerAncestors.add(current);
1483
+ var parent = current.parentElement;
1484
+ var siblings = [];
1485
+ if (parent) {
1486
+ siblings = parent.children;
1487
+ } else if (!parent && insideShadowRoot) {
1488
+ siblings = current.getRootNode().children;
1489
+ parent = current.getRootNode().host;
1490
+ insideShadowRoot = typeof ShadowRoot !== 'undefined' && parent.getRootNode() instanceof ShadowRoot;
1491
+ }
1492
+
1493
+ // Add all the children, we'll remove container lineage later.
1494
+ var _iterator2 = _createForOfIteratorHelper(siblings),
1495
+ _step2;
1496
+ try {
1497
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1498
+ var child = _step2.value;
1499
+ adjacentElements.add(child);
1500
+ }
1501
+ } catch (err) {
1502
+ _iterator2.e(err);
1503
+ } finally {
1504
+ _iterator2.f();
1505
+ }
1506
+ current = parent;
1507
+ }
1508
+ }
1509
+
1510
+ // Multi-container traps may overlap.
1511
+ // Remove elements within container lineages.
1512
+ } catch (err) {
1513
+ _iterator.e(err);
1514
+ } finally {
1515
+ _iterator.f();
1516
+ }
1517
+ containerAncestors.forEach(function (el) {
1518
+ adjacentElements["delete"](el);
1519
+ });
1520
+ state.adjacentElements = adjacentElements;
1521
+ };
1522
+ var removeListeners = function removeListeners() {
1523
+ if (!state.active) {
1524
+ return;
1525
+ }
1526
+ doc.removeEventListener('focusin', checkFocusIn, true);
1527
+ doc.removeEventListener('mousedown', checkPointerDown, true);
1528
+ doc.removeEventListener('touchstart', checkPointerDown, true);
1529
+ doc.removeEventListener('click', checkClick, true);
1530
+ doc.removeEventListener('keydown', checkTabKey, true);
1531
+ doc.removeEventListener('keydown', checkEscapeKey);
1532
+ return trap;
1533
+ };
1534
+
1535
+ //
1536
+ // MUTATION OBSERVER
1537
+ //
1538
+
1539
+ var checkDomRemoval = function checkDomRemoval(mutations) {
1540
+ var isFocusedNodeRemoved = mutations.some(function (mutation) {
1541
+ var removedNodes = Array.from(mutation.removedNodes);
1542
+ return removedNodes.some(function (node) {
1543
+ return node === state.mostRecentlyFocusedNode;
1544
+ });
1545
+ });
1546
+
1547
+ // If the currently focused is removed then browsers will move focus to the
1548
+ // <body> element. If this happens, try to move focus back into the trap.
1549
+ if (isFocusedNodeRemoved) {
1550
+ _tryFocus(getInitialFocusNode());
1551
+ }
1552
+ };
1553
+
1554
+ // Use MutationObserver - if supported - to detect if focused node is removed
1555
+ // from the DOM.
1556
+ var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
1557
+ var updateObservedNodes = function updateObservedNodes() {
1558
+ if (!mutationObserver) {
1559
+ return;
1560
+ }
1561
+ mutationObserver.disconnect();
1562
+ if (state.active && !state.paused) {
1563
+ state.containers.map(function (container) {
1564
+ mutationObserver.observe(container, {
1565
+ subtree: true,
1566
+ childList: true
1567
+ });
1568
+ });
1569
+ }
1570
+ };
1571
+
1572
+ //
1573
+ // TRAP DEFINITION
1574
+ //
1575
+
1576
+ trap = {
1577
+ get active() {
1578
+ return state.active;
1579
+ },
1580
+ get paused() {
1581
+ return state.paused;
1582
+ },
1583
+ activate: function activate(activateOptions) {
1584
+ if (state.active) {
1585
+ return this;
1586
+ }
1587
+ var onActivate = getOption(activateOptions, 'onActivate');
1588
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
1589
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
1590
+
1591
+ // If a currently-active trap is isolating its subtree, we need to remove
1592
+ // that isolation to allow the new trap to find tabbable nodes.
1593
+ var preexistingTrap = activeFocusTraps.getActiveTrap(trapStack);
1594
+ var revertState = false;
1595
+ if (preexistingTrap && !preexistingTrap.paused) {
1596
+ var _preexistingTrap$_set;
1597
+ // [#1729] method MAY not exist if using `trapStack` option to share stack with older
1598
+ // versions of Focus-trap in the same DOM so use optional chaining here just in case
1599
+ // since this is a trap we may not have created from this instance of the library
1600
+ (_preexistingTrap$_set = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set === void 0 || _preexistingTrap$_set.call(preexistingTrap, false);
1601
+ revertState = true;
1602
+ }
1603
+ try {
1604
+ if (!checkCanFocusTrap) {
1605
+ updateTabbableNodes();
1606
+ }
1607
+ state.active = true;
1608
+ state.paused = false;
1609
+ state.nodeFocusedBeforeActivation = _getActiveElement(doc);
1610
+ onActivate === null || onActivate === void 0 || onActivate();
1611
+ var finishActivation = function finishActivation() {
1612
+ if (checkCanFocusTrap) {
1613
+ updateTabbableNodes();
1614
+ }
1615
+ addListeners();
1616
+ updateObservedNodes();
1617
+ if (config.isolateSubtrees) {
1618
+ trap._setSubtreeIsolation(true);
1619
+ }
1620
+ onPostActivate === null || onPostActivate === void 0 || onPostActivate();
1621
+ };
1622
+ if (checkCanFocusTrap) {
1623
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1624
+ return this;
1625
+ }
1626
+ finishActivation();
1627
+ } catch (error) {
1628
+ // If our activation throws an exception and the stack hasn't changed,
1629
+ // we need to re-enable the prior trap's subtree isolation.
1630
+ if (preexistingTrap === activeFocusTraps.getActiveTrap(trapStack) && revertState) {
1631
+ var _preexistingTrap$_set2;
1632
+ // [#1729] method MAY not exist if using `trapStack` option to share stack with older
1633
+ // versions of Focus-trap in the same DOM so use optional chaining here just in case
1634
+ // since this is a trap we may not have created from this instance of the library
1635
+ (_preexistingTrap$_set2 = preexistingTrap._setSubtreeIsolation) === null || _preexistingTrap$_set2 === void 0 || _preexistingTrap$_set2.call(preexistingTrap, true);
1636
+ }
1637
+ throw error;
1638
+ }
1639
+ return this;
1640
+ },
1641
+ deactivate: function deactivate(deactivateOptions) {
1642
+ if (!state.active) {
1643
+ return this;
1644
+ }
1645
+ var options = _objectSpread2({
1646
+ onDeactivate: config.onDeactivate,
1647
+ onPostDeactivate: config.onPostDeactivate,
1648
+ checkCanReturnFocus: config.checkCanReturnFocus
1649
+ }, deactivateOptions);
1650
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
1651
+ state.delayInitialFocusTimer = undefined;
1652
+
1653
+ // Prior to removing this trap from the trapStack, we need to remove any applications of `inert`.
1654
+ // This allows the next trap down to update its tabbable nodes properly.
1655
+ //
1656
+ // If this trap is not top of the stack, don't change any current isolation.
1657
+ if (!state.paused) {
1658
+ trap._setSubtreeIsolation(false);
1659
+ }
1660
+ state.alreadySilent.clear();
1661
+ removeListeners();
1662
+ state.active = false;
1663
+ state.paused = false;
1664
+ updateObservedNodes();
1665
+ activeFocusTraps.deactivateTrap(trapStack, trap);
1666
+ var onDeactivate = getOption(options, 'onDeactivate');
1667
+ var onPostDeactivate = getOption(options, 'onPostDeactivate');
1668
+ var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
1669
+ var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
1670
+ onDeactivate === null || onDeactivate === void 0 || onDeactivate();
1671
+ var finishDeactivation = function finishDeactivation() {
1672
+ delay(function () {
1673
+ if (returnFocus) {
1674
+ _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1675
+ }
1676
+ onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
1677
+ });
1678
+ };
1679
+ if (returnFocus && checkCanReturnFocus) {
1680
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1681
+ return this;
1682
+ }
1683
+ finishDeactivation();
1684
+ return this;
1685
+ },
1686
+ pause: function pause(pauseOptions) {
1687
+ if (!state.active) {
1688
+ return this;
1689
+ }
1690
+ state.manuallyPaused = true;
1691
+ return this._setPausedState(true, pauseOptions);
1692
+ },
1693
+ unpause: function unpause(unpauseOptions) {
1694
+ if (!state.active) {
1695
+ return this;
1696
+ }
1697
+ state.manuallyPaused = false;
1698
+ if (trapStack[trapStack.length - 1] !== this) {
1699
+ return this;
1700
+ }
1701
+ return this._setPausedState(false, unpauseOptions);
1702
+ },
1703
+ updateContainerElements: function updateContainerElements(containerElements) {
1704
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
1705
+ state.containers = elementsAsArray.map(function (element) {
1706
+ return typeof element === 'string' ? doc.querySelector(element) : element;
1707
+ });
1708
+ if (config.isolateSubtrees) {
1709
+ collectAdjacentElements(state.containers);
1710
+ }
1711
+ if (state.active) {
1712
+ updateTabbableNodes();
1713
+ if (config.isolateSubtrees && !state.paused) {
1714
+ trap._setSubtreeIsolation(true);
1715
+ }
1716
+ }
1717
+ updateObservedNodes();
1718
+ return this;
1719
+ }
1720
+ };
1721
+ Object.defineProperties(trap, {
1722
+ _isManuallyPaused: {
1723
+ value: function value() {
1724
+ return state.manuallyPaused;
1725
+ }
1726
+ },
1727
+ _setPausedState: {
1728
+ value: function value(paused, options) {
1729
+ if (state.paused === paused) {
1730
+ return this;
1731
+ }
1732
+ state.paused = paused;
1733
+ if (paused) {
1734
+ var onPause = getOption(options, 'onPause');
1735
+ var onPostPause = getOption(options, 'onPostPause');
1736
+ onPause === null || onPause === void 0 || onPause();
1737
+ removeListeners();
1738
+ updateObservedNodes();
1739
+ trap._setSubtreeIsolation(false);
1740
+ onPostPause === null || onPostPause === void 0 || onPostPause();
1741
+ } else {
1742
+ var onUnpause = getOption(options, 'onUnpause');
1743
+ var onPostUnpause = getOption(options, 'onPostUnpause');
1744
+ onUnpause === null || onUnpause === void 0 || onUnpause();
1745
+ trap._setSubtreeIsolation(true);
1746
+ updateTabbableNodes();
1747
+ addListeners();
1748
+ updateObservedNodes();
1749
+ onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
1750
+ }
1751
+ return this;
1752
+ }
1753
+ },
1754
+ _setSubtreeIsolation: {
1755
+ value: function value(isEnabled) {
1756
+ if (config.isolateSubtrees) {
1757
+ state.adjacentElements.forEach(function (el) {
1758
+ var _el$getAttribute;
1759
+ if (isEnabled) {
1760
+ switch (config.isolateSubtrees) {
1761
+ case 'aria-hidden':
1762
+ // check both attribute and property to ensure initial state is captured
1763
+ // correctly across different browsers and test environments (like JSDOM)
1764
+ if (el.ariaHidden === 'true' || ((_el$getAttribute = el.getAttribute('aria-hidden')) === null || _el$getAttribute === void 0 ? void 0 : _el$getAttribute.toLowerCase()) === 'true') {
1765
+ state.alreadySilent.add(el);
1766
+ }
1767
+ el.setAttribute('aria-hidden', 'true');
1768
+ break;
1769
+ default:
1770
+ // check both attribute and property to ensure initial state is captured
1771
+ // correctly across different browsers and test environments (like JSDOM)
1772
+ if (el.inert || el.hasAttribute('inert')) {
1773
+ state.alreadySilent.add(el);
1774
+ }
1775
+ el.setAttribute('inert', true);
1776
+ break;
1777
+ }
1778
+ } else {
1779
+ if (state.alreadySilent.has(el)) ; else {
1780
+ switch (config.isolateSubtrees) {
1781
+ case 'aria-hidden':
1782
+ el.removeAttribute('aria-hidden');
1783
+ break;
1784
+ default:
1785
+ el.removeAttribute('inert');
1786
+ break;
1787
+ }
1788
+ }
1789
+ }
1790
+ });
1791
+ }
1792
+ }
1793
+ }
1794
+ });
1795
+
1796
+ // initialize container elements
1797
+ trap.updateContainerElements(elements);
1798
+ return trap;
1799
+ };
1800
+
1801
+ export { createFocusTrap as c };