@y14e/tabs 2.0.2 → 2.0.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/dist/index.js CHANGED
@@ -1,578 +1,6 @@
1
- // node_modules/@y14e/button/dist/index.js
2
- function getActiveElement() {
3
- let current = document.activeElement;
4
- while (current?.shadowRoot?.activeElement) {
5
- current = current.shadowRoot.activeElement;
6
- }
7
- return current;
8
- }
9
- var Button = class {
10
- #element;
11
- #controller = null;
12
- #isDestroyed = false;
13
- constructor(element) {
14
- if (!(element instanceof HTMLElement)) {
15
- throw new TypeError("Invalid element");
16
- }
17
- if (element.hasAttribute("data-button-initialized")) {
18
- console.warn("Already initialized");
19
- return;
20
- }
21
- this.#element = element;
22
- this.#initialize();
23
- }
24
- destroy() {
25
- if (this.#isDestroyed) {
26
- return;
27
- }
28
- this.#isDestroyed = true;
29
- this.#controller?.abort();
30
- this.#controller = null;
31
- this.#element.removeAttribute("data-button-initialized");
32
- }
33
- #initialize() {
34
- this.#controller = new AbortController();
35
- this.#element.addEventListener("keydown", this.#onKeyDown, {
36
- signal: this.#controller.signal
37
- });
38
- this.#element.setAttribute("data-button-initialized", "");
39
- }
40
- #onKeyDown = (event) => {
41
- const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
42
- if (altKey || ctrlKey || metaKey || shiftKey) {
43
- return;
44
- }
45
- if (!["Enter", " "].includes(key)) {
46
- return;
47
- }
48
- const active = getActiveElement();
49
- if (!(active instanceof HTMLElement)) {
50
- return;
51
- }
52
- event.preventDefault();
53
- active.click();
54
- };
55
- };
56
-
57
- // node_modules/@y14e/roving-tabindex/dist/index.js
58
- var DEFAULT_PARSER = (value) => value.split(/\s+/);
59
- var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
60
- function addTokenToAttribute(element, attribute, token, options = {}) {
61
- const {
62
- caseInsensitive = false,
63
- parse = DEFAULT_PARSER,
64
- serialize = DEFAULT_SERIALIZER
65
- } = options;
66
- const value = element.getAttribute(attribute)?.trim();
67
- const tokens = value ? parse(value).filter(Boolean) : [];
68
- if (caseInsensitive) {
69
- const lower = token.toLowerCase();
70
- if (tokens.every((token2) => token2.toLowerCase() !== lower)) {
71
- tokens.push(token);
72
- element.setAttribute(attribute, serialize(tokens));
73
- }
74
- } else {
75
- const set = new Set(tokens);
76
- set.add(token);
77
- element.setAttribute(attribute, serialize([...set]));
78
- }
79
- }
80
- var snapshots = /* @__PURE__ */ new WeakMap();
81
- function restoreAttributes(elements) {
82
- for (const element of elements) {
83
- const snapshot = snapshots.get(element);
84
- if (!snapshot) {
85
- continue;
86
- }
87
- for (const [attribute, value] of snapshot.entries()) {
88
- value === null ? element.removeAttribute(attribute) : element.setAttribute(attribute, value);
89
- }
90
- snapshots.delete(element);
91
- }
92
- }
93
- function saveAttributes(elements, attributes) {
94
- elements.forEach((element) => {
95
- let snapshot = snapshots.get(element);
96
- if (!snapshot) {
97
- snapshot = /* @__PURE__ */ new Map();
98
- snapshots.set(element, snapshot);
99
- }
100
- attributes.forEach((attribute) => {
101
- snapshot.set(attribute, element.getAttribute(attribute));
102
- });
103
- });
104
- }
105
- var FOCUSABLE_SELECTOR = `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`;
106
- function getFocusables(container = document.body, options = {}) {
107
- if (!(container instanceof Element)) {
108
- console.warn("Invalid container element. Fallback: <body> element.");
109
- container = document.body;
110
- }
111
- let {
112
- composed = false,
113
- filter,
114
- include,
115
- skipNegativeTabIndexCheck = false,
116
- skipVisibilityCheck = false
117
- } = options;
118
- if (typeof composed !== "boolean") {
119
- console.warn("Invalid composed option. Fallback: false.");
120
- composed = false;
121
- }
122
- if (typeof filter !== "undefined" && typeof filter !== "function") {
123
- console.warn(
124
- "Invalid filter function. Fallback: no filter function (undefined)."
125
- );
126
- filter = void 0;
127
- }
128
- if (typeof include !== "undefined" && typeof include !== "function") {
129
- console.warn(
130
- "Invalid include function. Fallback: no include function (undefined)."
131
- );
132
- include = void 0;
133
- }
134
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
135
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
136
- skipNegativeTabIndexCheck = false;
137
- }
138
- if (typeof skipVisibilityCheck !== "boolean") {
139
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
140
- skipVisibilityCheck = false;
141
- }
142
- const elements = [];
143
- if (composed || include) {
144
- let traverse2 = function(node) {
145
- if (!(node instanceof Element)) {
146
- return;
147
- }
148
- if (isFocusable(node, { skipNegativeTabIndexCheck, skipVisibilityCheck }) || include?.(node)) {
149
- elements[elements.length] = node;
150
- }
151
- const children = getComposedChildren(node);
152
- for (let i = 0, l = children.length; i < l; i++) {
153
- const child = children[i];
154
- child && traverse2(child);
155
- }
156
- };
157
- traverse2(container);
158
- } else {
159
- const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
160
- for (let i = 0, l = candidates.length; i < l; i++) {
161
- const candidate = candidates[i];
162
- if (candidate && isFocusable(candidate, {
163
- skipNegativeTabIndexCheck,
164
- skipVisibilityCheck
165
- })) {
166
- elements[elements.length] = candidate;
167
- }
168
- }
169
- }
170
- const unfiltered = normalizeRadioGroup(sortByTabIndex(elements));
171
- return filter ? unfiltered.filter(filter) : unfiltered;
172
- }
173
- function isFocusable(element, options = {}) {
174
- if (!(element instanceof Element)) {
175
- console.warn("Invalid element");
176
- return false;
177
- }
178
- let { skipNegativeTabIndexCheck = false, skipVisibilityCheck = false } = options;
179
- if (typeof skipNegativeTabIndexCheck !== "boolean") {
180
- console.warn("Invalid skipNegativeTabIndexCheck option. Fallback: false.");
181
- skipNegativeTabIndexCheck = false;
182
- }
183
- if (typeof skipVisibilityCheck !== "boolean") {
184
- console.warn("Invalid skipVisibilityCheck option. Fallback: false.");
185
- skipVisibilityCheck = false;
186
- }
187
- if (element.hasAttribute("hidden") || isInert(element)) {
188
- return false;
189
- }
190
- if (!skipNegativeTabIndexCheck && getTabIndex(element) < 0) {
191
- return false;
192
- }
193
- if (!element.matches(
194
- skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR.replace(/(,\s*)?\[tabindex="-1"\]/g, "") : FOCUSABLE_SELECTOR
195
- )) {
196
- return false;
197
- }
198
- if (isDisabledDeep(element)) {
199
- return false;
200
- }
201
- if (!skipVisibilityCheck && !element.checkVisibility({
202
- contentVisibilityAuto: true,
203
- opacityProperty: true,
204
- visibilityProperty: true
205
- })) {
206
- return false;
207
- }
208
- return true;
209
- }
210
- function isDisabledDeep(element) {
211
- let current = element;
212
- while (current) {
213
- if (current instanceof ShadowRoot) {
214
- if (current.mode !== "open") {
215
- return false;
216
- }
217
- current = current.host;
218
- continue;
219
- }
220
- if (!(current instanceof Element)) {
221
- current = current.parentNode;
222
- continue;
223
- }
224
- if (current === element && isFormControl(current) && isDisabled(current)) {
225
- return true;
226
- }
227
- if (isInert(current)) {
228
- return true;
229
- }
230
- if (isFormControl(element) && current.tagName === "FIELDSET" && isDisabled(current)) {
231
- if (!current.querySelector(":scope > legend:first-of-type")?.contains(element)) {
232
- return true;
233
- }
234
- }
235
- current = current.parentNode;
236
- }
237
- return false;
238
- }
239
- function normalizeRadioGroup(elements) {
240
- let map = null;
241
- for (let i = 0, l = elements.length; i < l; i++) {
242
- const element = elements[i];
243
- if (!(element instanceof HTMLInputElement)) {
244
- continue;
245
- }
246
- if (!isUngroupedRadio(element)) {
247
- continue;
248
- }
249
- if (!map) {
250
- map = /* @__PURE__ */ new Map();
251
- }
252
- const key = `${element.form?.id ?? "no-form"}::${element.name}`;
253
- const group = map.get(key) ?? map.set(key, []).get(key);
254
- if (group) {
255
- group[group.length] = element;
256
- }
257
- }
258
- if (!map) {
259
- return elements;
260
- }
261
- const placeholder = /* @__PURE__ */ new Set();
262
- for (const group of map.values()) {
263
- placeholder.add(group.find((radio) => radio.checked) ?? group[0]);
264
- }
265
- return elements.filter(
266
- (element) => isUngroupedRadio(element) ? placeholder.has(element) : true
267
- );
268
- }
269
- function sortByTabIndex(elements) {
270
- const ordered = [];
271
- const natural = [];
272
- for (let i = 0, l = elements.length; i < l; i++) {
273
- const element = elements[i];
274
- if (element) {
275
- const target = getTabIndex(element) > 0 ? ordered : natural;
276
- target[target.length] = element;
277
- }
278
- }
279
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
280
- let count = 0;
281
- const sorted = new Array(ordered.length + natural.length);
282
- for (let i = 0, l = ordered.length; i < l; i++) {
283
- sorted[count++] = ordered[i];
284
- }
285
- for (let i = 0, l = natural.length; i < l; i++) {
286
- sorted[count++] = natural[i];
287
- }
288
- return sorted;
289
- }
290
- function getComposedChildren(node) {
291
- if (node instanceof ShadowRoot) {
292
- return getChildren(node);
293
- }
294
- if (!(node instanceof Element)) {
295
- return [];
296
- }
297
- if (node instanceof HTMLSlotElement) {
298
- const assigned = node.assignedElements({ flatten: true });
299
- if (assigned.length) {
300
- return assigned;
301
- }
302
- }
303
- if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
304
- return getChildren(node.shadowRoot);
305
- }
306
- return getChildren(node);
307
- }
308
- function focusElement(element) {
309
- "focus" in element && typeof element.focus === "function" && element.focus();
310
- }
311
- function getActiveElement2() {
312
- let current = document.activeElement;
313
- while (current?.shadowRoot?.activeElement) {
314
- current = current.shadowRoot.activeElement;
315
- }
316
- return current;
317
- }
318
- function getChildren(node) {
319
- const elements = [];
320
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
321
- elements[elements.length] = child;
322
- }
323
- return elements;
324
- }
325
- function getTabIndex(element) {
326
- return "tabIndex" in element ? Number(element.tabIndex) : 0;
327
- }
328
- function isDisabled(element) {
329
- return "disabled" in element && !!element.disabled;
330
- }
331
- function isFormControl(element) {
332
- const name = element.tagName;
333
- return name === "BUTTON" || name === "INPUT" || name === "SELECT" || name === "TEXTAREA";
334
- }
335
- function isInert(element) {
336
- return "inert" in element && !!element.inert;
337
- }
338
- function isUngroupedRadio(element) {
339
- return element instanceof HTMLInputElement && element.type === "radio" && !!element.name;
340
- }
341
- function createRovingTabIndex(container, options = {}) {
342
- if (!(container instanceof Element)) {
343
- console.warn("Invalid container element");
344
- return () => {
345
- };
346
- }
347
- const roving = new RovingTabIndex(container, options);
348
- return () => roving.destroy();
349
- }
350
- var RovingTabIndex = class {
351
- #container;
352
- #settings;
353
- #focusables = /* @__PURE__ */ new Set();
354
- #focusablesByFirstChar = /* @__PURE__ */ new Map();
355
- #selectorFilter;
356
- #controller = null;
357
- #isDestroyed = false;
358
- constructor(container, options = {}) {
359
- this.#container = container;
360
- let {
361
- direction,
362
- navigationOnly = false,
363
- noMemory = false,
364
- noStart = false,
365
- selector,
366
- typeahead = false,
367
- wrap = false
368
- } = options;
369
- if (typeof direction !== "undefined" && !["horizontal", "vertical"].includes(direction)) {
370
- console.warn("Invalid direction option. Fallback: both (undefined).");
371
- direction = void 0;
372
- }
373
- if (typeof navigationOnly !== "boolean") {
374
- console.warn("Invalid navigationOnly option. Fallback: false.");
375
- navigationOnly = false;
376
- }
377
- if (typeof noMemory !== "boolean") {
378
- console.warn("Invalid noMemory option. Fallback: false.");
379
- noMemory = false;
380
- }
381
- if (typeof noStart !== "boolean") {
382
- console.warn("Invalid noStart option. Fallback: false.");
383
- noStart = false;
384
- }
385
- if (typeof selector !== "undefined" && (typeof selector !== "string" || !selector.trim())) {
386
- console.warn(
387
- "Invalid selector. Fallback: all focusable elements (undefined)."
388
- );
389
- selector = void 0;
390
- }
391
- if (typeof typeahead !== "boolean") {
392
- console.warn("Invalid typeahead option. Fallback: false.");
393
- typeahead = false;
394
- }
395
- if (typeof wrap !== "boolean") {
396
- console.warn("Invalid wrap option. Fallback: false.");
397
- wrap = false;
398
- }
399
- this.#settings = {
400
- navigationOnly,
401
- noMemory,
402
- noStart,
403
- typeahead,
404
- wrap
405
- };
406
- direction && Object.assign(this.#settings, { direction });
407
- selector && Object.assign(this.#settings, { selector });
408
- this.#selectorFilter = this.#createSelectorFilter();
409
- this.#initialize();
410
- }
411
- destroy() {
412
- if (this.#isDestroyed) {
413
- return;
414
- }
415
- this.#isDestroyed = true;
416
- this.#controller?.abort();
417
- this.#controller = null;
418
- restoreAttributes([...this.#focusables]);
419
- this.#focusables.clear();
420
- this.#focusablesByFirstChar.clear();
421
- this.#container.removeAttribute("data-roving-tabindex-initialized");
422
- }
423
- #initialize() {
424
- this.#update(document.activeElement);
425
- this.#controller = new AbortController();
426
- const { signal } = this.#controller;
427
- document.addEventListener("focusin", this.#onFocusIn, {
428
- capture: true,
429
- signal
430
- });
431
- document.addEventListener("keydown", this.#onKeyDown, {
432
- capture: true,
433
- signal
434
- });
435
- this.#container.setAttribute("data-roving-tabindex-initialized", "");
436
- }
437
- #onFocusIn = (event) => {
438
- const { target } = event;
439
- if (!(target instanceof Element)) {
440
- return;
441
- }
442
- const isFocusable22 = this.#focusables.has(target);
443
- this.#settings.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
444
- };
445
- #onKeyDown = (event) => {
446
- if (!event.composedPath().includes(this.#container)) {
447
- return;
448
- }
449
- const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
450
- if (altKey || ctrlKey || metaKey || shiftKey) {
451
- return;
452
- }
453
- const { direction, typeahead, wrap } = this.#settings;
454
- const isBoth = !direction;
455
- const isHorizontal = direction === "horizontal";
456
- if (![
457
- "End",
458
- "Home",
459
- ...isBoth ? ["ArrowLeft", "ArrowUp"] : [`Arrow${isHorizontal ? "Left" : "Up"}`],
460
- ...isBoth ? ["ArrowRight", "ArrowDown"] : [`Arrow${isHorizontal ? "Right" : "Down"}`]
461
- ].includes(key)) {
462
- if (!typeahead || !/^\S$/i.test(key) || !this.#focusablesByFirstChar.has(key.toUpperCase())) {
463
- return;
464
- }
465
- }
466
- const active = getActiveElement2();
467
- if (!(active instanceof HTMLElement)) {
468
- return;
469
- }
470
- const current = this.#getFocusables();
471
- if (!current.includes(active)) {
472
- return;
473
- }
474
- event.preventDefault();
475
- const currentIndex = current.indexOf(active);
476
- let newIndex;
477
- let target = current;
478
- switch (key) {
479
- case "End":
480
- newIndex = -1;
481
- break;
482
- case "Home":
483
- newIndex = 0;
484
- break;
485
- case "ArrowLeft":
486
- case "ArrowUp": {
487
- const rawIndex = currentIndex - 1;
488
- newIndex = wrap ? rawIndex : Math.max(rawIndex, 0);
489
- break;
490
- }
491
- case "ArrowRight":
492
- case "ArrowDown": {
493
- const rawIndex = currentIndex + 1;
494
- newIndex = wrap ? rawIndex % current.length : Math.min(rawIndex, current.length - 1);
495
- break;
496
- }
497
- default: {
498
- target = this.#focusablesByFirstChar.get(key.toUpperCase()) ?? [];
499
- const foundIndex = target.findIndex(
500
- (focusable2) => current.indexOf(focusable2) > currentIndex
501
- );
502
- newIndex = foundIndex >= 0 ? foundIndex : 0;
503
- }
504
- }
505
- const focusable = target.at(newIndex);
506
- focusable && focusElement(focusable);
507
- };
508
- #update(active) {
509
- const current = new Set(this.#getFocusables());
510
- for (const focusable of this.#focusables) {
511
- if (!current.has(focusable)) {
512
- focusable.isConnected && restoreAttributes([focusable]);
513
- this.#focusables.delete(focusable);
514
- this.#focusablesByFirstChar.forEach((focusables) => {
515
- const index = focusables.indexOf(focusable);
516
- index >= 0 && focusables.splice(index, 1);
517
- });
518
- }
519
- }
520
- const { navigationOnly, noStart, typeahead } = this.#settings;
521
- for (const focusable of current) {
522
- if (this.#focusables.has(focusable)) {
523
- continue;
524
- }
525
- this.#focusables.add(focusable);
526
- if (!navigationOnly) {
527
- saveAttributes([focusable], ["tabindex"]);
528
- focusable.setAttribute("tabindex", "-1");
529
- }
530
- if (!typeahead) {
531
- continue;
532
- }
533
- const char = focusable.textContent?.trim()?.at(0)?.toUpperCase();
534
- const value = focusable.ariaKeyShortcuts?.trim();
535
- const keys = new Set(
536
- value ? value.split(/\s+/).filter((key) => /^\S$/i.test(key)).map((key) => key.toUpperCase()) : []
537
- );
538
- if (char) {
539
- keys.add(char);
540
- saveAttributes([focusable], ["aria-keyshortcuts"]);
541
- addTokenToAttribute(focusable, "aria-keyshortcuts", char, {
542
- caseInsensitive: true
543
- });
544
- }
545
- keys.forEach((key) => {
546
- const focusables = this.#focusablesByFirstChar.get(key) ?? [];
547
- focusables.push(focusable);
548
- this.#focusablesByFirstChar.set(key, focusables);
549
- });
550
- }
551
- if (!navigationOnly) {
552
- if (active && this.#focusables.has(active)) {
553
- this.#focusables.forEach((focusable) => {
554
- focusable.setAttribute("tabindex", focusable === active ? "0" : "-1");
555
- });
556
- } else {
557
- [...this.#focusables].forEach((focusable, i) => {
558
- focusable.setAttribute("tabindex", i || noStart ? "-1" : "0");
559
- });
560
- }
561
- }
562
- }
563
- #createSelectorFilter() {
564
- const { selector } = this.#settings;
565
- return (element) => !selector || [...this.#container.querySelectorAll(selector)].includes(element);
566
- }
567
- #getFocusables() {
568
- return getFocusables(this.#container, {
569
- composed: true,
570
- filter: this.#selectorFilter,
571
- skipNegativeTabIndexCheck: !this.#settings.navigationOnly,
572
- skipVisibilityCheck: true
573
- });
574
- }
575
- };
1
+ import { restoreAttributes, saveAttributes, addTokenToAttribute } from '@y14e/attributes-utils';
2
+ import Button from '@y14e/button';
3
+ import { createRovingTabIndex } from '@y14e/roving-tabindex';
576
4
 
