@y14e/portal 1.2.1 → 1.2.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.
package/dist/index.cjs CHANGED
@@ -370,7 +370,8 @@ var Portal = class {
370
370
  }
371
371
  };
372
372
  #onKeyDown = (event) => {
373
- if (event.key !== "Tab" || event.altKey || event.ctrlKey || event.metaKey) {
373
+ const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
374
+ if (key !== "Tab" || altKey || ctrlKey || metaKey) {
374
375
  return;
375
376
  }
376
377
  const active = getActiveElement2();
@@ -384,7 +385,7 @@ var Portal = class {
384
385
  const focusables = this.#getFocusables();
385
386
  if (!focusables.length) {
386
387
  event.preventDefault();
387
- this.#focusSentinel(event.shiftKey);
388
+ this.#focusSentinel(shiftKey);
388
389
  return;
389
390
  }
390
391
  const index = focusables.indexOf(active);
@@ -392,17 +393,17 @@ var Portal = class {
392
393
  return;
393
394
  }
394
395
  event.preventDefault();
395
- const focusable = focusables[index + (event.shiftKey ? -1 : 1)];
396
+ const focusable = focusables[index + (shiftKey ? -1 : 1)];
396
397
  if (focusable) {
397
398
  focusElement(focusable);
398
399
  } else {
399
- this.#focusSentinel(event.shiftKey);
400
+ this.#focusSentinel(shiftKey);
400
401
  }
401
402
  };
402
403
  #update() {
403
404
  const current = /* @__PURE__ */ new Set([
404
- ...getFocusables(this.#host, { composed: true }),
405
- ...this.#getFocusables()
405
+ ...this.#getFocusables(),
406
+ ...getFocusables(this.#host, { composed: true })
406
407
  ]);
407
408
  this.#focusables.forEach((focusable) => {
408
409
  if (current.has(focusable)) {
@@ -444,9 +445,7 @@ var Portal = class {
444
445
  #getFocusables() {
445
446
  return getFocusables(this.#host, {
446
447
  composed: true,
447
- include: (element) => {
448
- return this.#focusables.has(element);
449
- }
448
+ include: (element) => this.#focusables.has(element)
450
449
  });
451
450
  }
452
451
  #moveFocus(direction) {
@@ -483,7 +482,7 @@ function getActiveElement2() {
483
482
  * Lightweight DOM portal (teleport) utility with fully focus management.
484
483
  * Designed for accessible dialogs, menus, overlays, popovers.
485
484
  *
486
- * @version 1.2.1
485
+ * @version 1.2.3
487
486
  * @author Yusuke Kamiyamane
488
487
  * @license MIT
489
488
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.2.1
6
+ * @version 1.2.3
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.2.1
6
+ * @version 1.2.3
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -368,7 +368,8 @@ var Portal = class {
368
368
  }
369
369
  };
370
370
  #onKeyDown = (event) => {
371
- if (event.key !== "Tab" || event.altKey || event.ctrlKey || event.metaKey) {
371
+ const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
372
+ if (key !== "Tab" || altKey || ctrlKey || metaKey) {
372
373
  return;
373
374
  }
374
375
  const active = getActiveElement2();
@@ -382,7 +383,7 @@ var Portal = class {
382
383
  const focusables = this.#getFocusables();
383
384
  if (!focusables.length) {
384
385
  event.preventDefault();
385
- this.#focusSentinel(event.shiftKey);
386
+ this.#focusSentinel(shiftKey);
386
387
  return;
387
388
  }
388
389
  const index = focusables.indexOf(active);
@@ -390,17 +391,17 @@ var Portal = class {
390
391
  return;
391
392
  }
392
393
  event.preventDefault();
393
- const focusable = focusables[index + (event.shiftKey ? -1 : 1)];
394
+ const focusable = focusables[index + (shiftKey ? -1 : 1)];
394
395
  if (focusable) {
395
396
  focusElement(focusable);
396
397
  } else {
397
- this.#focusSentinel(event.shiftKey);
398
+ this.#focusSentinel(shiftKey);
398
399
  }
399
400
  };
400
401
  #update() {
401
402
  const current = /* @__PURE__ */ new Set([
402
- ...getFocusables(this.#host, { composed: true }),
403
- ...this.#getFocusables()
403
+ ...this.#getFocusables(),
404
+ ...getFocusables(this.#host, { composed: true })
404
405
  ]);
405
406
  this.#focusables.forEach((focusable) => {
406
407
  if (current.has(focusable)) {
@@ -442,9 +443,7 @@ var Portal = class {
442
443
  #getFocusables() {
443
444
  return getFocusables(this.#host, {
444
445
  composed: true,
445
- include: (element) => {
446
- return this.#focusables.has(element);
447
- }
446
+ include: (element) => this.#focusables.has(element)
448
447
  });
449
448
  }
450
449
  #moveFocus(direction) {
@@ -481,7 +480,7 @@ function getActiveElement2() {
481
480
  * Lightweight DOM portal (teleport) utility with fully focus management.
482
481
  * Designed for accessible dialogs, menus, overlays, popovers.
483
482
  *
484
- * @version 1.2.1
483
+ * @version 1.2.3
485
484
  * @author Yusuke Kamiyamane
486
485
  * @license MIT
487
486
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",