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