@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.
Files changed (3) hide show
  1. package/dist/index.js +176 -173
  2. package/dist/index.mjs +176 -173
  3. 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
- initial: "unknown",
387
- context: {
388
- dir: "ltr",
389
- orientation: "horizontal",
390
- activationMode: "automatic",
391
- value: null,
392
- focusedValue: null,
393
- previousValues: [],
394
- indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
395
- hasMeasuredRect: false,
396
- isIndicatorRendered: false,
397
- loop: true,
398
- messages: {},
399
- ...ctx
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
- DELETE: {
416
- actions: "deleteValue"
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
- idle: {
429
- on: {
430
- TAB_FOCUS: {
431
- guard: "selectOnFocus",
432
- target: "focused",
433
- actions: ["setFocusedValue", "setValue"]
434
- },
435
- TAB_CLICK: {
436
- target: "focused",
437
- actions: ["setFocusedValue", "setValue"]
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
- focused: {
442
- on: {
443
- TAB_CLICK: {
444
- target: "focused",
445
- actions: ["setFocusedValue", "setValue"]
446
- },
447
- ARROW_LEFT: {
448
- guard: "isHorizontal",
449
- actions: "focusPrevTab"
450
- },
451
- ARROW_RIGHT: {
452
- guard: "isHorizontal",
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
- { actions: "setFocusedValue" }
479
- ],
480
- TAB_BLUR: {
481
- target: "idle",
482
- actions: "clearFocusedValue"
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
- actions: {
494
- setFocusedValue(ctx2, evt) {
495
- ctx2.focusedValue = evt.value;
496
- },
497
- clearFocusedValue(ctx2) {
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
- invokeOnDelete(ctx2, evt) {
504
- var _a;
505
- (_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
506
- },
507
- focusFirstTab(ctx2) {
508
- raf(() => {
509
- var _a;
510
- return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
511
- });
512
- },
513
- focusLastTab(ctx2) {
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
- return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
517
- });
518
- },
519
- focusNextTab(ctx2) {
520
- if (!ctx2.focusedValue)
521
- return;
522
- const next = dom.getNextEl(ctx2, ctx2.focusedValue);
523
- raf(() => next == null ? void 0 : next.focus());
524
- },
525
- focusPrevTab(ctx2) {
526
- if (!ctx2.focusedValue)
527
- return;
528
- const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
529
- raf(() => prev == null ? void 0 : prev.focus());
530
- },
531
- setIndicatorRect(ctx2) {
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
- ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
536
- if (ctx2.hasMeasuredRect)
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.hasMeasuredRect = true;
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
- checkRenderedElements(ctx2) {
544
- ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
545
- },
546
- clearMeasured(ctx2) {
547
- ctx2.hasMeasuredRect = false;
548
- },
549
- invokeOnChange(ctx2) {
550
- var _a;
551
- (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
552
- },
553
- invokeOnFocus(ctx2) {
554
- var _a;
555
- (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
556
- },
557
- setPrevSelectedTabs(ctx2) {
558
- if (ctx2.value != null) {
559
- const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
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
- initial: "unknown",
360
- context: {
361
- dir: "ltr",
362
- orientation: "horizontal",
363
- activationMode: "automatic",
364
- value: null,
365
- focusedValue: null,
366
- previousValues: [],
367
- indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
368
- hasMeasuredRect: false,
369
- isIndicatorRendered: false,
370
- loop: true,
371
- messages: {},
372
- ...ctx
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
- DELETE: {
389
- actions: "deleteValue"
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
- idle: {
402
- on: {
403
- TAB_FOCUS: {
404
- guard: "selectOnFocus",
405
- target: "focused",
406
- actions: ["setFocusedValue", "setValue"]
407
- },
408
- TAB_CLICK: {
409
- target: "focused",
410
- actions: ["setFocusedValue", "setValue"]
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
- focused: {
415
- on: {
416
- TAB_CLICK: {
417
- target: "focused",
418
- actions: ["setFocusedValue", "setValue"]
419
- },
420
- ARROW_LEFT: {
421
- guard: "isHorizontal",
422
- actions: "focusPrevTab"
423
- },
424
- ARROW_RIGHT: {
425
- guard: "isHorizontal",
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
- { actions: "setFocusedValue" }
452
- ],
453
- TAB_BLUR: {
454
- target: "idle",
455
- actions: "clearFocusedValue"
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
- actions: {
467
- setFocusedValue(ctx2, evt) {
468
- ctx2.focusedValue = evt.value;
469
- },
470
- clearFocusedValue(ctx2) {
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
- invokeOnDelete(ctx2, evt) {
477
- var _a;
478
- (_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
479
- },
480
- focusFirstTab(ctx2) {
481
- raf(() => {
482
- var _a;
483
- return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
484
- });
485
- },
486
- focusLastTab(ctx2) {
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
- return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
490
- });
491
- },
492
- focusNextTab(ctx2) {
493
- if (!ctx2.focusedValue)
494
- return;
495
- const next = dom.getNextEl(ctx2, ctx2.focusedValue);
496
- raf(() => next == null ? void 0 : next.focus());
497
- },
498
- focusPrevTab(ctx2) {
499
- if (!ctx2.focusedValue)
500
- return;
501
- const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
502
- raf(() => prev == null ? void 0 : prev.focus());
503
- },
504
- setIndicatorRect(ctx2) {
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
- ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
509
- if (ctx2.hasMeasuredRect)
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.hasMeasuredRect = true;
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
- checkRenderedElements(ctx2) {
517
- ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
518
- },
519
- clearMeasured(ctx2) {
520
- ctx2.hasMeasuredRect = false;
521
- },
522
- invokeOnChange(ctx2) {
523
- var _a;
524
- (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
525
- },
526
- invokeOnFocus(ctx2) {
527
- var _a;
528
- (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
529
- },
530
- setPrevSelectedTabs(ctx2) {
531
- if (ctx2.value != null) {
532
- const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
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.11",
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.3"
33
+ "@zag-js/types": "0.2.4"
34
34
  },
35
35
  "devDependencies": {
36
- "@zag-js/dom-utils": "0.1.8",
36
+ "@zag-js/dom-utils": "0.1.10",
37
37
  "@zag-js/utils": "0.1.3"
38
38
  },
39
39
  "scripts": {