577
5
  // src/index.ts
578
6
  var Tabs = class _Tabs {
@@ -682,7 +110,7 @@ var Tabs = class _Tabs {
682
110
  if (!panel) {
683
111
  return;
684
112
  }
685
- const binding = createBinding(tabsByIndex, panel);
113
+ const binding = this.#createBinding(tabsByIndex, panel);
686
114
  this.#bindings.set(tab, binding);
687
115
  i < length && this.#bindings.set(panel, binding);
688
116
  });
@@ -729,14 +157,14 @@ var Tabs = class _Tabs {
729
157
  }
730
158
  style2.setProperty("inline-size", "100%");
731
159
  style2.setProperty("position", "absolute");
732
- p === panel && !hasFocusable(p) ? p.setAttribute("tabindex", "0") : p.removeAttribute("tabindex");
160
+ p === panel && !this.#hasFocusable(p) ? p.setAttribute("tabindex", "0") : p.removeAttribute("tabindex");
733
161
  });
734
162
  this.#panelElements.forEach((p, i) => {
735
163
  if (p === panel) {
736
164
  p.removeAttribute("hidden");
737
165
  } else {
738
166
  const tab2 = this.#tabElements[i];
739
- tab2 && p.setAttribute("hidden", isFocusable2(tab2) ? "until-found" : "");
167
+ tab2 && p.setAttribute("hidden", this.#isFocusable(tab2) ? "until-found" : "");
740
168
  }
741
169
  });
