@zag-js/tabs 0.1.11 → 0.1.12
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 +176 -173
- package/dist/index.mjs +176 -173
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -382,199 +382,202 @@ function connect(state, send, normalize) {
|
|
|
382
382
|
var import_core = require("@zag-js/core");
|
|
383
383
|
var { not } = import_core.guards;
|
|
384
384
|
function machine(ctx) {
|
|
385
|
-
return (0, import_core.createMachine)(
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
computed: {
|
|
402
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
403
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
404
|
-
},
|
|
405
|
-
created: ["setPrevSelectedTabs"],
|
|
406
|
-
watch: {
|
|
407
|
-
focusedValue: "invokeOnFocus",
|
|
408
|
-
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
409
|
-
dir: ["clearMeasured", "setIndicatorRect"]
|
|
410
|
-
},
|
|
411
|
-
on: {
|
|
412
|
-
SET_VALUE: {
|
|
413
|
-
actions: "setValue"
|
|
385
|
+
return (0, import_core.createMachine)(
|
|
386
|
+
{
|
|
387
|
+
initial: "unknown",
|
|
388
|
+
context: {
|
|
389
|
+
dir: "ltr",
|
|
390
|
+
orientation: "horizontal",
|
|
391
|
+
activationMode: "automatic",
|
|
392
|
+
value: null,
|
|
393
|
+
focusedValue: null,
|
|
394
|
+
previousValues: [],
|
|
395
|
+
indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
|
|
396
|
+
hasMeasuredRect: false,
|
|
397
|
+
isIndicatorRendered: false,
|
|
398
|
+
loop: true,
|
|
399
|
+
messages: {},
|
|
400
|
+
...ctx
|
|
414
401
|
},
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
},
|
|
419
|
-
states: {
|
|
420
|
-
unknown: {
|
|
421
|
-
on: {
|
|
422
|
-
SETUP: {
|
|
423
|
-
target: "idle",
|
|
424
|
-
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
425
|
-
}
|
|
426
|
-
}
|
|
402
|
+
computed: {
|
|
403
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
404
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
427
405
|
},
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
406
|
+
created: ["setPrevSelectedTabs"],
|
|
407
|
+
watch: {
|
|
408
|
+
focusedValue: "invokeOnFocus",
|
|
409
|
+
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
410
|
+
dir: ["clearMeasured", "setIndicatorRect"]
|
|
411
|
+
},
|
|
412
|
+
on: {
|
|
413
|
+
SET_VALUE: {
|
|
414
|
+
actions: "setValue"
|
|
415
|
+
},
|
|
416
|
+
DELETE: {
|
|
417
|
+
actions: "deleteValue"
|
|
439
418
|
}
|
|
440
419
|
},
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
actions: "focusNextTab"
|
|
454
|
-
},
|
|
455
|
-
ARROW_UP: {
|
|
456
|
-
guard: "isVertical",
|
|
457
|
-
actions: "focusPrevTab"
|
|
458
|
-
},
|
|
459
|
-
ARROW_DOWN: {
|
|
460
|
-
guard: "isVertical",
|
|
461
|
-
actions: "focusNextTab"
|
|
462
|
-
},
|
|
463
|
-
HOME: {
|
|
464
|
-
actions: "focusFirstTab"
|
|
465
|
-
},
|
|
466
|
-
END: {
|
|
467
|
-
actions: "focusLastTab"
|
|
468
|
-
},
|
|
469
|
-
ENTER: {
|
|
470
|
-
guard: not("selectOnFocus"),
|
|
471
|
-
actions: "setValue"
|
|
472
|
-
},
|
|
473
|
-
TAB_FOCUS: [
|
|
474
|
-
{
|
|
420
|
+
states: {
|
|
421
|
+
unknown: {
|
|
422
|
+
on: {
|
|
423
|
+
SETUP: {
|
|
424
|
+
target: "idle",
|
|
425
|
+
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
idle: {
|
|
430
|
+
on: {
|
|
431
|
+
TAB_FOCUS: {
|
|
475
432
|
guard: "selectOnFocus",
|
|
433
|
+
target: "focused",
|
|
434
|
+
actions: ["setFocusedValue", "setValue"]
|
|
435
|
+
},
|
|
436
|
+
TAB_CLICK: {
|
|
437
|
+
target: "focused",
|
|
476
438
|
actions: ["setFocusedValue", "setValue"]
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
focused: {
|
|
443
|
+
on: {
|
|
444
|
+
TAB_CLICK: {
|
|
445
|
+
target: "focused",
|
|
446
|
+
actions: ["setFocusedValue", "setValue"]
|
|
447
|
+
},
|
|
448
|
+
ARROW_LEFT: {
|
|
449
|
+
guard: "isHorizontal",
|
|
450
|
+
actions: "focusPrevTab"
|
|
477
451
|
},
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
452
|
+
ARROW_RIGHT: {
|
|
453
|
+
guard: "isHorizontal",
|
|
454
|
+
actions: "focusNextTab"
|
|
455
|
+
},
|
|
456
|
+
ARROW_UP: {
|
|
457
|
+
guard: "isVertical",
|
|
458
|
+
actions: "focusPrevTab"
|
|
459
|
+
},
|
|
460
|
+
ARROW_DOWN: {
|
|
461
|
+
guard: "isVertical",
|
|
462
|
+
actions: "focusNextTab"
|
|
463
|
+
},
|
|
464
|
+
HOME: {
|
|
465
|
+
actions: "focusFirstTab"
|
|
466
|
+
},
|
|
467
|
+
END: {
|
|
468
|
+
actions: "focusLastTab"
|
|
469
|
+
},
|
|
470
|
+
ENTER: {
|
|
471
|
+
guard: not("selectOnFocus"),
|
|
472
|
+
actions: "setValue"
|
|
473
|
+
},
|
|
474
|
+
TAB_FOCUS: [
|
|
475
|
+
{
|
|
476
|
+
guard: "selectOnFocus",
|
|
477
|
+
actions: ["setFocusedValue", "setValue"]
|
|
478
|
+
},
|
|
479
|
+
{ actions: "setFocusedValue" }
|
|
480
|
+
],
|
|
481
|
+
TAB_BLUR: {
|
|
482
|
+
target: "idle",
|
|
483
|
+
actions: "clearFocusedValue"
|
|
484
|
+
}
|
|
483
485
|
}
|
|
484
486
|
}
|
|
485
487
|
}
|
|
486
|
-
}
|
|
487
|
-
}, {
|
|
488
|
-
guards: {
|
|
489
|
-
isVertical: (ctx2) => ctx2.isVertical,
|
|
490
|
-
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
491
|
-
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
492
488
|
},
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
ctx2
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
ctx2.focusedValue = null;
|
|
499
|
-
},
|
|
500
|
-
setValue(ctx2, evt) {
|
|
501
|
-
ctx2.value = evt.value;
|
|
489
|
+
{
|
|
490
|
+
guards: {
|
|
491
|
+
isVertical: (ctx2) => ctx2.isVertical,
|
|
492
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
493
|
+
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
502
494
|
},
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
raf(() => {
|
|
495
|
+
actions: {
|
|
496
|
+
setFocusedValue(ctx2, evt) {
|
|
497
|
+
ctx2.focusedValue = evt.value;
|
|
498
|
+
},
|
|
499
|
+
clearFocusedValue(ctx2) {
|
|
500
|
+
ctx2.focusedValue = null;
|
|
501
|
+
},
|
|
502
|
+
setValue(ctx2, evt) {
|
|
503
|
+
ctx2.value = evt.value;
|
|
504
|
+
},
|
|
505
|
+
invokeOnDelete(ctx2, evt) {
|
|
515
506
|
var _a;
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
nextTick(() => {
|
|
533
|
-
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
507
|
+
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
508
|
+
},
|
|
509
|
+
focusFirstTab(ctx2) {
|
|
510
|
+
raf(() => {
|
|
511
|
+
var _a;
|
|
512
|
+
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
focusLastTab(ctx2) {
|
|
516
|
+
raf(() => {
|
|
517
|
+
var _a;
|
|
518
|
+
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
focusNextTab(ctx2) {
|
|
522
|
+
if (!ctx2.focusedValue)
|
|
534
523
|
return;
|
|
535
|
-
|
|
536
|
-
|
|
524
|
+
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
525
|
+
raf(() => next == null ? void 0 : next.focus());
|
|
526
|
+
},
|
|
527
|
+
focusPrevTab(ctx2) {
|
|
528
|
+
if (!ctx2.focusedValue)
|
|
537
529
|
return;
|
|
530
|
+
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
531
|
+
raf(() => prev == null ? void 0 : prev.focus());
|
|
532
|
+
},
|
|
533
|
+
setIndicatorRect(ctx2) {
|
|
538
534
|
nextTick(() => {
|
|
539
|
-
ctx2.
|
|
535
|
+
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
536
|
+
return;
|
|
537
|
+
ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
|
|
538
|
+
if (ctx2.hasMeasuredRect)
|
|
539
|
+
return;
|
|
540
|
+
nextTick(() => {
|
|
541
|
+
ctx2.hasMeasuredRect = true;
|
|
542
|
+
});
|
|
540
543
|
});
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
561
|
-
}
|
|
562
|
-
},
|
|
563
|
-
setContentTabIndex(ctx2) {
|
|
564
|
-
raf(() => {
|
|
565
|
-
const panel = dom.getActiveContentEl(ctx2);
|
|
566
|
-
if (!panel)
|
|
567
|
-
return;
|
|
568
|
-
const focusables = getFocusables(panel);
|
|
569
|
-
if (focusables.length > 0) {
|
|
570
|
-
panel.removeAttribute("tabindex");
|
|
571
|
-
} else {
|
|
572
|
-
panel.setAttribute("tabindex", "0");
|
|
544
|
+
},
|
|
545
|
+
checkRenderedElements(ctx2) {
|
|
546
|
+
ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
|
|
547
|
+
},
|
|
548
|
+
clearMeasured(ctx2) {
|
|
549
|
+
ctx2.hasMeasuredRect = false;
|
|
550
|
+
},
|
|
551
|
+
invokeOnChange(ctx2) {
|
|
552
|
+
var _a;
|
|
553
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
554
|
+
},
|
|
555
|
+
invokeOnFocus(ctx2) {
|
|
556
|
+
var _a;
|
|
557
|
+
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
558
|
+
},
|
|
559
|
+
setPrevSelectedTabs(ctx2) {
|
|
560
|
+
if (ctx2.value != null) {
|
|
561
|
+
const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
|
|
562
|
+
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
573
563
|
}
|
|
574
|
-
}
|
|
564
|
+
},
|
|
565
|
+
setContentTabIndex(ctx2) {
|
|
566
|
+
raf(() => {
|
|
567
|
+
const panel = dom.getActiveContentEl(ctx2);
|
|
568
|
+
if (!panel)
|
|
569
|
+
return;
|
|
570
|
+
const focusables = getFocusables(panel);
|
|
571
|
+
if (focusables.length > 0) {
|
|
572
|
+
panel.removeAttribute("tabindex");
|
|
573
|
+
} else {
|
|
574
|
+
panel.setAttribute("tabindex", "0");
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
575
578
|
}
|
|
576
579
|
}
|
|
577
|
-
|
|
580
|
+
);
|
|
578
581
|
}
|
|
579
582
|
// Annotate the CommonJS export names for ESM import in node:
|
|
580
583
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -355,199 +355,202 @@ function connect(state, send, normalize) {
|
|
|
355
355
|
import { createMachine, guards } from "@zag-js/core";
|
|
356
356
|
var { not } = guards;
|
|
357
357
|
function machine(ctx) {
|
|
358
|
-
return createMachine(
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
computed: {
|
|
375
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
376
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
377
|
-
},
|
|
378
|
-
created: ["setPrevSelectedTabs"],
|
|
379
|
-
watch: {
|
|
380
|
-
focusedValue: "invokeOnFocus",
|
|
381
|
-
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
382
|
-
dir: ["clearMeasured", "setIndicatorRect"]
|
|
383
|
-
},
|
|
384
|
-
on: {
|
|
385
|
-
SET_VALUE: {
|
|
386
|
-
actions: "setValue"
|
|
358
|
+
return createMachine(
|
|
359
|
+
{
|
|
360
|
+
initial: "unknown",
|
|
361
|
+
context: {
|
|
362
|
+
dir: "ltr",
|
|
363
|
+
orientation: "horizontal",
|
|
364
|
+
activationMode: "automatic",
|
|
365
|
+
value: null,
|
|
366
|
+
focusedValue: null,
|
|
367
|
+
previousValues: [],
|
|
368
|
+
indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
|
|
369
|
+
hasMeasuredRect: false,
|
|
370
|
+
isIndicatorRendered: false,
|
|
371
|
+
loop: true,
|
|
372
|
+
messages: {},
|
|
373
|
+
...ctx
|
|
387
374
|
},
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
},
|
|
392
|
-
states: {
|
|
393
|
-
unknown: {
|
|
394
|
-
on: {
|
|
395
|
-
SETUP: {
|
|
396
|
-
target: "idle",
|
|
397
|
-
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
398
|
-
}
|
|
399
|
-
}
|
|
375
|
+
computed: {
|
|
376
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
377
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
400
378
|
},
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
379
|
+
created: ["setPrevSelectedTabs"],
|
|
380
|
+
watch: {
|
|
381
|
+
focusedValue: "invokeOnFocus",
|
|
382
|
+
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
383
|
+
dir: ["clearMeasured", "setIndicatorRect"]
|
|
384
|
+
},
|
|
385
|
+
on: {
|
|
386
|
+
SET_VALUE: {
|
|
387
|
+
actions: "setValue"
|
|
388
|
+
},
|
|
389
|
+
DELETE: {
|
|
390
|
+
actions: "deleteValue"
|
|
412
391
|
}
|
|
413
392
|
},
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
actions: "focusNextTab"
|
|
427
|
-
},
|
|
428
|
-
ARROW_UP: {
|
|
429
|
-
guard: "isVertical",
|
|
430
|
-
actions: "focusPrevTab"
|
|
431
|
-
},
|
|
432
|
-
ARROW_DOWN: {
|
|
433
|
-
guard: "isVertical",
|
|
434
|
-
actions: "focusNextTab"
|
|
435
|
-
},
|
|
436
|
-
HOME: {
|
|
437
|
-
actions: "focusFirstTab"
|
|
438
|
-
},
|
|
439
|
-
END: {
|
|
440
|
-
actions: "focusLastTab"
|
|
441
|
-
},
|
|
442
|
-
ENTER: {
|
|
443
|
-
guard: not("selectOnFocus"),
|
|
444
|
-
actions: "setValue"
|
|
445
|
-
},
|
|
446
|
-
TAB_FOCUS: [
|
|
447
|
-
{
|
|
393
|
+
states: {
|
|
394
|
+
unknown: {
|
|
395
|
+
on: {
|
|
396
|
+
SETUP: {
|
|
397
|
+
target: "idle",
|
|
398
|
+
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
idle: {
|
|
403
|
+
on: {
|
|
404
|
+
TAB_FOCUS: {
|
|
448
405
|
guard: "selectOnFocus",
|
|
406
|
+
target: "focused",
|
|
407
|
+
actions: ["setFocusedValue", "setValue"]
|
|
408
|
+
},
|
|
409
|
+
TAB_CLICK: {
|
|
410
|
+
target: "focused",
|
|
449
411
|
actions: ["setFocusedValue", "setValue"]
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
focused: {
|
|
416
|
+
on: {
|
|
417
|
+
TAB_CLICK: {
|
|
418
|
+
target: "focused",
|
|
419
|
+
actions: ["setFocusedValue", "setValue"]
|
|
420
|
+
},
|
|
421
|
+
ARROW_LEFT: {
|
|
422
|
+
guard: "isHorizontal",
|
|
423
|
+
actions: "focusPrevTab"
|
|
450
424
|
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
425
|
+
ARROW_RIGHT: {
|
|
426
|
+
guard: "isHorizontal",
|
|
427
|
+
actions: "focusNextTab"
|
|
428
|
+
},
|
|
429
|
+
ARROW_UP: {
|
|
430
|
+
guard: "isVertical",
|
|
431
|
+
actions: "focusPrevTab"
|
|
432
|
+
},
|
|
433
|
+
ARROW_DOWN: {
|
|
434
|
+
guard: "isVertical",
|
|
435
|
+
actions: "focusNextTab"
|
|
436
|
+
},
|
|
437
|
+
HOME: {
|
|
438
|
+
actions: "focusFirstTab"
|
|
439
|
+
},
|
|
440
|
+
END: {
|
|
441
|
+
actions: "focusLastTab"
|
|
442
|
+
},
|
|
443
|
+
ENTER: {
|
|
444
|
+
guard: not("selectOnFocus"),
|
|
445
|
+
actions: "setValue"
|
|
446
|
+
},
|
|
447
|
+
TAB_FOCUS: [
|
|
448
|
+
{
|
|
449
|
+
guard: "selectOnFocus",
|
|
450
|
+
actions: ["setFocusedValue", "setValue"]
|
|
451
|
+
},
|
|
452
|
+
{ actions: "setFocusedValue" }
|
|
453
|
+
],
|
|
454
|
+
TAB_BLUR: {
|
|
455
|
+
target: "idle",
|
|
456
|
+
actions: "clearFocusedValue"
|
|
457
|
+
}
|
|
456
458
|
}
|
|
457
459
|
}
|
|
458
460
|
}
|
|
459
|
-
}
|
|
460
|
-
}, {
|
|
461
|
-
guards: {
|
|
462
|
-
isVertical: (ctx2) => ctx2.isVertical,
|
|
463
|
-
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
464
|
-
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
465
461
|
},
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
ctx2
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
ctx2.focusedValue = null;
|
|
472
|
-
},
|
|
473
|
-
setValue(ctx2, evt) {
|
|
474
|
-
ctx2.value = evt.value;
|
|
462
|
+
{
|
|
463
|
+
guards: {
|
|
464
|
+
isVertical: (ctx2) => ctx2.isVertical,
|
|
465
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
466
|
+
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
475
467
|
},
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
raf(() => {
|
|
468
|
+
actions: {
|
|
469
|
+
setFocusedValue(ctx2, evt) {
|
|
470
|
+
ctx2.focusedValue = evt.value;
|
|
471
|
+
},
|
|
472
|
+
clearFocusedValue(ctx2) {
|
|
473
|
+
ctx2.focusedValue = null;
|
|
474
|
+
},
|
|
475
|
+
setValue(ctx2, evt) {
|
|
476
|
+
ctx2.value = evt.value;
|
|
477
|
+
},
|
|
478
|
+
invokeOnDelete(ctx2, evt) {
|
|
488
479
|
var _a;
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
nextTick(() => {
|
|
506
|
-
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
480
|
+
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
481
|
+
},
|
|
482
|
+
focusFirstTab(ctx2) {
|
|
483
|
+
raf(() => {
|
|
484
|
+
var _a;
|
|
485
|
+
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
focusLastTab(ctx2) {
|
|
489
|
+
raf(() => {
|
|
490
|
+
var _a;
|
|
491
|
+
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
492
|
+
});
|
|
493
|
+
},
|
|
494
|
+
focusNextTab(ctx2) {
|
|
495
|
+
if (!ctx2.focusedValue)
|
|
507
496
|
return;
|
|
508
|
-
|
|
509
|
-
|
|
497
|
+
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
498
|
+
raf(() => next == null ? void 0 : next.focus());
|
|
499
|
+
},
|
|
500
|
+
focusPrevTab(ctx2) {
|
|
501
|
+
if (!ctx2.focusedValue)
|
|
510
502
|
return;
|
|
503
|
+
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
504
|
+
raf(() => prev == null ? void 0 : prev.focus());
|
|
505
|
+
},
|
|
506
|
+
setIndicatorRect(ctx2) {
|
|
511
507
|
nextTick(() => {
|
|
512
|
-
ctx2.
|
|
508
|
+
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
509
|
+
return;
|
|
510
|
+
ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
|
|
511
|
+
if (ctx2.hasMeasuredRect)
|
|
512
|
+
return;
|
|
513
|
+
nextTick(() => {
|
|
514
|
+
ctx2.hasMeasuredRect = true;
|
|
515
|
+
});
|
|
513
516
|
});
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
534
|
-
}
|
|
535
|
-
},
|
|
536
|
-
setContentTabIndex(ctx2) {
|
|
537
|
-
raf(() => {
|
|
538
|
-
const panel = dom.getActiveContentEl(ctx2);
|
|
539
|
-
if (!panel)
|
|
540
|
-
return;
|
|
541
|
-
const focusables = getFocusables(panel);
|
|
542
|
-
if (focusables.length > 0) {
|
|
543
|
-
panel.removeAttribute("tabindex");
|
|
544
|
-
} else {
|
|
545
|
-
panel.setAttribute("tabindex", "0");
|
|
517
|
+
},
|
|
518
|
+
checkRenderedElements(ctx2) {
|
|
519
|
+
ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
|
|
520
|
+
},
|
|
521
|
+
clearMeasured(ctx2) {
|
|
522
|
+
ctx2.hasMeasuredRect = false;
|
|
523
|
+
},
|
|
524
|
+
invokeOnChange(ctx2) {
|
|
525
|
+
var _a;
|
|
526
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
527
|
+
},
|
|
528
|
+
invokeOnFocus(ctx2) {
|
|
529
|
+
var _a;
|
|
530
|
+
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
531
|
+
},
|
|
532
|
+
setPrevSelectedTabs(ctx2) {
|
|
533
|
+
if (ctx2.value != null) {
|
|
534
|
+
const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
|
|
535
|
+
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
546
536
|
}
|
|
547
|
-
}
|
|
537
|
+
},
|
|
538
|
+
setContentTabIndex(ctx2) {
|
|
539
|
+
raf(() => {
|
|
540
|
+
const panel = dom.getActiveContentEl(ctx2);
|
|
541
|
+
if (!panel)
|
|
542
|
+
return;
|
|
543
|
+
const focusables = getFocusables(panel);
|
|
544
|
+
if (focusables.length > 0) {
|
|
545
|
+
panel.removeAttribute("tabindex");
|
|
546
|
+
} else {
|
|
547
|
+
panel.setAttribute("tabindex", "0");
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
548
551
|
}
|
|
549
552
|
}
|
|
550
|
-
|
|
553
|
+
);
|
|
551
554
|
}
|
|
552
555
|
export {
|
|
553
556
|
connect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tabs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Core logic for the tabs widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@zag-js/core": "0.1.9",
|
|
33
|
-
"@zag-js/types": "0.2.
|
|
33
|
+
"@zag-js/types": "0.2.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@zag-js/dom-utils": "0.1.
|
|
36
|
+
"@zag-js/dom-utils": "0.1.10",
|
|
37
37
|
"@zag-js/utils": "0.1.3"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|