@ptcwebops/ptcw-design 6.3.3-beta → 6.3.3

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 (251) hide show
  1. package/dist/cjs/component-1b8ad4d2.js +1819 -0
  2. package/dist/cjs/{component-4dd13907.js → component-35540bfb.js} +1494 -3305
  3. package/dist/cjs/event-jumbotron-example.cjs.entry.js +196 -0
  4. package/dist/cjs/featured-list.cjs.entry.js +1 -1
  5. package/dist/cjs/focus-trap.esm-8c5a8938.js +1558 -0
  6. package/dist/cjs/icon-asset.cjs.entry.js +65 -0
  7. package/dist/cjs/innovator-toggle-container.cjs.entry.js +1 -1
  8. package/dist/cjs/list-item.cjs.entry.js +48 -0
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/cjs/ptc-bio-card.cjs.entry.js +1 -1
  11. package/dist/cjs/ptc-breadcrumb.cjs.entry.js +47 -0
  12. package/dist/cjs/ptc-button.cjs.entry.js +87 -0
  13. package/dist/cjs/ptc-card-bottom_2.cjs.entry.js +156 -0
  14. package/dist/cjs/ptc-card-content.cjs.entry.js +76 -0
  15. package/dist/cjs/ptc-card_2.cjs.entry.js +3 -4
  16. package/dist/cjs/ptc-case-studies-slider.cjs.entry.js +1 -1
  17. package/dist/cjs/ptc-close-icon_2.cjs.entry.js +336 -0
  18. package/dist/cjs/ptc-countdown.cjs.entry.js +19 -71
  19. package/dist/cjs/ptc-data-lookup.cjs.entry.js +2 -1
  20. package/dist/cjs/ptc-dynamic-card.cjs.entry.js +1 -1
  21. package/dist/cjs/ptc-featured-list.cjs.entry.js +1 -1
  22. package/dist/cjs/ptc-filter-level-theater.cjs.entry.js +1 -1
  23. package/dist/cjs/{ptc-form-checkbox_4.cjs.entry.js → ptc-form-checkbox_2.cjs.entry.js} +5 -787
  24. package/dist/cjs/ptc-icon-list.cjs.entry.js +2 -2
  25. package/dist/cjs/ptc-img.cjs.entry.js +133 -0
  26. package/dist/cjs/ptc-jumbotron.cjs.entry.js +1 -1
  27. package/dist/cjs/ptc-link.cjs.entry.js +87 -0
  28. package/dist/cjs/ptc-multi-select_2.cjs.entry.js +672 -0
  29. package/dist/cjs/ptc-office-location-card.cjs.entry.js +3 -2
  30. package/dist/cjs/ptc-office-locations.cjs.entry.js +5 -0
  31. package/dist/cjs/ptc-para.cjs.entry.js +127 -0
  32. package/dist/cjs/ptc-podcast-card.cjs.entry.js +1 -1
  33. package/dist/cjs/ptc-previous-url.cjs.entry.js +2 -10
  34. package/dist/cjs/ptc-product-card.cjs.entry.js +1 -1
  35. package/dist/cjs/ptc-product-category.cjs.entry.js +1 -1
  36. package/dist/cjs/ptc-product-highlight-card.cjs.entry.js +1 -1
  37. package/dist/cjs/ptc-readmore-char.cjs.entry.js +1 -1
  38. package/dist/cjs/ptc-readmore-v3.cjs.entry.js +1 -1
  39. package/dist/cjs/ptc-scroll-button.cjs.entry.js +136 -0
  40. package/dist/cjs/ptc-spacer.cjs.entry.js +38 -0
  41. package/dist/cjs/ptc-title.cjs.entry.js +152 -0
  42. package/dist/cjs/ptc-tooltip-v2.cjs.entry.js +1 -1
  43. package/dist/cjs/ptc-value-led-speed-bump.cjs.entry.js +1 -1
  44. package/dist/cjs/ptc-white-paper.cjs.entry.js +1 -1
  45. package/dist/cjs/ptcw-design.cjs.js +1 -1
  46. package/dist/cjs/validation-messages-33a4f26b.js +126 -0
  47. package/dist/collection/collection-manifest.json +0 -1
  48. package/dist/collection/components/icon-asset/media/designer-v6.0.6.svg +2 -30
  49. package/dist/collection/components/innovator-toggle-container/innovator-toggle-container.css +6 -6
  50. package/dist/collection/components/organism-bundles/bundle-featured-list/featured-list.css +3 -3
  51. package/dist/collection/components/ptc-bio-card/ptc-bio-card.css +6 -6
  52. package/dist/collection/components/ptc-case-studies-slider/ptc-case-studies-slider.css +6 -6
  53. package/dist/collection/components/ptc-countdown/ptc-countdown.css +0 -1
  54. package/dist/collection/components/ptc-countdown/ptc-countdown.js +17 -163
  55. package/dist/collection/components/ptc-dynamic-card/ptc-dynamic-card.css +5 -0
  56. package/dist/collection/components/ptc-featured-list/ptc-featured-list.css +6 -6
  57. package/dist/collection/components/ptc-filter-level-theater/ptc-filter-level-theater.css +6 -6
  58. package/dist/collection/components/ptc-icon-list/ptc-icon-list.css +6 -0
  59. package/dist/collection/components/ptc-icon-list/ptc-icon-list.js +1 -1
  60. package/dist/collection/components/ptc-jumbotron/ptc-jumbotron.css +6 -6
  61. package/dist/collection/components/ptc-modal/ptc-modal.css +0 -4
  62. package/dist/collection/components/ptc-modal/ptc-modal.js +86 -38
  63. package/dist/collection/components/ptc-multi-select/ptc-multi-select.js +3 -1
  64. package/dist/collection/components/ptc-office-location-card/ptc-office-location-card.js +3 -2
  65. package/dist/collection/components/ptc-office-locations/ptc-office-locations.js +5 -0
  66. package/dist/collection/components/ptc-para/ptc-para.css +0 -3
  67. package/dist/collection/components/ptc-para/ptc-para.js +2 -2
  68. package/dist/collection/components/ptc-podcast-card/ptc-podcast-card.css +6 -6
  69. package/dist/collection/components/ptc-preloader-section/ptc-preloader-section.js +3 -4
  70. package/dist/collection/components/ptc-previous-url/ptc-previous-url.css +0 -16
  71. package/dist/collection/components/ptc-previous-url/ptc-previous-url.js +1 -27
  72. package/dist/collection/components/ptc-product-card/ptc-product-card.css +6 -6
  73. package/dist/collection/components/ptc-product-category/ptc-product-category.css +6 -6
  74. package/dist/collection/components/ptc-product-highlight-card/ptc-product-highlight-card.css +6 -6
  75. package/dist/collection/components/ptc-readmore-char/ptc-readmore-char.css +6 -6
  76. package/dist/collection/components/ptc-readmore-v3/ptc-readmore-v3.css +6 -6
  77. package/dist/collection/components/ptc-textfield/ptc-textfield.js +1 -1
  78. package/dist/collection/components/ptc-tooltip-v2/ptc-tooltip-v2.css +6 -6
  79. package/dist/collection/components/ptc-value-led-speed-bump/ptc-value-led-speed-bump.css +6 -6
  80. package/dist/collection/components/ptc-white-paper/ptc-white-paper.css +6 -6
  81. package/dist/custom-elements/index.d.ts +0 -6
  82. package/dist/custom-elements/index.js +141 -240
  83. package/dist/esm/blog-detail-content_2.entry.js +1 -1
  84. package/dist/esm/blog-detail-layout.entry.js +1 -1
  85. package/dist/esm/blogs-search-section.entry.js +1 -1
  86. package/dist/esm/{component-9c921cc6.js → component-8c53e377.js} +1482 -3281
  87. package/dist/esm/component-9beac35b.js +1802 -0
  88. package/dist/esm/event-jumbotron-example.entry.js +192 -0
  89. package/dist/esm/featured-list.entry.js +1 -1
  90. package/dist/esm/focus-trap.esm-d205300d.js +1556 -0
  91. package/dist/esm/homepage-jumbotron.entry.js +1 -1
  92. package/dist/esm/homepage-toggled-content.entry.js +1 -1
  93. package/dist/esm/icon-asset.entry.js +61 -0
  94. package/dist/esm/innovator-toggle-container.entry.js +1 -1
  95. package/dist/esm/list-item.entry.js +44 -0
  96. package/dist/esm/loader.js +1 -1
  97. package/dist/esm/most-popular-news.entry.js +1 -1
  98. package/dist/esm/my-component.entry.js +1 -1
  99. package/dist/esm/ptc-accordion-item.entry.js +1 -1
  100. package/dist/esm/ptc-background-video.entry.js +1 -1
  101. package/dist/esm/ptc-bio-card.entry.js +1 -1
  102. package/dist/esm/ptc-breadcrumb.entry.js +43 -0
  103. package/dist/esm/ptc-button.entry.js +83 -0
  104. package/dist/esm/ptc-card-bottom_2.entry.js +151 -0
  105. package/dist/esm/ptc-card-content.entry.js +72 -0
  106. package/dist/esm/ptc-card_2.entry.js +3 -4
  107. package/dist/esm/ptc-case-studies-slider.entry.js +1 -1
  108. package/dist/esm/ptc-close-icon_2.entry.js +331 -0
  109. package/dist/esm/ptc-collapse-list.entry.js +1 -1
  110. package/dist/esm/ptc-countdown.entry.js +19 -71
  111. package/dist/esm/ptc-data-lookup.entry.js +2 -1
  112. package/dist/esm/ptc-dynamic-card.entry.js +1 -1
  113. package/dist/esm/ptc-featured-list.entry.js +1 -1
  114. package/dist/esm/ptc-filter-level-theater.entry.js +1 -1
  115. package/dist/esm/{ptc-form-checkbox_4.entry.js → ptc-form-checkbox_2.entry.js} +5 -785
  116. package/dist/esm/ptc-homepage-image-feature.entry.js +1 -1
  117. package/dist/esm/ptc-homepage-video-background.entry.js +1 -1
  118. package/dist/esm/ptc-icon-card.entry.js +1 -1
  119. package/dist/esm/ptc-icon-list.entry.js +2 -2
  120. package/dist/esm/ptc-img.entry.js +129 -0
  121. package/dist/esm/ptc-jumbotron.entry.js +1 -1
  122. package/dist/esm/ptc-link.entry.js +83 -0
  123. package/dist/esm/ptc-media-card.entry.js +1 -1
  124. package/dist/esm/ptc-multi-select_2.entry.js +667 -0
  125. package/dist/esm/ptc-office-location-card.entry.js +3 -2
  126. package/dist/esm/ptc-office-locations.entry.js +5 -0
  127. package/dist/esm/ptc-para.entry.js +123 -0
  128. package/dist/esm/ptc-podcast-card.entry.js +1 -1
  129. package/dist/esm/ptc-previous-url.entry.js +2 -10
  130. package/dist/esm/ptc-pricing-packaging-table.entry.js +1 -1
  131. package/dist/esm/ptc-pricing-tabs.entry.js +1 -1
  132. package/dist/esm/ptc-product-card.entry.js +1 -1
  133. package/dist/esm/ptc-product-category.entry.js +1 -1
  134. package/dist/esm/ptc-product-highlight-card.entry.js +1 -1
  135. package/dist/esm/ptc-readmore-char.entry.js +1 -1
  136. package/dist/esm/ptc-readmore-v3.entry.js +1 -1
  137. package/dist/esm/ptc-scroll-button.entry.js +132 -0
  138. package/dist/esm/ptc-social-icons-footer.entry.js +1 -1
  139. package/dist/esm/ptc-spacer.entry.js +34 -0
  140. package/dist/esm/ptc-title.entry.js +148 -0
  141. package/dist/esm/ptc-tooltip-v2.entry.js +1 -1
  142. package/dist/esm/ptc-value-led-speed-bump.entry.js +1 -1
  143. package/dist/esm/ptc-white-paper.entry.js +1 -1
  144. package/dist/esm/ptcw-design.js +1 -1
  145. package/dist/esm/{utils-ff65c75b.js → utils-63eab4bd.js} +1 -1
  146. package/dist/esm/validation-messages-adbb6518.js +124 -0
  147. package/dist/ptcw-design/media/designer-v6.0.6.svg +2 -30
  148. package/dist/ptcw-design/p-00e21489.entry.js +1 -0
  149. package/dist/ptcw-design/p-01075feb.entry.js +1 -0
  150. package/dist/ptcw-design/p-0b33279e.js +10 -0
  151. package/dist/ptcw-design/p-0c69ea52.entry.js +1 -0
  152. package/dist/ptcw-design/p-15758793.entry.js +1 -0
  153. package/dist/ptcw-design/{p-e0b873d0.entry.js → p-16e70f20.entry.js} +1 -1
  154. package/dist/ptcw-design/{p-ae970a60.entry.js → p-17f6e145.entry.js} +1 -1
  155. package/dist/ptcw-design/p-18a5a338.js +1 -0
  156. package/dist/ptcw-design/{p-d73cc053.entry.js → p-18ac526f.entry.js} +1 -1
  157. package/dist/ptcw-design/p-25a25451.entry.js +1 -0
  158. package/dist/ptcw-design/p-27a4ee73.entry.js +1 -0
  159. package/dist/ptcw-design/{p-e4000363.entry.js → p-28be539b.entry.js} +1 -1
  160. package/dist/ptcw-design/p-2b32297b.entry.js +1 -0
  161. package/dist/ptcw-design/p-2cb2de0f.entry.js +1 -0
  162. package/dist/ptcw-design/{p-4055f4f7.entry.js → p-38b782e8.entry.js} +1 -1
  163. package/dist/ptcw-design/p-42992202.entry.js +1 -0
  164. package/dist/ptcw-design/{p-d9abe7e8.entry.js → p-48c33817.entry.js} +1 -1
  165. package/dist/ptcw-design/{p-e3f8e5d5.entry.js → p-49e54079.entry.js} +1 -1
  166. package/dist/ptcw-design/{p-445329ed.entry.js → p-4d8f6f46.entry.js} +1 -1
  167. package/dist/ptcw-design/{p-2c6fc745.entry.js → p-4ee98a3e.entry.js} +1 -1
  168. package/dist/ptcw-design/p-51a45b13.entry.js +1 -0
  169. package/dist/ptcw-design/p-593b8eff.entry.js +1 -0
  170. package/dist/ptcw-design/p-5dae4f30.entry.js +1 -0
  171. package/dist/ptcw-design/{p-d10cb999.entry.js → p-627103d8.entry.js} +1 -1
  172. package/dist/ptcw-design/{p-c95f423e.entry.js → p-6a3caf2b.entry.js} +1 -1
  173. package/dist/ptcw-design/{p-7a9611b4.entry.js → p-6f5fecae.entry.js} +1 -1
  174. package/dist/ptcw-design/p-73a853fc.entry.js +1 -0
  175. package/dist/ptcw-design/{p-0de4cd11.entry.js → p-75988f52.entry.js} +1 -1
  176. package/dist/ptcw-design/p-7793babb.entry.js +1 -0
  177. package/dist/ptcw-design/{p-8872161f.js → p-77b1221e.js} +1 -1
  178. package/dist/ptcw-design/p-7a3e9ecd.entry.js +1 -0
  179. package/dist/ptcw-design/p-7fb155da.entry.js +1 -0
  180. package/dist/ptcw-design/p-7fe4d383.entry.js +1 -0
  181. package/dist/ptcw-design/{p-c37a3bd2.entry.js → p-821f0ff9.entry.js} +1 -1
  182. package/dist/ptcw-design/p-92d22c78.entry.js +1 -0
  183. package/dist/ptcw-design/p-98426799.js +203 -0
  184. package/dist/ptcw-design/p-98844b50.js +134 -0
  185. package/dist/ptcw-design/p-99355e65.entry.js +1 -0
  186. package/dist/ptcw-design/{p-21aa746d.entry.js → p-9f194554.entry.js} +1 -1
  187. package/dist/ptcw-design/p-a3822c52.entry.js +1 -0
  188. package/dist/ptcw-design/p-a58698ca.entry.js +1 -0
  189. package/dist/ptcw-design/{p-0b515839.entry.js → p-a791c53a.entry.js} +1 -1
  190. package/dist/ptcw-design/p-acdd9a1d.entry.js +1 -0
  191. package/dist/ptcw-design/p-ad821a01.entry.js +1 -0
  192. package/dist/ptcw-design/{p-94f99d2d.entry.js → p-b441e3fe.entry.js} +1 -1
  193. package/dist/ptcw-design/{p-918fb77d.entry.js → p-b52301e2.entry.js} +1 -1
  194. package/dist/ptcw-design/p-b651c1cb.entry.js +1 -0
  195. package/dist/ptcw-design/p-b8ee8699.entry.js +1 -0
  196. package/dist/ptcw-design/p-bf18b622.entry.js +1 -0
  197. package/dist/ptcw-design/p-bf3bc577.entry.js +1 -0
  198. package/dist/ptcw-design/{p-1b257420.entry.js → p-c01ea76f.entry.js} +1 -1
  199. package/dist/ptcw-design/{p-6d3326da.entry.js → p-cbee4653.entry.js} +1 -1
  200. package/dist/ptcw-design/{p-3dd0ded9.entry.js → p-d089dc37.entry.js} +1 -1
  201. package/dist/ptcw-design/{p-c66b8926.entry.js → p-d3229458.entry.js} +1 -1
  202. package/dist/ptcw-design/p-dd02e4d6.entry.js +68 -0
  203. package/dist/ptcw-design/{p-da82dc93.entry.js → p-e577ad62.entry.js} +1 -1
  204. package/dist/ptcw-design/{p-808ec62a.entry.js → p-eec2f3da.entry.js} +1 -1
  205. package/dist/ptcw-design/p-f4eb6d0a.entry.js +1 -0
  206. package/dist/ptcw-design/{p-a25578e9.entry.js → p-f867ebe6.entry.js} +1 -1
  207. package/dist/ptcw-design/p-f9256e3d.entry.js +1 -0
  208. package/dist/ptcw-design/{p-36007a57.entry.js → p-fd394e84.entry.js} +1 -1
  209. package/dist/ptcw-design/p-feecf6b5.entry.js +1 -0
  210. package/dist/ptcw-design/ptcw-design.css +2 -2
  211. package/dist/ptcw-design/ptcw-design.esm.js +1 -1
  212. package/dist/types/components/ptc-countdown/ptc-countdown.d.ts +0 -8
  213. package/dist/types/components/ptc-modal/ptc-modal.d.ts +6 -3
  214. package/dist/types/components/ptc-office-location-card/ptc-office-location-card.d.ts +1 -1
  215. package/dist/types/components/ptc-para/ptc-para.d.ts +1 -1
  216. package/dist/types/components/ptc-previous-url/ptc-previous-url.d.ts +0 -2
  217. package/dist/types/components.d.ts +4 -29
  218. package/package.json +1 -1
  219. package/readme.md +1 -5
  220. package/dist/cjs/event-jumbotron-example_15.cjs.entry.js +0 -3051
  221. package/dist/cjs/modal-form-example.cjs.entry.js +0 -94
  222. package/dist/cjs/ptc-card-bottom.cjs.entry.js +0 -67
  223. package/dist/collection/components/organism-bundles/form/modal-from-example/modal-form-example.css +0 -26
  224. package/dist/collection/components/organism-bundles/form/modal-from-example/modal-form-example.js +0 -99
  225. package/dist/collection/stories/organisms/eSupport/CaseTracker/preview.stories.js +0 -45
  226. package/dist/collection/stories/organisms/eSupport/SupportArticle/preview.stories.js +0 -47
  227. package/dist/collection/stories/organisms/eSupport/SupportPage/preview.stories.js +0 -157
  228. package/dist/esm/event-jumbotron-example_15.entry.js +0 -3033
  229. package/dist/esm/modal-form-example.entry.js +0 -90
  230. package/dist/esm/ptc-card-bottom.entry.js +0 -63
  231. package/dist/ptcw-design/p-0098c4f0.entry.js +0 -1
  232. package/dist/ptcw-design/p-0d223232.entry.js +0 -1
  233. package/dist/ptcw-design/p-1118ed9e.entry.js +0 -68
  234. package/dist/ptcw-design/p-1a6759a4.entry.js +0 -1
  235. package/dist/ptcw-design/p-32f64f48.entry.js +0 -1
  236. package/dist/ptcw-design/p-48815ee0.entry.js +0 -1
  237. package/dist/ptcw-design/p-67c248ec.entry.js +0 -1
  238. package/dist/ptcw-design/p-75390f63.entry.js +0 -1
  239. package/dist/ptcw-design/p-799afee5.entry.js +0 -1
  240. package/dist/ptcw-design/p-9501995f.entry.js +0 -1
  241. package/dist/ptcw-design/p-9c875e66.entry.js +0 -11
  242. package/dist/ptcw-design/p-9fe0c27d.entry.js +0 -1
  243. package/dist/ptcw-design/p-a3b57ede.entry.js +0 -1
  244. package/dist/ptcw-design/p-baff4d44.entry.js +0 -1
  245. package/dist/ptcw-design/p-bcab66bf.js +0 -336
  246. package/dist/ptcw-design/p-bd6af63e.entry.js +0 -1
  247. package/dist/ptcw-design/p-dbbe35bf.entry.js +0 -1
  248. package/dist/ptcw-design/p-de960790.entry.js +0 -1
  249. package/dist/ptcw-design/p-e6a272d9.entry.js +0 -1
  250. package/dist/ptcw-design/p-fe40421e.entry.js +0 -1
  251. package/dist/types/components/organism-bundles/form/modal-from-example/modal-form-example.d.ts +0 -25