742
170
  this.#animation?.cancel();
@@ -769,7 +197,7 @@ var Tabs = class _Tabs {
769
197
  "finish",
770
198
  () => {
771
199
  if (this.#animation === animation) {
772
- this.#onAnimationFinish();
200
+ this.#onContentAnimationFinish();
773
201
  cleanup();
774
202
  }
775
203
  },
@@ -846,7 +274,7 @@ var Tabs = class _Tabs {
846
274
  this.#panelElements.forEach((panel) => {
847
275
  this.#bindings.get(panel)?.animation?.cancel();
848
276
  });
849
- this.#onAnimationFinish();
277
+ this.#onContentAnimationFinish();
850
278
  this.#animationController?.abort();
851
279
  this.#animationController = null;
852
280
  restoreAttributes([
@@ -904,7 +332,7 @@ var Tabs = class _Tabs {
904
332
  tab.id ||= `tabs-tab-${id}`;
905
333
  }
906
334
  tab.setAttribute("role", "tab");
907
- !isFocusable2(tab) && tab.style.setProperty("pointer-events", "none");
335
+ !this.#isFocusable(tab) && tab.style.setProperty("pointer-events", "none");
908
336
  addTokenToAttribute(panel, "aria-labelledby", tab.id);
909
337
  tab.addEventListener("click", this.#onTabClick, { signal });
910
338
  tab.addEventListener("focus", this.#onTabFocus, { signal });
@@ -919,7 +347,7 @@ var Tabs = class _Tabs {
919
347
  });
920
348
  this.#panelElements.forEach((panel) => {
921
349
  panel.setAttribute("role", "tabpanel");
922
- !panel.hasAttribute("hidden") && !hasFocusable(panel) && panel.setAttribute("tabindex", "0");
350
+ !panel.hasAttribute("hidden") && !this.#hasFocusable(panel) && panel.setAttribute("tabindex", "0");
923
351
  panel.addEventListener("beforematch", this.#onPanelBeforeMatch, {
924
352
  signal
925
353
  });
@@ -955,6 +383,23 @@ var Tabs = class _Tabs {
955
383
  !this.#settings.manual && tab.click();
956
384
  this.#isAvoidedTab(tab) && tab.blur();
957
385
  };
386
+ #onContentAnimationFinish() {
387
+ ["block-size", "overflow", "position"].forEach((name) => {
388
+ this.#contentElement?.style.removeProperty(name);
389
+ });
390
+ this.#panelElements.forEach((panel) => {
391
+ [
392
+ "content-visibility",
393
+ "display",
394
+ "inline-size",
395
+ "opacity",
396
+ "position"
397
+ ].forEach((name) => {
398
+ panel.style.removeProperty(name);
399
+ });
400
+ });
401
+ this.#rootElement.removeAttribute("data-tabs-animating");
402
+ }
958
403
  #onPanelBeforeMatch = (event) => {
