focus-trap 7.6.3 β 7.6.4
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.
- package/CHANGELOG.md +6 -0
- package/README.md +17 -6
- package/dist/focus-trap.esm.js +1 -1
- package/dist/focus-trap.esm.min.js +1 -1
- package/dist/focus-trap.js +1 -1
- package/dist/focus-trap.min.js +1 -1
- package/dist/focus-trap.umd.js +1 -1
- package/dist/focus-trap.umd.min.js +1 -1
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# focus-trap [](https://github.com/focus-trap/focus-trap/actions?query=workflow:CI+branch:master) [](./LICENSE)
|
|
2
2
|
|
|
3
3
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
4
|
-
[](#contributors)
|
|
5
5
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
6
6
|
|
|
7
7
|
Trap focus within a DOM node.
|
|
@@ -231,6 +231,10 @@ Pause an active focus trap's event listening without deactivating the trap.
|
|
|
231
231
|
|
|
232
232
|
If the focus trap has not been activated, nothing happens.
|
|
233
233
|
|
|
234
|
+
Whether the trap is already paused or not, its paused state becomes __manually-paused__ even if the trap has already been auto-paused as a result of another trap being activated after this one (and so being higher on the stack than this one).
|
|
235
|
+
|
|
236
|
+
> Note that a manually-paused trap will not be auto-unpaused if it becomes the trap at the top of the `trapStack` again by way of all other traps higher than it on the stack being deactivated. It will remain paused until manually unpaused by calling `unpause()`. If the trap was auto-paused the entire time it was not at the top of the stack, then it will be auto-unpaused when it gets to the top of the stack again.
|
|
237
|
+
|
|
234
238
|
Returns the `trap`.
|
|
235
239
|
|
|
236
240
|
Any `onDeactivate` callback will not be called, and focus will not return to the element that was focused before the trap's activation. But the trap's behavior will be paused.
|
|
@@ -254,7 +258,11 @@ Unpause an active focus trap. (See `pause()`, above.)
|
|
|
254
258
|
|
|
255
259
|
Focus is forced into the trap just as described for `focusTrap.activate()`.
|
|
256
260
|
|
|
257
|
-
If the focus trap has not been activated
|
|
261
|
+
If the focus trap has not been activated, nothing happens.
|
|
262
|
+
|
|
263
|
+
If the focus trap has not been paused, nothing happens other than resetting its __manually-paused__ state.
|
|
264
|
+
|
|
265
|
+
If the focus trap is not at the top of the `trapStack`, it will not be unpaused (whether previously auto- or manually-paused) until all traps higher on the stack have been deactivated and this trap becomes the one at the top again.
|
|
258
266
|
|
|
259
267
|
Returns the `trap`.
|
|
260
268
|
|
|
@@ -380,45 +388,48 @@ In alphabetical order:
|
|
|
380
388
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/andersthorsen"><img src="https://avatars.githubusercontent.com/u/190081?v=4?s=100" width="100px;" alt="Anders Thorsen"/><br /><sub><b>Anders Thorsen</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Aandersthorsen" title="Bug reports">π</a></td>
|
|
381
389
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bparish628"><img src="https://avatars1.githubusercontent.com/u/8492971?v=4?s=100" width="100px;" alt="Benjamin Parish"/><br /><sub><b>Benjamin Parish</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Abparish628" title="Bug reports">π</a></td>
|
|
382
390
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bernhardoj"><img src="https://avatars.githubusercontent.com/u/50919443?v=4?s=100" width="100px;" alt="Bernhard Owen Josephus"/><br /><sub><b>Bernhard Owen Josephus</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=bernhardoj" title="Code">π»</a></td>
|
|
391
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chrisbishop-looka"><img src="https://avatars.githubusercontent.com/u/128391384?v=4?s=100" width="100px;" alt="Chris Bishop"/><br /><sub><b>Chris Bishop</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Achrisbishop-looka" title="Bug reports">π</a></td>
|
|
383
392
|
<td align="center" valign="top" width="14.28%"><a href="https://clintgoodman.com"><img src="https://avatars3.githubusercontent.com/u/5473697?v=4?s=100" width="100px;" alt="Clint Goodman"/><br /><sub><b>Clint Goodman</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Documentation">π</a> <a href="#example-cgood92" title="Examples">π‘</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Tests">β οΈ</a></td>
|
|
384
393
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Dan503"><img src="https://avatars.githubusercontent.com/u/10610368?v=4?s=100" width="100px;" alt="Daniel Tonon"/><br /><sub><b>Daniel Tonon</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=Dan503" title="Documentation">π</a> <a href="#tool-Dan503" title="Tools">π§</a> <a href="#a11y-Dan503" title="Accessibility">οΈοΈοΈοΈβΏοΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=Dan503" title="Code">π»</a></td>
|
|
385
394
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/DaviDevMod"><img src="https://avatars.githubusercontent.com/u/98312056?v=4?s=100" width="100px;" alt="DaviDevMod"/><br /><sub><b>DaviDevMod</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=DaviDevMod" title="Documentation">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=DaviDevMod" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ADaviDevMod" title="Bug reports">π</a></td>
|
|
386
|
-
<td align="center" valign="top" width="14.28%"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4?s=100" width="100px;" alt="David Clark"/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Adavidtheclark" title="Bug reports">π</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Documentation">π</a> <a href="#maintenance-davidtheclark" title="Maintenance">π§</a></td>
|
|
387
395
|
</tr>
|
|
388
396
|
<tr>
|
|
397
|
+
<td align="center" valign="top" width="14.28%"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4?s=100" width="100px;" alt="David Clark"/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Adavidtheclark" title="Bug reports">π</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Documentation">π</a> <a href="#maintenance-davidtheclark" title="Maintenance">π§</a></td>
|
|
389
398
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/features/security"><img src="https://avatars1.githubusercontent.com/u/27347476?v=4?s=100" width="100px;" alt="Dependabot"/><br /><sub><b>Dependabot</b></sub></a><br /><a href="#maintenance-dependabot" title="Maintenance">π§</a></td>
|
|
390
399
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jcfranco"><img src="https://avatars.githubusercontent.com/u/197440?v=4?s=100" width="100px;" alt="JC Franco"/><br /><sub><b>JC Franco</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=jcfranco" title="Code">π»</a></td>
|
|
391
400
|
<td align="center" valign="top" width="14.28%"><a href="https://www.schilljs.com/"><img src="https://avatars.githubusercontent.com/u/213943?v=4?s=100" width="100px;" alt="Joas Schilling"/><br /><sub><b>Joas Schilling</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/pulls?q=is%3Apr+reviewed-by%3Anickvergessen" title="Reviewed Pull Requests">π</a></td>
|
|
392
401
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/skjnldsv"><img src="https://avatars.githubusercontent.com/u/14975046?v=4?s=100" width="100px;" alt="John MolakvoΓ¦"/><br /><sub><b>John MolakvoΓ¦</b></sub></a><br /><a href="#ideas-skjnldsv" title="Ideas, Planning, & Feedback">π€</a></td>
|
|
393
402
|
<td align="center" valign="top" width="14.28%"><a href="http://reload.dk"><img src="https://avatars.githubusercontent.com/u/73966?v=4?s=100" width="100px;" alt="Kasper GarnΓ¦s"/><br /><sub><b>Kasper GarnΓ¦s</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=kasperg" title="Documentation">π</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Akasperg" title="Bug reports">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=kasperg" title="Code">π»</a></td>
|
|
394
403
|
<td align="center" valign="top" width="14.28%"><a href="http://blogs.esri.com/esri/arcgis/"><img src="https://avatars.githubusercontent.com/u/1231455?v=4?s=100" width="100px;" alt="Matt Driscoll"/><br /><sub><b>Matt Driscoll</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Adriskull" title="Bug reports">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=driskull" title="Code">π»</a> <a href="#tutorial-driskull" title="Tutorials">β
</a></td>
|
|
395
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/msev"><img src="https://avatars.githubusercontent.com/u/1529562?v=4?s=100" width="100px;" alt="Maxime"/><br /><sub><b>Maxime</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amsev" title="Bug reports">π</a></td>
|
|
396
404
|
</tr>
|
|
397
405
|
<tr>
|
|
406
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/msev"><img src="https://avatars.githubusercontent.com/u/1529562?v=4?s=100" width="100px;" alt="Maxime"/><br /><sub><b>Maxime</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amsev" title="Bug reports">π</a></td>
|
|
398
407
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/michael-ar"><img src="https://avatars3.githubusercontent.com/u/18557997?v=4?s=100" width="100px;" alt="Michael Reynolds"/><br /><sub><b>Michael Reynolds</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amichael-ar" title="Bug reports">π</a></td>
|
|
399
408
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/liunate"><img src="https://avatars2.githubusercontent.com/u/38996291?v=4?s=100" width="100px;" alt="Nate Liu"/><br /><sub><b>Nate Liu</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=liunate" title="Tests">β οΈ</a></td>
|
|
400
409
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/far-fetched"><img src="https://avatars.githubusercontent.com/u/11621383?v=4?s=100" width="100px;" alt="Piotr Panek"/><br /><sub><b>Piotr Panek</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Afar-fetched" title="Bug reports">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Documentation">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Tests">β οΈ</a></td>
|
|
401
410
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/randypuro"><img src="https://avatars2.githubusercontent.com/u/2579?v=4?s=100" width="100px;" alt="Randy Puro"/><br /><sub><b>Randy Puro</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Arandypuro" title="Bug reports">π</a></td>
|
|
402
411
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sadick254"><img src="https://avatars2.githubusercontent.com/u/5238135?v=4?s=100" width="100px;" alt="Sadick"/><br /><sub><b>Sadick</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Documentation">π</a></td>
|
|
403
412
|
<td align="center" valign="top" width="14.28%"><a href="https://scottblinch.me/"><img src="https://avatars2.githubusercontent.com/u/4682114?v=4?s=100" width="100px;" alt="Scott Blinch"/><br /><sub><b>Scott Blinch</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=scottblinch" title="Documentation">π</a></td>
|
|
404
|
-
<td align="center" valign="top" width="14.28%"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt="Sean McPherson"/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Documentation">π</a></td>
|
|
405
413
|
</tr>
|
|
406
414
|
<tr>
|
|
415
|
+
<td align="center" valign="top" width="14.28%"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt="Sean McPherson"/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Documentation">π</a></td>
|
|
407
416
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/skriems"><img src="https://avatars.githubusercontent.com/u/15573317?v=4?s=100" width="100px;" alt="Sebastian Kriems"/><br /><sub><b>Sebastian Kriems</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Askriems" title="Bug reports">π</a></td>
|
|
408
417
|
<td align="center" valign="top" width="14.28%"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt="Slapbox"/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ASlapbox" title="Bug reports">π</a></td>
|
|
409
418
|
<td align="center" valign="top" width="14.28%"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt="Stefan Cameron"/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Astefcameron" title="Bug reports">π</a> <a href="#infra-stefcameron" title="Infrastructure (Hosting, Build-Tools, etc)">π</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Documentation">π</a> <a href="#maintenance-stefcameron" title="Maintenance">π§</a></td>
|
|
410
419
|
<td align="center" valign="top" width="14.28%"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt="Tyler Hawkins"/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="#tool-thawkin3" title="Tools">π§</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Documentation">π</a></td>
|
|
411
420
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vasiliki-b"><img src="https://avatars.githubusercontent.com/u/98032598?v=4?s=100" width="100px;" alt="Vasiliki Boutas"/><br /><sub><b>Vasiliki Boutas</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Avasiliki-b" title="Bug reports">π</a></td>
|
|
412
421
|
<td align="center" valign="top" width="14.28%"><a href="https://vinicius73.dev/"><img src="https://avatars.githubusercontent.com/u/1561347?v=4?s=100" width="100px;" alt="Vinicius Reis"/><br /><sub><b>Vinicius Reis</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=vinicius73" title="Code">π»</a> <a href="#ideas-vinicius73" title="Ideas, Planning, & Feedback">π€</a></td>
|
|
413
|
-
<td align="center" valign="top" width="14.28%"><a href="https://github.com/wandroll"><img src="https://avatars.githubusercontent.com/u/4492317?v=4?s=100" width="100px;" alt="Wandrille Verlut"/><br /><sub><b>Wandrille Verlut</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Documentation">π</a> <a href="#tool-wandroll" title="Tools">π§</a></td>
|
|
414
422
|
</tr>
|
|
415
423
|
<tr>
|
|
424
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/wandroll"><img src="https://avatars.githubusercontent.com/u/4492317?v=4?s=100" width="100px;" alt="Wandrille Verlut"/><br /><sub><b>Wandrille Verlut</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Tests">β οΈ</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Documentation">π</a> <a href="#tool-wandroll" title="Tools">π§</a></td>
|
|
416
425
|
<td align="center" valign="top" width="14.28%"><a href="http://willmruzek.com/"><img src="https://avatars.githubusercontent.com/u/108522?v=4?s=100" width="100px;" alt="Will Mruzek"/><br /><sub><b>Will Mruzek</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Documentation">π</a> <a href="#example-mruzekw" title="Examples">π‘</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Tests">β οΈ</a> <a href="#question-mruzekw" title="Answering Questions">π¬</a></td>
|
|
417
426
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/zioth"><img src="https://avatars3.githubusercontent.com/u/945603?v=4?s=100" width="100px;" alt="Zioth"/><br /><sub><b>Zioth</b></sub></a><br /><a href="#ideas-zioth" title="Ideas, Planning, & Feedback">π€</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Azioth" title="Bug reports">π</a></td>
|
|
418
427
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/glushkova91"><img src="https://avatars.githubusercontent.com/u/13402897?v=4?s=100" width="100px;" alt="glushkova91"/><br /><sub><b>glushkova91</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=glushkova91" title="Documentation">π</a></td>
|
|
419
428
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jpveooys"><img src="https://avatars.githubusercontent.com/u/66470099?v=4?s=100" width="100px;" alt="jpveooys"/><br /><sub><b>jpveooys</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Ajpveooys" title="Bug reports">π</a></td>
|
|
420
429
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/konradr33"><img src="https://avatars.githubusercontent.com/u/32595283?v=4?s=100" width="100px;" alt="konradr33"/><br /><sub><b>konradr33</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Akonradr33" title="Bug reports">π</a></td>
|
|
421
430
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tomasvn"><img src="https://avatars.githubusercontent.com/u/17225564?v=4?s=100" width="100px;" alt="tomasvn"/><br /><sub><b>tomasvn</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=tomasvn" title="Code">π»</a></td>
|
|
431
|
+
</tr>
|
|
432
|
+
<tr>
|
|
422
433
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/simonxabris"><img src="https://avatars.githubusercontent.com/u/27497229?v=4?s=100" width="100px;" alt="Γbris Simon"/><br /><sub><b>Γbris Simon</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=simonxabris" title="Code">π»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Asimonxabris" title="Bug reports">π</a></td>
|
|
423
434
|
</tr>
|
|
424
435
|
</tbody>
|
package/dist/focus-trap.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* focus-trap 7.6.
|
|
2
|
+
* focus-trap 7.6.4
|
|
3
3
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
4
4
|
*/
|
|
5
5
|
import{tabbable as e,focusable as t,isTabbable as n,getTabIndex as o,isFocusable as r}from"tabbable";function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n._setPausedState(!0)}var o=e.indexOf(t);-1===o||e.splice(o,1),e.push(t)},d=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&!e[e.length-1]._isManuallyPaused()&&e[e.length-1]._setPausedState(!1)},f=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},b=function(e){return f(e)&&!e.shiftKey},v=function(e){return f(e)&&e.shiftKey},p=function(e){return setTimeout(e,0)},m=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return"function"==typeof e?e.apply(void 0,n):e},y=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},h=[],w=function(a,i){var u,w=(null==i?void 0:i.document)||document,g=(null==i?void 0:i.trapStack)||h,N=s({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:b,isKeyBackward:v},i),F={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},O=function(e,t,n){return e&&void 0!==e[t]?e[t]:N[n||t]},P=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return F.containerGroups.findIndex((function(t){var o=t.container,r=t.tabbableNodes;return o.contains(e)||(null==n?void 0:n.includes(o))||r.find((function(t){return t===e}))}))},E=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,o=void 0!==n&&n,r=t.params,a=void 0===r?[]:r,i=N[e];if("function"==typeof i&&(i=i.apply(void 0,c(a))),!0===i&&(i=void 0),!i){if(void 0===i||!1===i)return i;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var u=i;if("string"==typeof i){try{u=w.querySelector(i)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!u&&!o)throw new Error("`".concat(e,"` as selector refers to no known node"))}return u},k=function(){var e=E("initialFocus",{hasFallback:!0});if(!1===e)return!1;if(void 0===e||e&&!r(e,N.tabbableOptions))if(P(w.activeElement)>=0)e=w.activeElement;else{var t=F.tabbableGroups[0];e=t&&t.firstTabbableNode||E("fallbackFocus")}else null===e&&(e=E("fallbackFocus"));if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},T=function(){if(F.containerGroups=F.containers.map((function(r){var a=e(r,N.tabbableOptions),i=t(r,N.tabbableOptions),u=a.length>0?a[0]:void 0,s=a.length>0?a[a.length-1]:void 0,c=i.find((function(e){return n(e)})),l=i.slice().reverse().find((function(e){return n(e)})),d=!!a.find((function(e){return o(e)>0}));return{container:r,tabbableNodes:a,focusableNodes:i,posTabIndexesFound:d,firstTabbableNode:u,lastTabbableNode:s,firstDomTabbableNode:c,lastDomTabbableNode:l,nextTabbableNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=a.indexOf(e);return o<0?t?i.slice(i.indexOf(e)+1).find((function(e){return n(e)})):i.slice(0,i.indexOf(e)).reverse().find((function(e){return n(e)})):a[o+(t?1:-1)]}}})),F.tabbableGroups=F.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),F.tabbableGroups.length<=0&&!E("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(F.containerGroups.find((function(e){return e.posTabIndexesFound}))&&F.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},D=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?D(t.shadowRoot):t},G=function(e){!1!==e&&e!==D(document)&&(e&&e.focus?(e.focus({preventScroll:!!N.preventScroll}),F.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):G(k()))},x=function(e){var t=E("setReturnFocus",{params:[e]});return t||!1!==t&&e},S=function(e){var t=e.target,a=e.event,i=e.isBackward,u=void 0!==i&&i;t=t||y(a),T();var s=null;if(F.tabbableGroups.length>0){var c=P(t,a),l=c>=0?F.containerGroups[c]:void 0;if(c<0)s=u?F.tabbableGroups[F.tabbableGroups.length-1].lastTabbableNode:F.tabbableGroups[0].firstTabbableNode;else if(u){var d=F.tabbableGroups.findIndex((function(e){var n=e.firstTabbableNode;return t===n}));if(d<0&&(l.container===t||r(t,N.tabbableOptions)&&!n(t,N.tabbableOptions)&&!l.nextTabbableNode(t,!1))&&(d=c),d>=0){var b=0===d?F.tabbableGroups.length-1:d-1,v=F.tabbableGroups[b];s=o(t)>=0?v.lastTabbableNode:v.lastDomTabbableNode}else f(a)||(s=l.nextTabbableNode(t,!1))}else{var p=F.tabbableGroups.findIndex((function(e){var n=e.lastTabbableNode;return t===n}));if(p<0&&(l.container===t||r(t,N.tabbableOptions)&&!n(t,N.tabbableOptions)&&!l.nextTabbableNode(t))&&(p=c),p>=0){var m=p===F.tabbableGroups.length-1?0:p+1,h=F.tabbableGroups[m];s=o(t)>=0?h.firstTabbableNode:h.firstDomTabbableNode}else f(a)||(s=l.nextTabbableNode(t))}}else s=E("fallbackFocus");return s},R=function(e){var t=y(e);P(t,e)>=0||(m(N.clickOutsideDeactivates,e)?u.deactivate({returnFocus:N.returnFocusOnDeactivate}):m(N.allowOutsideClick,e)||e.preventDefault())},j=function(e){var t=y(e),n=P(t,e)>=0;if(n||t instanceof Document)n&&(F.mostRecentlyFocusedNode=t);else{var r;e.stopImmediatePropagation();var a=!0;if(F.mostRecentlyFocusedNode)if(o(F.mostRecentlyFocusedNode)>0){var i=P(F.mostRecentlyFocusedNode),u=F.containerGroups[i].tabbableNodes;if(u.length>0){var s=u.findIndex((function(e){return e===F.mostRecentlyFocusedNode}));s>=0&&(N.isKeyForward(F.recentNavEvent)?s+1<u.length&&(r=u[s+1],a=!1):s-1>=0&&(r=u[s-1],a=!1))}}else F.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return o(e)>0}))}))||(a=!1);else a=!1;a&&(r=S({target:F.mostRecentlyFocusedNode,isBackward:N.isKeyBackward(F.recentNavEvent)})),G(r||(F.mostRecentlyFocusedNode||k()))}F.recentNavEvent=void 0},I=function(e){(N.isKeyForward(e)||N.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];F.recentNavEvent=e;var n=S({event:e,isBackward:t});n&&(f(e)&&e.preventDefault(),G(n))}(e,N.isKeyBackward(e))},A=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===m(N.escapeDeactivates,e)||(e.preventDefault(),u.deactivate())},L=function(e){var t=y(e);P(t,e)>=0||m(N.clickOutsideDeactivates,e)||m(N.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},B=function(){if(F.active)return l(g,u),F.delayInitialFocusTimer=N.delayInitialFocus?p((function(){G(k())})):G(k()),w.addEventListener("focusin",j,!0),w.addEventListener("mousedown",R,{capture:!0,passive:!1}),w.addEventListener("touchstart",R,{capture:!0,passive:!1}),w.addEventListener("click",L,{capture:!0,passive:!1}),w.addEventListener("keydown",I,{capture:!0,passive:!1}),w.addEventListener("keydown",A),u},C=function(){if(F.active)return w.removeEventListener("focusin",j,!0),w.removeEventListener("mousedown",R,!0),w.removeEventListener("touchstart",R,!0),w.removeEventListener("click",L,!0),w.removeEventListener("keydown",I,!0),w.removeEventListener("keydown",A),u},K="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===F.mostRecentlyFocusedNode}))}))&&G(k())})):void 0,_=function(){K&&(K.disconnect(),F.active&&!F.paused&&F.containers.map((function(e){K.observe(e,{subtree:!0,childList:!0})})))};return u={get active(){return F.active},get paused(){return F.paused},activate:function(e){if(F.active)return this;var t=O(e,"onActivate"),n=O(e,"onPostActivate"),o=O(e,"checkCanFocusTrap");o||T(),F.active=!0,F.paused=!1,F.nodeFocusedBeforeActivation=w.activeElement,null==t||t();var r=function(){o&&T(),B(),_(),null==n||n()};return o?(o(F.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!F.active)return this;var t=s({onDeactivate:N.onDeactivate,onPostDeactivate:N.onPostDeactivate,checkCanReturnFocus:N.checkCanReturnFocus},e);clearTimeout(F.delayInitialFocusTimer),F.delayInitialFocusTimer=void 0,C(),F.active=!1,F.paused=!1,_(),d(g,u);var n=O(t,"onDeactivate"),o=O(t,"onPostDeactivate"),r=O(t,"checkCanReturnFocus"),a=O(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var i=function(){p((function(){a&&G(x(F.nodeFocusedBeforeActivation)),null==o||o()}))};return a&&r?(r(x(F.nodeFocusedBeforeActivation)).then(i,i),this):(i(),this)},pause:function(e){return F.active?(F.manuallyPaused=!0,this._setPausedState(!0,e)):this},unpause:function(e){return F.active?(F.manuallyPaused=!1,g[g.length-1]!==this?this:this._setPausedState(!1,e)):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return F.containers=t.map((function(e){return"string"==typeof e?w.querySelector(e):e})),F.active&&T(),_(),this}},Object.defineProperties(u,{_isManuallyPaused:{value:function(){return F.manuallyPaused}},_setPausedState:{value:function(e,t){if(F.paused===e)return this;if(F.paused=e,e){var n=O(t,"onPause"),o=O(t,"onPostPause");null==n||n(),C(),_(),null==o||o()}else{var r=O(t,"onUnpause"),a=O(t,"onPostUnpause");null==r||r(),T(),B(),_(),null==a||a()}return this}}}),u.updateContainerElements(a),u};export{w as createFocusTrap};
|
package/dist/focus-trap.js
CHANGED
package/dist/focus-trap.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* focus-trap 7.6.
|
|
2
|
+
* focus-trap 7.6.4
|
|
3
3
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
4
4
|
*/
|
|
5
5
|
"use strict";var e=require("tabbable");function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function n(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?a(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n._setPausedState(!0)}var a=e.indexOf(t);-1===a||e.splice(a,1),e.push(t)},u=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&!e[e.length-1]._isManuallyPaused()&&e[e.length-1]._setPausedState(!1)},s=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},c=function(e){return s(e)&&!e.shiftKey},l=function(e){return s(e)&&e.shiftKey},d=function(e){return setTimeout(e,0)},b=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},f=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},v=[];exports.createFocusTrap=function(t,n){var a,p=(null==n?void 0:n.document)||document,m=(null==n?void 0:n.trapStack)||v,y=o({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:c,isKeyBackward:l},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},w=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},g=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var a=t.container,o=t.tabbableNodes;return a.contains(e)||(null==n?void 0:n.includes(a))||o.find((function(t){return t===e}))}))},F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,a=void 0!==n&&n,o=t.params,i=void 0===o?[]:o,u=y[e];if("function"==typeof u&&(u=u.apply(void 0,r(i))),!0===u&&(u=void 0),!u){if(void 0===u||!1===u)return u;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var s=u;if("string"==typeof u){try{s=p.querySelector(u)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!s&&!a)throw new Error("`".concat(e,"` as selector refers to no known node"))}return s},N=function(){var t=F("initialFocus",{hasFallback:!0});if(!1===t)return!1;if(void 0===t||t&&!e.isFocusable(t,y.tabbableOptions))if(g(p.activeElement)>=0)t=p.activeElement;else{var n=h.tabbableGroups[0];t=n&&n.firstTabbableNode||F("fallbackFocus")}else null===t&&(t=F("fallbackFocus"));if(!t)throw new Error("Your focus-trap needs to have at least one focusable element");return t},T=function(){if(h.containerGroups=h.containers.map((function(t){var n=e.tabbable(t,y.tabbableOptions),a=e.focusable(t,y.tabbableOptions),o=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=a.find((function(t){return e.isTabbable(t)})),u=a.slice().reverse().find((function(t){return e.isTabbable(t)})),s=!!n.find((function(t){return e.getTabIndex(t)>0}));return{container:t,tabbableNodes:n,focusableNodes:a,posTabIndexesFound:s,firstTabbableNode:o,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(t){var o=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(t);return r<0?o?a.slice(a.indexOf(t)+1).find((function(t){return e.isTabbable(t)})):a.slice(0,a.indexOf(t)).reverse().find((function(t){return e.isTabbable(t)})):n[r+(o?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!F("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?O(t.shadowRoot):t},P=function(e){!1!==e&&e!==O(document)&&(e&&e.focus?(e.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):P(N()))},E=function(e){var t=F("setReturnFocus",{params:[e]});return t||!1!==t&&e},k=function(t){var n=t.target,a=t.event,o=t.isBackward,r=void 0!==o&&o;n=n||f(a),T();var i=null;if(h.tabbableGroups.length>0){var u=g(n,a),c=u>=0?h.containerGroups[u]:void 0;if(u<0)i=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var l=h.tabbableGroups.findIndex((function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n,!1))&&(l=u),l>=0){var d=0===l?h.tabbableGroups.length-1:l-1,b=h.tabbableGroups[d];i=e.getTabIndex(n)>=0?b.lastTabbableNode:b.lastDomTabbableNode}else s(a)||(i=c.nextTabbableNode(n,!1))}else{var v=h.tabbableGroups.findIndex((function(e){var t=e.lastTabbableNode;return n===t}));if(v<0&&(c.container===n||e.isFocusable(n,y.tabbableOptions)&&!e.isTabbable(n,y.tabbableOptions)&&!c.nextTabbableNode(n))&&(v=u),v>=0){var p=v===h.tabbableGroups.length-1?0:v+1,m=h.tabbableGroups[p];i=e.getTabIndex(n)>=0?m.firstTabbableNode:m.firstDomTabbableNode}else s(a)||(i=c.nextTabbableNode(n))}}else i=F("fallbackFocus");return i},D=function(e){var t=f(e);g(t,e)>=0||(b(y.clickOutsideDeactivates,e)?a.deactivate({returnFocus:y.returnFocusOnDeactivate}):b(y.allowOutsideClick,e)||e.preventDefault())},x=function(t){var n=f(t),a=g(n,t)>=0;if(a||n instanceof Document)a&&(h.mostRecentlyFocusedNode=n);else{var o;t.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(e.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=g(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var s=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));s>=0&&(y.isKeyForward(h.recentNavEvent)?s+1<u.length&&(o=u[s+1],r=!1):s-1>=0&&(o=u[s-1],r=!1))}}else h.containerGroups.some((function(t){return t.tabbableNodes.some((function(t){return e.getTabIndex(t)>0}))}))||(r=!1);else r=!1;r&&(o=k({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),P(o||(h.mostRecentlyFocusedNode||N()))}h.recentNavEvent=void 0},G=function(e){(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=k({event:e,isBackward:t});n&&(s(e)&&e.preventDefault(),P(n))}(e,y.isKeyBackward(e))},I=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===b(y.escapeDeactivates,e)||(e.preventDefault(),a.deactivate())},S=function(e){var t=f(e);g(t,e)>=0||b(y.clickOutsideDeactivates,e)||b(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},R=function(){if(h.active)return i(m,a),h.delayInitialFocusTimer=y.delayInitialFocus?d((function(){P(N())})):P(N()),p.addEventListener("focusin",x,!0),p.addEventListener("mousedown",D,{capture:!0,passive:!1}),p.addEventListener("touchstart",D,{capture:!0,passive:!1}),p.addEventListener("click",S,{capture:!0,passive:!1}),p.addEventListener("keydown",G,{capture:!0,passive:!1}),p.addEventListener("keydown",I),a},j=function(){if(h.active)return p.removeEventListener("focusin",x,!0),p.removeEventListener("mousedown",D,!0),p.removeEventListener("touchstart",D,!0),p.removeEventListener("click",S,!0),p.removeEventListener("keydown",G,!0),p.removeEventListener("keydown",I),a},A="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&P(N())})):void 0,L=function(){A&&(A.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){A.observe(e,{subtree:!0,childList:!0})})))};return a={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=w(e,"onActivate"),n=w(e,"onPostActivate"),a=w(e,"checkCanFocusTrap");a||T(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=p.activeElement,null==t||t();var o=function(){a&&T(),R(),L(),null==n||n()};return a?(a(h.containers.concat()).then(o,o),this):(o(),this)},deactivate:function(e){if(!h.active)return this;var t=o({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,j(),h.active=!1,h.paused=!1,L(),u(m,a);var n=w(t,"onDeactivate"),r=w(t,"onPostDeactivate"),i=w(t,"checkCanReturnFocus"),s=w(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var c=function(){d((function(){s&&P(E(h.nodeFocusedBeforeActivation)),null==r||r()}))};return s&&i?(i(E(h.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(e){return h.active?(h.manuallyPaused=!0,this._setPausedState(!0,e)):this},unpause:function(e){return h.active?(h.manuallyPaused=!1,m[m.length-1]!==this?this:this._setPausedState(!1,e)):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?p.querySelector(e):e})),h.active&&T(),L(),this}},Object.defineProperties(a,{_isManuallyPaused:{value:function(){return h.manuallyPaused}},_setPausedState:{value:function(e,t){if(h.paused===e)return this;if(h.paused=e,e){var n=w(t,"onPause"),a=w(t,"onPostPause");null==n||n(),j(),L(),null==a||a()}else{var o=w(t,"onUnpause"),r=w(t,"onPostUnpause");null==o||o(),T(),R(),L(),null==r||r()}return this}}}),a.updateContainerElements(t),a};
|
package/dist/focus-trap.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* focus-trap 7.6.
|
|
2
|
+
* focus-trap 7.6.4
|
|
3
3
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
4
4
|
*/
|
|
5
5
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tabbable")):"function"==typeof define&&define.amd?define(["exports","tabbable"],t):(e="undefined"!=typeof globalThis?globalThis:e||self,function(){var n=e.focusTrap,a=e.focusTrap={};t(a,e.tabbable),a.noConflict=function(){return e.focusTrap=n,a}}())}(this,(function(e,t){"use strict";function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}function a(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u=function(e,t){if(e.length>0){var n=e[e.length-1];n!==t&&n._setPausedState(!0)}var a=e.indexOf(t);-1===a||e.splice(a,1),e.push(t)},s=function(e,t){var n=e.indexOf(t);-1!==n&&e.splice(n,1),e.length>0&&!e[e.length-1]._isManuallyPaused()&&e[e.length-1]._setPausedState(!1)},c=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},l=function(e){return c(e)&&!e.shiftKey},d=function(e){return c(e)&&e.shiftKey},b=function(e){return setTimeout(e,0)},f=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return"function"==typeof e?e.apply(void 0,n):e},v=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},p=[];e.createFocusTrap=function(e,n){var a,o=(null==n?void 0:n.document)||document,m=(null==n?void 0:n.trapStack)||p,y=r({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:l,isKeyBackward:d},n),h={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},g=function(e,t,n){return e&&void 0!==e[t]?e[t]:y[n||t]},w=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return h.containerGroups.findIndex((function(t){var a=t.container,o=t.tabbableNodes;return a.contains(e)||(null==n?void 0:n.includes(a))||o.find((function(t){return t===e}))}))},T=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,a=void 0!==n&&n,r=t.params,u=void 0===r?[]:r,s=y[e];if("function"==typeof s&&(s=s.apply(void 0,i(u))),!0===s&&(s=void 0),!s){if(void 0===s||!1===s)return s;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var c=s;if("string"==typeof s){try{c=o.querySelector(s)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!c&&!a)throw new Error("`".concat(e,"` as selector refers to no known node"))}return c},F=function(){var e=T("initialFocus",{hasFallback:!0});if(!1===e)return!1;if(void 0===e||e&&!t.isFocusable(e,y.tabbableOptions))if(w(o.activeElement)>=0)e=o.activeElement;else{var n=h.tabbableGroups[0];e=n&&n.firstTabbableNode||T("fallbackFocus")}else null===e&&(e=T("fallbackFocus"));if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},N=function(){if(h.containerGroups=h.containers.map((function(e){var n=t.tabbable(e,y.tabbableOptions),a=t.focusable(e,y.tabbableOptions),o=n.length>0?n[0]:void 0,r=n.length>0?n[n.length-1]:void 0,i=a.find((function(e){return t.isTabbable(e)})),u=a.slice().reverse().find((function(e){return t.isTabbable(e)})),s=!!n.find((function(e){return t.getTabIndex(e)>0}));return{container:e,tabbableNodes:n,focusableNodes:a,posTabIndexesFound:s,firstTabbableNode:o,lastTabbableNode:r,firstDomTabbableNode:i,lastDomTabbableNode:u,nextTabbableNode:function(e){var o=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=n.indexOf(e);return r<0?o?a.slice(a.indexOf(e)+1).find((function(e){return t.isTabbable(e)})):a.slice(0,a.indexOf(e)).reverse().find((function(e){return t.isTabbable(e)})):n[r+(o?1:-1)]}}})),h.tabbableGroups=h.containerGroups.filter((function(e){return e.tabbableNodes.length>0})),h.tabbableGroups.length<=0&&!T("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(h.containerGroups.find((function(e){return e.posTabIndexesFound}))&&h.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},O=function(e){var t=e.activeElement;if(t)return t.shadowRoot&&null!==t.shadowRoot.activeElement?O(t.shadowRoot):t},P=function(e){!1!==e&&e!==O(document)&&(e&&e.focus?(e.focus({preventScroll:!!y.preventScroll}),h.mostRecentlyFocusedNode=e,function(e){return e.tagName&&"input"===e.tagName.toLowerCase()&&"function"==typeof e.select}(e)&&e.select()):P(F()))},E=function(e){var t=T("setReturnFocus",{params:[e]});return t||!1!==t&&e},k=function(e){var n=e.target,a=e.event,o=e.isBackward,r=void 0!==o&&o;n=n||v(a),N();var i=null;if(h.tabbableGroups.length>0){var u=w(n,a),s=u>=0?h.containerGroups[u]:void 0;if(u<0)i=r?h.tabbableGroups[h.tabbableGroups.length-1].lastTabbableNode:h.tabbableGroups[0].firstTabbableNode;else if(r){var l=h.tabbableGroups.findIndex((function(e){var t=e.firstTabbableNode;return n===t}));if(l<0&&(s.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n,!1))&&(l=u),l>=0){var d=0===l?h.tabbableGroups.length-1:l-1,b=h.tabbableGroups[d];i=t.getTabIndex(n)>=0?b.lastTabbableNode:b.lastDomTabbableNode}else c(a)||(i=s.nextTabbableNode(n,!1))}else{var f=h.tabbableGroups.findIndex((function(e){var t=e.lastTabbableNode;return n===t}));if(f<0&&(s.container===n||t.isFocusable(n,y.tabbableOptions)&&!t.isTabbable(n,y.tabbableOptions)&&!s.nextTabbableNode(n))&&(f=u),f>=0){var p=f===h.tabbableGroups.length-1?0:f+1,m=h.tabbableGroups[p];i=t.getTabIndex(n)>=0?m.firstTabbableNode:m.firstDomTabbableNode}else c(a)||(i=s.nextTabbableNode(n))}}else i=T("fallbackFocus");return i},x=function(e){var t=v(e);w(t,e)>=0||(f(y.clickOutsideDeactivates,e)?a.deactivate({returnFocus:y.returnFocusOnDeactivate}):f(y.allowOutsideClick,e)||e.preventDefault())},D=function(e){var n=v(e),a=w(n,e)>=0;if(a||n instanceof Document)a&&(h.mostRecentlyFocusedNode=n);else{var o;e.stopImmediatePropagation();var r=!0;if(h.mostRecentlyFocusedNode)if(t.getTabIndex(h.mostRecentlyFocusedNode)>0){var i=w(h.mostRecentlyFocusedNode),u=h.containerGroups[i].tabbableNodes;if(u.length>0){var s=u.findIndex((function(e){return e===h.mostRecentlyFocusedNode}));s>=0&&(y.isKeyForward(h.recentNavEvent)?s+1<u.length&&(o=u[s+1],r=!1):s-1>=0&&(o=u[s-1],r=!1))}}else h.containerGroups.some((function(e){return e.tabbableNodes.some((function(e){return t.getTabIndex(e)>0}))}))||(r=!1);else r=!1;r&&(o=k({target:h.mostRecentlyFocusedNode,isBackward:y.isKeyBackward(h.recentNavEvent)})),P(o||(h.mostRecentlyFocusedNode||F()))}h.recentNavEvent=void 0},G=function(e){(y.isKeyForward(e)||y.isKeyBackward(e))&&function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];h.recentNavEvent=e;var n=k({event:e,isBackward:t});n&&(c(e)&&e.preventDefault(),P(n))}(e,y.isKeyBackward(e))},I=function(e){var t;"Escape"!==(null==(t=e)?void 0:t.key)&&"Esc"!==(null==t?void 0:t.key)&&27!==(null==t?void 0:t.keyCode)||!1===f(y.escapeDeactivates,e)||(e.preventDefault(),a.deactivate())},S=function(e){var t=v(e);w(t,e)>=0||f(y.clickOutsideDeactivates,e)||f(y.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},j=function(){if(h.active)return u(m,a),h.delayInitialFocusTimer=y.delayInitialFocus?b((function(){P(F())})):P(F()),o.addEventListener("focusin",D,!0),o.addEventListener("mousedown",x,{capture:!0,passive:!1}),o.addEventListener("touchstart",x,{capture:!0,passive:!1}),o.addEventListener("click",S,{capture:!0,passive:!1}),o.addEventListener("keydown",G,{capture:!0,passive:!1}),o.addEventListener("keydown",I),a},R=function(){if(h.active)return o.removeEventListener("focusin",D,!0),o.removeEventListener("mousedown",x,!0),o.removeEventListener("touchstart",x,!0),o.removeEventListener("click",S,!0),o.removeEventListener("keydown",G,!0),o.removeEventListener("keydown",I),a},A="undefined"!=typeof window&&"MutationObserver"in window?new MutationObserver((function(e){e.some((function(e){return Array.from(e.removedNodes).some((function(e){return e===h.mostRecentlyFocusedNode}))}))&&P(F())})):void 0,L=function(){A&&(A.disconnect(),h.active&&!h.paused&&h.containers.map((function(e){A.observe(e,{subtree:!0,childList:!0})})))};return a={get active(){return h.active},get paused(){return h.paused},activate:function(e){if(h.active)return this;var t=g(e,"onActivate"),n=g(e,"onPostActivate"),a=g(e,"checkCanFocusTrap");a||N(),h.active=!0,h.paused=!1,h.nodeFocusedBeforeActivation=o.activeElement,null==t||t();var r=function(){a&&N(),j(),L(),null==n||n()};return a?(a(h.containers.concat()).then(r,r),this):(r(),this)},deactivate:function(e){if(!h.active)return this;var t=r({onDeactivate:y.onDeactivate,onPostDeactivate:y.onPostDeactivate,checkCanReturnFocus:y.checkCanReturnFocus},e);clearTimeout(h.delayInitialFocusTimer),h.delayInitialFocusTimer=void 0,R(),h.active=!1,h.paused=!1,L(),s(m,a);var n=g(t,"onDeactivate"),o=g(t,"onPostDeactivate"),i=g(t,"checkCanReturnFocus"),u=g(t,"returnFocus","returnFocusOnDeactivate");null==n||n();var c=function(){b((function(){u&&P(E(h.nodeFocusedBeforeActivation)),null==o||o()}))};return u&&i?(i(E(h.nodeFocusedBeforeActivation)).then(c,c),this):(c(),this)},pause:function(e){return h.active?(h.manuallyPaused=!0,this._setPausedState(!0,e)):this},unpause:function(e){return h.active?(h.manuallyPaused=!1,m[m.length-1]!==this?this:this._setPausedState(!1,e)):this},updateContainerElements:function(e){var t=[].concat(e).filter(Boolean);return h.containers=t.map((function(e){return"string"==typeof e?o.querySelector(e):e})),h.active&&N(),L(),this}},Object.defineProperties(a,{_isManuallyPaused:{value:function(){return h.manuallyPaused}},_setPausedState:{value:function(e,t){if(h.paused===e)return this;if(h.paused=e,e){var n=g(t,"onPause"),a=g(t,"onPostPause");null==n||n(),R(),L(),null==a||a()}else{var o=g(t,"onUnpause"),r=g(t,"onPostUnpause");null==o||o(),N(),j(),L(),null==r||r()}return this}}}),a.updateContainerElements(e),a}}));
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.4",
|
|
4
4
|
"description": "Trap focus within a DOM node.",
|
|
5
|
-
"engines": {
|
|
6
|
-
"node": "^20.11.0 || >=21.2.0"
|
|
7
|
-
},
|
|
8
5
|
"main": "dist/focus-trap.js",
|
|
9
6
|
"module": "dist/focus-trap.esm.js",
|
|
10
7
|
"types": "index.d.ts",
|