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