@content-blocks/js 0.3.2

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 (369) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/cjs/BehaviorSubject-771fd78b.js +640 -0
  4. package/dist/cjs/BehaviorSubject-771fd78b.js.map +1 -0
  5. package/dist/cjs/Youtube-41424972.js +807 -0
  6. package/dist/cjs/Youtube-41424972.js.map +1 -0
  7. package/dist/cjs/content-accordion.cjs.entry.js +114 -0
  8. package/dist/cjs/content-accordion.cjs.entry.js.map +1 -0
  9. package/dist/cjs/content-blocks.cjs.js +25 -0
  10. package/dist/cjs/content-blocks.cjs.js.map +1 -0
  11. package/dist/cjs/content-button_4.cjs.entry.js +2165 -0
  12. package/dist/cjs/content-button_4.cjs.entry.js.map +1 -0
  13. package/dist/cjs/content-carousel-8b0e8962.js +1488 -0
  14. package/dist/cjs/content-carousel-8b0e8962.js.map +1 -0
  15. package/dist/cjs/content-carousel.cjs.entry.js +13 -0
  16. package/dist/cjs/content-carousel.cjs.entry.js.map +1 -0
  17. package/dist/cjs/content-grid-formatter.cjs.entry.js +50 -0
  18. package/dist/cjs/content-grid-formatter.cjs.entry.js.map +1 -0
  19. package/dist/cjs/content-hero-block.cjs.entry.js +46 -0
  20. package/dist/cjs/content-hero-block.cjs.entry.js.map +1 -0
  21. package/dist/cjs/content-image.cjs.entry.js +95 -0
  22. package/dist/cjs/content-image.cjs.entry.js.map +1 -0
  23. package/dist/cjs/content-navigation-block.cjs.entry.js +62 -0
  24. package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -0
  25. package/dist/cjs/content-split-block.cjs.entry.js +36 -0
  26. package/dist/cjs/content-split-block.cjs.entry.js.map +1 -0
  27. package/dist/cjs/content-tabs.cjs.entry.js +219 -0
  28. package/dist/cjs/content-tabs.cjs.entry.js.map +1 -0
  29. package/dist/cjs/content-text-block.cjs.entry.js +48 -0
  30. package/dist/cjs/content-text-block.cjs.entry.js.map +1 -0
  31. package/dist/cjs/content-tout-block.cjs.entry.js +32 -0
  32. package/dist/cjs/content-tout-block.cjs.entry.js.map +1 -0
  33. package/dist/cjs/content-video.cjs.entry.js +114 -0
  34. package/dist/cjs/content-video.cjs.entry.js.map +1 -0
  35. package/dist/cjs/index-a42fb1d0.js +2116 -0
  36. package/dist/cjs/index-a42fb1d0.js.map +1 -0
  37. package/dist/cjs/index.cjs.js +11 -0
  38. package/dist/cjs/index.cjs.js.map +1 -0
  39. package/dist/cjs/loader.cjs.js +15 -0
  40. package/dist/cjs/loader.cjs.js.map +1 -0
  41. package/dist/cjs/swiper-8c9ab198.js +3612 -0
  42. package/dist/cjs/swiper-8c9ab198.js.map +1 -0
  43. package/dist/cjs/utils-6c985f2f.js +113 -0
  44. package/dist/cjs/utils-6c985f2f.js.map +1 -0
  45. package/dist/cjs/video.es-7d4d33f5.js +64206 -0
  46. package/dist/cjs/video.es-7d4d33f5.js.map +1 -0
  47. package/dist/cjs/window-resize-service-c9766178.js +35 -0
  48. package/dist/cjs/window-resize-service-c9766178.js.map +1 -0
  49. package/dist/collection/blocks/content-hero-block/content-hero-block.css +39 -0
  50. package/dist/collection/blocks/content-hero-block/content-hero-block.js +138 -0
  51. package/dist/collection/blocks/content-hero-block/content-hero-block.js.map +1 -0
  52. package/dist/collection/blocks/content-hero-block/test/content-hero-block.e2e.js +10 -0
  53. package/dist/collection/blocks/content-hero-block/test/content-hero-block.e2e.js.map +1 -0
  54. package/dist/collection/blocks/content-hero-block/test/content-hero-block.spec.js +18 -0
  55. package/dist/collection/blocks/content-hero-block/test/content-hero-block.spec.js.map +1 -0
  56. package/dist/collection/blocks/content-split-block/content-split-block.css +18 -0
  57. package/dist/collection/blocks/content-split-block/content-split-block.js +125 -0
  58. package/dist/collection/blocks/content-split-block/content-split-block.js.map +1 -0
  59. package/dist/collection/blocks/content-split-block/test/content-split-block.e2e.js +10 -0
  60. package/dist/collection/blocks/content-split-block/test/content-split-block.e2e.js.map +1 -0
  61. package/dist/collection/blocks/content-split-block/test/content-split-block.spec.js +18 -0
  62. package/dist/collection/blocks/content-split-block/test/content-split-block.spec.js.map +1 -0
  63. package/dist/collection/blocks/content-text-block/content-text-block.css +47 -0
  64. package/dist/collection/blocks/content-text-block/content-text-block.js +192 -0
  65. package/dist/collection/blocks/content-text-block/content-text-block.js.map +1 -0
  66. package/dist/collection/blocks/content-text-block/test/content-text-block.e2e.js +10 -0
  67. package/dist/collection/blocks/content-text-block/test/content-text-block.e2e.js.map +1 -0
  68. package/dist/collection/blocks/content-text-block/test/content-text-block.spec.js +18 -0
  69. package/dist/collection/blocks/content-text-block/test/content-text-block.spec.js.map +1 -0
  70. package/dist/collection/blocks/content-tout-block/content-tout-block.css +35 -0
  71. package/dist/collection/blocks/content-tout-block/content-tout-block.js +74 -0
  72. package/dist/collection/blocks/content-tout-block/content-tout-block.js.map +1 -0
  73. package/dist/collection/blocks/content-tout-block/test/content-tout-block.e2e.js +10 -0
  74. package/dist/collection/blocks/content-tout-block/test/content-tout-block.e2e.js.map +1 -0
  75. package/dist/collection/blocks/content-tout-block/test/content-tout-block.spec.js +18 -0
  76. package/dist/collection/blocks/content-tout-block/test/content-tout-block.spec.js.map +1 -0
  77. package/dist/collection/collection-manifest.json +27 -0
  78. package/dist/collection/components/content-accordion/content-accordion.css +11 -0
  79. package/dist/collection/components/content-accordion/content-accordion.js +33 -0
  80. package/dist/collection/components/content-accordion/content-accordion.js.map +1 -0
  81. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js +87 -0
  82. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js.map +1 -0
  83. package/dist/collection/components/content-accordion/test/content-accordion.e2e.js +10 -0
  84. package/dist/collection/components/content-accordion/test/content-accordion.e2e.js.map +1 -0
  85. package/dist/collection/components/content-accordion/test/content-accordion.spec.js +18 -0
  86. package/dist/collection/components/content-accordion/test/content-accordion.spec.js.map +1 -0
  87. package/dist/collection/components/content-carousel/content-carousel.css +21 -0
  88. package/dist/collection/components/content-carousel/content-carousel.js +152 -0
  89. package/dist/collection/components/content-carousel/content-carousel.js.map +1 -0
  90. package/dist/collection/components/content-carousel/test/content-carousel.e2e.js +10 -0
  91. package/dist/collection/components/content-carousel/test/content-carousel.e2e.js.map +1 -0
  92. package/dist/collection/components/content-carousel/test/content-carousel.spec.js +18 -0
  93. package/dist/collection/components/content-carousel/test/content-carousel.spec.js.map +1 -0
  94. package/dist/collection/components/content-navigation-block/content-navigation-block.css +51 -0
  95. package/dist/collection/components/content-navigation-block/content-navigation-block.js +146 -0
  96. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -0
  97. package/dist/collection/components/content-navigation-block/test/content-navigation-block.e2e.js +10 -0
  98. package/dist/collection/components/content-navigation-block/test/content-navigation-block.e2e.js.map +1 -0
  99. package/dist/collection/components/content-navigation-block/test/content-navigation-block.spec.js +18 -0
  100. package/dist/collection/components/content-navigation-block/test/content-navigation-block.spec.js.map +1 -0
  101. package/dist/collection/components/content-overlay/content-overlay.css +103 -0
  102. package/dist/collection/components/content-overlay/content-overlay.js +384 -0
  103. package/dist/collection/components/content-overlay/content-overlay.js.map +1 -0
  104. package/dist/collection/components/content-overlay/libraries/aria-dialog.js +356 -0
  105. package/dist/collection/components/content-overlay/libraries/aria-dialog.js.map +1 -0
  106. package/dist/collection/components/content-overlay/libraries/aria-utilities.js +78 -0
  107. package/dist/collection/components/content-overlay/libraries/aria-utilities.js.map +1 -0
  108. package/dist/collection/components/content-overlay/test/content-overlay.e2e.js +10 -0
  109. package/dist/collection/components/content-overlay/test/content-overlay.e2e.js.map +1 -0
  110. package/dist/collection/components/content-overlay/test/content-overlay.spec.js +18 -0
  111. package/dist/collection/components/content-overlay/test/content-overlay.spec.js.map +1 -0
  112. package/dist/collection/components/content-tabs/content-tabs.css +19 -0
  113. package/dist/collection/components/content-tabs/content-tabs.js +27 -0
  114. package/dist/collection/components/content-tabs/content-tabs.js.map +1 -0
  115. package/dist/collection/components/content-tabs/libraries/w3_tabs.js +223 -0
  116. package/dist/collection/components/content-tabs/libraries/w3_tabs.js.map +1 -0
  117. package/dist/collection/components/content-tabs/test/content-tabs.e2e.js +10 -0
  118. package/dist/collection/components/content-tabs/test/content-tabs.e2e.js.map +1 -0
  119. package/dist/collection/components/content-tabs/test/content-tabs.spec.js +18 -0
  120. package/dist/collection/components/content-tabs/test/content-tabs.spec.js.map +1 -0
  121. package/dist/collection/elements/content-button/content-button.css +37 -0
  122. package/dist/collection/elements/content-button/content-button.js +257 -0
  123. package/dist/collection/elements/content-button/content-button.js.map +1 -0
  124. package/dist/collection/elements/content-button/test/content-button.e2e.js +10 -0
  125. package/dist/collection/elements/content-button/test/content-button.e2e.js.map +1 -0
  126. package/dist/collection/elements/content-button/test/content-button.spec.js +18 -0
  127. package/dist/collection/elements/content-button/test/content-button.spec.js.map +1 -0
  128. package/dist/collection/elements/content-image/content-image.css +53 -0
  129. package/dist/collection/elements/content-image/content-image.js +305 -0
  130. package/dist/collection/elements/content-image/content-image.js.map +1 -0
  131. package/dist/collection/elements/content-image/test/content-image.e2e.js +10 -0
  132. package/dist/collection/elements/content-image/test/content-image.e2e.js.map +1 -0
  133. package/dist/collection/elements/content-image/test/content-image.spec.js +18 -0
  134. package/dist/collection/elements/content-image/test/content-image.spec.js.map +1 -0
  135. package/dist/collection/elements/content-line/content-line.css +18 -0
  136. package/dist/collection/elements/content-line/content-line.e2e.js +10 -0
  137. package/dist/collection/elements/content-line/content-line.e2e.js.map +1 -0
  138. package/dist/collection/elements/content-line/content-line.js +229 -0
  139. package/dist/collection/elements/content-line/content-line.js.map +1 -0
  140. package/dist/collection/elements/content-video/content-video.css +75 -0
  141. package/dist/collection/elements/content-video/content-video.js +391 -0
  142. package/dist/collection/elements/content-video/content-video.js.map +1 -0
  143. package/dist/collection/elements/content-video/test/content-video.e2e.js +10 -0
  144. package/dist/collection/elements/content-video/test/content-video.e2e.js.map +1 -0
  145. package/dist/collection/elements/content-video/test/content-video.spec.js +18 -0
  146. package/dist/collection/elements/content-video/test/content-video.spec.js.map +1 -0
  147. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +43 -0
  148. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +269 -0
  149. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +1 -0
  150. package/dist/collection/formatters/content-grid-formatter/test/content-grid-formatter.e2e.js +10 -0
  151. package/dist/collection/formatters/content-grid-formatter/test/content-grid-formatter.e2e.js.map +1 -0
  152. package/dist/collection/formatters/content-grid-formatter/test/content-grid-formatter.spec.js +18 -0
  153. package/dist/collection/formatters/content-grid-formatter/test/content-grid-formatter.spec.js.map +1 -0
  154. package/dist/collection/formatters/content-spacer/content-spacer.css +32 -0
  155. package/dist/collection/formatters/content-spacer/content-spacer.js +350 -0
  156. package/dist/collection/formatters/content-spacer/content-spacer.js.map +1 -0
  157. package/dist/collection/formatters/content-spacer/test/content-spacer.e2e.js +10 -0
  158. package/dist/collection/formatters/content-spacer/test/content-spacer.e2e.js.map +1 -0
  159. package/dist/collection/formatters/content-spacer/test/content-spacer.spec.js +18 -0
  160. package/dist/collection/formatters/content-spacer/test/content-spacer.spec.js.map +1 -0
  161. package/dist/collection/globalScript.js +15 -0
  162. package/dist/collection/globalScript.js.map +1 -0
  163. package/dist/collection/index.js +3 -0
  164. package/dist/collection/index.js.map +1 -0
  165. package/dist/collection/sass/_mixins.scss +249 -0
  166. package/dist/collection/sass/_variables.scss +18 -0
  167. package/dist/collection/services/content-events-service.js +23 -0
  168. package/dist/collection/services/content-events-service.js.map +1 -0
  169. package/dist/collection/services/window-resize-service.js +29 -0
  170. package/dist/collection/services/window-resize-service.js.map +1 -0
  171. package/dist/collection/utils/utils.js +88 -0
  172. package/dist/collection/utils/utils.js.map +1 -0
  173. package/dist/collection/utils/utils.spec.js +1 -0
  174. package/dist/collection/utils/utils.spec.js.map +1 -0
  175. package/dist/components/BehaviorSubject.js +637 -0
  176. package/dist/components/BehaviorSubject.js.map +1 -0
  177. package/dist/components/Youtube.js +805 -0
  178. package/dist/components/Youtube.js.map +1 -0
  179. package/dist/components/content-accordion.d.ts +11 -0
  180. package/dist/components/content-accordion.js +127 -0
  181. package/dist/components/content-accordion.js.map +1 -0
  182. package/dist/components/content-button.d.ts +11 -0
  183. package/dist/components/content-button.js +88 -0
  184. package/dist/components/content-button.js.map +1 -0
  185. package/dist/components/content-carousel.d.ts +11 -0
  186. package/dist/components/content-carousel.js +1489 -0
  187. package/dist/components/content-carousel.js.map +1 -0
  188. package/dist/components/content-grid-formatter.d.ts +11 -0
  189. package/dist/components/content-grid-formatter.js +8 -0
  190. package/dist/components/content-grid-formatter.js.map +1 -0
  191. package/dist/components/content-grid-formatter2.js +68 -0
  192. package/dist/components/content-grid-formatter2.js.map +1 -0
  193. package/dist/components/content-hero-block.d.ts +11 -0
  194. package/dist/components/content-hero-block.js +63 -0
  195. package/dist/components/content-hero-block.js.map +1 -0
  196. package/dist/components/content-image.d.ts +11 -0
  197. package/dist/components/content-image.js +120 -0
  198. package/dist/components/content-image.js.map +1 -0
  199. package/dist/components/content-line.d.ts +11 -0
  200. package/dist/components/content-line.js +70 -0
  201. package/dist/components/content-line.js.map +1 -0
  202. package/dist/components/content-navigation-block.d.ts +11 -0
  203. package/dist/components/content-navigation-block.js +79 -0
  204. package/dist/components/content-navigation-block.js.map +1 -0
  205. package/dist/components/content-overlay.d.ts +11 -0
  206. package/dist/components/content-overlay.js +2048 -0
  207. package/dist/components/content-overlay.js.map +1 -0
  208. package/dist/components/content-spacer.d.ts +11 -0
  209. package/dist/components/content-spacer.js +76 -0
  210. package/dist/components/content-spacer.js.map +1 -0
  211. package/dist/components/content-split-block.d.ts +11 -0
  212. package/dist/components/content-split-block.js +58 -0
  213. package/dist/components/content-split-block.js.map +1 -0
  214. package/dist/components/content-tabs.d.ts +11 -0
  215. package/dist/components/content-tabs.js +232 -0
  216. package/dist/components/content-tabs.js.map +1 -0
  217. package/dist/components/content-text-block.d.ts +11 -0
  218. package/dist/components/content-text-block.js +66 -0
  219. package/dist/components/content-text-block.js.map +1 -0
  220. package/dist/components/content-tout-block.d.ts +11 -0
  221. package/dist/components/content-tout-block.js +46 -0
  222. package/dist/components/content-tout-block.js.map +1 -0
  223. package/dist/components/content-video.d.ts +11 -0
  224. package/dist/components/content-video.js +141 -0
  225. package/dist/components/content-video.js.map +1 -0
  226. package/dist/components/index.d.ts +33 -0
  227. package/dist/components/index.js +4 -0
  228. package/dist/components/index.js.map +1 -0
  229. package/dist/components/swiper.js +3608 -0
  230. package/dist/components/swiper.js.map +1 -0
  231. package/dist/components/utils.js +106 -0
  232. package/dist/components/utils.js.map +1 -0
  233. package/dist/components/video.es.js +64201 -0
  234. package/dist/components/video.es.js.map +1 -0
  235. package/dist/components/window-resize-service.js +33 -0
  236. package/dist/components/window-resize-service.js.map +1 -0
  237. package/dist/content-blocks/content-blocks.esm.js +2 -0
  238. package/dist/content-blocks/content-blocks.esm.js.map +1 -0
  239. package/dist/content-blocks/index.esm.js +2 -0
  240. package/dist/content-blocks/index.esm.js.map +1 -0
  241. package/dist/content-blocks/p-03ca48aa.js +2 -0
  242. package/dist/content-blocks/p-03ca48aa.js.map +1 -0
  243. package/dist/content-blocks/p-0ee5bbb6.entry.js +2 -0
  244. package/dist/content-blocks/p-0ee5bbb6.entry.js.map +1 -0
  245. package/dist/content-blocks/p-193fa2c0.entry.js +2 -0
  246. package/dist/content-blocks/p-193fa2c0.entry.js.map +1 -0
  247. package/dist/content-blocks/p-1b699607.js +2 -0
  248. package/dist/content-blocks/p-1b699607.js.map +1 -0
  249. package/dist/content-blocks/p-1efe0577.entry.js +2 -0
  250. package/dist/content-blocks/p-1efe0577.entry.js.map +1 -0
  251. package/dist/content-blocks/p-2357f07a.entry.js +2 -0
  252. package/dist/content-blocks/p-2357f07a.entry.js.map +1 -0
  253. package/dist/content-blocks/p-363e8357.entry.js +2 -0
  254. package/dist/content-blocks/p-363e8357.entry.js.map +1 -0
  255. package/dist/content-blocks/p-36793013.entry.js +10 -0
  256. package/dist/content-blocks/p-36793013.entry.js.map +1 -0
  257. package/dist/content-blocks/p-3a170c2c.entry.js +2 -0
  258. package/dist/content-blocks/p-3a170c2c.entry.js.map +1 -0
  259. package/dist/content-blocks/p-43a91cc7.js +29 -0
  260. package/dist/content-blocks/p-43a91cc7.js.map +1 -0
  261. package/dist/content-blocks/p-6d43a03c.js +2 -0
  262. package/dist/content-blocks/p-6d43a03c.js.map +1 -0
  263. package/dist/content-blocks/p-89fb0d8f.js +2 -0
  264. package/dist/content-blocks/p-89fb0d8f.js.map +1 -0
  265. package/dist/content-blocks/p-a7dfb547.entry.js +2 -0
  266. package/dist/content-blocks/p-a7dfb547.entry.js.map +1 -0
  267. package/dist/content-blocks/p-b27d54cb.entry.js +2 -0
  268. package/dist/content-blocks/p-b27d54cb.entry.js.map +1 -0
  269. package/dist/content-blocks/p-bf1cfb7b.js +3 -0
  270. package/dist/content-blocks/p-bf1cfb7b.js.map +1 -0
  271. package/dist/content-blocks/p-c5891e59.js +2 -0
  272. package/dist/content-blocks/p-c5891e59.js.map +1 -0
  273. package/dist/content-blocks/p-cd552ce2.js +2 -0
  274. package/dist/content-blocks/p-cd552ce2.js.map +1 -0
  275. package/dist/content-blocks/p-ce179781.entry.js +2 -0
  276. package/dist/content-blocks/p-ce179781.entry.js.map +1 -0
  277. package/dist/content-blocks/p-d3503dde.entry.js +2 -0
  278. package/dist/content-blocks/p-d3503dde.entry.js.map +1 -0
  279. package/dist/content-blocks/p-dca7ab2c.entry.js +2 -0
  280. package/dist/content-blocks/p-dca7ab2c.entry.js.map +1 -0
  281. package/dist/content-blocks/sass/_mixins.scss +249 -0
  282. package/dist/content-blocks/sass/_variables.scss +18 -0
  283. package/dist/esm/BehaviorSubject-bc7e0e99.js +637 -0
  284. package/dist/esm/BehaviorSubject-bc7e0e99.js.map +1 -0
  285. package/dist/esm/Youtube-6c271d8d.js +805 -0
  286. package/dist/esm/Youtube-6c271d8d.js.map +1 -0
  287. package/dist/esm/content-accordion.entry.js +110 -0
  288. package/dist/esm/content-accordion.entry.js.map +1 -0
  289. package/dist/esm/content-blocks.js +20 -0
  290. package/dist/esm/content-blocks.js.map +1 -0
  291. package/dist/esm/content-button_4.entry.js +2158 -0
  292. package/dist/esm/content-button_4.entry.js.map +1 -0
  293. package/dist/esm/content-carousel-cf7daf22.js +1469 -0
  294. package/dist/esm/content-carousel-cf7daf22.js.map +1 -0
  295. package/dist/esm/content-carousel.entry.js +5 -0
  296. package/dist/esm/content-carousel.entry.js.map +1 -0
  297. package/dist/esm/content-grid-formatter.entry.js +46 -0
  298. package/dist/esm/content-grid-formatter.entry.js.map +1 -0
  299. package/dist/esm/content-hero-block.entry.js +42 -0
  300. package/dist/esm/content-hero-block.entry.js.map +1 -0
  301. package/dist/esm/content-image.entry.js +91 -0
  302. package/dist/esm/content-image.entry.js.map +1 -0
  303. package/dist/esm/content-navigation-block.entry.js +58 -0
  304. package/dist/esm/content-navigation-block.entry.js.map +1 -0
  305. package/dist/esm/content-split-block.entry.js +32 -0
  306. package/dist/esm/content-split-block.entry.js.map +1 -0
  307. package/dist/esm/content-tabs.entry.js +215 -0
  308. package/dist/esm/content-tabs.entry.js.map +1 -0
  309. package/dist/esm/content-text-block.entry.js +44 -0
  310. package/dist/esm/content-text-block.entry.js.map +1 -0
  311. package/dist/esm/content-tout-block.entry.js +28 -0
  312. package/dist/esm/content-tout-block.entry.js.map +1 -0
  313. package/dist/esm/content-video.entry.js +110 -0
  314. package/dist/esm/content-video.entry.js.map +1 -0
  315. package/dist/esm/index-6701e2ba.js +2087 -0
  316. package/dist/esm/index-6701e2ba.js.map +1 -0
  317. package/dist/esm/index.js +3 -0
  318. package/dist/esm/index.js.map +1 -0
  319. package/dist/esm/loader.js +11 -0
  320. package/dist/esm/loader.js.map +1 -0
  321. package/dist/esm/polyfills/core-js.js +11 -0
  322. package/dist/esm/polyfills/dom.js +79 -0
  323. package/dist/esm/polyfills/es5-html-element.js +1 -0
  324. package/dist/esm/polyfills/index.js +34 -0
  325. package/dist/esm/polyfills/system.js +6 -0
  326. package/dist/esm/swiper-977c310f.js +3610 -0
  327. package/dist/esm/swiper-977c310f.js.map +1 -0
  328. package/dist/esm/utils-27374a56.js +106 -0
  329. package/dist/esm/utils-27374a56.js.map +1 -0
  330. package/dist/esm/video.es-e4c3f886.js +64201 -0
  331. package/dist/esm/video.es-e4c3f886.js.map +1 -0
  332. package/dist/esm/window-resize-service-8a52f08c.js +33 -0
  333. package/dist/esm/window-resize-service-8a52f08c.js.map +1 -0
  334. package/dist/index.cjs.js +1 -0
  335. package/dist/index.js +1 -0
  336. package/dist/types/blocks/content-hero-block/content-hero-block.d.ts +33 -0
  337. package/dist/types/blocks/content-split-block/content-split-block.d.ts +27 -0
  338. package/dist/types/blocks/content-text-block/content-text-block.d.ts +44 -0
  339. package/dist/types/blocks/content-tout-block/content-tout-block.d.ts +22 -0
  340. package/dist/types/components/content-accordion/content-accordion.d.ts +12 -0
  341. package/dist/types/components/content-accordion/libraries/w3_disclosure_button.d.ts +4 -0
  342. package/dist/types/components/content-carousel/content-carousel.d.ts +36 -0
  343. package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +31 -0
  344. package/dist/types/components/content-overlay/content-overlay.d.ts +69 -0
  345. package/dist/types/components/content-overlay/libraries/aria-dialog.d.ts +5 -0
  346. package/dist/types/components/content-overlay/libraries/aria-utilities.d.ts +5 -0
  347. package/dist/types/components/content-tabs/content-tabs.d.ts +10 -0
  348. package/dist/types/components/content-tabs/libraries/w3_tabs.d.ts +4 -0
  349. package/dist/types/components.d.ts +994 -0
  350. package/dist/types/elements/content-button/content-button.d.ts +55 -0
  351. package/dist/types/elements/content-image/content-image.d.ts +56 -0
  352. package/dist/types/elements/content-line/content-line.d.ts +56 -0
  353. package/dist/types/elements/content-video/content-video.d.ts +77 -0
  354. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +52 -0
  355. package/dist/types/formatters/content-spacer/content-spacer.d.ts +73 -0
  356. package/dist/types/globalScript.d.ts +1 -0
  357. package/dist/types/index.d.ts +3 -0
  358. package/dist/types/services/content-events-service.d.ts +11 -0
  359. package/dist/types/services/window-resize-service.d.ts +11 -0
  360. package/dist/types/stencil-public-runtime.d.ts +1652 -0
  361. package/dist/types/typings.d.ts +11 -0
  362. package/dist/types/utils/utils.d.ts +13 -0
  363. package/loader/cdn.js +3 -0
  364. package/loader/index.cjs.js +3 -0
  365. package/loader/index.d.ts +21 -0
  366. package/loader/index.es2017.js +3 -0
  367. package/loader/index.js +4 -0
  368. package/loader/package.json +11 -0
  369. package/package.json +65 -0