@@ -0,0 +1,1558 @@
1
+ 'use strict';
2
+
3
+ /*!
4
+ * tabbable 6.2.0
5
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
6
+ */
7
+ // NOTE: separate `:not()` selectors has broader browser support than the newer
8
+ // `:not([inert], [inert] *)` (Feb 2023)
9
+ // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
10
+ // the entire query to fail, resulting in no nodes found, which will break a lot
11
+ // of things... so we have to rely on JS to identify nodes inside an inert container
12
+ 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])'];
13
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
14
+ var NoElement = typeof Element === 'undefined';
15
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
16
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
17
+ var _element$getRootNode;
18
+ return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
19
+ } : function (element) {
20
+ return element === null || element === void 0 ? void 0 : element.ownerDocument;
21
+ };
22
+
23
+ /**
24
+ * Determines if a node is inert or in an inert ancestor.
25
+ * @param {Element} [node]
26
+ * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
27
+ * see if any of them are inert. If false, only `node` itself is considered.
28
+ * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
29
+ * False if `node` is falsy.
30
+ */
31
+ var isInert = function isInert(node, lookUp) {
32
+ var _node$getAttribute;
33
+ if (lookUp === void 0) {
34
+ lookUp = true;
35
+ }
36
+ // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
37
+ // JS API property; we have to check the attribute, which can either be empty or 'true';
38
+ // if it's `null` (not specified) or 'false', it's an active element
39
+ 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');
40
+ var inert = inertAtt === '' || inertAtt === 'true';
41
+
42
+ // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
43
+ // if it weren't for `matches()` not being a function on shadow roots; the following
44
+ // code works for any kind of node
45
+ // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
46
+ // so it likely would not support `:is([inert] *)` either...
47
+ var result = inert || lookUp && node && isInert(node.parentNode); // recursive
48
+
49
+ return result;
50
+ };
51
+
52
+ /**
53
+ * Determines if a node's content is editable.
54
+ * @param {Element} [node]
55
+ * @returns True if it's content-editable; false if it's not or `node` is falsy.
56
+ */
57
+ var isContentEditable = function isContentEditable(node) {
58
+ var _node$getAttribute2;
59
+ // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
60
+ // to use the attribute directly to check for this, which can either be empty or 'true';
61
+ // if it's `null` (not specified) or 'false', it's a non-editable element
62
+ 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');
63
+ return attValue === '' || attValue === 'true';
64
+ };
65
+
66
+ /**
67
+ * @param {Element} el container to check in
68
+ * @param {boolean} includeContainer add container to check
69
+ * @param {(node: Element) => boolean} filter filter candidates
70
+ * @returns {Element[]}
71
+ */
72
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
73
+ // even if `includeContainer=false`, we still have to check it for inertness because
74
+ // if it's inert, all its children are inert
75
+ if (isInert(el)) {
76
+ return [];
77
+ }
78
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
79
+ if (includeContainer && matches.call(el, candidateSelector)) {
80
+ candidates.unshift(el);
81
+ }
82
+ candidates = candidates.filter(filter);
83
+ return candidates;
84
+ };
85
+
86
+ /**
87
+ * @callback GetShadowRoot
88
+ * @param {Element} element to check for shadow root
89
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
90
+ */
91
+
92
+ /**
93
+ * @callback ShadowRootFilter
94
+ * @param {Element} shadowHostNode the element which contains shadow content
95
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
96
+ */
97
+
98
+ /**
99
+ * @typedef {Object} CandidateScope
100
+ * @property {Element} scopeParent contains inner candidates
101
+ * @property {Element[]} candidates list of candidates found in the scope parent
102
+ */
103
+
104
+ /**
105
+ * @typedef {Object} IterativeOptions
106
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
107
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
108
+ * or a boolean stating if it has an undisclosed shadow root
109
+ * @property {(node: Element) => boolean} filter filter candidates
110
+ * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
111
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
112
+ */
113
+
114
+ /**
115
+ * @param {Element[]} elements list of element containers to match candidates from
116
+ * @param {boolean} includeContainer add container list to check
117
+ * @param {IterativeOptions} options
118
+ * @returns {Array.<Element|CandidateScope>}
119
+ */
120
+ var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
121
+ var candidates = [];
122
+ var elementsToCheck = Array.from(elements);
123
+ while (elementsToCheck.length) {
124
+ var element = elementsToCheck.shift();
125
+ if (isInert(element, false)) {
126
+ // no need to look up since we're drilling down
127
+ // anything inside this container will also be inert
128
+ continue;
129
+ }
130
+ if (element.tagName === 'SLOT') {
131
+ // add shadow dom slot scope (slot itself cannot be focusable)
132
+ var assigned = element.assignedElements();
133
+ var content = assigned.length ? assigned : element.children;
134
+ var nestedCandidates = getCandidatesIteratively(content, true, options);
135
+ if (options.flatten) {
136
+ candidates.push.apply(candidates, nestedCandidates);
137
+ } else {
138
+ candidates.push({
139
+ scopeParent: element,
140
+ candidates: nestedCandidates
141
+ });
142
+ }
143
+ } else {
144
+ // check candidate element
145
+ var validCandidate = matches.call(element, candidateSelector);
146
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
147
+ candidates.push(element);
148
+ }
149
+
150
+ // iterate over shadow content if possible
151
+ var shadowRoot = element.shadowRoot ||
152
+ // check for an undisclosed shadow
153
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
154
+
155
+ // no inert look up because we're already drilling down and checking for inertness
156
+ // on the way down, so all containers to this root node should have already been
157
+ // vetted as non-inert
158
+ var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
159
+ if (shadowRoot && validShadowRoot) {
160
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
161
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
162
+ // child candidates found because they're likely slotted elements (elements that are
163
+ // children of the web component element (which has the shadow), in the light dom, but
164
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
165
+ // _after_ we return from this recursive call
166
+ var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
167
+ if (options.flatten) {
168
+ candidates.push.apply(candidates, _nestedCandidates);
169
+ } else {
170
+ candidates.push({
171
+ scopeParent: element,
172
+ candidates: _nestedCandidates
173
+ });
174
+ }
175
+ } else {
176
+ // there's not shadow so just dig into the element's (light dom) children
177
+ // __without__ giving the element special scope treatment
178
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
179
+ }
180
+ }
181
+ }
182
+ return candidates;
183
+ };
184
+
185
+ /**
186
+ * @private
187
+ * Determines if the node has an explicitly specified `tabindex` attribute.
188
+ * @param {HTMLElement} node
189
+ * @returns {boolean} True if so; false if not.
190
+ */
191
+ var hasTabIndex = function hasTabIndex(node) {
192
+ return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
193
+ };
194
+
195
+ /**
196
+ * Determine the tab index of a given node.
197
+ * @param {HTMLElement} node
198
+ * @returns {number} Tab order (negative, 0, or positive number).
199
+ * @throws {Error} If `node` is falsy.
200
+ */
201
+ var getTabIndex = function getTabIndex(node) {
202
+ if (!node) {
203
+ throw new Error('No node provided');
204
+ }
205
+ if (node.tabIndex < 0) {
206
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
207
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
208
+ // yet they are still part of the regular tab order; in FF, they get a default
209
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
210
+ // order, consider their tab index to be 0.
211
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
212
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
213
+ if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
214
+ return 0;
215
+ }
216
+ }
217
+ return node.tabIndex;
218
+ };
219
+
220
+ /**
221
+ * Determine the tab index of a given node __for sort order purposes__.
222
+ * @param {HTMLElement} node
223
+ * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
224
+ * has tabIndex -1, but needs to be sorted by document order in order for its content to be
225
+ * inserted into the correct sort position.
226
+ * @returns {number} Tab order (negative, 0, or positive number).
227
+ */
228
+ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
229
+ var tabIndex = getTabIndex(node);
230
+ if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
231
+ return 0;
232
+ }
233
+ return tabIndex;
234
+ };
235
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
236
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
237
+ };
238
+ var isInput = function isInput(node) {
239
+ return node.tagName === 'INPUT';
240
+ };
241
+ var isHiddenInput = function isHiddenInput(node) {
242
+ return isInput(node) && node.type === 'hidden';
243
+ };
244
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
245
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
246
+ return child.tagName === 'SUMMARY';
247
+ });
248
+ return r;
249
+ };
250
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
251
+ for (var i = 0; i < nodes.length; i++) {
252
+ if (nodes[i].checked && nodes[i].form === form) {
253
+ return nodes[i];
254
+ }
255
+ }
256
+ };
257
+ var isTabbableRadio = function isTabbableRadio(node) {
258
+ if (!node.name) {
259
+ return true;
260
+ }
261
+ var radioScope = node.form || getRootNode(node);
262
+ var queryRadios = function queryRadios(name) {
263
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
264
+ };
265
+ var radioSet;
266
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
267
+ radioSet = queryRadios(window.CSS.escape(node.name));
268
+ } else {
269
+ try {
270
+ radioSet = queryRadios(node.name);
271
+ } catch (err) {
272
+ // eslint-disable-next-line no-console
273
+ 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);
274
+ return false;
275
+ }
276
+ }
277
+ var checked = getCheckedRadio(radioSet, node.form);
278
+ return !checked || checked === node;
279
+ };
280
+ var isRadio = function isRadio(node) {
281
+ return isInput(node) && node.type === 'radio';
282
+ };
283
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
284
+ return isRadio(node) && !isTabbableRadio(node);
285
+ };
286
+
287
+ // determines if a node is ultimately attached to the window's document
288
+ var isNodeAttached = function isNodeAttached(node) {
289
+ var _nodeRoot;
290
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
291
+ // (but NOT _the_ document; see second 'If' comment below for more).
292
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
293
+ // is attached, and the one we need to check if it's in the document or not (because the
294
+ // shadow, and all nodes it contains, is never considered in the document since shadows
295
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
296
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
297
+ // visibility, including all the nodes it contains). The host could be any normal node,
298
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
299
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
300
+ // tested).
301
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
302
+ // that is attached (or find none) because the node might be in nested shadows...
303
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
304
+ // document (per the docs) and while it's a Document-type object, that document does not
305
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
306
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
307
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
308
+ // node is actually detached.
309
+ // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
310
+ // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
311
+ // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
312
+ // `ownerDocument` will be `null`, hence the optional chaining on it.
313
+ var nodeRoot = node && getRootNode(node);
314
+ var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
315
+
316
+ // in some cases, a detached node will return itself as the root instead of a document or
317
+ // shadow root object, in which case, we shouldn't try to look further up the host chain
318
+ var attached = false;
319
+ if (nodeRoot && nodeRoot !== node) {
320
+ var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
321
+ 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));
322
+ while (!attached && nodeRootHost) {
323
+ var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
324
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
325
+ // which means we need to get the host's host and check if that parent host is contained
326
+ // in (i.e. attached to) the document
327
+ nodeRoot = getRootNode(nodeRootHost);
328
+ nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
329
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
330
+ }
331
+ }
332
+ return attached;
333
+ };
334
+ var isZeroArea = function isZeroArea(node) {
335
+ var _node$getBoundingClie = node.getBoundingClientRect(),
336
+ width = _node$getBoundingClie.width,
337
+ height = _node$getBoundingClie.height;
338
+ return width === 0 && height === 0;
339
+ };
340
+ var isHidden = function isHidden(node, _ref) {
341
+ var displayCheck = _ref.displayCheck,
342
+ getShadowRoot = _ref.getShadowRoot;
343
+ // NOTE: visibility will be `undefined` if node is detached from the document
344
+ // (see notes about this further down), which means we will consider it visible
345
+ // (this is legacy behavior from a very long way back)
346
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
347
+ // _visibility_ check, not a _display_ check
348
+ if (getComputedStyle(node).visibility === 'hidden') {
349
+ return true;
350
+ }
351
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
352
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
353
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
354
+ return true;
355
+ }
356
+ if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
357
+ if (typeof getShadowRoot === 'function') {
358
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
359
+ // 'non-zero-area' fallback
360
+ var originalNode = node;
361
+ while (node) {
362
+ var parentElement = node.parentElement;
363
+ var rootNode = getRootNode(node);
364
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
365
+ ) {
366
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
367
+ // fall back to a non-zero-area test
368
+ return isZeroArea(node);
369
+ } else if (node.assignedSlot) {
370
+ // iterate up slot
371
+ node = node.assignedSlot;
372
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
373
+ // cross shadow boundary
374
+ node = rootNode.host;
375
+ } else {
376
+ // iterate up normal dom
377
+ node = parentElement;
378
+ }
379
+ }
380
+ node = originalNode;
381
+ }
382
+ // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
383
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
384
+ // it might be a falsy value, which means shadow DOM support is disabled
385
+
386
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
387
+ // now we can just test to see if it would normally be visible or not, provided it's
388
+ // attached to the main document.
389
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
390
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
391
+
392
+ if (isNodeAttached(node)) {
393
+ // this works wherever the node is: if there's at least one client rect, it's
394
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
395
+ // node itself is hidden in place of its contents; and there's no need to search
396
+ // up the hierarchy either
397
+ return !node.getClientRects().length;
398
+ }
399
+
400
+ // Else, the node isn't attached to the document, which means the `getClientRects()`
401
+ // API will __always__ return zero rects (this can happen, for example, if React
402
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
403
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
404
+ //
405
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
406
+ // because styles are only computed for nodes that are in the document.
407
+ //
408
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
409
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
410
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
411
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
412
+ // considering __everything__ to be visible because of the innability to determine styles.
413
+ //
414
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
415
+ // nodes as visible with the 'none' fallback.__
416
+ if (displayCheck !== 'legacy-full') {
417
+ return true; // hidden
418
+ }
419
+ // else, fallback to 'none' mode and consider the node visible
420
+ } else if (displayCheck === 'non-zero-area') {
421
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
422
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
423
+ // client rect, we don't special-case for whether the node is attached or not. In
424
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
425
+ // times, and that includes attached or not.
426
+ return isZeroArea(node);
427
+ }
428
+
429
+ // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
430
+ // it's visible
431
+ return false;
432
+ };
433
+
434
+ // form fields (nested) inside a disabled fieldset are not focusable/tabbable
435
+ // unless they are in the _first_ <legend> element of the top-most disabled
436
+ // fieldset
437
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
438
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
439
+ var parentNode = node.parentElement;
440
+ // check if `node` is contained in a disabled <fieldset>
441
+ while (parentNode) {
442
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
443
+ // look for the first <legend> among the children of the disabled <fieldset>
444
+ for (var i = 0; i < parentNode.children.length; i++) {
445
+ var child = parentNode.children.item(i);
446
+ // when the first <legend> (in document order) is found
447
+ if (child.tagName === 'LEGEND') {
448
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
449
+ // return whether `node` is a descendant of its first <legend>
450
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
451
+ }
452
+ }
453
+ // the disabled <fieldset> containing `node` has no <legend>
454
+ return true;
455
+ }
456
+ parentNode = parentNode.parentElement;
457
+ }
458
+ }
459
+
460
+ // else, node's tabbable/focusable state should not be affected by a fieldset's
461
+ // enabled/disabled state
462
+ return false;
463
+ };
464
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
465
+ if (node.disabled ||
466
+ // we must do an inert look up to filter out any elements inside an inert ancestor
467
+ // because we're limited in the type of selectors we can use in JSDom (see related
468
+ // note related to `candidateSelectors`)
469
+ isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
470
+ // For a details element with a summary, the summary element gets the focus
471
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
472
+ return false;
473
+ }
474
+ return true;
475
+ };
476
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
477
+ if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
478
+ return false;
479
+ }
480
+ return true;
481
+ };
482
+ var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
483
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
484
+ if (isNaN(tabIndex) || tabIndex >= 0) {
485
+ return true;
486
+ }
487
+ // If a custom element has an explicit negative tabindex,
488
+ // browsers will not allow tab targeting said element's children.
489
+ return false;
490
+ };
491
+
492
+ /**
493
+ * @param {Array.<Element|CandidateScope>} candidates
494
+ * @returns Element[]
495
+ */
496
+ var sortByOrder = function sortByOrder(candidates) {
497
+ var regularTabbables = [];
498
+ var orderedTabbables = [];
499
+ candidates.forEach(function (item, i) {
500
+ var isScope = !!item.scopeParent;
501
+ var element = isScope ? item.scopeParent : item;
502
+ var candidateTabindex = getSortOrderTabIndex(element, isScope);
503
+ var elements = isScope ? sortByOrder(item.candidates) : element;
504
+ if (candidateTabindex === 0) {
505
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
506
+ } else {
507
+ orderedTabbables.push({
508
+ documentOrder: i,
509
+ tabIndex: candidateTabindex,
510
+ item: item,
511
+ isScope: isScope,
512
+ content: elements
513
+ });
514
+ }
515
+ });
516
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
517
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
518
+ return acc;
519
+ }, []).concat(regularTabbables);
520
+ };
521
+ var tabbable = function tabbable(container, options) {
522
+ options = options || {};
523
+ var candidates;
524
+ if (options.getShadowRoot) {
525
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
526
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
527
+ flatten: false,
528
+ getShadowRoot: options.getShadowRoot,
529
+ shadowRootFilter: isValidShadowRootTabbable
530
+ });
531
+ } else {
532
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
533
+ }
534
+ return sortByOrder(candidates);
535
+ };
536
+ var focusable = function focusable(container, options) {
537
+ options = options || {};
538
+ var candidates;
539
+ if (options.getShadowRoot) {
540
+ candidates = getCandidatesIteratively([container], options.includeContainer, {
541
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
542
+ flatten: true,
543
+ getShadowRoot: options.getShadowRoot
544
+ });
545
+ } else {
546
+ candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
547
+ }
548
+ return candidates;
549
+ };
550
+ var isTabbable = function isTabbable(node, options) {
551
+ options = options || {};
552
+ if (!node) {
553
+ throw new Error('No node provided');
554
+ }
555
+ if (matches.call(node, candidateSelector) === false) {
556
+ return false;
557
+ }
558
+ return isNodeMatchingSelectorTabbable(options, node);
559
+ };
560
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
561
+ var isFocusable = function isFocusable(node, options) {
562
+ options = options || {};
563
+ if (!node) {
564
+ throw new Error('No node provided');
565
+ }
566
+ if (matches.call(node, focusableCandidateSelector) === false) {
567
+ return false;
568
+ }
569
+ return isNodeMatchingSelectorFocusable(options, node);
570
+ };
571
+
572
+ /*!
573
+ * focus-trap 7.6.4
574
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
575
+ */
576
+
577
+ function _arrayLikeToArray(r, a) {
578
+ (null == a || a > r.length) && (a = r.length);
579
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
580
+ return n;
581
+ }
582
+ function _arrayWithoutHoles(r) {
583
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
584
+ }
585
+ function _defineProperty(e, r, t) {
586
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
587
+ value: t,
588
+ enumerable: true,
589
+ configurable: true,
590
+ writable: true
591
+ }) : e[r] = t, e;
592
+ }
593
+ function _iterableToArray(r) {
594
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
595
+ }
596
+ function _nonIterableSpread() {
597
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
598
+ }
599
+ function ownKeys(e, r) {
600
+ var t = Object.keys(e);
601
+ if (Object.getOwnPropertySymbols) {
602
+ var o = Object.getOwnPropertySymbols(e);
603
+ r && (o = o.filter(function (r) {
604
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
605
+ })), t.push.apply(t, o);
606
+ }
607
+ return t;
608
+ }
609
+ function _objectSpread2(e) {
610
+ for (var r = 1; r < arguments.length; r++) {
611
+ var t = null != arguments[r] ? arguments[r] : {};
612
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
613
+ _defineProperty(e, r, t[r]);
614
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
615
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
616
+ });
617
+ }
618
+ return e;
619
+ }
620
+ function _toConsumableArray(r) {
621
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
622
+ }
623
+ function _toPrimitive(t, r) {
624
+ if ("object" != typeof t || !t) return t;
625
+ var e = t[Symbol.toPrimitive];
626
+ if (undefined !== e) {
627
+ var i = e.call(t, r || "default");
628
+ if ("object" != typeof i) return i;
629
+ throw new TypeError("@@toPrimitive must return a primitive value.");
630
+ }
631
+ return ("string" === r ? String : Number)(t);
632
+ }
633
+ function _toPropertyKey(t) {
634
+ var i = _toPrimitive(t, "string");
635
+ return "symbol" == typeof i ? i : i + "";
636
+ }
637
+ function _unsupportedIterableToArray(r, a) {
638
+ if (r) {
639
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
640
+ var t = {}.toString.call(r).slice(8, -1);
641
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
642
+ }
643
+ }
644
+
645
+ var activeFocusTraps = {
646
+ activateTrap: function activateTrap(trapStack, trap) {
647
+ if (trapStack.length > 0) {
648
+ var activeTrap = trapStack[trapStack.length - 1];
649
+ if (activeTrap !== trap) {
650
+ activeTrap._setPausedState(true);
651
+ }
652
+ }
653
+ var trapIndex = trapStack.indexOf(trap);
654
+ if (trapIndex === -1) {
655
+ trapStack.push(trap);
656
+ } else {
657
+ // move this existing trap to the front of the queue
658
+ trapStack.splice(trapIndex, 1);
659
+ trapStack.push(trap);
660
+ }
661
+ },
662
+ deactivateTrap: function deactivateTrap(trapStack, trap) {
663
+ var trapIndex = trapStack.indexOf(trap);
664
+ if (trapIndex !== -1) {
665
+ trapStack.splice(trapIndex, 1);
666
+ }
667
+ if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
668
+ trapStack[trapStack.length - 1]._setPausedState(false);
669
+ }
670
+ }
671
+ };
672
+ var isSelectableInput = function isSelectableInput(node) {
673
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
674
+ };
675
+ var isEscapeEvent = function isEscapeEvent(e) {
676
+ return (e === null || e === undefined ? undefined : e.key) === 'Escape' || (e === null || e === undefined ? undefined : e.key) === 'Esc' || (e === null || e === undefined ? undefined : e.keyCode) === 27;
677
+ };
678
+ var isTabEvent = function isTabEvent(e) {
679
+ return (e === null || e === undefined ? undefined : e.key) === 'Tab' || (e === null || e === undefined ? undefined : e.keyCode) === 9;
680
+ };
681
+
682
+ // checks for TAB by default
683
+ var isKeyForward = function isKeyForward(e) {
684
+ return isTabEvent(e) && !e.shiftKey;
685
+ };
686
+
687
+ // checks for SHIFT+TAB by default
688
+ var isKeyBackward = function isKeyBackward(e) {
689
+ return isTabEvent(e) && e.shiftKey;
690
+ };
691
+ var delay = function delay(fn) {
692
+ return setTimeout(fn, 0);
693
+ };
694
+
695
+ /**
696
+ * Get an option's value when it could be a plain value, or a handler that provides
697
+ * the value.
698
+ * @param {*} value Option's value to check.
699
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
700
+ * @returns {*} The `value`, or the handler's returned value.
701
+ */
702
+ var valueOrHandler = function valueOrHandler(value) {
703
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
704
+ params[_key - 1] = arguments[_key];
705
+ }
706
+ return typeof value === 'function' ? value.apply(undefined, params) : value;
707
+ };
708
+ var getActualTarget = function getActualTarget(event) {
709
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
710
+ // shadow host. However, event.target.composedPath() will be an array of
711
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
712
+ // outer-most (the host HTML document). If we have access to composedPath(),
713
+ // then use its first element; otherwise, fall back to event.target (and
714
+ // this only works for an _open_ shadow DOM; otherwise,
715
+ // composedPath()[0] === event.target always).
716
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
717
+ };
718
+
719
+ // NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
720
+ // current instance use the same stack if `userOptions.trapStack` isn't specified
721
+ var internalTrapStack = [];
722
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
723
+ // SSR: a live trap shouldn't be created in this type of environment so this
724
+ // should be safe code to execute if the `document` option isn't specified
725
+ var doc = (userOptions === null || userOptions === undefined ? undefined : userOptions.document) || document;
726
+ var trapStack = (userOptions === null || userOptions === undefined ? undefined : userOptions.trapStack) || internalTrapStack;
727
+ var config = _objectSpread2({
728
+ returnFocusOnDeactivate: true,
729
+ escapeDeactivates: true,
730
+ delayInitialFocus: true,
731
+ isKeyForward: isKeyForward,
732
+ isKeyBackward: isKeyBackward
733
+ }, userOptions);
734
+ var state = {
735
+ // containers given to createFocusTrap()
736
+ // @type {Array<HTMLElement>}
737
+ containers: [],
738
+ // list of objects identifying tabbable nodes in `containers` in the trap
739
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
740
+ // is active, but the trap should never get to a state where there isn't at least one group
741
+ // with at least one tabbable node in it (that would lead to an error condition that would
742
+ // result in an error being thrown)
743
+ // @type {Array<{
744
+ // container: HTMLElement,
745
+ // tabbableNodes: Array<HTMLElement>, // empty if none
746
+ // focusableNodes: Array<HTMLElement>, // empty if none
747
+ // posTabIndexesFound: boolean,
748
+ // firstTabbableNode: HTMLElement|undefined,
749
+ // lastTabbableNode: HTMLElement|undefined,
750
+ // firstDomTabbableNode: HTMLElement|undefined,
751
+ // lastDomTabbableNode: HTMLElement|undefined,
752
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
753
+ // }>}
754
+ containerGroups: [],
755
+ // same order/length as `containers` list
756
+
757
+ // references to objects in `containerGroups`, but only those that actually have
758
+ // tabbable nodes in them
759
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
760
+ // the same length
761
+ tabbableGroups: [],
762
+ nodeFocusedBeforeActivation: null,
763
+ mostRecentlyFocusedNode: null,
764
+ active: false,
765
+ paused: false,
766
+ manuallyPaused: false,
767
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
768
+ // has been delayed during activation
769
+ delayInitialFocusTimer: undefined,
770
+ // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
771
+ recentNavEvent: undefined
772
+ };
773
+ 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
774
+
775
+ /**
776
+ * Gets a configuration option value.
777
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
778
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
779
+ * @param {string} optionName Name of the option whose value is sought.
780
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
781
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
782
+ */
783
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
784
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
785
+ };
786
+
787
+ /**
788
+ * Finds the index of the container that contains the element.
789
+ * @param {HTMLElement} element
790
+ * @param {Event} [event] If available, and `element` isn't directly found in any container,
791
+ * the event's composed path is used to see if includes any known trap containers in the
792
+ * case where the element is inside a Shadow DOM.
793
+ * @returns {number} Index of the container in either `state.containers` or
794
+ * `state.containerGroups` (the order/length of these lists are the same); -1
795
+ * if the element isn't found.
796
+ */
797
+ var findContainerIndex = function findContainerIndex(element, event) {
798
+ var composedPath = typeof (event === null || event === undefined ? undefined : event.composedPath) === 'function' ? event.composedPath() : undefined;
799
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
800
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
801
+ // and we still need to find the element in there
802
+ return state.containerGroups.findIndex(function (_ref) {
803
+ var container = _ref.container,
804
+ tabbableNodes = _ref.tabbableNodes;
805
+ return container.contains(element) || (// fall back to explicit tabbable search which will take into consideration any
806
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
807
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
808
+ // look inside web components even if open)
809
+ composedPath === null || composedPath === undefined ? undefined : composedPath.includes(container)) || tabbableNodes.find(function (node) {
810
+ return node === element;
811
+ });
812
+ });
813
+ };
814
+
815
+ /**
816
+ * Gets the node for the given option, which is expected to be an option that
817
+ * can be either a DOM node, a string that is a selector to get a node, `false`
818
+ * (if a node is explicitly NOT given), or a function that returns any of these
819
+ * values.
820
+ * @param {string} optionName
821
+ * @param {Object} options
822
+ * @param {boolean} [options.hasFallback] True if the option could be a selector string
823
+ * and the option allows for a fallback scenario in the case where the selector is
824
+ * valid but does not match a node (i.e. the queried node doesn't exist in the DOM).
825
+ * @param {Array} [options.params] Params to pass to the option if it's a function.
826
+ * @returns {undefined | null | false | HTMLElement | SVGElement} Returns
827
+ * `undefined` if the option is not specified; `null` if the option didn't resolve
828
+ * to a node but `options.hasFallback=true`, `false` if the option resolved to `false`
829
+ * (node explicitly not given); otherwise, the resolved DOM node.
830
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
831
+ * resolve to a node, unless the option is a selector string and `options.hasFallback=true`.
832
+ */
833
+ var getNodeForOption = function getNodeForOption(optionName) {
834
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
835
+ _ref2$hasFallback = _ref2.hasFallback,
836
+ hasFallback = _ref2$hasFallback === undefined ? false : _ref2$hasFallback,
837
+ _ref2$params = _ref2.params,
838
+ params = _ref2$params === undefined ? [] : _ref2$params;
839
+ var optionValue = config[optionName];
840
+ if (typeof optionValue === 'function') {
841
+ optionValue = optionValue.apply(undefined, _toConsumableArray(params));
842
+ }
843
+ if (optionValue === true) {
844
+ optionValue = undefined; // use default value
845
+ }
846
+ if (!optionValue) {
847
+ if (optionValue === undefined || optionValue === false) {
848
+ return optionValue;
849
+ }
850
+ // else, empty string (invalid), null (invalid), 0 (invalid)
851
+
852
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
853
+ }
854
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
855
+
856
+ if (typeof optionValue === 'string') {
857
+ try {
858
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
859
+ } catch (err) {
860
+ throw new Error("`".concat(optionName, "` appears to be an invalid selector; error=\"").concat(err.message, "\""));
861
+ }
862
+ if (!node) {
863
+ if (!hasFallback) {
864
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
865
+ }
866
+ // else, `node` MUST be `null` because that's what `Document.querySelector()` returns
867
+ // if the selector is valid but doesn't match anything
868
+ }
869
+ }
870
+ return node;
871
+ };
872
+ var getInitialFocusNode = function getInitialFocusNode() {
873
+ var node = getNodeForOption('initialFocus', {
874
+ hasFallback: true
875
+ });
876
+
877
+ // false explicitly indicates we want no initialFocus at all
878
+ if (node === false) {
879
+ return false;
880
+ }
881
+ if (node === undefined || node && !isFocusable(node, config.tabbableOptions)) {
882
+ // option not specified nor focusable: use fallback options
883
+ if (findContainerIndex(doc.activeElement) >= 0) {
884
+ node = doc.activeElement;
885
+ } else {
886
+ var firstTabbableGroup = state.tabbableGroups[0];
887
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
888
+
889
+ // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
890
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
891
+ }
892
+ } else if (node === null) {
893
+ // option is a VALID selector string that doesn't yield a node: use the `fallbackFocus`
894
+ // option instead of the default behavior when the option isn't specified at all
895
+ node = getNodeForOption('fallbackFocus');
896
+ }
897
+ if (!node) {
898
+ throw new Error('Your focus-trap needs to have at least one focusable element');
899
+ }
900
+ return node;
901
+ };
902
+ var updateTabbableNodes = function updateTabbableNodes() {
903
+ state.containerGroups = state.containers.map(function (container) {
904
+ var tabbableNodes = tabbable(container, config.tabbableOptions);
905
+
906
+ // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
907
+ // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
908
+ // are focusable but not tabbable
909
+ var focusableNodes = focusable(container, config.tabbableOptions);
910
+ var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
911
+ var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
912
+ var firstDomTabbableNode = focusableNodes.find(function (node) {
913
+ return isTabbable(node);
914
+ });
915
+ var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
916
+ return isTabbable(node);
917
+ });
918
+ var posTabIndexesFound = !!tabbableNodes.find(function (node) {
919
+ return getTabIndex(node) > 0;
920
+ });
921
+ return {
922
+ container: container,
923
+ tabbableNodes: tabbableNodes,
924
+ focusableNodes: focusableNodes,
925
+ /** True if at least one node with positive `tabindex` was found in this container. */
926
+ posTabIndexesFound: posTabIndexesFound,
927
+ /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
928
+ firstTabbableNode: firstTabbableNode,
929
+ /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
930
+ lastTabbableNode: lastTabbableNode,
931
+ // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
932
+ // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
933
+ // because that API doesn't work with Shadow DOM as well as it should (@see
934
+ // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
935
+ // to address an edge case related to positive tabindex support, this seems like a much easier,
936
+ // "close enough most of the time" alternative for positive tabindexes which should generally
937
+ // be avoided anyway...
938
+ /** First tabbable node in container, __DOM__ order; `undefined` if none. */
939
+ firstDomTabbableNode: firstDomTabbableNode,
940
+ /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
941
+ lastDomTabbableNode: lastDomTabbableNode,
942
+ /**
943
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
944
+ * in this container, if any.
945
+ * @param {HTMLElement} node
946
+ * @param {boolean} [forward] True if going in forward tab order; false if going
947
+ * in reverse.
948
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
949
+ */
950
+ nextTabbableNode: function nextTabbableNode(node) {
951
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
952
+ var nodeIdx = tabbableNodes.indexOf(node);
953
+ if (nodeIdx < 0) {
954
+ // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
955
+ // since `node` should at least have been focusable, we assume that's the case and mimic
956
+ // what browsers do, which is set focus to the next node in __document position order__,
957
+ // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
958
+ // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
959
+ // basic DOM order
960
+ if (forward) {
961
+ return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
962
+ return isTabbable(el);
963
+ });
964
+ }
965
+ return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
966
+ return isTabbable(el);
967
+ });
968
+ }
969
+ return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
970
+ }
971
+ };
972
+ });
973
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
974
+ return group.tabbableNodes.length > 0;
975
+ });
976
+
977
+ // throw if no groups have tabbable nodes and we don't have a fallback focus node either
978
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
979
+ ) {
980
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
981
+ }
982
+
983
+ // NOTE: Positive tabindexes are only properly supported in single-container traps because
984
+ // doing it across multiple containers where tabindexes could be all over the place
985
+ // would require Tabbable to support multiple containers, would require additional
986
+ // specialized Shadow DOM support, and would require Tabbable's multi-container support
987
+ // to look at those containers in document position order rather than user-provided
988
+ // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
989
+ // https://github.com/focus-trap/focus-trap/issues/375 for more details.
990
+ if (state.containerGroups.find(function (g) {
991
+ return g.posTabIndexesFound;
992
+ }) && state.containerGroups.length > 1) {
993
+ 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.");
994
+ }
995
+ };
996
+
997
+ /**
998
+ * Gets the current activeElement. If it's a web-component and has open shadow-root
999
+ * it will recursively search inside shadow roots for the "true" activeElement.
1000
+ *
1001
+ * @param {Document | ShadowRoot} el
1002
+ *
1003
+ * @returns {HTMLElement} The element that currently has the focus
1004
+ **/
1005
+ var _getActiveElement = function getActiveElement(el) {
1006
+ var activeElement = el.activeElement;
1007
+ if (!activeElement) {
1008
+ return;
1009
+ }
1010
+ if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
1011
+ return _getActiveElement(activeElement.shadowRoot);
1012
+ }
1013
+ return activeElement;
1014
+ };
1015
+ var _tryFocus = function tryFocus(node) {
1016
+ if (node === false) {
1017
+ return;
1018
+ }
1019
+ if (node === _getActiveElement(document)) {
1020
+ return;
1021
+ }
1022
+ if (!node || !node.focus) {
1023
+ _tryFocus(getInitialFocusNode());
1024
+ return;
1025
+ }
1026
+ node.focus({
1027
+ preventScroll: !!config.preventScroll
1028
+ });
1029
+ // NOTE: focus() API does not trigger focusIn event so set MRU node manually
1030
+ state.mostRecentlyFocusedNode = node;
1031
+ if (isSelectableInput(node)) {
1032
+ node.select();
1033
+ }
1034
+ };
1035
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
1036
+ var node = getNodeForOption('setReturnFocus', {
1037
+ params: [previousActiveElement]
1038
+ });
1039
+ return node ? node : node === false ? false : previousActiveElement;
1040
+ };
1041
+
1042
+ /**
1043
+ * Finds the next node (in either direction) where focus should move according to a
1044
+ * keyboard focus-in event.
1045
+ * @param {Object} params
1046
+ * @param {Node} [params.target] Known target __from which__ to navigate, if any.
1047
+ * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
1048
+ * will be used to determine the `target`). Ignored if `target` is specified.
1049
+ * @param {boolean} [params.isBackward] True if focus should move backward.
1050
+ * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
1051
+ * determined given the current state of the trap.
1052
+ */
1053
+ var findNextNavNode = function findNextNavNode(_ref3) {
1054
+ var target = _ref3.target,
1055
+ event = _ref3.event,
1056
+ _ref3$isBackward = _ref3.isBackward,
1057
+ isBackward = _ref3$isBackward === undefined ? false : _ref3$isBackward;
1058
+ target = target || getActualTarget(event);
1059
+ updateTabbableNodes();
1060
+ var destinationNode = null;
1061
+ if (state.tabbableGroups.length > 0) {
1062
+ // make sure the target is actually contained in a group
1063
+ // NOTE: the target may also be the container itself if it's focusable
1064
+ // with tabIndex='-1' and was given initial focus
1065
+ var containerIndex = findContainerIndex(target, event);
1066
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
1067
+ if (containerIndex < 0) {
1068
+ // target not found in any group: quite possible focus has escaped the trap,
1069
+ // so bring it back into...
1070
+ if (isBackward) {
1071
+ // ...the last node in the last group
1072
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
1073
+ } else {
1074
+ // ...the first node in the first group
1075
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
1076
+ }
1077
+ } else if (isBackward) {
1078
+ // REVERSE
1079
+
1080
+ // is the target the first tabbable node in a group?
1081
+ var startOfGroupIndex = state.tabbableGroups.findIndex(function (_ref4) {
1082
+ var firstTabbableNode = _ref4.firstTabbableNode;
1083
+ return target === firstTabbableNode;
1084
+ });
1085
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
1086
+ // an exception case where the target is either the container itself, or
1087
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1088
+ // and user clicked on it or node was programmatically given focus)
1089
+ // and is not followed by any other tabbable node, in which
1090
+ // case, we should handle shift+tab as if focus were on the container's
1091
+ // first tabbable node, and go to the last tabbable node of the LAST group
1092
+ startOfGroupIndex = containerIndex;
1093
+ }
1094
+ if (startOfGroupIndex >= 0) {
1095
+ // YES: then shift+tab should go to the last tabbable node in the
1096
+ // previous group (and wrap around to the last tabbable node of
1097
+ // the LAST group if it's the first tabbable node of the FIRST group)
1098
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
1099
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
1100
+ destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
1101
+ } else if (!isTabEvent(event)) {
1102
+ // user must have customized the nav keys so we have to move focus manually _within_
1103
+ // the active group: do this based on the order determined by tabbable()
1104
+ destinationNode = containerGroup.nextTabbableNode(target, false);
1105
+ }
1106
+ } else {
1107
+ // FORWARD
1108
+
1109
+ // is the target the last tabbable node in a group?
1110
+ var lastOfGroupIndex = state.tabbableGroups.findIndex(function (_ref5) {
1111
+ var lastTabbableNode = _ref5.lastTabbableNode;
1112
+ return target === lastTabbableNode;
1113
+ });
1114
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
1115
+ // an exception case where the target is the container itself, or
1116
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
1117
+ // and user clicked on it or node was programmatically given focus)
1118
+ // and is not followed by any other tabbable node, in which
1119
+ // case, we should handle tab as if focus were on the container's
1120
+ // last tabbable node, and go to the first tabbable node of the FIRST group
1121
+ lastOfGroupIndex = containerIndex;
1122
+ }
1123
+ if (lastOfGroupIndex >= 0) {
1124
+ // YES: then tab should go to the first tabbable node in the next
1125
+ // group (and wrap around to the first tabbable node of the FIRST
1126
+ // group if it's the last tabbable node of the LAST group)
1127
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
1128
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
1129
+ destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
1130
+ } else if (!isTabEvent(event)) {
1131
+ // user must have customized the nav keys so we have to move focus manually _within_
1132
+ // the active group: do this based on the order determined by tabbable()
1133
+ destinationNode = containerGroup.nextTabbableNode(target);
1134
+ }
1135
+ }
1136
+ } else {
1137
+ // no groups available
1138
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
1139
+ destinationNode = getNodeForOption('fallbackFocus');
1140
+ }
1141
+ return destinationNode;
1142
+ };
1143
+
1144
+ // This needs to be done on mousedown and touchstart instead of click
1145
+ // so that it precedes the focus event.
1146
+ var checkPointerDown = function checkPointerDown(e) {
1147
+ var target = getActualTarget(e);
1148
+ if (findContainerIndex(target, e) >= 0) {
1149
+ // allow the click since it ocurred inside the trap
1150
+ return;
1151
+ }
1152
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1153
+ // immediately deactivate the trap
1154
+ trap.deactivate({
1155
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
1156
+ // which will result in the outside click setting focus to the node
1157
+ // that was clicked (and if not focusable, to "nothing"); by setting
1158
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
1159
+ // on activation (or the configured `setReturnFocus` node), whether the
1160
+ // outside click was on a focusable node or not
1161
+ returnFocus: config.returnFocusOnDeactivate
1162
+ });
1163
+ return;
1164
+ }
1165
+
1166
+ // This is needed for mobile devices.
1167
+ // (If we'll only let `click` events through,
1168
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
1169
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1170
+ // allow the click outside the trap to take place
1171
+ return;
1172
+ }
1173
+
1174
+ // otherwise, prevent the click
1175
+ e.preventDefault();
1176
+ };
1177
+
1178
+ // In case focus escapes the trap for some strange reason, pull it back in.
1179
+ // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
1180
+ // scrolling if the node that got focused was out of view; there's nothing we can do to
1181
+ // prevent that from happening by the time we discover that focus escaped
1182
+ var checkFocusIn = function checkFocusIn(event) {
1183
+ var target = getActualTarget(event);
1184
+ var targetContained = findContainerIndex(target, event) >= 0;
1185
+
1186
+ // In Firefox when you Tab out of an iframe the Document is briefly focused.
1187
+ if (targetContained || target instanceof Document) {
1188
+ if (targetContained) {
1189
+ state.mostRecentlyFocusedNode = target;
1190
+ }
1191
+ } else {
1192
+ // escaped! pull it back in to where it just left
1193
+ event.stopImmediatePropagation();
1194
+
1195
+ // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
1196
+ // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
1197
+ // toward a node with a positive tab index
1198
+ var nextNode; // next node to focus, if we find one
1199
+ var navAcrossContainers = true;
1200
+ if (state.mostRecentlyFocusedNode) {
1201
+ if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
1202
+ // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
1203
+ var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
1204
+ // there MAY not be any tabbable nodes in the container if there are at least 2 containers
1205
+ // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
1206
+ // with at least one tabbable node in order to function, so this could be the other container
1207
+ // with nothing tabbable in it)
1208
+ var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
1209
+ if (tabbableNodes.length > 0) {
1210
+ // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
1211
+ var mruTabIdx = tabbableNodes.findIndex(function (node) {
1212
+ return node === state.mostRecentlyFocusedNode;
1213
+ });
1214
+ if (mruTabIdx >= 0) {
1215
+ if (config.isKeyForward(state.recentNavEvent)) {
1216
+ if (mruTabIdx + 1 < tabbableNodes.length) {
1217
+ nextNode = tabbableNodes[mruTabIdx + 1];
1218
+ navAcrossContainers = false;
1219
+ }
1220
+ // else, don't wrap within the container as focus should move to next/previous
1221
+ // container
1222
+ } else {
1223
+ if (mruTabIdx - 1 >= 0) {
1224
+ nextNode = tabbableNodes[mruTabIdx - 1];
1225
+ navAcrossContainers = false;
1226
+ }
1227
+ // else, don't wrap within the container as focus should move to next/previous
1228
+ // container
1229
+ }
1230
+ // else, don't find in container order without considering direction too
1231
+ }
1232
+ }
1233
+ // else, no tabbable nodes in that container (which means we must have at least one other
1234
+ // container with at least one tabbable node in it, otherwise focus-trap would've thrown
1235
+ // an error the last time updateTabbableNodes() was run): find next node among all known
1236
+ // containers
1237
+ } else {
1238
+ // check to see if there's at least one tabbable node with a positive tab index inside
1239
+ // the trap because focus seems to escape when navigating backward from a tabbable node
1240
+ // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
1241
+ // the greatest positive tab index like it should)
1242
+ if (!state.containerGroups.some(function (g) {
1243
+ return g.tabbableNodes.some(function (n) {
1244
+ return getTabIndex(n) > 0;
1245
+ });
1246
+ })) {
1247
+ // no containers with tabbable nodes with positive tab indexes which means the focus
1248
+ // escaped for some other reason and we should just execute the fallback to the
1249
+ // MRU node or initial focus node, if any
1250
+ navAcrossContainers = false;
1251
+ }
1252
+ }
1253
+ } else {
1254
+ // no MRU node means we're likely in some initial condition when the trap has just
1255
+ // been activated and initial focus hasn't been given yet, in which case we should
1256
+ // fall through to trying to focus the initial focus node, which is what should
1257
+ // happen below at this point in the logic
1258
+ navAcrossContainers = false;
1259
+ }
1260
+ if (navAcrossContainers) {
1261
+ nextNode = findNextNavNode({
1262
+ // move FROM the MRU node, not event-related node (which will be the node that is
1263
+ // outside the trap causing the focus escape we're trying to fix)
1264
+ target: state.mostRecentlyFocusedNode,
1265
+ isBackward: config.isKeyBackward(state.recentNavEvent)
1266
+ });
1267
+ }
1268
+ if (nextNode) {
1269
+ _tryFocus(nextNode);
1270
+ } else {
1271
+ _tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
1272
+ }
1273
+ }
1274
+ state.recentNavEvent = undefined; // clear
1275
+ };
1276
+
1277
+ // Hijack key nav events on the first and last focusable nodes of the trap,
1278
+ // in order to prevent focus from escaping. If it escapes for even a
1279
+ // moment it can end up scrolling the page and causing confusion so we
1280
+ // kind of need to capture the action at the keydown phase.
1281
+ var checkKeyNav = function checkKeyNav(event) {
1282
+ var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1283
+ state.recentNavEvent = event;
1284
+ var destinationNode = findNextNavNode({
1285
+ event: event,
1286
+ isBackward: isBackward
1287
+ });
1288
+ if (destinationNode) {
1289
+ if (isTabEvent(event)) {
1290
+ // since tab natively moves focus, we wouldn't have a destination node unless we
1291
+ // were on the edge of a container and had to move to the next/previous edge, in
1292
+ // which case we want to prevent default to keep the browser from moving focus
1293
+ // to where it normally would
1294
+ event.preventDefault();
1295
+ }
1296
+ _tryFocus(destinationNode);
1297
+ }
1298
+ // else, let the browser take care of [shift+]tab and move the focus
1299
+ };
1300
+ var checkTabKey = function checkTabKey(event) {
1301
+ if (config.isKeyForward(event) || config.isKeyBackward(event)) {
1302
+ checkKeyNav(event, config.isKeyBackward(event));
1303
+ }
1304
+ };
1305
+
1306
+ // we use a different event phase for the Escape key to allow canceling the event and checking for this in escapeDeactivates
1307
+ var checkEscapeKey = function checkEscapeKey(event) {
1308
+ if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
1309
+ event.preventDefault();
1310
+ trap.deactivate();
1311
+ }
1312
+ };
1313
+ var checkClick = function checkClick(e) {
1314
+ var target = getActualTarget(e);
1315
+ if (findContainerIndex(target, e) >= 0) {
1316
+ return;
1317
+ }
1318
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1319
+ return;
1320
+ }
1321
+ if (valueOrHandler(config.allowOutsideClick, e)) {
1322
+ return;
1323
+ }
1324
+ e.preventDefault();
1325
+ e.stopImmediatePropagation();
1326
+ };
1327
+
1328
+ //
1329
+ // EVENT LISTENERS
1330
+ //
1331
+
1332
+ var addListeners = function addListeners() {
1333
+ if (!state.active) {
1334
+ return;
1335
+ }
1336
+
1337
+ // There can be only one listening focus trap at a time
1338
+ activeFocusTraps.activateTrap(trapStack, trap);
1339
+
1340
+ // Delay ensures that the focused element doesn't capture the event
1341
+ // that caused the focus trap activation.
1342
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
1343
+ _tryFocus(getInitialFocusNode());
1344
+ }) : _tryFocus(getInitialFocusNode());
1345
+ doc.addEventListener('focusin', checkFocusIn, true);
1346
+ doc.addEventListener('mousedown', checkPointerDown, {
1347
+ capture: true,
1348
+ passive: false
1349
+ });
1350
+ doc.addEventListener('touchstart', checkPointerDown, {
1351
+ capture: true,
1352
+ passive: false
1353
+ });
1354
+ doc.addEventListener('click', checkClick, {
1355
+ capture: true,
1356
+ passive: false
1357
+ });
1358
+ doc.addEventListener('keydown', checkTabKey, {
1359
+ capture: true,
1360
+ passive: false
1361
+ });
1362
+ doc.addEventListener('keydown', checkEscapeKey);
1363
+ return trap;
1364
+ };
1365
+ var removeListeners = function removeListeners() {
1366
+ if (!state.active) {
1367
+ return;
1368
+ }
1369
+ doc.removeEventListener('focusin', checkFocusIn, true);
1370
+ doc.removeEventListener('mousedown', checkPointerDown, true);
1371
+ doc.removeEventListener('touchstart', checkPointerDown, true);
1372
+ doc.removeEventListener('click', checkClick, true);
1373
+ doc.removeEventListener('keydown', checkTabKey, true);
1374
+ doc.removeEventListener('keydown', checkEscapeKey);
1375
+ return trap;
1376
+ };
1377
+
1378
+ //
1379
+ // MUTATION OBSERVER
1380
+ //
1381
+
1382
+ var checkDomRemoval = function checkDomRemoval(mutations) {
1383
+ var isFocusedNodeRemoved = mutations.some(function (mutation) {
1384
+ var removedNodes = Array.from(mutation.removedNodes);
1385
+ return removedNodes.some(function (node) {
1386
+ return node === state.mostRecentlyFocusedNode;
1387
+ });
1388
+ });
1389
+
1390
+ // If the currently focused is removed then browsers will move focus to the
1391
+ // <body> element. If this happens, try to move focus back into the trap.
1392
+ if (isFocusedNodeRemoved) {
1393
+ _tryFocus(getInitialFocusNode());
1394
+ }
1395
+ };
1396
+
1397
+ // Use MutationObserver - if supported - to detect if focused node is removed
1398
+ // from the DOM.
1399
+ var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
1400
+ var updateObservedNodes = function updateObservedNodes() {
1401
+ if (!mutationObserver) {
1402
+ return;
1403
+ }
1404
+ mutationObserver.disconnect();
1405
+ if (state.active && !state.paused) {
1406
+ state.containers.map(function (container) {
1407
+ mutationObserver.observe(container, {
1408
+ subtree: true,
1409
+ childList: true
1410
+ });
1411
+ });
1412
+ }
1413
+ };
1414
+
1415
+ //
1416
+ // TRAP DEFINITION
1417
+ //
1418
+
1419
+ trap = {
1420
+ get active() {
1421
+ return state.active;
1422
+ },
1423
+ get paused() {
1424
+ return state.paused;
1425
+ },
1426
+ activate: function activate(activateOptions) {
1427
+ if (state.active) {
1428
+ return this;
1429
+ }
1430
+ var onActivate = getOption(activateOptions, 'onActivate');
1431
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
1432
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
1433
+ if (!checkCanFocusTrap) {
1434
+ updateTabbableNodes();
1435
+ }
1436
+ state.active = true;
1437
+ state.paused = false;
1438
+ state.nodeFocusedBeforeActivation = doc.activeElement;
1439
+ onActivate === null || onActivate === undefined || onActivate();
1440
+ var finishActivation = function finishActivation() {
1441
+ if (checkCanFocusTrap) {
1442
+ updateTabbableNodes();
1443
+ }
1444
+ addListeners();
1445
+ updateObservedNodes();
1446
+ onPostActivate === null || onPostActivate === undefined || onPostActivate();
1447
+ };
1448
+ if (checkCanFocusTrap) {
1449
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1450
+ return this;
1451
+ }
1452
+ finishActivation();
1453
+ return this;
1454
+ },
1455
+ deactivate: function deactivate(deactivateOptions) {
1456
+ if (!state.active) {
1457
+ return this;
1458
+ }
1459
+ var options = _objectSpread2({
1460
+ onDeactivate: config.onDeactivate,
1461
+ onPostDeactivate: config.onPostDeactivate,
1462
+ checkCanReturnFocus: config.checkCanReturnFocus
1463
+ }, deactivateOptions);
1464
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
1465
+ state.delayInitialFocusTimer = undefined;
1466
+ removeListeners();
1467
+ state.active = false;
1468
+ state.paused = false;
1469
+ updateObservedNodes();
1470
+ activeFocusTraps.deactivateTrap(trapStack, trap);
1471
+ var onDeactivate = getOption(options, 'onDeactivate');
1472
+ var onPostDeactivate = getOption(options, 'onPostDeactivate');
1473
+ var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
1474
+ var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
1475
+ onDeactivate === null || onDeactivate === undefined || onDeactivate();
1476
+ var finishDeactivation = function finishDeactivation() {
1477
+ delay(function () {
1478
+ if (returnFocus) {
1479
+ _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1480
+ }
1481
+ onPostDeactivate === null || onPostDeactivate === undefined || onPostDeactivate();
1482
+ });
1483
+ };
1484
+ if (returnFocus && checkCanReturnFocus) {
1485
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1486
+ return this;
1487
+ }
1488
+ finishDeactivation();
1489
+ return this;
1490
+ },
1491
+ pause: function pause(pauseOptions) {
1492
+ if (!state.active) {
1493
+ return this;
1494
+ }
1495
+ state.manuallyPaused = true;
1496
+ return this._setPausedState(true, pauseOptions);
1497
+ },
1498
+ unpause: function unpause(unpauseOptions) {
1499
+ if (!state.active) {
1500
+ return this;
1501
+ }
1502
+ state.manuallyPaused = false;
1503
+ if (trapStack[trapStack.length - 1] !== this) {
1504
+ return this;
1505
+ }
1506
+ return this._setPausedState(false, unpauseOptions);
1507
+ },
1508
+ updateContainerElements: function updateContainerElements(containerElements) {
1509
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
1510
+ state.containers = elementsAsArray.map(function (element) {
1511
+ return typeof element === 'string' ? doc.querySelector(element) : element;
1512
+ });
1513
+ if (state.active) {
1514
+ updateTabbableNodes();
1515
+ }
1516
+ updateObservedNodes();
1517
+ return this;
1518
+ }
1519
+ };
1520
+ Object.defineProperties(trap, {
1521
+ _isManuallyPaused: {
1522
+ value: function value() {
1523
+ return state.manuallyPaused;
1524
+ }
1525
+ },
1526
+ _setPausedState: {
1527
+ value: function value(paused, options) {
1528
+ if (state.paused === paused) {
1529
+ return this;
1530
+ }
1531
+ state.paused = paused;
1532
+ if (paused) {
1533
+ var onPause = getOption(options, 'onPause');
1534
+ var onPostPause = getOption(options, 'onPostPause');
1535
+ onPause === null || onPause === undefined || onPause();
1536
+ removeListeners();
1537
+ updateObservedNodes();
1538
+ onPostPause === null || onPostPause === undefined || onPostPause();
1539
+ } else {
1540
+ var onUnpause = getOption(options, 'onUnpause');
1541
+ var onPostUnpause = getOption(options, 'onPostUnpause');
1542
+ onUnpause === null || onUnpause === undefined || onUnpause();
1543
+ updateTabbableNodes();
1544
+ addListeners();
1545
+ updateObservedNodes();
1546
+ onPostUnpause === null || onPostUnpause === undefined || onPostUnpause();
1547
+ }
1548
+ return this;
1549
+ }
1550
+ }
1551
+ });
1552
+
1553
+ // initialize container elements
1554
+ trap.updateContainerElements(elements);
1555
+ return trap;
1556
+ };
1557
+
1558
+ exports.createFocusTrap = createFocusTrap;