@zag-js/tabs 0.0.0-dev-20220416152643 → 0.0.0-dev-20220418173111
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +184 -182
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +184 -182
- package/dist/index.mjs.map +2 -2
- package/dist/tabs.connect.d.ts +2 -3
- package/dist/tabs.connect.d.ts.map +1 -1
- package/dist/tabs.machine.d.ts +2 -2
- package/dist/tabs.machine.d.ts.map +1 -1
- package/dist/tabs.types.d.ts +45 -30
- package/dist/tabs.types.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,YAAY,EAAE,kBAAkB,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -399,204 +399,206 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
399
399
|
// src/tabs.machine.ts
|
|
400
400
|
var import_core = require("@zag-js/core");
|
|
401
401
|
var { not } = import_core.guards;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
created: ["setPrevSelectedTabs"],
|
|
423
|
-
watch: {
|
|
424
|
-
focusedValue: "invokeOnFocus",
|
|
425
|
-
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
426
|
-
dir: ["clearMeasured", "setIndicatorRect"]
|
|
427
|
-
},
|
|
428
|
-
on: {
|
|
429
|
-
SET_VALUE: {
|
|
430
|
-
actions: "setValue"
|
|
402
|
+
function machine(ctx = {}) {
|
|
403
|
+
return (0, import_core.createMachine)({
|
|
404
|
+
initial: "unknown",
|
|
405
|
+
context: __spreadValues({
|
|
406
|
+
dir: "ltr",
|
|
407
|
+
orientation: "horizontal",
|
|
408
|
+
activationMode: "automatic",
|
|
409
|
+
value: null,
|
|
410
|
+
focusedValue: null,
|
|
411
|
+
uid: "",
|
|
412
|
+
previousValues: [],
|
|
413
|
+
indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
|
|
414
|
+
hasMeasuredRect: false,
|
|
415
|
+
isIndicatorRendered: false,
|
|
416
|
+
loop: true,
|
|
417
|
+
messages: {}
|
|
418
|
+
}, ctx),
|
|
419
|
+
computed: {
|
|
420
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
421
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
431
422
|
},
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
unknown: {
|
|
438
|
-
on: {
|
|
439
|
-
SETUP: {
|
|
440
|
-
target: "idle",
|
|
441
|
-
actions: ["setupDocument", "checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
442
|
-
}
|
|
443
|
-
}
|
|
423
|
+
created: ["setPrevSelectedTabs"],
|
|
424
|
+
watch: {
|
|
425
|
+
focusedValue: "invokeOnFocus",
|
|
426
|
+
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
427
|
+
dir: ["clearMeasured", "setIndicatorRect"]
|
|
444
428
|
},
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
},
|
|
452
|
-
TAB_CLICK: {
|
|
453
|
-
target: "focused",
|
|
454
|
-
actions: ["setFocusedValue", "setValue"]
|
|
455
|
-
}
|
|
429
|
+
on: {
|
|
430
|
+
SET_VALUE: {
|
|
431
|
+
actions: "setValue"
|
|
432
|
+
},
|
|
433
|
+
DELETE: {
|
|
434
|
+
actions: "deleteValue"
|
|
456
435
|
}
|
|
457
436
|
},
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
actions: "focusNextTab"
|
|
471
|
-
},
|
|
472
|
-
ARROW_UP: {
|
|
473
|
-
guard: "isVertical",
|
|
474
|
-
actions: "focusPrevTab"
|
|
475
|
-
},
|
|
476
|
-
ARROW_DOWN: {
|
|
477
|
-
guard: "isVertical",
|
|
478
|
-
actions: "focusNextTab"
|
|
479
|
-
},
|
|
480
|
-
HOME: {
|
|
481
|
-
actions: "focusFirstTab"
|
|
482
|
-
},
|
|
483
|
-
END: {
|
|
484
|
-
actions: "focusLastTab"
|
|
485
|
-
},
|
|
486
|
-
ENTER: {
|
|
487
|
-
guard: not("selectOnFocus"),
|
|
488
|
-
actions: "setValue"
|
|
489
|
-
},
|
|
490
|
-
TAB_FOCUS: [
|
|
491
|
-
{
|
|
437
|
+
states: {
|
|
438
|
+
unknown: {
|
|
439
|
+
on: {
|
|
440
|
+
SETUP: {
|
|
441
|
+
target: "idle",
|
|
442
|
+
actions: ["setupDocument", "checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
idle: {
|
|
447
|
+
on: {
|
|
448
|
+
TAB_FOCUS: {
|
|
492
449
|
guard: "selectOnFocus",
|
|
450
|
+
target: "focused",
|
|
493
451
|
actions: ["setFocusedValue", "setValue"]
|
|
494
452
|
},
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
453
|
+
TAB_CLICK: {
|
|
454
|
+
target: "focused",
|
|
455
|
+
actions: ["setFocusedValue", "setValue"]
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
focused: {
|
|
460
|
+
on: {
|
|
461
|
+
TAB_CLICK: {
|
|
462
|
+
target: "focused",
|
|
463
|
+
actions: ["setFocusedValue", "setValue"]
|
|
464
|
+
},
|
|
465
|
+
ARROW_LEFT: {
|
|
466
|
+
guard: "isHorizontal",
|
|
467
|
+
actions: "focusPrevTab"
|
|
468
|
+
},
|
|
469
|
+
ARROW_RIGHT: {
|
|
470
|
+
guard: "isHorizontal",
|
|
471
|
+
actions: "focusNextTab"
|
|
472
|
+
},
|
|
473
|
+
ARROW_UP: {
|
|
474
|
+
guard: "isVertical",
|
|
475
|
+
actions: "focusPrevTab"
|
|
476
|
+
},
|
|
477
|
+
ARROW_DOWN: {
|
|
478
|
+
guard: "isVertical",
|
|
479
|
+
actions: "focusNextTab"
|
|
480
|
+
},
|
|
481
|
+
HOME: {
|
|
482
|
+
actions: "focusFirstTab"
|
|
483
|
+
},
|
|
484
|
+
END: {
|
|
485
|
+
actions: "focusLastTab"
|
|
486
|
+
},
|
|
487
|
+
ENTER: {
|
|
488
|
+
guard: not("selectOnFocus"),
|
|
489
|
+
actions: "setValue"
|
|
490
|
+
},
|
|
491
|
+
TAB_FOCUS: [
|
|
492
|
+
{
|
|
493
|
+
guard: "selectOnFocus",
|
|
494
|
+
actions: ["setFocusedValue", "setValue"]
|
|
495
|
+
},
|
|
496
|
+
{ actions: "setFocusedValue" }
|
|
497
|
+
],
|
|
498
|
+
TAB_BLUR: {
|
|
499
|
+
target: "idle",
|
|
500
|
+
actions: "clearFocusedValue"
|
|
501
|
+
}
|
|
500
502
|
}
|
|
501
503
|
}
|
|
502
504
|
}
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
selectOnFocus: (ctx) => ctx.activationMode === "automatic"
|
|
509
|
-
},
|
|
510
|
-
actions: {
|
|
511
|
-
setupDocument(ctx, evt) {
|
|
512
|
-
ctx.uid = evt.id;
|
|
513
|
-
if (evt.doc)
|
|
514
|
-
ctx.doc = (0, import_core.ref)(evt.doc);
|
|
515
|
-
},
|
|
516
|
-
setFocusedValue(ctx, evt) {
|
|
517
|
-
ctx.focusedValue = evt.value;
|
|
518
|
-
},
|
|
519
|
-
clearFocusedValue(ctx) {
|
|
520
|
-
ctx.focusedValue = null;
|
|
521
|
-
},
|
|
522
|
-
setValue(ctx, evt) {
|
|
523
|
-
ctx.value = evt.value;
|
|
524
|
-
},
|
|
525
|
-
invokeOnDelete(ctx, evt) {
|
|
526
|
-
var _a;
|
|
527
|
-
(_a = ctx.onDelete) == null ? void 0 : _a.call(ctx, { value: evt.value });
|
|
505
|
+
}, {
|
|
506
|
+
guards: {
|
|
507
|
+
isVertical: (ctx2) => ctx2.isVertical,
|
|
508
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
509
|
+
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
528
510
|
},
|
|
529
|
-
|
|
530
|
-
|
|
511
|
+
actions: {
|
|
512
|
+
setupDocument(ctx2, evt) {
|
|
513
|
+
ctx2.uid = evt.id;
|
|
514
|
+
if (evt.doc)
|
|
515
|
+
ctx2.doc = (0, import_core.ref)(evt.doc);
|
|
516
|
+
},
|
|
517
|
+
setFocusedValue(ctx2, evt) {
|
|
518
|
+
ctx2.focusedValue = evt.value;
|
|
519
|
+
},
|
|
520
|
+
clearFocusedValue(ctx2) {
|
|
521
|
+
ctx2.focusedValue = null;
|
|
522
|
+
},
|
|
523
|
+
setValue(ctx2, evt) {
|
|
524
|
+
ctx2.value = evt.value;
|
|
525
|
+
},
|
|
526
|
+
invokeOnDelete(ctx2, evt) {
|
|
531
527
|
var _a;
|
|
532
|
-
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (!ctx.focusedValue)
|
|
549
|
-
return;
|
|
550
|
-
const prev = dom.getPrevEl(ctx, ctx.focusedValue);
|
|
551
|
-
nextTick(() => prev == null ? void 0 : prev.focus());
|
|
552
|
-
},
|
|
553
|
-
setIndicatorRect(ctx) {
|
|
554
|
-
nextTick(() => {
|
|
555
|
-
if (!ctx.isIndicatorRendered || !ctx.value)
|
|
528
|
+
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
529
|
+
},
|
|
530
|
+
focusFirstTab(ctx2) {
|
|
531
|
+
nextTick(() => {
|
|
532
|
+
var _a;
|
|
533
|
+
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
534
|
+
});
|
|
535
|
+
},
|
|
536
|
+
focusLastTab(ctx2) {
|
|
537
|
+
nextTick(() => {
|
|
538
|
+
var _a;
|
|
539
|
+
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
540
|
+
});
|
|
541
|
+
},
|
|
542
|
+
focusNextTab(ctx2) {
|
|
543
|
+
if (!ctx2.focusedValue)
|
|
556
544
|
return;
|
|
557
|
-
|
|
558
|
-
|
|
545
|
+
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
546
|
+
nextTick(() => next == null ? void 0 : next.focus());
|
|
547
|
+
},
|
|
548
|
+
focusPrevTab(ctx2) {
|
|
549
|
+
if (!ctx2.focusedValue)
|
|
559
550
|
return;
|
|
551
|
+
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
552
|
+
nextTick(() => prev == null ? void 0 : prev.focus());
|
|
553
|
+
},
|
|
554
|
+
setIndicatorRect(ctx2) {
|
|
560
555
|
nextTick(() => {
|
|
561
|
-
|
|
556
|
+
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
557
|
+
return;
|
|
558
|
+
ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
|
|
559
|
+
if (ctx2.hasMeasuredRect)
|
|
560
|
+
return;
|
|
561
|
+
nextTick(() => {
|
|
562
|
+
ctx2.hasMeasuredRect = true;
|
|
563
|
+
});
|
|
562
564
|
});
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
ctx.previousValues = Array.from(new Set(newSelected));
|
|
585
|
-
}
|
|
586
|
-
},
|
|
587
|
-
setContentTabIndex(ctx) {
|
|
588
|
-
nextTick(() => {
|
|
589
|
-
const panel = dom.getActiveContentEl(ctx);
|
|
590
|
-
if (!panel)
|
|
591
|
-
return;
|
|
592
|
-
const focusables = getFocusables(panel);
|
|
593
|
-
if (focusables.length > 0) {
|
|
594
|
-
panel.removeAttribute("tabindex");
|
|
595
|
-
} else {
|
|
596
|
-
panel.setAttribute("tabindex", "0");
|
|
565
|
+
},
|
|
566
|
+
checkRenderedElements(ctx2) {
|
|
567
|
+
nextTick(() => {
|
|
568
|
+
ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
|
|
569
|
+
});
|
|
570
|
+
},
|
|
571
|
+
clearMeasured(ctx2) {
|
|
572
|
+
ctx2.hasMeasuredRect = false;
|
|
573
|
+
},
|
|
574
|
+
invokeOnChange(ctx2) {
|
|
575
|
+
var _a;
|
|
576
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
577
|
+
},
|
|
578
|
+
invokeOnFocus(ctx2) {
|
|
579
|
+
var _a;
|
|
580
|
+
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
581
|
+
},
|
|
582
|
+
setPrevSelectedTabs(ctx2) {
|
|
583
|
+
if (ctx2.value != null) {
|
|
584
|
+
const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
|
|
585
|
+
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
597
586
|
}
|
|
598
|
-
}
|
|
587
|
+
},
|
|
588
|
+
setContentTabIndex(ctx2) {
|
|
589
|
+
nextTick(() => {
|
|
590
|
+
const panel = dom.getActiveContentEl(ctx2);
|
|
591
|
+
if (!panel)
|
|
592
|
+
return;
|
|
593
|
+
const focusables = getFocusables(panel);
|
|
594
|
+
if (focusables.length > 0) {
|
|
595
|
+
panel.removeAttribute("tabindex");
|
|
596
|
+
} else {
|
|
597
|
+
panel.setAttribute("tabindex", "0");
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
}
|
|
599
601
|
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
602
604
|
//# sourceMappingURL=index.js.map
|