959
404
  const panel = event.currentTarget;
960
405
  if (!(panel instanceof HTMLElement)) {
@@ -963,6 +408,16 @@ var Tabs = class _Tabs {
963
408
  const tab = this.#bindings.get(panel)?.tabs[0];
964
409
  tab && this.activate(tab, true);
965
410
  };
411
+ #createBinding(tabs, panel) {
412
+ return { tabs, panel, animation: null };
413
+ }
414
+ #hasFocusable(container) {
415
+ return !![
416
+ ...container.querySelectorAll(
417
+ `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`
418
+ )
419
+ ].filter((element) => element.checkVisibility()).length;
420
+ }
966
421
  #isAvoidedTab(tab) {
967
422
  const binding = this.#bindings.get(tab);
968
423
  if (!binding) {
@@ -970,6 +425,9 @@ var Tabs = class _Tabs {
970
425
  }
971
426
  return this.#settings.avoidDuplicates && binding.tabs.indexOf(tab) > 0;
972
427
  }
428
+ #isFocusable(element) {
429
+ return !element.hasAttribute("disabled");
430
+ }
973
431
  #mergeOptions(target, source) {
974
432
  return {
975
433
  ...target,
@@ -990,23 +448,6 @@ var Tabs = class _Tabs {
990
448
  }
991
449
  };
