@y14e/accordion 1.3.2 → 1.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.
package/dist/index.cjs CHANGED
@@ -105,7 +105,12 @@ function getFocusables(container = document.body, options = {}) {
105
105
  console.warn("Invalid container element. Fallback: <body> element.");
106
106
  container = document.body;
107
107
  }
108
- let { composed = false, filter, include } = options;
108
+ let {
109
+ composed = false,
110
+ filter,
111
+ include,
112
+ skipVisibilityCheck = false
113
+ } = options;
109
114
  if (typeof composed !== "boolean") {
110
115
  console.warn("Invalid composed option. Fallback: false.");
111
116
  composed = false;
@@ -126,7 +131,7 @@ function getFocusables(container = document.body, options = {}) {
126
131
  if (composed || include) {
127
132
  let traverse2 = function(node) {
128
133
  if (node instanceof Element) {
129
- if (isFocusable(node) || include?.(node)) {
134
+ if (isFocusable(node, { skipVisibilityCheck }) || include?.(node)) {
130
135
  elements[elements.length] = node;
131
136
  }
132
137
  }
@@ -147,7 +152,7 @@ function getFocusables(container = document.body, options = {}) {
147
152
  if (!(candidate instanceof Element)) {
148
153
  continue;
149
154
  }
150
- if (isFocusable(candidate)) {
155
+ if (isFocusable(candidate, { skipVisibilityCheck })) {
151
156
  elements[elements.length] = candidate;
152
157
  }
153
158
  }
@@ -155,11 +160,16 @@ function getFocusables(container = document.body, options = {}) {
155
160
  const unfiltered = normalizeRadioGroup(sortByTabIndex(elements));
156
161
  return filter ? unfiltered.filter(filter) : unfiltered;
157
162
  }
158
- function isFocusable(element) {
163
+ function isFocusable(element, options = {}) {
159
164
  if (!(element instanceof Element)) {
160
165
  console.warn("Invalid element");
161
166
  return false;
162
167
  }
168
+ let { skipVisibilityCheck = false } = options;
169
+ if (typeof skipVisibilityCheck !== "boolean") {
170
+ console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
171
+ skipVisibilityCheck = false;
172
+ }
163
173
  if (element.hasAttribute("hidden") || isInert(element)) {
164
174
  return false;
165
175
  }
@@ -172,7 +182,7 @@ function isFocusable(element) {
172
182
  if (isDisabledDeep(element)) {
173
183
  return false;
174
184
  }
175
- if (!element.checkVisibility({
185
+ if (!skipVisibilityCheck && !element.checkVisibility({
176
186
  contentVisibilityAuto: true,
177
187
  opacityProperty: true,
178
188
  visibilityProperty: true
@@ -457,7 +467,8 @@ var RovingTabIndex = class {
457
467
  ...this.#getFocusables(),
458
468
  ...getFocusables(this.#container, {
459
469
  composed: true,
460
- filter: this.#selectorFilter
470
+ filter: this.#selectorFilter,
471
+ skipVisibilityCheck: true
461
472
  })
462
473
  ]);
463
474
  for (const focusable of this.#focusables) {
@@ -523,7 +534,8 @@ var RovingTabIndex = class {
523
534
  return getFocusables(this.#container, {
524
535
  composed: true,
525
536
  filter: this.#selectorFilter,
526
- include: (element) => this.#focusables.has(element)
537
+ include: (element) => this.#focusables.has(element),
538
+ skipVisibilityCheck: true
527
539
  });
528
540
  }
529
541
  };
@@ -708,12 +720,7 @@ var Accordion = class _Accordion {
708
720
  return;
709
721
  }
710
722
  event.preventDefault();
711
- switch (key) {
712
- case "Enter":
713
- case " ":
714
- active.click();
715
- return;
716
- }
723
+ active.click();
717
724
  };
718
725
  #onContentBeforeMatch = (event) => {
719
726
  const content = event.currentTarget;
@@ -834,7 +841,7 @@ function waitAnimationFinish(animation) {
834
841
  * Accordion
835
842
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
836
843
  *
837
- * @version 1.3.2
844
+ * @version 1.3.3
838
845
  * @author Yusuke Kamiyamane
839
846
  * @license MIT
840
847
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -859,7 +866,7 @@ function waitAnimationFinish(animation) {
859
866
  * Lightweight roving tabindex utility with fully focus management.
860
867
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
861
868
  *
862
- * @version 1.3.0
869
+ * @version 1.3.1
863
870
  * @author Yusuke Kamiyamane
864
871
  * @license MIT
865
872
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -884,7 +891,7 @@ function waitAnimationFinish(animation) {
884
891
  * High-precision focus management utility with full composed tree support.
885
892
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
886
893
  *
887
- * @version 4.1.8
894
+ * @version 4.2.0
888
895
  * @author Yusuke Kamiyamane
889
896
  * @license MIT
890
897
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.3.2
5
+ * @version 1.3.3
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.3.2
5
+ * @version 1.3.3
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -103,7 +103,12 @@ function getFocusables(container = document.body, options = {}) {
103
103
  console.warn("Invalid container element. Fallback: <body> element.");
104
104
  container = document.body;
105
105
  }
106
- let { composed = false, filter, include } = options;
106
+ let {
107
+ composed = false,
108
+ filter,
109
+ include,
110
+ skipVisibilityCheck = false
111
+ } = options;
107
112
  if (typeof composed !== "boolean") {
108
113
  console.warn("Invalid composed option. Fallback: false.");
109
114
  composed = false;
@@ -124,7 +129,7 @@ function getFocusables(container = document.body, options = {}) {
124
129
  if (composed || include) {
125
130
  let traverse2 = function(node) {
126
131
  if (node instanceof Element) {
127
- if (isFocusable(node) || include?.(node)) {
132
+ if (isFocusable(node, { skipVisibilityCheck }) || include?.(node)) {
128
133
  elements[elements.length] = node;
129
134
  }
130
135
  }
@@ -145,7 +150,7 @@ function getFocusables(container = document.body, options = {}) {
145
150
  if (!(candidate instanceof Element)) {
146
151
  continue;
147
152
  }
148
- if (isFocusable(candidate)) {
153
+ if (isFocusable(candidate, { skipVisibilityCheck })) {
149
154
  elements[elements.length] = candidate;
150
155
  }
151
156
  }
@@ -153,11 +158,16 @@ function getFocusables(container = document.body, options = {}) {
153
158
  const unfiltered = normalizeRadioGroup(sortByTabIndex(elements));
154
159
  return filter ? unfiltered.filter(filter) : unfiltered;
155
160
  }
156
- function isFocusable(element) {
161
+ function isFocusable(element, options = {}) {
157
162
  if (!(element instanceof Element)) {
158
163
  console.warn("Invalid element");
159
164
  return false;
160
165
  }
166
+ let { skipVisibilityCheck = false } = options;
167
+ if (typeof skipVisibilityCheck !== "boolean") {
168
+ console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
169
+ skipVisibilityCheck = false;
170
+ }
161
171
  if (element.hasAttribute("hidden") || isInert(element)) {
162
172
  return false;
163
173
  }
@@ -170,7 +180,7 @@ function isFocusable(element) {
170
180
  if (isDisabledDeep(element)) {
171
181
  return false;
172
182
  }
173
- if (!element.checkVisibility({
183
+ if (!skipVisibilityCheck && !element.checkVisibility({
174
184
  contentVisibilityAuto: true,
175
185
  opacityProperty: true,
176
186
  visibilityProperty: true
@@ -455,7 +465,8 @@ var RovingTabIndex = class {
455
465
  ...this.#getFocusables(),
456
466
  ...getFocusables(this.#container, {
457
467
  composed: true,
458
- filter: this.#selectorFilter
468
+ filter: this.#selectorFilter,
469
+ skipVisibilityCheck: true
459
470
  })
460
471
  ]);
461
472
  for (const focusable of this.#focusables) {
@@ -521,7 +532,8 @@ var RovingTabIndex = class {
521
532
  return getFocusables(this.#container, {
522
533
  composed: true,
523
534
  filter: this.#selectorFilter,
524
- include: (element) => this.#focusables.has(element)
535
+ include: (element) => this.#focusables.has(element),
536
+ skipVisibilityCheck: true
525
537
  });
526
538
  }
527
539
  };
@@ -706,12 +718,7 @@ var Accordion = class _Accordion {
706
718
  return;
707
719
  }
708
720
  event.preventDefault();
709
- switch (key) {
710
- case "Enter":
711
- case " ":
712
- active.click();
713
- return;
714
- }
721
+ active.click();
715
722
  };
716
723
  #onContentBeforeMatch = (event) => {
717
724
  const content = event.currentTarget;
@@ -832,7 +839,7 @@ function waitAnimationFinish(animation) {
832
839
  * Accordion
833
840
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
834
841
  *
835
- * @version 1.3.2
842
+ * @version 1.3.3
836
843
  * @author Yusuke Kamiyamane
837
844
  * @license MIT
838
845
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -857,7 +864,7 @@ function waitAnimationFinish(animation) {
857
864
  * Lightweight roving tabindex utility with fully focus management.
858
865
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
859
866
  *
860
- * @version 1.3.0
867
+ * @version 1.3.1
861
868
  * @author Yusuke Kamiyamane
862
869
  * @license MIT
863
870
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -882,7 +889,7 @@ function waitAnimationFinish(animation) {
882
889
  * High-precision focus management utility with full composed tree support.
883
890
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
884
891
  *
885
- * @version 4.1.8
892
+ * @version 4.2.0
886
893
  * @author Yusuke Kamiyamane
887
894
  * @license MIT
888
895
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,7 +44,7 @@
44
44
  "homepage": "https://github.com/y14e/accordion#readme",
45
45
  "devDependencies": {
46
46
  "@y14e/attributes-utils": "^1.0.5",
47
- "@y14e/roving-tabindex": "^1.3.0",
47
+ "@y14e/roving-tabindex": "^1.3.1",
48
48
  "bun-types": "latest",
49
49
  "tsup": "^8.0.0",
50
50
  "typescript": "^5.6.0",