@@ -0,0 +1,2165 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-a42fb1d0.js');
6
+ const windowResizeService = require('./window-resize-service-c9766178.js');
7
+ const utils = require('./utils-6c985f2f.js');
8
+ require('./BehaviorSubject-771fd78b.js');
9
+
10
+ const contentButtonCss = "content-button{display:inline-block;visibility:hidden}content-button.hydrated{visibility:inherit}content-button>a,content-button>button{display:flex;width:100%;align-items:center;justify-content:center}content-button>button{appearance:none;background:inherit;cursor:pointer}content-button[clickable-block=true]{display:block;width:100%;height:100%}content-button[clickable-block=true]>a,content-button[clickable-block=true]>button{height:100%;width:100%}content-button[clickable-block=true]>a>*,content-button[clickable-block=true]>button>*{display:block;width:100%}content-button[clickable-block=true] .content-button__clickable-content{width:100%;height:100%}";
11
+
12
+ const ContentButton = class {
13
+ constructor(hostRef) {
14
+ index.registerInstance(this, hostRef);
15
+ this.href = undefined;
16
+ this.target = undefined;
17
+ this.class = '';
18
+ this.clickableBlock = false;
19
+ this.expanded = undefined;
20
+ this.controls = undefined;
21
+ this.linkLabel = undefined;
22
+ this.linkClass = undefined;
23
+ }
24
+ componentWillLoad() {
25
+ this.activatedContent = this.hostElement.querySelector('[slot="activatedContent"]');
26
+ this.hasContentToActivate = !!this.activatedContent;
27
+ // If this is a clickable block, forcefully add a # to force an anchor link
28
+ if (!this.href || this.href === '#') {
29
+ this.href = 'javascript:void(0);';
30
+ }
31
+ return windowResizeService.WindowResizeService.registerProp(this.linkClass).subscribe(newValue => {
32
+ this.linkClass = newValue;
33
+ });
34
+ }
35
+ onHandleClickEvent(ev) {
36
+ if (this.hasContentToActivate) {
37
+ ev.preventDefault();
38
+ ev.stopPropagation();
39
+ this.activatedContent.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: this.activatedContent }));
40
+ this.activatedContent.scrollIntoView({ behavior: 'smooth' });
41
+ }
42
+ else if (this.href && this.href.length > 1 && this.href.substring(0, 1) === '#') {
43
+ let element = document.getElementById(this.href.substring(1));
44
+ if (element) {
45
+ ev.preventDefault();
46
+ ev.stopPropagation();
47
+ element.dispatchEvent(new CustomEvent('contentBlockActivated', { detail: element }));
48
+ element.scrollIntoView({ behavior: 'smooth' });
49
+ }
50
+ }
51
+ }
52
+ render() {
53
+ if (!this.classSubscription$) {
54
+ this.classSubscription$ = windowResizeService.WindowResizeService.registerProp(this.class);
55
+ this.classSubscription$.subscribe(newValue => {
56
+ this.class = utils.getHydratedClassString(newValue);
57
+ });
58
+ }
59
+ return (index.h(index.Host, { class: this.class }, index.h("a", { "aria-label": this.linkLabel, class: this.linkClass, role: this.href === 'javascript:void(0);' ? 'button' : '', onClick: ev => this.onHandleClickEvent(ev), "aria-expanded": this.expanded, "aria-controls": this.controls, href: this.href, target: this.target }, !this.clickableBlock ? (index.h("span", null, index.h("slot", { name: "content" }), index.h("slot", null))) : (index.h("div", { class: "content-button__clickable-content" }, index.h("slot", { name: "content" }), index.h("slot", null)))), index.h("slot", { name: "activatedContent" })));
60
+ }
61
+ get hostElement() { return index.getElement(this); }
62
+ };
63
+ ContentButton.style = contentButtonCss;
64
+
65
+ const contentLineCss = "content-line{display:block;word-break:break-word;white-space:normal}content-line .content-line__inner{display:inline-block;width:auto}content-line[text-align=left]{text-align:left}content-line[text-align=center]{text-align:center}content-line[text-align=right]{text-align:right}";
66
+
67
+ const ContentBlockLine = class {
68
+ constructor(hostRef) {
69
+ index.registerInstance(this, hostRef);
70
+ this.tag = 'div';
71
+ this.textAlign = 'default';
72
+ this.class = undefined;
73
+ this.maxWidth = '100%';
74
+ this.inlineStyle = {};
75
+ }
76
+ componentWillLoad() {
77
+ let promises = [];
78
+ promises.push(windowResizeService.WindowResizeService.registerProp(this.textAlign).subscribe(newValue => this.textAlign = newValue));
79
+ if (this.maxWidth) {
80
+ promises.push(windowResizeService.WindowResizeService.registerProp(this.maxWidth).subscribe((newValue) => {
81
+ this.inlineStyle = {
82
+ 'max-width': isNaN(newValue) ? newValue : newValue + '%',
83
+ };
84
+ }));
85
+ }
86
+ return Promise.allSettled(promises);
87
+ }
88
+ componentDidLoad() {
89
+ windowResizeService.WindowResizeService.registerProp(this.class).subscribe(newValue => setTimeout(() => this.class = utils.getHydratedClassString(newValue), 100));
90
+ }
91
+ render() {
92
+ if (!this.classSubscription$) {
93
+ this.classSubscription$ = windowResizeService.WindowResizeService.registerProp(this.class);
94
+ this.classSubscription$.subscribe(newValue => {
95
+ this.class = utils.getHydratedClassString(newValue);
96
+ });
97
+ }
98
+ // The capital case in this JSX variable is important
99
+ const ElementTagParsed = `${this.tag}`;
100
+ return (index.h(index.Host, { class: this.class, "text-align": this.textAlign }, index.h(ElementTagParsed, { class: "content-line__inner", style: this.inlineStyle }, index.h("slot", { name: "content" }), index.h("slot", null))));
101
+ }
102
+ };
103
+ ContentBlockLine.style = contentLineCss;
104
+
105
+ /*!
106
+ * tabbable 6.2.0
107
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
108
+ */
109
+ // NOTE: separate `:not()` selectors has broader browser support than the newer
110
+ // `:not([inert], [inert] *)` (Feb 2023)
111
+ // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
112
+ // the entire query to fail, resulting in no nodes found, which will break a lot
113
+ // of things... so we have to rely on JS to identify nodes inside an inert container
114
+ var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
115
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
116
+ var NoElement = typeof Element === 'undefined';
117
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
118
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
119
+ var _element$getRootNode;
120
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
121
+ } : function (element) {
122
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
123
+ };
124
+
125
+ /**
126
+ * Determines if a node is inert or in an inert ancestor.
127
+ * @param {Element} [node]
128
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
129
+ * see if any of them are inert. If false, only `node` itself is considered.
130
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
131
+ * False if `node` is falsy.
132
+ */
133
+ var isInert = function isInert(node, lookUp) {
134
+ var _node$getAttribute;
135
+ if (lookUp === void 0) {
136
+ lookUp = true;
137
+ }
138
+ // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
139
+ // JS API property; we have to check the attribute, which can either be empty or 'true';
140
+ // if it's `null` (not specified) or 'false', it's an active element
141
+ var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');
142
+ var inert = inertAtt === '' || inertAtt === 'true';
143
+
144
+ // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
145
+ // if it weren't for `matches()` not being a function on shadow roots; the following
146
+ // code works for any kind of node
147
+ // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
148
+ // so it likely would not support `:is([inert] *)` either...
149
+ var result = inert || lookUp && node && isInert(node.parentNode); // recursive
150
+
151
+ return result;
152
+ };
153
+
154
+ /**
155
+ * Determines if a node's content is editable.
156
+ * @param {Element} [node]
157
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
158
+ */
159
+ var isContentEditable = function isContentEditable(node) {
160
+ var _node$getAttribute2;
161
+ // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
162
+ // to use the attribute directly to check for this, which can either be empty or 'true';
163
+ // if it's `null` (not specified) or 'false', it's a non-editable element
164
+ var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');
165
+ return attValue === '' || attValue === 'true';
166
+ };
167
+
168
+ /**
169
+ * @param {Element} el container to check in
170
+ * @param {boolean} includeContainer add container to check
171
+ * @param {(node: Element) => boolean} filter filter candidates
172
+ * @returns {Element[]}
173
+ */
174
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
175
+ // even if `includeContainer=false`, we still have to check it for inertness because
176
+ // if it's inert, all its children are inert
177
+ if (isInert(el)) {
178
+ return [];
179
+ }
180
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
181
+ if (includeContainer && matches.call(el, candidateSelector)) {
182
+ candidates.unshift(el);
183
+ }
184
+ candidates = candidates.filter(filter);
185
+ return candidates;
186
+ };
187
+
188
+ /**
189
+ * @callback GetShadowRoot
190
+ * @param {Element} element to check for shadow root
191
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
192
+ */
193
+
194
+ /**
195
+ * @callback ShadowRootFilter
196
+ * @param {Element} shadowHostNode the element which contains shadow content
197
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
198
+ */
199
+
200
+ /**
201
+ * @typedef {Object} CandidateScope
202
+ * @property {Element} scopeParent contains inner candidates
203
+ * @property {Element[]} candidates list of candidates found in the scope parent
204
+ */
205
+
206
+ /**
207
+ * @typedef {Object} IterativeOptions
208
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
209
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
210
+ * or a boolean stating if it has an undisclosed shadow root
211
+ * @property {(node: Element) => boolean} filter filter candidates
212
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
213
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
214
+ */
215
+
216
+ /**
217
+ * @param {Element[]} elements list of element containers to match candidates from
218
+ * @param {boolean} includeContainer add container list to check
219
+ * @param {IterativeOptions} options
220
+ * @returns {Array.<Element|CandidateScope>}
221
+ */
222
+ var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
223
+ var candidates = [];
224
+ var elementsToCheck = Array.from(elements);
225
+ while (elementsToCheck.length) {
226
+ var element = elementsToCheck.shift();
227
+ if (isInert(element, false)) {
228
+ // no need to look up since we're drilling down
229
+ // anything inside this container will also be inert
230
+ continue;
231
+ }
232
+ if (element.tagName === 'SLOT') {
233
+ // add shadow dom slot scope (slot itself cannot be focusable)
234
+ var assigned = element.assignedElements();
235
+ var content = assigned.length ? assigned : element.children;
236
+ var nestedCandidates = getCandidatesIteratively(content, true, options);
237
+ if (options.flatten) {
238
+ candidates.push.apply(candidates, nestedCandidates);
239
+ } else {
240
+ candidates.push({
241
+ scopeParent: element,
242
+ candidates: nestedCandidates
243
+ });
244
+ }
245
+ } else {
246
+ // check candidate element
247
+ var validCandidate = matches.call(element, candidateSelector);
248
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
249
+ candidates.push(element);
250
+ }
251
+
252
+ // iterate over shadow content if possible
253
+ var shadowRoot = element.shadowRoot ||
254
+ // check for an undisclosed shadow
255
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
256
+
257
+ // no inert look up because we're already drilling down and checking for inertness
258
+ // on the way down, so all containers to this root node should have already been
259
+ // vetted as non-inert
260
+ var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
261
+ if (shadowRoot && validShadowRoot) {
262
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
263
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
264
+ // child candidates found because they're likely slotted elements (elements that are
265
+ // children of the web component element (which has the shadow), in the light dom, but
266
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
267
+ // _after_ we return from this recursive call
268
+ var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
269
+ if (options.flatten) {
270
+ candidates.push.apply(candidates, _nestedCandidates);
271
+ } else {
272
+ candidates.push({
273
+ scopeParent: element,
274
+ candidates: _nestedCandidates
275
+ });
276
+ }
277
+ } else {
278
+ // there's not shadow so just dig into the element's (light dom) children
279
+ // __without__ giving the element special scope treatment
280
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
281
+ }
282
+ }
283
+ }
284
+ return candidates;
285
+ };
286
+
287
+ /**
288
+ * @private
289
+ * Determines if the node has an explicitly specified `tabindex` attribute.
290
+ * @param {HTMLElement} node
291
+ * @returns {boolean} True if so; false if not.
292
+ */
293
+ var hasTabIndex = function hasTabIndex(node) {
294
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
295
+ };
296
+
297
+ /**
298
+ * Determine the tab index of a given node.
299
+ * @param {HTMLElement} node
300
+ * @returns {number} Tab order (negative, 0, or positive number).
301
+ * @throws {Error} If `node` is falsy.
302
+ */
303
+ var getTabIndex = function getTabIndex(node) {
304
+ if (!node) {
305
+ throw new Error('No node provided');
306
+ }
307
+ if (node.tabIndex < 0) {
308
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
309
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
310
+ // yet they are still part of the regular tab order; in FF, they get a default
311
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
312
+ // order, consider their tab index to be 0.
313
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
314
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
315
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
316
+ return 0;
317
+ }
318
+ }
319
+ return node.tabIndex;
320
+ };
321
+
322
+ /**
323
+ * Determine the tab index of a given node __for sort order purposes__.
324
+ * @param {HTMLElement} node
325
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
326
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
327
+ * inserted into the correct sort position.
328
+ * @returns {number} Tab order (negative, 0, or positive number).
329
+ */
330
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
331
+ var tabIndex = getTabIndex(node);
332
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
333
+ return 0;
334
+ }
335
+ return tabIndex;
336
+ };
337
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
338
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
339
+ };
340
+ var isInput = function isInput(node) {
341
+ return node.tagName === 'INPUT';
342
+ };
343
+ var isHiddenInput = function isHiddenInput(node) {
344
+ return isInput(node) && node.type === 'hidden';
345
+ };
346
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
347
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
348
+ return child.tagName === 'SUMMARY';
349
+ });
350
+ return r;
351
+ };
352
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
353
+ for (var i = 0; i < nodes.length; i++) {
354
+ if (nodes[i].checked && nodes[i].form === form) {
355
+ return nodes[i];
356
+ }
357
+ }
358
+ };
359
+ var isTabbableRadio = function isTabbableRadio(node) {
360
+ if (!node.name) {
361
+ return true;
362
+ }
363
+ var radioScope = node.form || getRootNode(node);
364
+ var queryRadios = function queryRadios(name) {
365
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
366
+ };
367
+ var radioSet;
368
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
369
+ radioSet = queryRadios(window.CSS.escape(node.name));
370
+ } else {
371
+ try {
372
+ radioSet = queryRadios(node.name);
373
+ } catch (err) {
374
+ // eslint-disable-next-line no-console
375
+ 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);
376
+ return false;
377
+ }
378
+ }
379
+ var checked = getCheckedRadio(radioSet, node.form);
380
+ return !checked || checked === node;
381
+ };
382
+ var isRadio = function isRadio(node) {
383
+ return isInput(node) && node.type === 'radio';
384
+ };
385
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
386
+ return isRadio(node) && !isTabbableRadio(node);
387
+ };
388
+
389
+ // determines if a node is ultimately attached to the window's document
390
+ var isNodeAttached = function isNodeAttached(node) {
391
+ var _nodeRoot;
392
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
393
+ // (but NOT _the_ document; see second 'If' comment below for more).
394
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
395
+ // is attached, and the one we need to check if it's in the document or not (because the
396
+ // shadow, and all nodes it contains, is never considered in the document since shadows
397
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
398
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
399
+ // visibility, including all the nodes it contains). The host could be any normal node,
400
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
401
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
402
+ // tested).
403
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
404
+ // that is attached (or find none) because the node might be in nested shadows...
405
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
406
+ // document (per the docs) and while it's a Document-type object, that document does not
407
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
408
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
409
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
410
+ // node is actually detached.
411
+ // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
412
+ // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
413
+ // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
414
+ // `ownerDocument` will be `null`, hence the optional chaining on it.
415
+ var nodeRoot = node && getRootNode(node);
416
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
417
+
418
+ // in some cases, a detached node will return itself as the root instead of a document or
419
+ // shadow root object, in which case, we shouldn't try to look further up the host chain
420
+ var attached = false;
421
+ if (nodeRoot && nodeRoot !== node) {
422
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
423
+ attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
424
+ while (!attached && nodeRootHost) {
425
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
426
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
427
+ // which means we need to get the host's host and check if that parent host is contained
428
+ // in (i.e. attached to) the document
429
+ nodeRoot = getRootNode(nodeRootHost);
430
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
431
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
432
+ }
433
+ }
434
+ return attached;
435
+ };
436
+ var isZeroArea = function isZeroArea(node) {
437
+ var _node$getBoundingClie = node.getBoundingClientRect(),
438
+ width = _node$getBoundingClie.width,
439
+ height = _node$getBoundingClie.height;
440
+ return width === 0 && height === 0;
441
+ };
442
+ var isHidden = function isHidden(node, _ref) {
443
+ var displayCheck = _ref.displayCheck,
444
+ getShadowRoot = _ref.getShadowRoot;
445
+ // NOTE: visibility will be `undefined` if node is detached from the document
446
+ // (see notes about this further down), which means we will consider it visible
447
+ // (this is legacy behavior from a very long way back)
448
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
449
+ // _visibility_ check, not a _display_ check
450
+ if (getComputedStyle(node).visibility === 'hidden') {
451
+ return true;
452
+ }
453
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
454
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
455
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
456
+ return true;
457
+ }
458
+ if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
459
+ if (typeof getShadowRoot === 'function') {
460
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
461
+ // 'non-zero-area' fallback
462
+ var originalNode = node;
463
+ while (node) {
464
+ var parentElement = node.parentElement;
465
+ var rootNode = getRootNode(node);
466
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
467
+ ) {
468
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
469
+ // fall back to a non-zero-area test
470
+ return isZeroArea(node);
471
+ } else if (node.assignedSlot) {
472
+ // iterate up slot
473
+ node = node.assignedSlot;
474
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
475
+ // cross shadow boundary
476
+ node = rootNode.host;
477
+ } else {
478
+ // iterate up normal dom
479
+ node = parentElement;
480
+ }
481
+ }
482
+ node = originalNode;
483
+ }
484
+ // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
485
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
486
+ // it might be a falsy value, which means shadow DOM support is disabled
487
+
488
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
489
+ // now we can just test to see if it would normally be visible or not, provided it's
490
+ // attached to the main document.
491
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
492
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
493
+
494
+ if (isNodeAttached(node)) {
495
+ // this works wherever the node is: if there's at least one client rect, it's
496
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
497
+ // node itself is hidden in place of its contents; and there's no need to search
498
+ // up the hierarchy either
499
+ return !node.getClientRects().length;
500
+ }
501
+
502
+ // Else, the node isn't attached to the document, which means the `getClientRects()`
503
+ // API will __always__ return zero rects (this can happen, for example, if React
504
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
505
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
506
+ //
507
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
508
+ // because styles are only computed for nodes that are in the document.
509
+ //
510
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
511
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
512
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
513
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
514
+ // considering __everything__ to be visible because of the innability to determine styles.
515
+ //
516
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
517
+ // nodes as visible with the 'none' fallback.__
518
+ if (displayCheck !== 'legacy-full') {
519
+ return true; // hidden
520
+ }
521
+ // else, fallback to 'none' mode and consider the node visible
522
+ } else if (displayCheck === 'non-zero-area') {
523
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
524
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
525
+ // client rect, we don't special-case for whether the node is attached or not. In
526
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
527
+ // times, and that includes attached or not.
528
+ return isZeroArea(node);
529
+ }
530
+
531
+ // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
532
+ // it's visible
533
+ return false;
534
+ };
535
+
536
+ // form fields (nested) inside a disabled fieldset are not focusable/tabbable
537
+ // unless they are in the _first_ <legend> element of the top-most disabled
538
+ // fieldset
539
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
540
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
541
+ var parentNode = node.parentElement;
542
+ // check if `node` is contained in a disabled <fieldset>
543
+ while (parentNode) {
544
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
545
+ // look for the first <legend> among the children of the disabled <fieldset>
546
+ for (var i = 0; i < parentNode.children.length; i++) {
547
+ var child = parentNode.children.item(i);
548
+ // when the first <legend> (in document order) is found
549
+ if (child.tagName === 'LEGEND') {
550
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
551
+ // return whether `node` is a descendant of its first <legend>
552
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
553
+ }
554
+ }
555
+ // the disabled <fieldset> containing `node` has no <legend>
556
+ return true;
557
+ }
558
+ parentNode = parentNode.parentElement;
559
+ }
560
+ }
561
+
562
+ // else, node's tabbable/focusable state should not be affected by a fieldset's
563
+ // enabled/disabled state
564
+ return false;
565
+ };
566
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
567
+ if (node.disabled ||
568
+ // we must do an inert look up to filter out any elements inside an inert ancestor
569
+ // because we're limited in the type of selectors we can use in JSDom (see related
570
+ // note related to `candidateSelectors`)
571
+ isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
572
+ // For a details element with a summary, the summary element gets the focus
573
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
574
+ return false;
575
+ }
576
+ return true;
577
+ };
578
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
579
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
580
+ return false;
581
+ }
582
+ return true;
583
+ };
584
+ var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
585
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
586
+ if (isNaN(tabIndex) || tabIndex >= 0) {
587
+ return true;
588
+ }
589
+ // If a custom element has an explicit negative tabindex,
590
+ // browsers will not allow tab targeting said element's children.
591
+ return false;
592
+ };
593
+
594
+ /**
595
+ * @param {Array.<Element|CandidateScope>} candidates
596
+ * @returns Element[]
597
+ */
598
+ var sortByOrder = function sortByOrder(candidates) {
599
+ var regularTabbables = [];
600
+ var orderedTabbables = [];
601
+ candidates.forEach(function (item, i) {
602
+ var isScope = !!item.scopeParent;
603
+ var element = isScope ? item.scopeParent : item;
604
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
605
+ var elements = isScope ? sortByOrder(item.candidates) : element;
606
+ if (candidateTabindex === 0) {
607
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
608
+ } else {
609
+ orderedTabbables.push({
610
+ documentOrder: i,
611
+ tabIndex: candidateTabindex,
612
+ item: item,
613
+ isScope: isScope,
614
+ content: elements
615
+ });
616
+ }
617
+ });
618
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
619
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
620
+ return acc;
621
+ }, []).concat(regularTabbables);
622
+ };
623
+ var tabbable = function tabbable(container, options) {
624
+ options = options || {};
625
+ var candidates;
626
+ if (options.getShadowRoot) {
627
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
628
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
629
+ flatten: false,
630
+ getShadowRoot: options.getShadowRoot,
631
+ shadowRootFilter: isValidShadowRootTabbable
632
+ });
633
+ } else {
634
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
635
+ }
636
+ return sortByOrder(candidates);
637
+ };
638
+ var focusable = function focusable(container, options) {
639
+ options = options || {};
640
+ var candidates;
641
+ if (options.getShadowRoot) {
642
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
643
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
644
+ flatten: true,
645
+ getShadowRoot: options.getShadowRoot
646
+ });
647
+ } else {
648
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
649
+ }
650
+ return candidates;
651
+ };
652
+ var isTabbable = function isTabbable(node, options) {
653
+ options = options || {};
654
+ if (!node) {
655
+ throw new Error('No node provided');
656
+ }
657
+ if (matches.call(node, candidateSelector) === false) {
658
+ return false;
659
+ }
660
+ return isNodeMatchingSelectorTabbable(options, node);
661
+ };
662
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
663
+ var isFocusable = function isFocusable(node, options) {
664
+ options = options || {};
665
+ if (!node) {
666
+ throw new Error('No node provided');
667
+ }
668
+ if (matches.call(node, focusableCandidateSelector) === false) {
669
+ return false;
670
+ }
671
+ return isNodeMatchingSelectorFocusable(options, node);
672
+ };
673
+
674
+ /*!
675
+ * focus-trap 7.5.2
676
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
677
+ */
678
+
679
+ function ownKeys(object, enumerableOnly) {
680
+ var keys = Object.keys(object);
681
+ if (Object.getOwnPropertySymbols) {
682
+ var symbols = Object.getOwnPropertySymbols(object);
683
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
684
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
685
+ })), keys.push.apply(keys, symbols);
686
+ }
687
+ return keys;
688
+ }
689
+ function _objectSpread2(target) {
690
+ for (var i = 1; i < arguments.length; i++) {
691
+ var source = null != arguments[i] ? arguments[i] : {};
692
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
693
+ _defineProperty(target, key, source[key]);
694
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
695
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
696
+ });
697
+ }
698
+ return target;
699
+ }
700
+ function _defineProperty(obj, key, value) {
701
+ key = _toPropertyKey(key);
702
+ if (key in obj) {
703
+ Object.defineProperty(obj, key, {
704
+ value: value,
705
+ enumerable: true,
706
+ configurable: true,
707
+ writable: true
708
+ });
709
+ } else {
710
+ obj[key] = value;
711
+ }
712
+ return obj;
713
+ }
714
+ function _toPrimitive(input, hint) {
715
+ if (typeof input !== "object" || input === null) return input;
716
+ var prim = input[Symbol.toPrimitive];
717
+ if (prim !== undefined) {
718
+ var res = prim.call(input, hint || "default");
719
+ if (typeof res !== "object") return res;
720
+ throw new TypeError("@@toPrimitive must return a primitive value.");
721
+ }
722
+ return (hint === "string" ? String : Number)(input);
723
+ }
724
+ function _toPropertyKey(arg) {
725
+ var key = _toPrimitive(arg, "string");
726
+ return typeof key === "symbol" ? key : String(key);
727
+ }
728
+
729
+ var activeFocusTraps = {
730
+ activateTrap: function activateTrap(trapStack, trap) {
731
+ if (trapStack.length > 0) {
732
+ var activeTrap = trapStack[trapStack.length - 1];
733
+ if (activeTrap !== trap) {
734
+ activeTrap.pause();
735
+ }
736
+ }
737
+ var trapIndex = trapStack.indexOf(trap);
738
+ if (trapIndex === -1) {
739
+ trapStack.push(trap);
740
+ } else {
741
+ // move this existing trap to the front of the queue
742
+ trapStack.splice(trapIndex, 1);
743
+ trapStack.push(trap);
744
+ }
745
+ },
746
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
747
+ var trapIndex = trapStack.indexOf(trap);
748
+ if (trapIndex !== -1) {
749
+ trapStack.splice(trapIndex, 1);
750
+ }
751
+ if (trapStack.length > 0) {
752
+ trapStack[trapStack.length - 1].unpause();
753
+ }
754
+ }
755
+ };
756
+ var isSelectableInput = function isSelectableInput(node) {
757
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
758
+ };
759
+ var isEscapeEvent = function isEscapeEvent(e) {
760
+ 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;
761
+ };
762
+ var isTabEvent = function isTabEvent(e) {
763
+ return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
764
+ };
765
+
766
+ // checks for TAB by default
767
+ var isKeyForward = function isKeyForward(e) {
768
+ return isTabEvent(e) && !e.shiftKey;
769
+ };
770
+
771
+ // checks for SHIFT+TAB by default
772
+ var isKeyBackward = function isKeyBackward(e) {
773
+ return isTabEvent(e) && e.shiftKey;
774
+ };
775
+ var delay = function delay(fn) {
776
+ return setTimeout(fn, 0);
777
+ };
778
+
779
+ // Array.find/findIndex() are not supported on IE; this replicates enough
780
+ // of Array.findIndex() for our needs
781
+ var findIndex = function findIndex(arr, fn) {
782
+ var idx = -1;
783
+ arr.every(function (value, i) {
784
+ if (fn(value)) {
785
+ idx = i;
786
+ return false; // break
787
+ }
788
+
789
+ return true; // next
790
+ });
791
+
792
+ return idx;
793
+ };
794
+
795
+ /**
796
+ * Get an option's value when it could be a plain value, or a handler that provides
797
+ * the value.
798
+ * @param {*} value Option's value to check.
799
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
800
+ * @returns {*} The `value`, or the handler's returned value.
801
+ */
802
+ var valueOrHandler = function valueOrHandler(value) {
803
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
804
+ params[_key - 1] = arguments[_key];
805
+ }
806
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
807
+ };
808
+ var getActualTarget = function getActualTarget(event) {
809
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
810
+ // shadow host. However, event.target.composedPath() will be an array of
811
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
812
+ // outer-most (the host HTML document). If we have access to composedPath(),
813
+ // then use its first element; otherwise, fall back to event.target (and
814
+ // this only works for an _open_ shadow DOM; otherwise,
815
+ // composedPath()[0] === event.target always).
816
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
817
+ };
818
+
819
+ // NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
820
+ // current instance use the same stack if `userOptions.trapStack` isn't specified
821
+ var internalTrapStack = [];
822
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
823
+ // SSR: a live trap shouldn't be created in this type of environment so this
824
+ // should be safe code to execute if the `document` option isn't specified
825
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
826
+ var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
827
+ var config = _objectSpread2({
828
+ returnFocusOnDeactivate: true,
829
+ escapeDeactivates: true,
830
+ delayInitialFocus: true,
831
+ isKeyForward: isKeyForward,
832
+ isKeyBackward: isKeyBackward
833
+ }, userOptions);
834
+ var state = {
835
+ // containers given to createFocusTrap()
836
+ // @type {Array<HTMLElement>}
837
+ containers: [],
838
+ // list of objects identifying tabbable nodes in `containers` in the trap
839
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
840
+ // is active, but the trap should never get to a state where there isn't at least one group
841
+ // with at least one tabbable node in it (that would lead to an error condition that would
842
+ // result in an error being thrown)
843
+ // @type {Array<{
844
+ // container: HTMLElement,
845
+ // tabbableNodes: Array<HTMLElement>, // empty if none
846
+ // focusableNodes: Array<HTMLElement>, // empty if none
847
+ // posTabIndexesFound: boolean,
848
+ // firstTabbableNode: HTMLElement|undefined,
849
+ // lastTabbableNode: HTMLElement|undefined,
850
+ // firstDomTabbableNode: HTMLElement|undefined,
851
+ // lastDomTabbableNode: HTMLElement|undefined,
852
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
853
+ // }>}
854
+ containerGroups: [],
855
+ // same order/length as `containers` list
856
+
857
+ // references to objects in `containerGroups`, but only those that actually have
858
+ // tabbable nodes in them
859
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
860
+ // the same length
861
+ tabbableGroups: [],
862
+ nodeFocusedBeforeActivation: null,
863
+ mostRecentlyFocusedNode: null,
864
+ active: false,
865
+ paused: false,
866
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
867
+ // has been delayed during activation
868
+ delayInitialFocusTimer: undefined,
869
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
870
+ recentNavEvent: undefined
871
+ };
872
+ 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
873
+
874
+ /**
875
+ * Gets a configuration option value.
876
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
877
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
878
+ * @param {string} optionName Name of the option whose value is sought.
879
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
880
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
881
+ */
882
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
883
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
884
+ };
885
+
886
+ /**
887
+ * Finds the index of the container that contains the element.
888
+ * @param {HTMLElement} element
889
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
890
+ * the event's composed path is used to see if includes any known trap containers in the
891
+ * case where the element is inside a Shadow DOM.
892
+ * @returns {number} Index of the container in either `state.containers` or
893
+ * `state.containerGroups` (the order/length of these lists are the same); -1
894
+ * if the element isn't found.
895
+ */
896
+ var findContainerIndex = function findContainerIndex(element, event) {
897
+ var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
898
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
899
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
900
+ // and we still need to find the element in there
901
+ return state.containerGroups.findIndex(function (_ref) {
902
+ var container = _ref.container,
903
+ tabbableNodes = _ref.tabbableNodes;
904
+ return container.contains(element) || ( // fall back to explicit tabbable search which will take into consideration any
905
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
906
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
907
+ // look inside web components even if open)
908
+ composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
909
+ return node === element;
910
+ });
911
+ });
912
+ };
913
+
914
+ /**
915
+ * Gets the node for the given option, which is expected to be an option that
916
+ * can be either a DOM node, a string that is a selector to get a node, `false`
917
+ * (if a node is explicitly NOT given), or a function that returns any of these
918
+ * values.
919
+ * @param {string} optionName
920
+ * @returns {undefined | false | HTMLElement | SVGElement} Returns
921
+ * `undefined` if the option is not specified; `false` if the option
922
+ * resolved to `false` (node explicitly not given); otherwise, the resolved
923
+ * DOM node.
924
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
925
+ * resolve to a node.
926
+ */
927
+ var getNodeForOption = function getNodeForOption(optionName) {
928
+ var optionValue = config[optionName];
929
+ if (typeof optionValue === 'function') {
930
+ for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
931
+ params[_key2 - 1] = arguments[_key2];
932
+ }
933
+ optionValue = optionValue.apply(void 0, params);
934
+ }
935
+ if (optionValue === true) {
936
+ optionValue = undefined; // use default value
937
+ }
938
+
939
+ if (!optionValue) {
940
+ if (optionValue === undefined || optionValue === false) {
941
+ return optionValue;
942
+ }
943
+ // else, empty string (invalid), null (invalid), 0 (invalid)
944
+
945
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
946
+ }
947
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
948
+
949
+ if (typeof optionValue === 'string') {
950
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
951
+ if (!node) {
952
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
953
+ }
954
+ }
955
+ return node;
956
+ };
957
+ var getInitialFocusNode = function getInitialFocusNode() {
958
+ var node = getNodeForOption('initialFocus');
959
+
960
+ // false explicitly indicates we want no initialFocus at all
961
+ if (node === false) {
962
+ return false;
963
+ }
964
+ if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
965
+ // option not specified nor focusable: use fallback options
966
+ if (findContainerIndex(doc.activeElement) >= 0) {
967
+ node = doc.activeElement;
968
+ } else {
969
+ var firstTabbableGroup = state.tabbableGroups[0];
970
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
971
+
972
+ // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
973
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
974
+ }
975
+ }
976
+ if (!node) {
977
+ throw new Error('Your focus-trap needs to have at least one focusable element');
978
+ }
979
+ return node;
980
+ };
981
+ var updateTabbableNodes = function updateTabbableNodes() {
982
+ state.containerGroups = state.containers.map(function (container) {
983
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
984
+
985
+ // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
986
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
987
+ // are focusable but not tabbable
988
+ var focusableNodes = focusable(container, config.tabbableOptions);
989
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
990
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
991
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
992
+ return isTabbable(node);
993
+ });
994
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
995
+ return isTabbable(node);
996
+ });
997
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
998
+ return getTabIndex(node) > 0;
999
+ });
1000
+ return {
1001
+ container: container,
1002
+ tabbableNodes: tabbableNodes,
1003
+ focusableNodes: focusableNodes,
1004
+ /** True if at least one node with positive `tabindex` was found in this container. */
1005
+ posTabIndexesFound: posTabIndexesFound,
1006
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
1007
+ firstTabbableNode: firstTabbableNode,
1008
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
1009
+ lastTabbableNode: lastTabbableNode,
1010
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
1011
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
1012
+ // because that API doesn't work with Shadow DOM as well as it should (@see
1013
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
1014
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
1015
+ // "close enough most of the time" alternative for positive tabindexes which should generally
1016
+ // be avoided anyway...
1017
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
1018
+ firstDomTabbableNode: firstDomTabbableNode,
1019
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
1020
+ lastDomTabbableNode: lastDomTabbableNode,
1021
+ /**
1022
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
1023
+ * in this container, if any.
1024
+ * @param {HTMLElement} node
1025
+ * @param {boolean} [forward] True if going in forward tab order; false if going
1026
+ * in reverse.
1027
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
1028
+ */
1029
+ nextTabbableNode: function nextTabbableNode(node) {
1030
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1031
+ var nodeIdx = tabbableNodes.indexOf(node);
1032
+ if (nodeIdx < 0) {
1033
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
1034
+ // since `node` should at least have been focusable, we assume that's the case and mimic
1035
+ // what browsers do, which is set focus to the next node in __document position order__,
1036
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
1037
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
1038
+ // basic DOM order
1039
+ if (forward) {
1040
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
1041
+ return isTabbable(el);
1042
+ });
1043
+ }
1044
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
1045
+ return isTabbable(el);
1046
+ });
1047
+ }
1048
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
1049
+ }
1050
+ };
1051
+ });
1052
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
1053
+ return group.tabbableNodes.length > 0;
1054
+ });
1055
+
1056
+ // throw if no groups have tabbable nodes and we don't have a fallback focus node either
1057
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
1058
+ ) {
1059
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
1060
+ }
1061
+
1062
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
1063
+ // doing it across multiple containers where tabindexes could be all over the place
1064
+ // would require Tabbable to support multiple containers, would require additional
1065
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
1066
+ // to look at those containers in document position order rather than user-provided
1067
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
1068
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
1069
+ if (state.containerGroups.find(function (g) {
1070
+ return g.posTabIndexesFound;
1071
+ }) && state.containerGroups.length > 1) {
1072
+ 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.");
1073
+ }
1074
+ };
1075
+ var tryFocus = function tryFocus(node) {
1076
+ if (node === false) {
1077
+ return;
1078
+ }
1079
+ if (node === doc.activeElement) {
1080
+ return;
1081
+ }
1082
+ if (!node || !node.focus) {
1083
+ tryFocus(getInitialFocusNode());
1084
+ return;
1085
+ }
1086
+ node.focus({
1087
+ preventScroll: !!config.preventScroll
1088
+ });
1089
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
1090
+ state.mostRecentlyFocusedNode = node;
1091
+ if (isSelectableInput(node)) {
1092
+ node.select();
1093
+ }
1094
+ };
1095
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
1096
+ var node = getNodeForOption('setReturnFocus', previousActiveElement);
1097
+ return node ? node : node === false ? false : previousActiveElement;
1098
+ };
1099
+
1100
+ /**
1101
+ * Finds the next node (in either direction) where focus should move according to a
1102
+ * keyboard focus-in event.
1103
+ * @param {Object} params
1104
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
1105
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
1106
+ * will be used to determine the `target`). Ignored if `target` is specified.
1107
+ * @param {boolean} [params.isBackward] True if focus should move backward.
1108
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
1109
+ * determined given the current state of the trap.
1110
+ */
1111
+ var findNextNavNode = function findNextNavNode(_ref2) {
1112
+ var target = _ref2.target,
1113
+ event = _ref2.event,
1114
+ _ref2$isBackward = _ref2.isBackward,
1115
+ isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
1116
+ target = target || getActualTarget(event);
1117
+ updateTabbableNodes();
1118
+ var destinationNode = null;
1119
+ if (state.tabbableGroups.length > 0) {
1120
+ // make sure the target is actually contained in a group
1121
+ // NOTE: the target may also be the container itself if it's focusable
1122
+ // with tabIndex='-1' and was given initial focus
1123
+ var containerIndex = findContainerIndex(target, event);
1124
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
1125
+ if (containerIndex < 0) {
1126
+ // target not found in any group: quite possible focus has escaped the trap,
1127
+ // so bring it back into...
1128
+ if (isBackward) {
1129
+ // ...the last node in the last group
1130
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
1131
+ } else {
1132
+ // ...the first node in the first group
1133
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
1134
+ }
1135
+ } else if (isBackward) {
1136
+ // REVERSE
1137
+
1138
+ // is the target the first tabbable node in a group?
1139
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
1140
+ var firstTabbableNode = _ref3.firstTabbableNode;
1141
+ return target === firstTabbableNode;
1142
+ });
1143
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
1144
+ // an exception case where the target is either the container itself, or
1145
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1146
+ // and user clicked on it or node was programmatically given focus)
1147
+ // and is not followed by any other tabbable node, in which
1148
+ // case, we should handle shift+tab as if focus were on the container's
1149
+ // first tabbable node, and go to the last tabbable node of the LAST group
1150
+ startOfGroupIndex = containerIndex;
1151
+ }
1152
+ if (startOfGroupIndex >= 0) {
1153
+ // YES: then shift+tab should go to the last tabbable node in the
1154
+ // previous group (and wrap around to the last tabbable node of
1155
+ // the LAST group if it's the first tabbable node of the FIRST group)
1156
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
1157
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
1158
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
1159
+ } else if (!isTabEvent(event)) {
1160
+ // user must have customized the nav keys so we have to move focus manually _within_
1161
+ // the active group: do this based on the order determined by tabbable()
1162
+ destinationNode = containerGroup.nextTabbableNode(target, false);
1163
+ }
1164
+ } else {
1165
+ // FORWARD
1166
+
1167
+ // is the target the last tabbable node in a group?
1168
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
1169
+ var lastTabbableNode = _ref4.lastTabbableNode;
1170
+ return target === lastTabbableNode;
1171
+ });
1172
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
1173
+ // an exception case where the target is the container itself, or
1174
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1175
+ // and user clicked on it or node was programmatically given focus)
1176
+ // and is not followed by any other tabbable node, in which
1177
+ // case, we should handle tab as if focus were on the container's
1178
+ // last tabbable node, and go to the first tabbable node of the FIRST group
1179
+ lastOfGroupIndex = containerIndex;
1180
+ }
1181
+ if (lastOfGroupIndex >= 0) {
1182
+ // YES: then tab should go to the first tabbable node in the next
1183
+ // group (and wrap around to the first tabbable node of the FIRST
1184
+ // group if it's the last tabbable node of the LAST group)
1185
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
1186
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
1187
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
1188
+ } else if (!isTabEvent(event)) {
1189
+ // user must have customized the nav keys so we have to move focus manually _within_
1190
+ // the active group: do this based on the order determined by tabbable()
1191
+ destinationNode = containerGroup.nextTabbableNode(target);
1192
+ }
1193
+ }
1194
+ } else {
1195
+ // no groups available
1196
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
1197
+ destinationNode = getNodeForOption('fallbackFocus');
1198
+ }
1199
+ return destinationNode;
1200
+ };
1201
+
1202
+ // This needs to be done on mousedown and touchstart instead of click
1203
+ // so that it precedes the focus event.
1204
+ var checkPointerDown = function checkPointerDown(e) {
1205
+ var target = getActualTarget(e);
1206
+ if (findContainerIndex(target, e) >= 0) {
1207
+ // allow the click since it ocurred inside the trap
1208
+ return;
1209
+ }
1210
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1211
+ // immediately deactivate the trap
1212
+ trap.deactivate({
1213
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
1214
+ // which will result in the outside click setting focus to the node
1215
+ // that was clicked (and if not focusable, to "nothing"); by setting
1216
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
1217
+ // on activation (or the configured `setReturnFocus` node), whether the
1218
+ // outside click was on a focusable node or not
1219
+ returnFocus: config.returnFocusOnDeactivate
1220
+ });
1221
+ return;
1222
+ }
1223
+
1224
+ // This is needed for mobile devices.
1225
+ // (If we'll only let `click` events through,
1226
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
1227
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1228
+ // allow the click outside the trap to take place
1229
+ return;
1230
+ }
1231
+
1232
+ // otherwise, prevent the click
1233
+ e.preventDefault();
1234
+ };
1235
+
1236
+ // In case focus escapes the trap for some strange reason, pull it back in.
1237
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
1238
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
1239
+ // prevent that from happening by the time we discover that focus escaped
1240
+ var checkFocusIn = function checkFocusIn(event) {
1241
+ var target = getActualTarget(event);
1242
+ var targetContained = findContainerIndex(target, event) >= 0;
1243
+
1244
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
1245
+ if (targetContained || target instanceof Document) {
1246
+ if (targetContained) {
1247
+ state.mostRecentlyFocusedNode = target;
1248
+ }
1249
+ } else {
1250
+ // escaped! pull it back in to where it just left
1251
+ event.stopImmediatePropagation();
1252
+
1253
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
1254
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
1255
+ // toward a node with a positive tab index
1256
+ var nextNode; // next node to focus, if we find one
1257
+ var navAcrossContainers = true;
1258
+ if (state.mostRecentlyFocusedNode) {
1259
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
1260
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
1261
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
1262
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
1263
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
1264
+ // with at least one tabbable node in order to function, so this could be the other container
1265
+ // with nothing tabbable in it)
1266
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
1267
+ if (tabbableNodes.length > 0) {
1268
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
1269
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
1270
+ return node === state.mostRecentlyFocusedNode;
1271
+ });
1272
+ if (mruTabIdx >= 0) {
1273
+ if (config.isKeyForward(state.recentNavEvent)) {
1274
+ if (mruTabIdx + 1 < tabbableNodes.length) {
1275
+ nextNode = tabbableNodes[mruTabIdx + 1];
1276
+ navAcrossContainers = false;
1277
+ }
1278
+ // else, don't wrap within the container as focus should move to next/previous
1279
+ // container
1280
+ } else {
1281
+ if (mruTabIdx - 1 >= 0) {
1282
+ nextNode = tabbableNodes[mruTabIdx - 1];
1283
+ navAcrossContainers = false;
1284
+ }
1285
+ // else, don't wrap within the container as focus should move to next/previous
1286
+ // container
1287
+ }
1288
+ // else, don't find in container order without considering direction too
1289
+ }
1290
+ }
1291
+ // else, no tabbable nodes in that container (which means we must have at least one other
1292
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
1293
+ // an error the last time updateTabbableNodes() was run): find next node among all known
1294
+ // containers
1295
+ } else {
1296
+ // check to see if there's at least one tabbable node with a positive tab index inside
1297
+ // the trap because focus seems to escape when navigating backward from a tabbable node
1298
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
1299
+ // the greatest positive tab index like it should)
1300
+ if (!state.containerGroups.some(function (g) {
1301
+ return g.tabbableNodes.some(function (n) {
1302
+ return getTabIndex(n) > 0;
1303
+ });
1304
+ })) {
1305
+ // no containers with tabbable nodes with positive tab indexes which means the focus
1306
+ // escaped for some other reason and we should just execute the fallback to the
1307
+ // MRU node or initial focus node, if any
1308
+ navAcrossContainers = false;
1309
+ }
1310
+ }
1311
+ } else {
1312
+ // no MRU node means we're likely in some initial condition when the trap has just
1313
+ // been activated and initial focus hasn't been given yet, in which case we should
1314
+ // fall through to trying to focus the initial focus node, which is what should
1315
+ // happen below at this point in the logic
1316
+ navAcrossContainers = false;
1317
+ }
1318
+ if (navAcrossContainers) {
1319
+ nextNode = findNextNavNode({
1320
+ // move FROM the MRU node, not event-related node (which will be the node that is
1321
+ // outside the trap causing the focus escape we're trying to fix)
1322
+ target: state.mostRecentlyFocusedNode,
1323
+ isBackward: config.isKeyBackward(state.recentNavEvent)
1324
+ });
1325
+ }
1326
+ if (nextNode) {
1327
+ tryFocus(nextNode);
1328
+ } else {
1329
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
1330
+ }
1331
+ }
1332
+ state.recentNavEvent = undefined; // clear
1333
+ };
1334
+
1335
+ // Hijack key nav events on the first and last focusable nodes of the trap,
1336
+ // in order to prevent focus from escaping. If it escapes for even a
1337
+ // moment it can end up scrolling the page and causing confusion so we
1338
+ // kind of need to capture the action at the keydown phase.
1339
+ var checkKeyNav = function checkKeyNav(event) {
1340
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1341
+ state.recentNavEvent = event;
1342
+ var destinationNode = findNextNavNode({
1343
+ event: event,
1344
+ isBackward: isBackward
1345
+ });
1346
+ if (destinationNode) {
1347
+ if (isTabEvent(event)) {
1348
+ // since tab natively moves focus, we wouldn't have a destination node unless we
1349
+ // were on the edge of a container and had to move to the next/previous edge, in
1350
+ // which case we want to prevent default to keep the browser from moving focus
1351
+ // to where it normally would
1352
+ event.preventDefault();
1353
+ }
1354
+ tryFocus(destinationNode);
1355
+ }
1356
+ // else, let the browser take care of [shift+]tab and move the focus
1357
+ };
1358
+
1359
+ var checkKey = function checkKey(event) {
1360
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
1361
+ event.preventDefault();
1362
+ trap.deactivate();
1363
+ return;
1364
+ }
1365
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
1366
+ checkKeyNav(event, config.isKeyBackward(event));
1367
+ }
1368
+ };
1369
+ var checkClick = function checkClick(e) {
1370
+ var target = getActualTarget(e);
1371
+ if (findContainerIndex(target, e) >= 0) {
1372
+ return;
1373
+ }
1374
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1375
+ return;
1376
+ }
1377
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1378
+ return;
1379
+ }
1380
+ e.preventDefault();
1381
+ e.stopImmediatePropagation();
1382
+ };
1383
+
1384
+ //
1385
+ // EVENT LISTENERS
1386
+ //
1387
+
1388
+ var addListeners = function addListeners() {
1389
+ if (!state.active) {
1390
+ return;
1391
+ }
1392
+
1393
+ // There can be only one listening focus trap at a time
1394
+ activeFocusTraps.activateTrap(trapStack, trap);
1395
+
1396
+ // Delay ensures that the focused element doesn't capture the event
1397
+ // that caused the focus trap activation.
1398
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
1399
+ tryFocus(getInitialFocusNode());
1400
+ }) : tryFocus(getInitialFocusNode());
1401
+ doc.addEventListener('focusin', checkFocusIn, true);
1402
+ doc.addEventListener('mousedown', checkPointerDown, {
1403
+ capture: true,
1404
+ passive: false
1405
+ });
1406
+ doc.addEventListener('touchstart', checkPointerDown, {
1407
+ capture: true,
1408
+ passive: false
1409
+ });
1410
+ doc.addEventListener('click', checkClick, {
1411
+ capture: true,
1412
+ passive: false
1413
+ });
1414
+ doc.addEventListener('keydown', checkKey, {
1415
+ capture: true,
1416
+ passive: false
1417
+ });
1418
+ return trap;
1419
+ };
1420
+ var removeListeners = function removeListeners() {
1421
+ if (!state.active) {
1422
+ return;
1423
+ }
1424
+ doc.removeEventListener('focusin', checkFocusIn, true);
1425
+ doc.removeEventListener('mousedown', checkPointerDown, true);
1426
+ doc.removeEventListener('touchstart', checkPointerDown, true);
1427
+ doc.removeEventListener('click', checkClick, true);
1428
+ doc.removeEventListener('keydown', checkKey, true);
1429
+ return trap;
1430
+ };
1431
+
1432
+ //
1433
+ // MUTATION OBSERVER
1434
+ //
1435
+
1436
+ var checkDomRemoval = function checkDomRemoval(mutations) {
1437
+ var isFocusedNodeRemoved = mutations.some(function (mutation) {
1438
+ var removedNodes = Array.from(mutation.removedNodes);
1439
+ return removedNodes.some(function (node) {
1440
+ return node === state.mostRecentlyFocusedNode;
1441
+ });
1442
+ });
1443
+
1444
+ // If the currently focused is removed then browsers will move focus to the
1445
+ // <body> element. If this happens, try to move focus back into the trap.
1446
+ if (isFocusedNodeRemoved) {
1447
+ tryFocus(getInitialFocusNode());
1448
+ }
1449
+ };
1450
+
1451
+ // Use MutationObserver - if supported - to detect if focused node is removed
1452
+ // from the DOM.
1453
+ var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
1454
+ var updateObservedNodes = function updateObservedNodes() {
1455
+ if (!mutationObserver) {
1456
+ return;
1457
+ }
1458
+ mutationObserver.disconnect();
1459
+ if (state.active && !state.paused) {
1460
+ state.containers.map(function (container) {
1461
+ mutationObserver.observe(container, {
1462
+ subtree: true,
1463
+ childList: true
1464
+ });
1465
+ });
1466
+ }
1467
+ };
1468
+
1469
+ //
1470
+ // TRAP DEFINITION
1471
+ //
1472
+
1473
+ trap = {
1474
+ get active() {
1475
+ return state.active;
1476
+ },
1477
+ get paused() {
1478
+ return state.paused;
1479
+ },
1480
+ activate: function activate(activateOptions) {
1481
+ if (state.active) {
1482
+ return this;
1483
+ }
1484
+ var onActivate = getOption(activateOptions, 'onActivate');
1485
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
1486
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
1487
+ if (!checkCanFocusTrap) {
1488
+ updateTabbableNodes();
1489
+ }
1490
+ state.active = true;
1491
+ state.paused = false;
1492
+ state.nodeFocusedBeforeActivation = doc.activeElement;
1493
+ onActivate === null || onActivate === void 0 ? void 0 : onActivate();
1494
+ var finishActivation = function finishActivation() {
1495
+ if (checkCanFocusTrap) {
1496
+ updateTabbableNodes();
1497
+ }
1498
+ addListeners();
1499
+ updateObservedNodes();
1500
+ onPostActivate === null || onPostActivate === void 0 ? void 0 : onPostActivate();
1501
+ };
1502
+ if (checkCanFocusTrap) {
1503
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1504
+ return this;
1505
+ }
1506
+ finishActivation();
1507
+ return this;
1508
+ },
1509
+ deactivate: function deactivate(deactivateOptions) {
1510
+ if (!state.active) {
1511
+ return this;
1512
+ }
1513
+ var options = _objectSpread2({
1514
+ onDeactivate: config.onDeactivate,
1515
+ onPostDeactivate: config.onPostDeactivate,
1516
+ checkCanReturnFocus: config.checkCanReturnFocus
1517
+ }, deactivateOptions);
1518
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
1519
+ state.delayInitialFocusTimer = undefined;
1520
+ removeListeners();
1521
+ state.active = false;
1522
+ state.paused = false;
1523
+ updateObservedNodes();
1524
+ activeFocusTraps.deactivateTrap(trapStack, trap);
1525
+ var onDeactivate = getOption(options, 'onDeactivate');
1526
+ var onPostDeactivate = getOption(options, 'onPostDeactivate');
1527
+ var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
1528
+ var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
1529
+ onDeactivate === null || onDeactivate === void 0 ? void 0 : onDeactivate();
1530
+ var finishDeactivation = function finishDeactivation() {
1531
+ delay(function () {
1532
+ if (returnFocus) {
1533
+ tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1534
+ }
1535
+ onPostDeactivate === null || onPostDeactivate === void 0 ? void 0 : onPostDeactivate();
1536
+ });
1537
+ };
1538
+ if (returnFocus && checkCanReturnFocus) {
1539
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1540
+ return this;
1541
+ }
1542
+ finishDeactivation();
1543
+ return this;
1544
+ },
1545
+ pause: function pause(pauseOptions) {
1546
+ if (state.paused || !state.active) {
1547
+ return this;
1548
+ }
1549
+ var onPause = getOption(pauseOptions, 'onPause');
1550
+ var onPostPause = getOption(pauseOptions, 'onPostPause');
1551
+ state.paused = true;
1552
+ onPause === null || onPause === void 0 ? void 0 : onPause();
1553
+ removeListeners();
1554
+ updateObservedNodes();
1555
+ onPostPause === null || onPostPause === void 0 ? void 0 : onPostPause();
1556
+ return this;
1557
+ },
1558
+ unpause: function unpause(unpauseOptions) {
1559
+ if (!state.paused || !state.active) {
1560
+ return this;
1561
+ }
1562
+ var onUnpause = getOption(unpauseOptions, 'onUnpause');
1563
+ var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');
1564
+ state.paused = false;
1565
+ onUnpause === null || onUnpause === void 0 ? void 0 : onUnpause();
1566
+ updateTabbableNodes();
1567
+ addListeners();
1568
+ updateObservedNodes();
1569
+ onPostUnpause === null || onPostUnpause === void 0 ? void 0 : onPostUnpause();
1570
+ return this;
1571
+ },
1572
+ updateContainerElements: function updateContainerElements(containerElements) {
1573
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
1574
+ state.containers = elementsAsArray.map(function (element) {
1575
+ return typeof element === 'string' ? doc.querySelector(element) : element;
1576
+ });
1577
+ if (state.active) {
1578
+ updateTabbableNodes();
1579
+ }
1580
+ updateObservedNodes();
1581
+ return this;
1582
+ }
1583
+ };
1584
+
1585
+ // initialize container elements
1586
+ trap.updateContainerElements(elements);
1587
+ return trap;
1588
+ };
1589
+
1590
+ /**
1591
+ * @namespace aria
1592
+ */
1593
+ var aria$1 = aria$1 || {};
1594
+ aria$1.Utils = aria$1.Utils || {};
1595
+ // Polyfill src https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
1596
+ aria$1.Utils.matches = function (element, selector) {
1597
+ return element.matches(selector);
1598
+ };
1599
+ aria$1.Utils.remove = function (item) {
1600
+ if (item.remove && typeof item.remove === 'function') {
1601
+ return item.remove();
1602
+ }
1603
+ if (item.parentNode &&
1604
+ item.parentNode.removeChild &&
1605
+ typeof item.parentNode.removeChild === 'function') {
1606
+ return item.parentNode.removeChild(item);
1607
+ }
1608
+ return false;
1609
+ };
1610
+ aria$1.Utils.isFocusable = function (element) {
1611
+ if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)) {
1612
+ return true;
1613
+ }
1614
+ if (element.disabled) {
1615
+ return false;
1616
+ }
1617
+ switch (element.nodeName) {
1618
+ case 'A':
1619
+ return !!element.href && element.rel != 'ignore';
1620
+ case 'INPUT':
1621
+ return element.type != 'hidden' && element.type != 'file';
1622
+ case 'BUTTON':
1623
+ case 'SELECT':
1624
+ case 'TEXTAREA':
1625
+ return true;
1626
+ default:
1627
+ return false;
1628
+ }
1629
+ };
1630
+ aria$1.Utils.getAncestorBySelector = function (element, selector) {
1631
+ if (!aria$1.Utils.matches(element, selector + ' ' + element.tagName)) {
1632
+ // Element is not inside an element that matches selector
1633
+ return null;
1634
+ }
1635
+ // Move up the DOM tree until a parent matching the selector is found
1636
+ var currentNode = element;
1637
+ var ancestor = null;
1638
+ while (ancestor === null) {
1639
+ if (aria$1.Utils.matches(currentNode.parentNode, selector)) {
1640
+ ancestor = currentNode.parentNode;
1641
+ }
1642
+ else {
1643
+ currentNode = currentNode.parentNode;
1644
+ }
1645
+ }
1646
+ return ancestor;
1647
+ };
1648
+ aria$1.Utils.hasClass = function (element, className) {
1649
+ return (new RegExp('(\\s|^)' + className + '(\\s|$)')).test(element.className);
1650
+ };
1651
+ aria$1.Utils.addClass = function (element, className) {
1652
+ if (!aria$1.Utils.hasClass(element, className)) {
1653
+ element.className += ' ' + className;
1654
+ }
1655
+ };
1656
+ aria$1.Utils.removeClass = function (element, className) {
1657
+ var classRegex = new RegExp('(\\s|^)' + className + '(\\s|$)');
1658
+ element.className = element.className.replace(classRegex, ' ').trim();
1659
+ };
1660
+ aria$1.Utils.bindMethods = function (object) {
1661
+ var methodNames = Array.prototype.slice.call(arguments, 1);
1662
+ methodNames.forEach(function (method) {
1663
+ object[method] = object[method].bind(object);
1664
+ });
1665
+ };
1666
+ window.aria = aria$1;
1667
+
1668
+ /*
1669
+ * This content is licensed according to the W3C Software License at
1670
+ * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
1671
+ */
1672
+ /**
1673
+ * @namespace aria
1674
+ */
1675
+ var aria = aria || {};
1676
+ aria.Utils = aria.Utils || {};
1677
+ // Polyfill src https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
1678
+ aria.Utils.matches = function (element, selector) {
1679
+ return element.matches(selector);
1680
+ };
1681
+ aria.Utils.remove = function (item) {
1682
+ if (item.remove && typeof item.remove === 'function') {
1683
+ return item.remove();
1684
+ }
1685
+ if (item.parentNode &&
1686
+ item.parentNode.removeChild &&
1687
+ typeof item.parentNode.removeChild === 'function') {
1688
+ return item.parentNode.removeChild(item);
1689
+ }
1690
+ return false;
1691
+ };
1692
+ aria.Utils.isFocusable = function (element) {
1693
+ if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute('tabIndex') !== null)) {
1694
+ return true;
1695
+ }
1696
+ if (element.disabled) {
1697
+ return false;
1698
+ }
1699
+ switch (element.nodeName) {
1700
+ case 'A':
1701
+ return !!element.href && element.rel != 'ignore';
1702
+ case 'INPUT':
1703
+ return element.type != 'hidden' && element.type != 'file';
1704
+ case 'BUTTON':
1705
+ case 'SELECT':
1706
+ case 'TEXTAREA':
1707
+ return true;
1708
+ default:
1709
+ return false;
1710
+ }
1711
+ };
1712
+ aria.Utils.getAncestorBySelector = function (element, selector) {
1713
+ if (!aria.Utils.matches(element, selector + ' ' + element.tagName)) {
1714
+ // Element is not inside an element that matches selector
1715
+ return null;
1716
+ }
1717
+ // Move up the DOM tree until a parent matching the selector is found
1718
+ var currentNode = element;
1719
+ var ancestor = null;
1720
+ while (ancestor === null) {
1721
+ if (aria.Utils.matches(currentNode.parentNode, selector)) {
1722
+ ancestor = currentNode.parentNode;
1723
+ }
1724
+ else {
1725
+ currentNode = currentNode.parentNode;
1726
+ }
1727
+ }
1728
+ return ancestor;
1729
+ };
1730
+ aria.Utils.hasClass = function (element, className) {
1731
+ return (new RegExp('(\\s|^)' + className + '(\\s|$)')).test(element.className);
1732
+ };
1733
+ aria.Utils.addClass = function (element, className) {
1734
+ if (!aria.Utils.hasClass(element, className)) {
1735
+ element.className += ' ' + className;
1736
+ }
1737
+ };
1738
+ aria.Utils.removeClass = function (element, className) {
1739
+ var classRegex = new RegExp('(\\s|^)' + className + '(\\s|$)');
1740
+ element.className = element.className.replace(classRegex, ' ').trim();
1741
+ };
1742
+ aria.Utils.bindMethods = function (object) {
1743
+ var methodNames = Array.prototype.slice.call(arguments, 1);
1744
+ methodNames.forEach(function (method) {
1745
+ object[method] = object[method].bind(object);
1746
+ });
1747
+ };
1748
+ /*
1749
+ * When util functions move focus around, set this true so the focus listener
1750
+ * can ignore the events.
1751
+ */
1752
+ aria.Utils.IgnoreUtilFocusChanges = false;
1753
+ aria.Utils.dialogOpenClass = 'has-dialog';
1754
+ /**
1755
+ * @desc Set focus on descendant nodes until the first focusable element is
1756
+ * found.
1757
+ * @param element
1758
+ * DOM node for which to find the first focusable descendant.
1759
+ * @returns
1760
+ * true if a focusable element is found and focus is set.
1761
+ */
1762
+ aria.Utils.focusFirstDescendant = function (element) {
1763
+ for (var i = 0; i < element.childNodes.length; i++) {
1764
+ var child = element.childNodes[i];
1765
+ if (aria.Utils.attemptFocus(child) ||
1766
+ aria.Utils.focusFirstDescendant(child)) {
1767
+ return true;
1768
+ }
1769
+ }
1770
+ return false;
1771
+ }; // end focusFirstDescendant
1772
+ /**
1773
+ * @desc Find the last descendant node that is focusable.
1774
+ * @param element
1775
+ * DOM node for which to find the last focusable descendant.
1776
+ * @returns
1777
+ * true if a focusable element is found and focus is set.
1778
+ */
1779
+ aria.Utils.focusLastDescendant = function (element) {
1780
+ for (var i = element.childNodes.length - 1; i >= 0; i--) {
1781
+ var child = element.childNodes[i];
1782
+ if (aria.Utils.attemptFocus(child) ||
1783
+ aria.Utils.focusLastDescendant(child)) {
1784
+ return true;
1785
+ }
1786
+ }
1787
+ return false;
1788
+ }; // end focusLastDescendant
1789
+ /**
1790
+ * @desc Set Attempt to set focus on the current node.
1791
+ * @param element
1792
+ * The node to attempt to focus on.
1793
+ * @returns
1794
+ * true if element is focused.
1795
+ */
1796
+ aria.Utils.attemptFocus = function (element) {
1797
+ if (!aria.Utils.isFocusable(element)) {
1798
+ return false;
1799
+ }
1800
+ aria.Utils.IgnoreUtilFocusChanges = true;
1801
+ try {
1802
+ element.focus();
1803
+ }
1804
+ catch (e) {
1805
+ }
1806
+ aria.Utils.IgnoreUtilFocusChanges = false;
1807
+ return (document.activeElement === element);
1808
+ }; // end attemptFocus
1809
+ /* Modals can open modals. Keep track of them with this array. */
1810
+ aria.OpenDialogList = aria.OpenDialogList || new Array(0);
1811
+ /**
1812
+ * @returns the last opened dialog (the current dialog)
1813
+ */
1814
+ aria.getCurrentDialog = function () {
1815
+ if (aria.OpenDialogList && aria.OpenDialogList.length) {
1816
+ return aria.OpenDialogList[aria.OpenDialogList.length - 1];
1817
+ }
1818
+ };
1819
+ aria.closeCurrentDialog = function () {
1820
+ var currentDialog = aria.getCurrentDialog();
1821
+ if (currentDialog) {
1822
+ currentDialog.close();
1823
+ return true;
1824
+ }
1825
+ return false;
1826
+ };
1827
+ aria.handleEscape = function (event) {
1828
+ if (event.key === 'Escape' && aria.closeCurrentDialog()) {
1829
+ event.stopPropagation();
1830
+ }
1831
+ };
1832
+ document.addEventListener('keyup', aria.handleEscape);
1833
+ /**
1834
+ * @constructor
1835
+ * @desc Dialog object providing modal focus management.
1836
+ *
1837
+ * Assumptions: The element serving as the dialog container is present in the
1838
+ * DOM and hidden. The dialog container has role='dialog'.
1839
+ *
1840
+ * @param dialogNode
1841
+ * The element serving as the dialog container.
1842
+ * @param focusAfterClosed
1843
+ * Either the DOM node or the ID of the DOM node to focus when the
1844
+ * dialog closes.
1845
+ * @param focusFirst
1846
+ * Optional parameter containing either the DOM node or the ID of the
1847
+ * DOM node to focus when the dialog opens. If not specified, the
1848
+ * first focusable element in the dialog will receive focus.
1849
+ */
1850
+ aria.Dialog = function (dialogNode, focusAfterClosed, focusFirst, isFullScreen) {
1851
+ this.dialogNode = dialogNode;
1852
+ if (this.dialogNode === null) {
1853
+ throw new Error('No element found');
1854
+ }
1855
+ var validRoles = ['dialog', 'alertdialog'];
1856
+ var isDialog = (this.dialogNode.getAttribute('role') || '')
1857
+ .trim()
1858
+ .split(/\s+/g)
1859
+ .some(function (token) {
1860
+ return validRoles.some(function (role) {
1861
+ return token === role;
1862
+ });
1863
+ });
1864
+ if (!isDialog) {
1865
+ throw new Error('Dialog() requires a DOM element with ARIA role of dialog or alertdialog.');
1866
+ }
1867
+ // Wrap in an individual backdrop element if one doesn't exist
1868
+ // Native <dialog> elements use the ::backdrop pseudo-element, which
1869
+ // works similarly.
1870
+ var backdropClass = 'content-overlay-background';
1871
+ if (this.dialogNode.parentNode.classList.contains(backdropClass)) {
1872
+ this.backdropNode = this.dialogNode.parentNode;
1873
+ }
1874
+ else {
1875
+ this.backdropNode = document.createElement('div');
1876
+ this.backdropNode.className = backdropClass;
1877
+ this.dialogNode.parentNode.insertBefore(this.backdropNode, this.dialogNode);
1878
+ this.backdropNode.appendChild(this.dialogNode);
1879
+ }
1880
+ this.backdropNode.classList.add('active');
1881
+ setTimeout(() => {
1882
+ this.backdropNode.classList.add('transition');
1883
+ }, 1);
1884
+ // Disable scroll on the body element
1885
+ this.isFullscreen = isFullScreen;
1886
+ if (isFullScreen) {
1887
+ document.body.classList.add(aria.Utils.dialogOpenClass);
1888
+ }
1889
+ if (typeof focusAfterClosed === 'string') {
1890
+ this.focusAfterClosed = document.getElementById(focusAfterClosed);
1891
+ }
1892
+ else if (typeof focusAfterClosed === 'object') {
1893
+ this.focusAfterClosed = focusAfterClosed;
1894
+ }
1895
+ else {
1896
+ throw new Error('the focusAfterClosed parameter is required for the aria.Dialog constructor.');
1897
+ }
1898
+ if (typeof focusFirst === 'string') {
1899
+ this.focusFirst = document.getElementById(focusFirst);
1900
+ }
1901
+ else if (typeof focusFirst === 'object') {
1902
+ this.focusFirst = focusFirst;
1903
+ }
1904
+ else {
1905
+ this.focusFirst = null;
1906
+ }
1907
+ // Bracket the dialog node with two invisible, focusable nodes.
1908
+ // While this dialog is open, we use these to make sure that focus never
1909
+ // leaves the document even if dialogNode is the first or last node.
1910
+ var preDiv = document.createElement('div');
1911
+ this.preNode = this.dialogNode.parentNode.insertBefore(preDiv, this.dialogNode);
1912
+ this.preNode.tabIndex = 0;
1913
+ var postDiv = document.createElement('div');
1914
+ this.postNode = this.dialogNode.parentNode.insertBefore(postDiv, this.dialogNode.nextSibling);
1915
+ this.postNode.tabIndex = 0;
1916
+ // If this modal is opening on top of one that is already open,
1917
+ // get rid of the document focus listener of the open dialog.
1918
+ if (aria.OpenDialogList.length > 0) {
1919
+ aria.getCurrentDialog().removeListeners();
1920
+ }
1921
+ if (isFullScreen) {
1922
+ this.addListeners();
1923
+ }
1924
+ aria.OpenDialogList.push(this);
1925
+ this.dialogNode.className = 'content-overlay-dialog'; // make visible
1926
+ if (this.focusFirst) {
1927
+ this.focusFirst.focus();
1928
+ }
1929
+ else {
1930
+ aria.Utils.focusFirstDescendant(this.dialogNode);
1931
+ }
1932
+ this.lastFocus = document.activeElement;
1933
+ }; // end Dialog constructor
1934
+ /**
1935
+ * @desc
1936
+ * Hides the current top dialog,
1937
+ * removes listeners of the top dialog,
1938
+ * restore listeners of a parent dialog if one was open under the one that just closed,
1939
+ * and sets focus on the element specified for focusAfterClosed.
1940
+ */
1941
+ aria.Dialog.prototype.close = function () {
1942
+ aria.OpenDialogList.pop();
1943
+ this.removeListeners();
1944
+ aria.Utils.remove(this.preNode);
1945
+ aria.Utils.remove(this.postNode);
1946
+ this.dialogNode.className = 'hidden';
1947
+ this.backdropNode.classList.remove('active');
1948
+ this.backdropNode.classList.remove('transition');
1949
+ this.focusAfterClosed.focus();
1950
+ // If a dialog was open underneath this one, restore its listeners.
1951
+ if (aria.OpenDialogList.length > 0 && aria.OpenDialogList.filter(dialog => dialog.isFullscreen === true).length) {
1952
+ aria.getCurrentDialog().addListeners();
1953
+ }
1954
+ else {
1955
+ document.body.classList.remove(aria.Utils.dialogOpenClass);
1956
+ }
1957
+ this.dialogNode.dispatchEvent(new CustomEvent("ariaDialog.closed", {
1958
+ bubbles: true,
1959
+ "detail": {}
1960
+ }));
1961
+ }; // end close
1962
+ /**
1963
+ * @desc
1964
+ * Hides the current dialog and replaces it with another.
1965
+ *
1966
+ * @param newDialogId
1967
+ * ID of the dialog that will replace the currently open top dialog.
1968
+ * @param newFocusAfterClosed
1969
+ * Optional ID or DOM node specifying where to place focus when the new dialog closes.
1970
+ * If not specified, focus will be placed on the element specified by the dialog being replaced.
1971
+ * @param newFocusFirst
1972
+ * Optional ID or DOM node specifying where to place focus in the new dialog when it opens.
1973
+ * If not specified, the first focusable element will receive focus.
1974
+ */
1975
+ aria.Dialog.prototype.replace = function (newDialogId, newFocusAfterClosed, newFocusFirst) {
1976
+ // var closedDialog = aria.getCurrentDialog();
1977
+ aria.OpenDialogList.pop();
1978
+ this.removeListeners();
1979
+ aria.Utils.remove(this.preNode);
1980
+ aria.Utils.remove(this.postNode);
1981
+ this.dialogNode.className = 'hidden';
1982
+ this.backdropNode.classList.remove('active');
1983
+ this.backdropNode.classList.remove('transition');
1984
+ var focusAfterClosed = newFocusAfterClosed || this.focusAfterClosed;
1985
+ new aria.Dialog(newDialogId, focusAfterClosed, newFocusFirst);
1986
+ // var dialog = new aria.Dialog(newDialogId, focusAfterClosed, newFocusFirst);
1987
+ }; // end replace
1988
+ aria.Dialog.prototype.addListeners = function () {
1989
+ document.addEventListener('focus', this.trapFocus, true);
1990
+ }; // end addListeners
1991
+ aria.Dialog.prototype.removeListeners = function () {
1992
+ document.removeEventListener('focus', this.trapFocus, true);
1993
+ }; // end removeListeners
1994
+ aria.Dialog.prototype.trapFocus = function (event) {
1995
+ if (aria.Utils.IgnoreUtilFocusChanges) {
1996
+ return;
1997
+ }
1998
+ var currentDialog = aria.getCurrentDialog();
1999
+ if (currentDialog.dialogNode.contains(event.target)) {
2000
+ currentDialog.lastFocus = event.target;
2001
+ }
2002
+ else {
2003
+ aria.Utils.focusFirstDescendant(currentDialog.dialogNode);
2004
+ if (currentDialog.lastFocus == document.activeElement) {
2005
+ aria.Utils.focusLastDescendant(currentDialog.dialogNode);
2006
+ }
2007
+ currentDialog.lastFocus = document.activeElement;
2008
+ }
2009
+ }; // end trapFocus
2010
+ aria.closeDialog = function (closeButton) {
2011
+ var topDialog = aria.getCurrentDialog();
2012
+ if (topDialog.dialogNode.contains(closeButton)) {
2013
+ topDialog.close();
2014
+ }
2015
+ }; // end closeDialog
2016
+ aria.replaceDialog = function (newDialogId, newFocusAfterClosed, newFocusFirst) {
2017
+ var topDialog = aria.getCurrentDialog();
2018
+ if (topDialog.dialogNode.contains(document.activeElement)) {
2019
+ topDialog.replace(newDialogId, newFocusAfterClosed, newFocusFirst);
2020
+ }
2021
+ }; // end replaceDialog
2022
+ window.aria = aria;
2023
+
2024
+ const contentOverlayCss = "@charset \"UTF-8\";.content-block-overlay-container{position:relative;display:block}content-overlay{display:block;position:relative;visibility:hidden}content-overlay.hydrated{visibility:inherit}content-overlay .content-overlay__content>*[slot=content]{height:100%}content-overlay.content-overlay-inactive{display:none}content-overlay.content-overlay-active{display:block}content-overlay[vertical-position=left]{align-items:flex-start}content-overlay[vertical-position=center]{align-items:center}content-overlay[vertical-position=right]{align-items:flex-end}content-overlay[vertical-position=top]{justify-content:flex-start}content-overlay[vertical-position=center]{justify-content:center}content-overlay[vertical-position=bottom]{justify-content:flex-end}content-overlay .content-overlay-background{background:rgba(255, 255, 255, 0.8);bottom:0;display:none;top:0;z-index:100000;right:0;left:0}content-overlay .content-overlay-background.active{display:block}content-overlay .content-overlay__header{display:flex;align-items:center}content-overlay .content-overlay__close{order:2;margin-left:auto;cursor:pointer;z-index:1;appearance:none;background:none;border:none}content-overlay .content-overlay__close:after{content:\"×\";font-size:2.5rem}content-overlay.content-overlay--fullscreen .content-overlay-background{position:fixed}content-overlay.content-overlay--absolute{position:absolute;box-sizing:border-box;z-index:100000;height:100%;width:100%;top:0;left:0}content-overlay.content-overlay--absolute .content-overlay-background{position:absolute}content-overlay.content-overlay--absolute .content-overlay__content,content-overlay.content-overlay--fullscreen .content-overlay__content{flex:1;overflow:hidden}content-overlay [role=dialog]{display:flex;flex-direction:column;height:100%;justify-content:flex-start}content-overlay [role=dialog].hidden{display:none}body.has-dialog{overflow:hidden}";
2025
+
2026
+ const ContentOverlay = class {
2027
+ constructor(hostRef) {
2028
+ index.registerInstance(this, hostRef);
2029
+ this.contentOverlayActivated = index.createEvent(this, "contentOverlayActivated", 7);
2030
+ this.target = undefined;
2031
+ this.fullScreen = 'true';
2032
+ this.styleClass = undefined;
2033
+ this.horizontalAlignment = 'center';
2034
+ this.verticalAlignment = 'center';
2035
+ this.closeTitle = 'Close Overlay';
2036
+ this.isActive = false;
2037
+ this.activeClass = '';
2038
+ this.isFullScreen = false;
2039
+ }
2040
+ onContentBlockActivated(event) {
2041
+ if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {
2042
+ event.preventDefault();
2043
+ this.openOverlay();
2044
+ }
2045
+ }
2046
+ async openOverlay() {
2047
+ if (this.isActive) {
2048
+ return false;
2049
+ }
2050
+ if (this.target) {
2051
+ let targetElement = document.getElementById(this.target);
2052
+ if (targetElement) {
2053
+ targetElement.classList.add('content-block-overlay-container');
2054
+ }
2055
+ }
2056
+ else if (this.isFullScreen) {
2057
+ if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) ;
2058
+ }
2059
+ if (this.contentSlot) {
2060
+ this.isActive = true;
2061
+ this.setComputedActiveClass();
2062
+ this.focusTrap = createFocusTrap(this.hostElement, {
2063
+ onDeactivate: () => {
2064
+ this.isActive = false;
2065
+ this.setComputedActiveClass();
2066
+ }
2067
+ });
2068
+ }
2069
+ this.contentOverlayActivated.emit(this.hostElement);
2070
+ }
2071
+ async closeOverlay() {
2072
+ this.focusTrap.deactivate();
2073
+ }
2074
+ setComputedActiveClass() {
2075
+ let positioningValue = 'static';
2076
+ if (this.target) {
2077
+ positioningValue = 'absolute';
2078
+ }
2079
+ if (this.isFullScreen) {
2080
+ positioningValue = 'fullscreen';
2081
+ }
2082
+ this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue} ${utils.getCurrentValue(this.styleClass)}`;
2083
+ }
2084
+ ;
2085
+ componentWillLoad() {
2086
+ return Promise.allSettled([
2087
+ windowResizeService.WindowResizeService.registerProp(this.horizontalAlignment).subscribe(newValue => this.horizontalAlignment = newValue),
2088
+ windowResizeService.WindowResizeService.registerProp(this.verticalAlignment).subscribe(newValue => this.verticalAlignment = newValue),
2089
+ windowResizeService.WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {
2090
+ if (!this.target)
2091
+ this.isFullScreen = newValue === 'true';
2092
+ }),
2093
+ windowResizeService.WindowResizeService.breakpointIndex$.subscribe(() => {
2094
+ this.setComputedActiveClass();
2095
+ }),
2096
+ ]);
2097
+ }
2098
+ componentDidLoad() {
2099
+ this.contentSlot = this.hostElement.querySelector('[slot="content"]');
2100
+ }
2101
+ closeOverlayButtonClicked(event) {
2102
+ event.preventDefault();
2103
+ this.closeOverlay();
2104
+ }
2105
+ render() {
2106
+ return (index.h(index.Host, { class: this.activeClass }, index.h("div", { class: "content-block-overlay-container" }, index.h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, index.h("div", { ref: element => this.dialogElement = element, role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": "false" }, index.h("div", { class: "content-overlay__header" }, index.h("button", { onClick: e => this.closeOverlayButtonClicked(e), class: "content-overlay__close", title: this.closeTitle }, index.h("slot", { name: "closeButton" })), index.h("slot", { name: "header" })), index.h("div", { ref: element => this.contentElement = element, class: "content-overlay__content" }, index.h("slot", { name: "content" })))))));
2107
+ }
2108
+ componentDidRender() {
2109
+ if (this.isActive && !this.focusTrap.active) {
2110
+ this.focusTrap.activate();
2111
+ }
2112
+ }
2113
+ get hostElement() { return index.getElement(this); }
2114
+ };
2115
+ ContentOverlay.style = contentOverlayCss;
2116
+
2117
+ const contentSpacerCss = "content-spacer{display:block;width:100%;height:auto}content-spacer.hydrated{visibility:inherit}content-spacer[full-height=true]{height:100%}content-spacer[text-align=left]{text-align:left}content-spacer[text-align=center]{text-align:center}content-spacer[text-align=right]{text-align:right}content-spacer[horizontal-position=left]{margin-left:0;margin-right:auto}content-spacer[horizontal-position=center]{margin-left:auto;margin-right:auto}content-spacer[horizontal-position=right]{margin-left:auto;margin-right:0}";
2118
+
2119
+ const ContentSpacingWrapper = class {
2120
+ constructor(hostRef) {
2121
+ index.registerInstance(this, hostRef);
2122
+ this.maxWidth = '100';
2123
+ this.fullHeight = 'false';
2124
+ this.textAlign = 'default';
2125
+ this.horizontalPosition = undefined;
2126
+ this.topOffset = '0';
2127
+ this.bottomOffset = '0';
2128
+ this.leftOffset = '0';
2129
+ this.rightOffset = '0';
2130
+ this.inlineStyle = {};
2131
+ }
2132
+ componentWillLoad() {
2133
+ return Promise.allSettled([
2134
+ windowResizeService.WindowResizeService.registerProp(this.fullHeight).subscribe(newValue => this.fullHeight = newValue),
2135
+ windowResizeService.WindowResizeService.registerProp(this.textAlign).subscribe(newValue => this.textAlign = newValue),
2136
+ windowResizeService.WindowResizeService.registerProp(this.horizontalPosition).subscribe(newValue => this.horizontalPosition = newValue),
2137
+ windowResizeService.WindowResizeService.registerProp(this.maxWidth).subscribe(newValue => {
2138
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { 'max-width': isNaN(newValue) ? newValue : newValue + '%' });
2139
+ }),
2140
+ windowResizeService.WindowResizeService.registerProp(this.topOffset).subscribe(newValue => {
2141
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { 'padding-top': isNaN(newValue) ? newValue : newValue + '%' });
2142
+ }),
2143
+ windowResizeService.WindowResizeService.registerProp(this.bottomOffset).subscribe(newValue => {
2144
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { 'padding-bottom': isNaN(newValue) ? newValue : newValue + '%' });
2145
+ }),
2146
+ windowResizeService.WindowResizeService.registerProp(this.leftOffset).subscribe(newValue => {
2147
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { 'padding-left': isNaN(newValue) ? newValue : newValue + '%' });
2148
+ }),
2149
+ windowResizeService.WindowResizeService.registerProp(this.rightOffset).subscribe(newValue => {
2150
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { 'padding-right': isNaN(newValue) ? newValue : newValue + '%' });
2151
+ })
2152
+ ]);
2153
+ }
2154
+ render() {
2155
+ return (index.h(index.Host, { style: this.inlineStyle }, index.h("slot", { name: "content" }), index.h("slot", null)));
2156
+ }
2157
+ };
2158
+ ContentSpacingWrapper.style = contentSpacerCss;
2159
+
2160
+ exports.content_button = ContentButton;
2161
+ exports.content_line = ContentBlockLine;
2162
+ exports.content_overlay = ContentOverlay;
2163
+ exports.content_spacer = ContentSpacingWrapper;
2164
+
2165
+ //# sourceMappingURL=content-button_4.cjs.entry.js.map