992
450
  }
993
- #onAnimationFinish() {
994
- ["block-size", "overflow", "position"].forEach((name) => {
995
- this.#contentElement?.style.removeProperty(name);
996
- });
997
- this.#panelElements.forEach((panel) => {
998
- [
999
- "content-visibility",
1000
- "display",
1001
- "inline-size",
1002
- "opacity",
1003
- "position"
1004
- ].forEach((name) => {
1005
- panel.style.removeProperty(name);
1006
- });
1007
- });
1008
- this.#rootElement.removeAttribute("data-tabs-animating");
1009
- }
1010
451
  };
1011
452
  var TabsIndicator = class {
1012
453
  #rootElement;
@@ -1076,95 +517,15 @@ var TabsIndicator = class {
1076
517
  this.#listElement = null;
1077
518
  }
1078
519
  };
1079
- function createBinding(tabs, panel) {
1080
- return { tabs, panel, animation: null };
1081
- }
1082
- function hasFocusable(container) {
1083
- return !![
1084
- ...container.querySelectorAll(
1085
- `:is(a[href], area[href], button, embed, iframe, input:not([type="hidden" i]), object, select, details > summary:first-of-type, textarea, [contenteditable]:not([contenteditable="false" i]), [controls], [tabindex]):not(:disabled, [hidden], [inert], [tabindex="-1"])`
1086
- )
1087
- ].filter((element) => element.checkVisibility()).length;
1088
- }
1089
- function isFocusable2(element) {
1090
- return !element.hasAttribute("disabled");
1091
- }
1092
520
  /**
1093
521
  * Tabs
1094
522
  * WAI-ARIA compliant tabs pattern implementation in TypeScript.
1095
523
  *
1096
- * @version 2.0.2
524
+ * @version 2.0.4
1097
525
  * @author Yusuke Kamiyamane
1098
526
  * @license MIT
1099
527
  * @copyright Copyright (c) Yusuke Kamiyamane
1100
528
  * @see {@link https://github.com/y14e/tabs}
1101
529
  */
1102
- /*! Bundled license information:
1103
-
1104
- @y14e/button/dist/index.js:
1105
- (**
1106
- * Button
1107
- *
1108
- * @version 1.0.3
1109
- * @author Yusuke Kamiyamane
1110
- * @license MIT
1111
- * @copyright Copyright (c) Yusuke Kamiyamane
1112
- * @see {@link https://github.com/y14e/button}
1113
- *)
1114
- (*! Bundled license information:
1115
-
1116
- power-focusable/dist/index.js:
1117
- (**
1118
- * Power Focusable
1119
- * High-precision focus management utility with full composed tree support.
1120
- * Handles complex focus rules including tabindex ordering, radio groups, inert.
1121
- *
1122
- * @version 4.3.3
1123
- * @author Yusuke Kamiyamane
1124
- * @license MIT
1125
- * @copyright Copyright (c) Yusuke Kamiyamane
1126
- * @see {@link https://github.com/y14e/power-focusable}
1127
- *)
1128
- *)
1129
-
1130
- @y14e/roving-tabindex/dist/index.js:
1131
- (**
1132
- * Roving Tabindex
1133
- * Lightweight roving tabindex utility with fully focus management.
1134
- * Designed for accessible menus, tabs, toolbars, and composite widgets.
1135
- *
1136
- * @version 3.0.8
1137
- * @author Yusuke Kamiyamane
1138
- * @license MIT
1139
- * @copyright Copyright (c) Yusuke Kamiyamane
1140
- * @see {@link https://github.com/y14e/roving-tabindex}
1141
- *)
1142
- (*! Bundled license information:
1143
-
1144
- @y14e/attributes-utils/dist/index.js:
1145
- (**
1146
- * Attributes Utils
1147
- *
1148
- * @version 1.1.2
1149
- * @author Yusuke Kamiyamane
1150
- * @license MIT
1151
- * @copyright Copyright (c) Yusuke Kamiyamane
1152
- * @see {@link https://github.com/y14e/attributes-utils}
1153
- *)
1154
-
1155
- power-focusable/dist/index.js:
1156
- (**
1157
- * Power Focusable
1158
- * High-precision focus management utility with full composed tree support.
1159
- * Handles complex focus rules including tabindex ordering, radio groups, inert.
1160
- *
1161
- * @version 4.3.3
1162
- * @author Yusuke Kamiyamane
1163
- * @license MIT
1164
- * @copyright Copyright (c) Yusuke Kamiyamane
1165
- * @see {@link https://github.com/y14e/power-focusable}
1166
- *)
1167
- *)
1168
- */
1169
530
 
1170
531
  export { Tabs as default };