@zag-js/tabs 0.0.0-dev-20240513172202 → 0.0.0-dev-20240515121647

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.mts CHANGED
@@ -63,6 +63,10 @@ interface PublicContext extends DirectionProperty, CommonProperties {
63
63
  * Callback to be called when the focused tab changes
64
64
  */
65
65
  onFocusChange?: (details: FocusChangeDetails) => void;
66
+ /**
67
+ * Whether the tab is composite
68
+ */
69
+ composite: boolean;
66
70
  }
67
71
  type UserDefinedContext = RequiredBy<PublicContext, "id">;
68
72
  type ComputedContext = Readonly<{}>;
@@ -126,6 +130,23 @@ interface MachineApi<T extends PropTypes = PropTypes> {
126
130
  * Sets the indicator rect to the tab with the given value
127
131
  */
128
132
  setIndicatorRect(value: string): void;
133
+ /**
134
+ * Synchronizes the tab index of the content element.
135
+ * Useful when rendering tabs within a select or combobox
136
+ */
137
+ syncTabIndex(): void;
138
+ /**
139
+ * Set focus on the selected tab trigger
140
+ */
141
+ focus(): void;
142
+ /**
143
+ * Selects the next tab
144
+ */
145
+ selectNext(fromValue?: string): void;
146
+ /**
147
+ * Selects the previous tab
148
+ */
149
+ selectPrev(fromValue?: string): void;
129
150
  /**
130
151
  * Returns the state of the trigger with the given props
131
152
  */
@@ -141,8 +162,8 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
141
162
 
142
163
  declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
143
164
 
144
- declare const props: ("value" | "dir" | "id" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "getRootNode")[];
145
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "dir" | "id" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "getRootNode">];
165
+ declare const props: ("value" | "dir" | "id" | "getRootNode" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "composite")[];
166
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "dir" | "id" | "getRootNode" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "composite">];
146
167
  declare const triggerProps: (keyof TriggerProps)[];
147
168
  declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
148
169
  declare const contentProps: "value"[];
package/dist/index.d.ts CHANGED
@@ -63,6 +63,10 @@ interface PublicContext extends DirectionProperty, CommonProperties {
63
63
  * Callback to be called when the focused tab changes
64
64
  */
65
65
  onFocusChange?: (details: FocusChangeDetails) => void;
66
+ /**
67
+ * Whether the tab is composite
68
+ */
69
+ composite: boolean;
66
70
  }
67
71
  type UserDefinedContext = RequiredBy<PublicContext, "id">;
68
72
  type ComputedContext = Readonly<{}>;
@@ -126,6 +130,23 @@ interface MachineApi<T extends PropTypes = PropTypes> {
126
130
  * Sets the indicator rect to the tab with the given value
127
131
  */
128
132
  setIndicatorRect(value: string): void;
133
+ /**
134
+ * Synchronizes the tab index of the content element.
135
+ * Useful when rendering tabs within a select or combobox
136
+ */
137
+ syncTabIndex(): void;
138
+ /**
139
+ * Set focus on the selected tab trigger
140
+ */
141
+ focus(): void;
142
+ /**
143
+ * Selects the next tab
144
+ */
145
+ selectNext(fromValue?: string): void;
146
+ /**
147
+ * Selects the previous tab
148
+ */
149
+ selectPrev(fromValue?: string): void;
129
150
  /**
130
151
  * Returns the state of the trigger with the given props
131
152
  */
@@ -141,8 +162,8 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
141
162
 
142
163
  declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
143
164
 
144
- declare const props: ("value" | "dir" | "id" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "getRootNode")[];
145
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "dir" | "id" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "getRootNode">];
165
+ declare const props: ("value" | "dir" | "id" | "getRootNode" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "composite")[];
166
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "dir" | "id" | "getRootNode" | "orientation" | "ids" | "translations" | "loopFocus" | "activationMode" | "onValueChange" | "onFocusChange" | "composite">];
146
167
  declare const triggerProps: (keyof TriggerProps)[];
147
168
  declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
148
169
  declare const contentProps: "value"[];
package/dist/index.js CHANGED
@@ -59,16 +59,16 @@ var dom = (0, import_dom_query.createScope)({
59
59
  const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`;
60
60
  return (0, import_dom_query.queryAll)(dom.getListEl(ctx), selector);
61
61
  },
62
- getFirstEl: (ctx) => (0, import_utils.first)(dom.getElements(ctx)),
63
- getLastEl: (ctx) => (0, import_utils.last)(dom.getElements(ctx)),
64
- getNextEl: (ctx, id) => (0, import_dom_query.nextById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),
65
- getPrevEl: (ctx, id) => (0, import_dom_query.prevById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),
66
- getActiveContentEl: (ctx) => {
62
+ getFirstTriggerEl: (ctx) => (0, import_utils.first)(dom.getElements(ctx)),
63
+ getLastTriggerEl: (ctx) => (0, import_utils.last)(dom.getElements(ctx)),
64
+ getNextTriggerEl: (ctx, id) => (0, import_dom_query.nextById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),
65
+ getPrevTriggerEl: (ctx, id) => (0, import_dom_query.prevById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),
66
+ getSelectedContentEl: (ctx) => {
67
67
  if (!ctx.value)
68
68
  return;
69
69
  return dom.getContentEl(ctx, ctx.value);
70
70
  },
71
- getActiveTabEl: (ctx) => {
71
+ getSelectedTriggerEl: (ctx) => {
72
72
  if (!ctx.value)
73
73
  return;
74
74
  return dom.getTriggerEl(ctx, ctx.value);
@@ -99,6 +99,8 @@ function connect(state, send, normalize) {
99
99
  const focused = state.matches("focused");
100
100
  const isVertical = state.context.orientation === "vertical";
101
101
  const isHorizontal = state.context.orientation === "horizontal";
102
+ const composite = state.context.composite;
103
+ const indicator = state.context.indicatorState;
102
104
  function getTriggerState(props2) {
103
105
  return {
104
106
  selected: state.context.value === props2.value,
@@ -119,6 +121,20 @@ function connect(state, send, normalize) {
119
121
  const id = dom.getTriggerId(state.context, value);
120
122
  send({ type: "SET_INDICATOR_RECT", id });
121
123
  },
124
+ syncTabIndex() {
125
+ send("SYNC_TAB_INDEX");
126
+ },
127
+ selectNext(fromValue) {
128
+ send({ type: "TAB_FOCUS", value: fromValue, src: "selectNext" });
129
+ send({ type: "ARROW_NEXT", src: "selectNext" });
130
+ },
131
+ selectPrev(fromValue) {
132
+ send({ type: "TAB_FOCUS", value: fromValue, src: "selectPrev" });
133
+ send({ type: "ARROW_PREV", src: "selectPrev" });
134
+ },
135
+ focus() {
136
+ dom.getSelectedTriggerEl(state.context)?.focus();
137
+ },
122
138
  getTriggerState,
123
139
  rootProps: normalize.element({
124
140
  ...parts.root.attrs,
@@ -202,7 +218,7 @@ function connect(state, send, normalize) {
202
218
  "aria-controls": triggerState.selected ? dom.getContentId(state.context, value) : void 0,
203
219
  "data-ownedby": dom.getListId(state.context),
204
220
  id: dom.getTriggerId(state.context, value),
205
- tabIndex: triggerState.selected ? 0 : -1,
221
+ tabIndex: triggerState.selected && composite ? 0 : -1,
206
222
  onFocus() {
207
223
  send({ type: "TAB_FOCUS", value });
208
224
  },
@@ -231,7 +247,7 @@ function connect(state, send, normalize) {
231
247
  ...parts.content.attrs,
232
248
  dir: state.context.dir,
233
249
  id: dom.getContentId(state.context, value),
234
- tabIndex: 0,
250
+ tabIndex: composite ? 0 : -1,
235
251
  "aria-labelledby": dom.getTriggerId(state.context, value),
236
252
  role: "tabpanel",
237
253
  "data-ownedby": dom.getListId(state.context),
@@ -247,14 +263,14 @@ function connect(state, send, normalize) {
247
263
  "data-orientation": state.context.orientation,
248
264
  style: {
249
265
  "--transition-property": "left, right, top, bottom, width, height",
250
- "--left": state.context.indicatorRect?.left,
251
- "--top": state.context.indicatorRect?.top,
252
- "--width": state.context.indicatorRect?.width,
253
- "--height": state.context.indicatorRect?.height,
266
+ "--left": indicator.rect?.left,
267
+ "--top": indicator.rect?.top,
268
+ "--width": indicator.rect?.width,
269
+ "--height": indicator.rect?.height,
254
270
  position: "absolute",
255
271
  willChange: "var(--transition-property)",
256
272
  transitionProperty: "var(--transition-property)",
257
- transitionDuration: state.context.canIndicatorTransition ? "var(--transition-duration, 150ms)" : "0ms",
273
+ transitionDuration: indicator.transition ? "var(--transition-duration, 150ms)" : "0ms",
258
274
  transitionTimingFunction: "var(--transition-timing-function)",
259
275
  [isHorizontal ? "left" : "top"]: isHorizontal ? "var(--left)" : "var(--top)"
260
276
  }
@@ -267,7 +283,6 @@ var import_core = require("@zag-js/core");
267
283
  var import_dom_event2 = require("@zag-js/dom-event");
268
284
  var import_dom_query3 = require("@zag-js/dom-query");
269
285
  var import_element_rect = require("@zag-js/element-rect");
270
- var import_tabbable = require("@zag-js/tabbable");
271
286
  var import_utils2 = require("@zag-js/utils");
272
287
  var { not } = import_core.guards;
273
288
  function machine(userContext) {
@@ -280,17 +295,18 @@ function machine(userContext) {
280
295
  orientation: "horizontal",
281
296
  activationMode: "automatic",
282
297
  value: null,
283
- indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
284
298
  loopFocus: true,
299
+ composite: true,
285
300
  ...ctx,
286
- focusedValue: null,
287
- canIndicatorTransition: false,
288
- isIndicatorRendered: false
301
+ focusedValue: ctx.value ?? null,
302
+ indicatorState: {
303
+ rendered: false,
304
+ transition: false,
305
+ rect: { left: "0px", top: "0px", width: "0px", height: "0px" }
306
+ }
289
307
  },
290
- entry: ["checkRenderedElements", "syncIndicatorRect", "setContentTabIndex"],
291
- exit: ["cleanupObserver"],
292
308
  watch: {
293
- value: ["enableIndicatorTransition", "syncIndicatorRect", "setContentTabIndex", "clickIfLink"],
309
+ value: ["allowIndicatorTransition", "syncIndicatorRect", "syncTabIndex", "clickIfLink"],
294
310
  dir: ["syncIndicatorRect"],
295
311
  orientation: ["syncIndicatorRect"]
296
312
  },
@@ -303,8 +319,14 @@ function machine(userContext) {
303
319
  },
304
320
  SET_INDICATOR_RECT: {
305
321
  actions: "setIndicatorRect"
322
+ },
323
+ SYNC_TAB_INDEX: {
324
+ actions: "syncTabIndex"
306
325
  }
307
326
  },
327
+ created: ["syncFocusedValue"],
328
+ entry: ["checkRenderedElements", "syncIndicatorRect", "syncTabIndex"],
329
+ exit: ["cleanupObserver"],
308
330
  states: {
309
331
  idle: {
310
332
  on: {
@@ -380,12 +402,19 @@ function machine(userContext) {
380
402
  selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
381
403
  },
382
404
  actions: {
405
+ syncFocusedValue(ctx2) {
406
+ if (ctx2.value != null && ctx2.focusedValue == null) {
407
+ ctx2.focusedValue = ctx2.value;
408
+ }
409
+ },
383
410
  selectFocusedTab(ctx2) {
384
411
  (0, import_dom_query3.raf)(() => {
385
412
  set.value(ctx2, ctx2.focusedValue);
386
413
  });
387
414
  },
388
415
  setFocusedValue(ctx2, evt) {
416
+ if (evt.value == null)
417
+ return;
389
418
  set.focusedValue(ctx2, evt.value);
390
419
  },
391
420
  clearFocusedValue(ctx2) {
@@ -398,80 +427,95 @@ function machine(userContext) {
398
427
  set.value(ctx2, null);
399
428
  },
400
429
  focusFirstTab(ctx2) {
401
- (0, import_dom_query3.raf)(() => dom.getFirstEl(ctx2)?.focus());
430
+ (0, import_dom_query3.raf)(() => {
431
+ dom.getFirstTriggerEl(ctx2)?.focus();
432
+ });
402
433
  },
403
434
  focusLastTab(ctx2) {
404
- (0, import_dom_query3.raf)(() => dom.getLastEl(ctx2)?.focus());
435
+ (0, import_dom_query3.raf)(() => {
436
+ dom.getLastTriggerEl(ctx2)?.focus();
437
+ });
405
438
  },
406
439
  focusNextTab(ctx2) {
407
440
  if (!ctx2.focusedValue)
408
441
  return;
409
- const next = dom.getNextEl(ctx2, ctx2.focusedValue);
410
- (0, import_dom_query3.raf)(() => next?.focus());
442
+ const triggerEl = dom.getNextTriggerEl(ctx2, ctx2.focusedValue);
443
+ (0, import_dom_query3.raf)(() => {
444
+ if (ctx2.composite) {
445
+ triggerEl?.focus();
446
+ } else if (triggerEl?.dataset.value != null) {
447
+ set.focusedValue(ctx2, triggerEl.dataset.value);
448
+ }
449
+ });
411
450
  },
412
451
  focusPrevTab(ctx2) {
413
452
  if (!ctx2.focusedValue)
414
453
  return;
415
- const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
416
- (0, import_dom_query3.raf)(() => prev?.focus());
454
+ const triggerEl = dom.getPrevTriggerEl(ctx2, ctx2.focusedValue);
455
+ (0, import_dom_query3.raf)(() => {
456
+ if (ctx2.composite) {
457
+ triggerEl?.focus();
458
+ } else if (triggerEl?.dataset.value != null) {
459
+ set.focusedValue(ctx2, triggerEl.dataset.value);
460
+ }
461
+ });
417
462
  },
418
463
  checkRenderedElements(ctx2) {
419
- ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
464
+ ctx2.indicatorState.rendered = !!dom.getIndicatorEl(ctx2);
420
465
  },
421
- // if tab panel contains focusable elements, remove the tabindex attribute
422
- setContentTabIndex(ctx2) {
466
+ syncTabIndex(ctx2) {
423
467
  (0, import_dom_query3.raf)(() => {
424
- const panel = dom.getActiveContentEl(ctx2);
425
- if (!panel)
468
+ const contentEl = dom.getSelectedContentEl(ctx2);
469
+ if (!contentEl)
426
470
  return;
427
- const focusables = (0, import_tabbable.getFocusables)(panel);
471
+ const focusables = (0, import_dom_query3.getFocusables)(contentEl);
428
472
  if (focusables.length > 0) {
429
- panel.removeAttribute("tabindex");
473
+ contentEl.removeAttribute("tabindex");
430
474
  } else {
431
- panel.setAttribute("tabindex", "0");
475
+ contentEl.setAttribute("tabindex", "0");
432
476
  }
433
477
  });
434
478
  },
435
479
  cleanupObserver(ctx2) {
436
480
  ctx2.indicatorCleanup?.();
437
481
  },
438
- enableIndicatorTransition(ctx2) {
439
- ctx2.canIndicatorTransition = true;
482
+ allowIndicatorTransition(ctx2) {
483
+ ctx2.indicatorState.transition = true;
440
484
  },
441
485
  setIndicatorRect(ctx2, evt) {
442
486
  const value = evt.id ?? ctx2.value;
443
- if (!ctx2.isIndicatorRendered || !value)
487
+ if (!ctx2.indicatorState.rendered || !value)
444
488
  return;
445
- const tabEl = dom.getTriggerEl(ctx2, value);
446
- if (!tabEl)
489
+ const triggerEl = dom.getTriggerEl(ctx2, value);
490
+ if (!triggerEl)
447
491
  return;
448
- ctx2.indicatorRect = dom.getRectById(ctx2, value);
492
+ ctx2.indicatorState.rect = dom.getRectById(ctx2, value);
449
493
  (0, import_dom_query3.nextTick)(() => {
450
- ctx2.canIndicatorTransition = false;
494
+ ctx2.indicatorState.transition = false;
451
495
  });
452
496
  },
453
497
  syncIndicatorRect(ctx2) {
454
498
  ctx2.indicatorCleanup?.();
455
499
  const value = ctx2.value;
456
- if (!ctx2.isIndicatorRendered || !value)
500
+ if (!ctx2.indicatorState.rendered || !value)
457
501
  return;
458
- const tabEl = dom.getActiveTabEl(ctx2);
459
- if (!tabEl)
502
+ const triggerEl = dom.getSelectedTriggerEl(ctx2);
503
+ if (!triggerEl)
460
504
  return;
461
- ctx2.indicatorCleanup = (0, import_element_rect.trackElementRect)(tabEl, {
505
+ ctx2.indicatorCleanup = (0, import_element_rect.trackElementRect)(triggerEl, {
462
506
  getRect(el) {
463
507
  return dom.getOffsetRect(el);
464
508
  },
465
509
  onChange(rect) {
466
- ctx2.indicatorRect = dom.resolveRect(rect);
510
+ ctx2.indicatorState.rect = dom.resolveRect(rect);
467
511
  (0, import_dom_query3.nextTick)(() => {
468
- ctx2.canIndicatorTransition = false;
512
+ ctx2.indicatorState.transition = false;
469
513
  });
470
514
  }
471
515
  });
472
516
  },
473
517
  clickIfLink(ctx2) {
474
- (0, import_dom_event2.clickIfLink)(dom.getActiveTabEl(ctx2));
518
+ (0, import_dom_event2.clickIfLink)(dom.getSelectedTriggerEl(ctx2));
475
519
  }
476
520
  }
477
521
  }
@@ -509,6 +553,7 @@ var import_types = require("@zag-js/types");
509
553
  var import_utils3 = require("@zag-js/utils");
510
554
  var props = (0, import_types.createProps)()([
511
555
  "activationMode",
556
+ "composite",
512
557
  "dir",
513
558
  "getRootNode",
514
559
  "id",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/tabs.anatomy.ts","../src/tabs.connect.ts","../src/tabs.dom.ts","../src/tabs.machine.ts","../src/tabs.props.ts"],"sourcesContent":["export { anatomy } from \"./tabs.anatomy\"\nexport { connect } from \"./tabs.connect\"\nexport { machine } from \"./tabs.machine\"\nexport * from \"./tabs.props\"\nexport type {\n MachineApi as Api,\n ContentProps,\n UserDefinedContext as Context,\n ElementIds,\n FocusChangeDetails,\n IntlTranslations,\n TriggerProps,\n ValueChangeDetails,\n} from \"./tabs.types\"\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"tabs\").parts(\"root\", \"list\", \"trigger\", \"content\", \"indicator\")\nexport const parts = anatomy.build()\n","import { getEventKey, getNativeEvent, type EventKeyMap } from \"@zag-js/dom-event\"\nimport { dataAttr, isSafari, isSelfTarget } from \"@zag-js/dom-query\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./tabs.anatomy\"\nimport { dom } from \"./tabs.dom\"\nimport type { MachineApi, Send, State, TriggerProps, TriggerState } from \"./tabs.types\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T> {\n const translations = state.context.translations\n const focused = state.matches(\"focused\")\n\n const isVertical = state.context.orientation === \"vertical\"\n const isHorizontal = state.context.orientation === \"horizontal\"\n\n function getTriggerState(props: TriggerProps): TriggerState {\n return {\n selected: state.context.value === props.value,\n focused: state.context.focusedValue === props.value,\n disabled: !!props.disabled,\n }\n }\n\n return {\n value: state.context.value,\n focusedValue: state.context.focusedValue,\n setValue(value) {\n send({ type: \"SET_VALUE\", value })\n },\n clearValue() {\n send({ type: \"CLEAR_VALUE\" })\n },\n setIndicatorRect(value) {\n const id = dom.getTriggerId(state.context, value)\n send({ type: \"SET_INDICATOR_RECT\", id })\n },\n getTriggerState,\n\n rootProps: normalize.element({\n ...parts.root.attrs,\n id: dom.getRootId(state.context),\n \"data-orientation\": state.context.orientation,\n \"data-focus\": dataAttr(focused),\n dir: state.context.dir,\n }),\n\n listProps: normalize.element({\n ...parts.list.attrs,\n id: dom.getListId(state.context),\n role: \"tablist\",\n dir: state.context.dir,\n \"data-focus\": dataAttr(focused),\n \"aria-orientation\": state.context.orientation,\n \"data-orientation\": state.context.orientation,\n \"aria-label\": translations?.listLabel,\n onKeyDown(event) {\n if (event.defaultPrevented) return\n const evt = getNativeEvent(event)\n\n if (!isSelfTarget(evt)) return\n if (evt.isComposing) return\n\n const keyMap: EventKeyMap = {\n ArrowDown() {\n if (isHorizontal) return\n send({ type: \"ARROW_NEXT\", key: \"ArrowDown\" })\n },\n ArrowUp() {\n if (isHorizontal) return\n send({ type: \"ARROW_PREV\", key: \"ArrowUp\" })\n },\n ArrowLeft() {\n if (isVertical) return\n send({ type: \"ARROW_PREV\", key: \"ArrowLeft\" })\n },\n ArrowRight() {\n if (isVertical) return\n send({ type: \"ARROW_NEXT\", key: \"ArrowRight\" })\n },\n Home() {\n send(\"HOME\")\n },\n End() {\n send(\"END\")\n },\n Enter() {\n send({ type: \"ENTER\" })\n },\n }\n\n let key = getEventKey(event, state.context)\n const exec = keyMap[key]\n\n if (exec) {\n event.preventDefault()\n exec(event)\n }\n },\n }),\n\n getTriggerProps(props) {\n const { value, disabled } = props\n const triggerState = getTriggerState(props)\n\n return normalize.button({\n ...parts.trigger.attrs,\n role: \"tab\",\n type: \"button\",\n disabled,\n dir: state.context.dir,\n \"data-orientation\": state.context.orientation,\n \"data-disabled\": dataAttr(disabled),\n \"aria-disabled\": disabled,\n \"data-value\": value,\n \"aria-selected\": triggerState.selected,\n \"data-selected\": dataAttr(triggerState.selected),\n \"data-focus\": dataAttr(triggerState.focused),\n \"aria-controls\": triggerState.selected ? dom.getContentId(state.context, value) : undefined,\n \"data-ownedby\": dom.getListId(state.context),\n id: dom.getTriggerId(state.context, value),\n tabIndex: triggerState.selected ? 0 : -1,\n onFocus() {\n send({ type: \"TAB_FOCUS\", value })\n },\n onBlur(event) {\n const target = event.relatedTarget as HTMLElement | null\n if (target?.getAttribute(\"role\") !== \"tab\") {\n send({ type: \"TAB_BLUR\" })\n }\n },\n onClick(event) {\n if (event.defaultPrevented) return\n if (disabled) return\n if (isSafari()) {\n event.currentTarget.focus()\n }\n send({ type: \"TAB_CLICK\", value })\n },\n })\n },\n\n getContentProps(props) {\n const { value } = props\n const selected = state.context.value === value\n return normalize.element({\n ...parts.content.attrs,\n dir: state.context.dir,\n id: dom.getContentId(state.context, value),\n tabIndex: 0,\n \"aria-labelledby\": dom.getTriggerId(state.context, value),\n role: \"tabpanel\",\n \"data-ownedby\": dom.getListId(state.context),\n \"data-selected\": dataAttr(selected),\n \"data-orientation\": state.context.orientation,\n hidden: !selected,\n })\n },\n\n indicatorProps: normalize.element({\n id: dom.getIndicatorId(state.context),\n ...parts.indicator.attrs,\n dir: state.context.dir,\n \"data-orientation\": state.context.orientation,\n style: {\n \"--transition-property\": \"left, right, top, bottom, width, height\",\n \"--left\": state.context.indicatorRect?.left,\n \"--top\": state.context.indicatorRect?.top,\n \"--width\": state.context.indicatorRect?.width,\n \"--height\": state.context.indicatorRect?.height,\n position: \"absolute\",\n willChange: \"var(--transition-property)\",\n transitionProperty: \"var(--transition-property)\",\n transitionDuration: state.context.canIndicatorTransition ? \"var(--transition-duration, 150ms)\" : \"0ms\",\n transitionTimingFunction: \"var(--transition-timing-function)\",\n [isHorizontal ? \"left\" : \"top\"]: isHorizontal ? \"var(--left)\" : \"var(--top)\",\n },\n }),\n }\n}\n","import { createScope, itemById, nextById, prevById, queryAll } from \"@zag-js/dom-query\"\nimport { first, last } from \"@zag-js/utils\"\nimport type { MachineContext as Ctx } from \"./tabs.types\"\n\nexport const dom = createScope({\n getRootId: (ctx: Ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,\n getListId: (ctx: Ctx) => ctx.ids?.list ?? `tabs:${ctx.id}:list`,\n getContentId: (ctx: Ctx, id: string) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,\n getTriggerId: (ctx: Ctx, id: string) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,\n getIndicatorId: (ctx: Ctx) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`,\n\n getListEl: (ctx: Ctx) => dom.getById(ctx, dom.getListId(ctx)),\n getContentEl: (ctx: Ctx, id: string) => dom.getById(ctx, dom.getContentId(ctx, id)),\n getTriggerEl: (ctx: Ctx, id: string) => dom.getById(ctx, dom.getTriggerId(ctx, id)),\n getIndicatorEl: (ctx: Ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),\n\n getElements: (ctx: Ctx) => {\n const ownerId = CSS.escape(dom.getListId(ctx))\n const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`\n return queryAll(dom.getListEl(ctx), selector)\n },\n\n getFirstEl: (ctx: Ctx) => first(dom.getElements(ctx)),\n getLastEl: (ctx: Ctx) => last(dom.getElements(ctx)),\n getNextEl: (ctx: Ctx, id: string) => nextById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),\n getPrevEl: (ctx: Ctx, id: string) => prevById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),\n getActiveContentEl: (ctx: Ctx) => {\n if (!ctx.value) return\n return dom.getContentEl(ctx, ctx.value)\n },\n getActiveTabEl: (ctx: Ctx) => {\n if (!ctx.value) return\n return dom.getTriggerEl(ctx, ctx.value)\n },\n\n getOffsetRect: (el: HTMLElement | undefined) => {\n return {\n left: el?.offsetLeft ?? 0,\n top: el?.offsetTop ?? 0,\n width: el?.offsetWidth ?? 0,\n height: el?.offsetHeight ?? 0,\n }\n },\n\n getRectById: (ctx: Ctx, id: string) => {\n const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id))\n return dom.resolveRect(dom.getOffsetRect(tab))\n },\n\n resolveRect: (rect: Record<\"width\" | \"height\" | \"left\" | \"top\", number>) => ({\n width: `${rect.width}px`,\n height: `${rect.height}px`,\n left: `${rect.left}px`,\n top: `${rect.top}px`,\n }),\n})\n","import { createMachine, guards } from \"@zag-js/core\"\nimport { clickIfLink } from \"@zag-js/dom-event\"\nimport { nextTick, raf } from \"@zag-js/dom-query\"\nimport { trackElementRect } from \"@zag-js/element-rect\"\nimport { getFocusables } from \"@zag-js/tabbable\"\nimport { compact, isEqual } from \"@zag-js/utils\"\nimport { dom } from \"./tabs.dom\"\nimport type { MachineContext, MachineState, UserDefinedContext } from \"./tabs.types\"\n\nconst { not } = guards\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n return createMachine<MachineContext, MachineState>(\n {\n initial: \"idle\",\n\n context: {\n dir: \"ltr\",\n orientation: \"horizontal\",\n activationMode: \"automatic\",\n value: null,\n indicatorRect: { left: \"0px\", top: \"0px\", width: \"0px\", height: \"0px\" },\n loopFocus: true,\n ...ctx,\n focusedValue: null,\n canIndicatorTransition: false,\n isIndicatorRendered: false,\n },\n\n entry: [\"checkRenderedElements\", \"syncIndicatorRect\", \"setContentTabIndex\"],\n\n exit: [\"cleanupObserver\"],\n\n watch: {\n value: [\"enableIndicatorTransition\", \"syncIndicatorRect\", \"setContentTabIndex\", \"clickIfLink\"],\n dir: [\"syncIndicatorRect\"],\n orientation: [\"syncIndicatorRect\"],\n },\n\n on: {\n SET_VALUE: {\n actions: \"setValue\",\n },\n CLEAR_VALUE: {\n actions: \"clearValue\",\n },\n SET_INDICATOR_RECT: {\n actions: \"setIndicatorRect\",\n },\n },\n\n states: {\n idle: {\n on: {\n TAB_FOCUS: {\n target: \"focused\",\n actions: \"setFocusedValue\",\n },\n TAB_CLICK: {\n target: \"focused\",\n actions: [\"setFocusedValue\", \"setValue\"],\n },\n },\n },\n focused: {\n on: {\n TAB_CLICK: {\n target: \"focused\",\n actions: [\"setFocusedValue\", \"setValue\"],\n },\n ARROW_PREV: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusPrevTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusPrevTab\",\n },\n ],\n ARROW_NEXT: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusNextTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusNextTab\",\n },\n ],\n HOME: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusFirstTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusFirstTab\",\n },\n ],\n END: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusLastTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusLastTab\",\n },\n ],\n ENTER: {\n guard: not(\"selectOnFocus\"),\n actions: \"selectFocusedTab\",\n },\n TAB_FOCUS: {\n actions: [\"setFocusedValue\"],\n },\n TAB_BLUR: {\n target: \"idle\",\n actions: \"clearFocusedValue\",\n },\n },\n },\n },\n },\n {\n guards: {\n selectOnFocus: (ctx) => ctx.activationMode === \"automatic\",\n },\n\n actions: {\n selectFocusedTab(ctx) {\n raf(() => {\n set.value(ctx, ctx.focusedValue)\n })\n },\n setFocusedValue(ctx, evt) {\n set.focusedValue(ctx, evt.value)\n },\n clearFocusedValue(ctx) {\n set.focusedValue(ctx, null)\n },\n setValue(ctx, evt) {\n set.value(ctx, evt.value)\n },\n clearValue(ctx) {\n set.value(ctx, null)\n },\n focusFirstTab(ctx) {\n raf(() => dom.getFirstEl(ctx)?.focus())\n },\n focusLastTab(ctx) {\n raf(() => dom.getLastEl(ctx)?.focus())\n },\n focusNextTab(ctx) {\n if (!ctx.focusedValue) return\n const next = dom.getNextEl(ctx, ctx.focusedValue)\n raf(() => next?.focus())\n },\n focusPrevTab(ctx) {\n if (!ctx.focusedValue) return\n const prev = dom.getPrevEl(ctx, ctx.focusedValue)\n raf(() => prev?.focus())\n },\n checkRenderedElements(ctx) {\n ctx.isIndicatorRendered = !!dom.getIndicatorEl(ctx)\n },\n // if tab panel contains focusable elements, remove the tabindex attribute\n setContentTabIndex(ctx) {\n raf(() => {\n const panel = dom.getActiveContentEl(ctx)\n if (!panel) return\n const focusables = getFocusables(panel)\n if (focusables.length > 0) {\n panel.removeAttribute(\"tabindex\")\n } else {\n panel.setAttribute(\"tabindex\", \"0\")\n }\n })\n },\n cleanupObserver(ctx) {\n ctx.indicatorCleanup?.()\n },\n enableIndicatorTransition(ctx) {\n ctx.canIndicatorTransition = true\n },\n setIndicatorRect(ctx, evt) {\n const value = evt.id ?? ctx.value\n if (!ctx.isIndicatorRendered || !value) return\n\n const tabEl = dom.getTriggerEl(ctx, value)\n if (!tabEl) return\n\n ctx.indicatorRect = dom.getRectById(ctx, value)\n nextTick(() => {\n ctx.canIndicatorTransition = false\n })\n },\n syncIndicatorRect(ctx) {\n ctx.indicatorCleanup?.()\n\n const value = ctx.value\n if (!ctx.isIndicatorRendered || !value) return\n\n const tabEl = dom.getActiveTabEl(ctx)\n if (!tabEl) return\n\n ctx.indicatorCleanup = trackElementRect(tabEl, {\n getRect(el) {\n return dom.getOffsetRect(el)\n },\n onChange(rect) {\n ctx.indicatorRect = dom.resolveRect(rect)\n nextTick(() => {\n ctx.canIndicatorTransition = false\n })\n },\n })\n },\n clickIfLink(ctx) {\n clickIfLink(dom.getActiveTabEl(ctx))\n },\n },\n },\n )\n}\n\nconst invoke = {\n change: (ctx: MachineContext) => {\n if (ctx.value == null) return\n ctx.onValueChange?.({ value: ctx.value })\n },\n focusChange: (ctx: MachineContext) => {\n if (ctx.focusedValue == null) return\n ctx.onFocusChange?.({ focusedValue: ctx.focusedValue })\n },\n}\n\nconst set = {\n value: (ctx: MachineContext, value: string | null) => {\n if (isEqual(value, ctx.value)) return\n ctx.value = value\n invoke.change(ctx)\n },\n focusedValue: (ctx: MachineContext, value: string | null) => {\n if (isEqual(value, ctx.focusedValue)) return\n ctx.focusedValue = value\n invoke.focusChange(ctx)\n },\n}\n","import { createProps } from \"@zag-js/types\"\nimport { createSplitProps } from \"@zag-js/utils\"\nimport type { ContentProps, TriggerProps, UserDefinedContext } from \"./tabs.types\"\n\nexport const props = createProps<UserDefinedContext>()([\n \"activationMode\",\n \"dir\",\n \"getRootNode\",\n \"id\",\n \"ids\",\n \"loopFocus\",\n \"onFocusChange\",\n \"onValueChange\",\n \"orientation\",\n \"translations\",\n \"value\",\n])\n\nexport const splitProps = createSplitProps<Partial<UserDefinedContext>>(props)\n\nexport const triggerProps = createProps<TriggerProps>()([\"disabled\", \"value\"])\nexport const splitTriggerProps = createSplitProps<TriggerProps>(triggerProps)\n\nexport const contentProps = createProps<ContentProps>()([\"value\"])\nexport const splitContentProps = createSplitProps<ContentProps>(contentProps)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA8B;AAEvB,IAAM,cAAU,8BAAc,MAAM,EAAE,MAAM,QAAQ,QAAQ,WAAW,WAAW,WAAW;AAC7F,IAAM,QAAQ,QAAQ,MAAM;;;ACHnC,uBAA8D;AAC9D,IAAAA,oBAAiD;;;ACDjD,uBAAoE;A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AI,gBAAgB;AAAM;AAC9B,QAAI,gBAAgB,EAAE,cAAc,IAAI,aAAa,CAAC;AAAA,EACxD;AACF;AAEA,IAAM,MAAM;AAAA,EACV,OAAO,CAAC,KAAqB,UAAyB;AACpD,YAAI,uBAAQ,OAAO,IAAI,KAAK;AAAG;AAC/B,QAAI,QAAQ;AACZ,WAAO,OAAO,GAAG;AAAA,EACnB;AAAA,EACA,cAAc,CAAC,KAAqB,UAAyB;AAC3D,YAAI,uBAAQ,OAAO,IAAI,YAAY;AAAG;AACtC,QAAI,eAAe;AACnB,WAAO,YAAY,GAAG;AAAA,EACxB;AACF;;;ACtPA,mBAA4B;AAC5B,IAAAC,gBAAiC;AAG1B,IAAM,YAAQ,0BAAgC,EAAE;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,iBAAa,gCAA8C,KAAK;AAEtE,IAAM,mBAAe,0BAA0B,EAAE,CAAC,YAAY,OAAO,CAAC;AACtE,IAAM,wBAAoB,gCAA+B,YAAY;AAErE,IAAM,mBAAe,0BAA0B,EAAE,CAAC,OAAO,CAAC;AAC1D,IAAM,wBAAoB,gCAA+B,YAAY;","names":["import_dom_query","props","import_dom_event","import_dom_query","import_utils","ctx","import_utils"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/tabs.anatomy.ts","../src/tabs.connect.ts","../src/tabs.dom.ts","../src/tabs.machine.ts","../src/tabs.props.ts"],"sourcesContent":["export { anatomy } from \"./tabs.anatomy\"\nexport { connect } from \"./tabs.connect\"\nexport { machine } from \"./tabs.machine\"\nexport * from \"./tabs.props\"\nexport type {\n MachineApi as Api,\n ContentProps,\n UserDefinedContext as Context,\n ElementIds,\n FocusChangeDetails,\n IntlTranslations,\n TriggerProps,\n ValueChangeDetails,\n} from \"./tabs.types\"\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"tabs\").parts(\"root\", \"list\", \"trigger\", \"content\", \"indicator\")\nexport const parts = anatomy.build()\n","import { getEventKey, getNativeEvent, type EventKeyMap } from \"@zag-js/dom-event\"\nimport { dataAttr, isSafari, isSelfTarget } from \"@zag-js/dom-query\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./tabs.anatomy\"\nimport { dom } from \"./tabs.dom\"\nimport type { MachineApi, Send, State, TriggerProps, TriggerState } from \"./tabs.types\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T> {\n const translations = state.context.translations\n const focused = state.matches(\"focused\")\n\n const isVertical = state.context.orientation === \"vertical\"\n const isHorizontal = state.context.orientation === \"horizontal\"\n const composite = state.context.composite\n const indicator = state.context.indicatorState\n\n function getTriggerState(props: TriggerProps): TriggerState {\n return {\n selected: state.context.value === props.value,\n focused: state.context.focusedValue === props.value,\n disabled: !!props.disabled,\n }\n }\n\n return {\n value: state.context.value,\n focusedValue: state.context.focusedValue,\n setValue(value) {\n send({ type: \"SET_VALUE\", value })\n },\n clearValue() {\n send({ type: \"CLEAR_VALUE\" })\n },\n setIndicatorRect(value) {\n const id = dom.getTriggerId(state.context, value)\n send({ type: \"SET_INDICATOR_RECT\", id })\n },\n syncTabIndex() {\n send(\"SYNC_TAB_INDEX\")\n },\n selectNext(fromValue) {\n send({ type: \"TAB_FOCUS\", value: fromValue, src: \"selectNext\" })\n send({ type: \"ARROW_NEXT\", src: \"selectNext\" })\n },\n selectPrev(fromValue) {\n send({ type: \"TAB_FOCUS\", value: fromValue, src: \"selectPrev\" })\n send({ type: \"ARROW_PREV\", src: \"selectPrev\" })\n },\n focus() {\n dom.getSelectedTriggerEl(state.context)?.focus()\n },\n getTriggerState,\n\n rootProps: normalize.element({\n ...parts.root.attrs,\n id: dom.getRootId(state.context),\n \"data-orientation\": state.context.orientation,\n \"data-focus\": dataAttr(focused),\n dir: state.context.dir,\n }),\n\n listProps: normalize.element({\n ...parts.list.attrs,\n id: dom.getListId(state.context),\n role: \"tablist\",\n dir: state.context.dir,\n \"data-focus\": dataAttr(focused),\n \"aria-orientation\": state.context.orientation,\n \"data-orientation\": state.context.orientation,\n \"aria-label\": translations?.listLabel,\n onKeyDown(event) {\n if (event.defaultPrevented) return\n const evt = getNativeEvent(event)\n\n if (!isSelfTarget(evt)) return\n if (evt.isComposing) return\n\n const keyMap: EventKeyMap = {\n ArrowDown() {\n if (isHorizontal) return\n send({ type: \"ARROW_NEXT\", key: \"ArrowDown\" })\n },\n ArrowUp() {\n if (isHorizontal) return\n send({ type: \"ARROW_PREV\", key: \"ArrowUp\" })\n },\n ArrowLeft() {\n if (isVertical) return\n send({ type: \"ARROW_PREV\", key: \"ArrowLeft\" })\n },\n ArrowRight() {\n if (isVertical) return\n send({ type: \"ARROW_NEXT\", key: \"ArrowRight\" })\n },\n Home() {\n send(\"HOME\")\n },\n End() {\n send(\"END\")\n },\n Enter() {\n send({ type: \"ENTER\" })\n },\n }\n\n let key = getEventKey(event, state.context)\n const exec = keyMap[key]\n\n if (exec) {\n event.preventDefault()\n exec(event)\n }\n },\n }),\n\n getTriggerProps(props) {\n const { value, disabled } = props\n const triggerState = getTriggerState(props)\n\n return normalize.button({\n ...parts.trigger.attrs,\n role: \"tab\",\n type: \"button\",\n disabled,\n dir: state.context.dir,\n \"data-orientation\": state.context.orientation,\n \"data-disabled\": dataAttr(disabled),\n \"aria-disabled\": disabled,\n \"data-value\": value,\n \"aria-selected\": triggerState.selected,\n \"data-selected\": dataAttr(triggerState.selected),\n \"data-focus\": dataAttr(triggerState.focused),\n \"aria-controls\": triggerState.selected ? dom.getContentId(state.context, value) : undefined,\n \"data-ownedby\": dom.getListId(state.context),\n id: dom.getTriggerId(state.context, value),\n tabIndex: triggerState.selected && composite ? 0 : -1,\n onFocus() {\n send({ type: \"TAB_FOCUS\", value })\n },\n onBlur(event) {\n const target = event.relatedTarget as HTMLElement | null\n if (target?.getAttribute(\"role\") !== \"tab\") {\n send({ type: \"TAB_BLUR\" })\n }\n },\n onClick(event) {\n if (event.defaultPrevented) return\n if (disabled) return\n if (isSafari()) {\n event.currentTarget.focus()\n }\n send({ type: \"TAB_CLICK\", value })\n },\n })\n },\n\n getContentProps(props) {\n const { value } = props\n const selected = state.context.value === value\n return normalize.element({\n ...parts.content.attrs,\n dir: state.context.dir,\n id: dom.getContentId(state.context, value),\n tabIndex: composite ? 0 : -1,\n \"aria-labelledby\": dom.getTriggerId(state.context, value),\n role: \"tabpanel\",\n \"data-ownedby\": dom.getListId(state.context),\n \"data-selected\": dataAttr(selected),\n \"data-orientation\": state.context.orientation,\n hidden: !selected,\n })\n },\n\n indicatorProps: normalize.element({\n id: dom.getIndicatorId(state.context),\n ...parts.indicator.attrs,\n dir: state.context.dir,\n \"data-orientation\": state.context.orientation,\n style: {\n \"--transition-property\": \"left, right, top, bottom, width, height\",\n \"--left\": indicator.rect?.left,\n \"--top\": indicator.rect?.top,\n \"--width\": indicator.rect?.width,\n \"--height\": indicator.rect?.height,\n position: \"absolute\",\n willChange: \"var(--transition-property)\",\n transitionProperty: \"var(--transition-property)\",\n transitionDuration: indicator.transition ? \"var(--transition-duration, 150ms)\" : \"0ms\",\n transitionTimingFunction: \"var(--transition-timing-function)\",\n [isHorizontal ? \"left\" : \"top\"]: isHorizontal ? \"var(--left)\" : \"var(--top)\",\n },\n }),\n }\n}\n","import { createScope, itemById, nextById, prevById, queryAll } from \"@zag-js/dom-query\"\nimport { first, last } from \"@zag-js/utils\"\nimport type { MachineContext as Ctx } from \"./tabs.types\"\n\nexport const dom = createScope({\n getRootId: (ctx: Ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,\n getListId: (ctx: Ctx) => ctx.ids?.list ?? `tabs:${ctx.id}:list`,\n getContentId: (ctx: Ctx, id: string) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,\n getTriggerId: (ctx: Ctx, id: string) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,\n getIndicatorId: (ctx: Ctx) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`,\n\n getListEl: (ctx: Ctx) => dom.getById(ctx, dom.getListId(ctx)),\n getContentEl: (ctx: Ctx, id: string) => dom.getById(ctx, dom.getContentId(ctx, id)),\n getTriggerEl: (ctx: Ctx, id: string) => dom.getById(ctx, dom.getTriggerId(ctx, id)),\n getIndicatorEl: (ctx: Ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),\n\n getElements: (ctx: Ctx) => {\n const ownerId = CSS.escape(dom.getListId(ctx))\n const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`\n return queryAll(dom.getListEl(ctx), selector)\n },\n\n getFirstTriggerEl: (ctx: Ctx) => first(dom.getElements(ctx)),\n getLastTriggerEl: (ctx: Ctx) => last(dom.getElements(ctx)),\n getNextTriggerEl: (ctx: Ctx, id: string) => nextById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),\n getPrevTriggerEl: (ctx: Ctx, id: string) => prevById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loopFocus),\n getSelectedContentEl: (ctx: Ctx) => {\n if (!ctx.value) return\n return dom.getContentEl(ctx, ctx.value)\n },\n getSelectedTriggerEl: (ctx: Ctx) => {\n if (!ctx.value) return\n return dom.getTriggerEl(ctx, ctx.value)\n },\n\n getOffsetRect: (el: HTMLElement | undefined) => {\n return {\n left: el?.offsetLeft ?? 0,\n top: el?.offsetTop ?? 0,\n width: el?.offsetWidth ?? 0,\n height: el?.offsetHeight ?? 0,\n }\n },\n\n getRectById: (ctx: Ctx, id: string) => {\n const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id))\n return dom.resolveRect(dom.getOffsetRect(tab))\n },\n\n resolveRect: (rect: Record<\"width\" | \"height\" | \"left\" | \"top\", number>) => ({\n width: `${rect.width}px`,\n height: `${rect.height}px`,\n left: `${rect.left}px`,\n top: `${rect.top}px`,\n }),\n})\n","import { createMachine, guards } from \"@zag-js/core\"\nimport { clickIfLink } from \"@zag-js/dom-event\"\nimport { nextTick, raf, getFocusables } from \"@zag-js/dom-query\"\nimport { trackElementRect } from \"@zag-js/element-rect\"\nimport { compact, isEqual } from \"@zag-js/utils\"\nimport { dom } from \"./tabs.dom\"\nimport type { MachineContext, MachineState, UserDefinedContext } from \"./tabs.types\"\n\nconst { not } = guards\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n return createMachine<MachineContext, MachineState>(\n {\n initial: \"idle\",\n\n context: {\n dir: \"ltr\",\n orientation: \"horizontal\",\n activationMode: \"automatic\",\n value: null,\n loopFocus: true,\n composite: true,\n ...ctx,\n focusedValue: ctx.value ?? null,\n indicatorState: {\n rendered: false,\n transition: false,\n rect: { left: \"0px\", top: \"0px\", width: \"0px\", height: \"0px\" },\n },\n },\n\n watch: {\n value: [\"allowIndicatorTransition\", \"syncIndicatorRect\", \"syncTabIndex\", \"clickIfLink\"],\n dir: [\"syncIndicatorRect\"],\n orientation: [\"syncIndicatorRect\"],\n },\n\n on: {\n SET_VALUE: {\n actions: \"setValue\",\n },\n CLEAR_VALUE: {\n actions: \"clearValue\",\n },\n SET_INDICATOR_RECT: {\n actions: \"setIndicatorRect\",\n },\n SYNC_TAB_INDEX: {\n actions: \"syncTabIndex\",\n },\n },\n\n created: [\"syncFocusedValue\"],\n entry: [\"checkRenderedElements\", \"syncIndicatorRect\", \"syncTabIndex\"],\n exit: [\"cleanupObserver\"],\n\n states: {\n idle: {\n on: {\n TAB_FOCUS: {\n target: \"focused\",\n actions: \"setFocusedValue\",\n },\n TAB_CLICK: {\n target: \"focused\",\n actions: [\"setFocusedValue\", \"setValue\"],\n },\n },\n },\n focused: {\n on: {\n TAB_CLICK: {\n target: \"focused\",\n actions: [\"setFocusedValue\", \"setValue\"],\n },\n ARROW_PREV: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusPrevTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusPrevTab\",\n },\n ],\n ARROW_NEXT: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusNextTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusNextTab\",\n },\n ],\n HOME: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusFirstTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusFirstTab\",\n },\n ],\n END: [\n {\n guard: \"selectOnFocus\",\n actions: [\"focusLastTab\", \"selectFocusedTab\"],\n },\n {\n actions: \"focusLastTab\",\n },\n ],\n ENTER: {\n guard: not(\"selectOnFocus\"),\n actions: \"selectFocusedTab\",\n },\n TAB_FOCUS: {\n actions: [\"setFocusedValue\"],\n },\n TAB_BLUR: {\n target: \"idle\",\n actions: \"clearFocusedValue\",\n },\n },\n },\n },\n },\n {\n guards: {\n selectOnFocus: (ctx) => ctx.activationMode === \"automatic\",\n },\n\n actions: {\n syncFocusedValue(ctx) {\n if (ctx.value != null && ctx.focusedValue == null) {\n ctx.focusedValue = ctx.value\n }\n },\n selectFocusedTab(ctx) {\n raf(() => {\n set.value(ctx, ctx.focusedValue)\n })\n },\n setFocusedValue(ctx, evt) {\n if (evt.value == null) return\n set.focusedValue(ctx, evt.value)\n },\n clearFocusedValue(ctx) {\n set.focusedValue(ctx, null)\n },\n setValue(ctx, evt) {\n set.value(ctx, evt.value)\n },\n clearValue(ctx) {\n set.value(ctx, null)\n },\n focusFirstTab(ctx) {\n raf(() => {\n dom.getFirstTriggerEl(ctx)?.focus()\n })\n },\n focusLastTab(ctx) {\n raf(() => {\n dom.getLastTriggerEl(ctx)?.focus()\n })\n },\n focusNextTab(ctx) {\n if (!ctx.focusedValue) return\n const triggerEl = dom.getNextTriggerEl(ctx, ctx.focusedValue)\n raf(() => {\n if (ctx.composite) {\n triggerEl?.focus()\n } else if (triggerEl?.dataset.value != null) {\n set.focusedValue(ctx, triggerEl.dataset.value)\n }\n })\n },\n focusPrevTab(ctx) {\n if (!ctx.focusedValue) return\n const triggerEl = dom.getPrevTriggerEl(ctx, ctx.focusedValue)\n raf(() => {\n if (ctx.composite) {\n triggerEl?.focus()\n } else if (triggerEl?.dataset.value != null) {\n set.focusedValue(ctx, triggerEl.dataset.value)\n }\n })\n },\n checkRenderedElements(ctx) {\n ctx.indicatorState.rendered = !!dom.getIndicatorEl(ctx)\n },\n syncTabIndex(ctx) {\n raf(() => {\n const contentEl = dom.getSelectedContentEl(ctx)\n if (!contentEl) return\n const focusables = getFocusables(contentEl)\n if (focusables.length > 0) {\n contentEl.removeAttribute(\"tabindex\")\n } else {\n contentEl.setAttribute(\"tabindex\", \"0\")\n }\n })\n },\n cleanupObserver(ctx) {\n ctx.indicatorCleanup?.()\n },\n allowIndicatorTransition(ctx) {\n ctx.indicatorState.transition = true\n },\n setIndicatorRect(ctx, evt) {\n const value = evt.id ?? ctx.value\n if (!ctx.indicatorState.rendered || !value) return\n\n const triggerEl = dom.getTriggerEl(ctx, value)\n if (!triggerEl) return\n\n ctx.indicatorState.rect = dom.getRectById(ctx, value)\n nextTick(() => {\n ctx.indicatorState.transition = false\n })\n },\n syncIndicatorRect(ctx) {\n ctx.indicatorCleanup?.()\n\n const value = ctx.value\n if (!ctx.indicatorState.rendered || !value) return\n\n const triggerEl = dom.getSelectedTriggerEl(ctx)\n if (!triggerEl) return\n\n ctx.indicatorCleanup = trackElementRect(triggerEl, {\n getRect(el) {\n return dom.getOffsetRect(el)\n },\n onChange(rect) {\n ctx.indicatorState.rect = dom.resolveRect(rect)\n nextTick(() => {\n ctx.indicatorState.transition = false\n })\n },\n })\n },\n clickIfLink(ctx) {\n clickIfLink(dom.getSelectedTriggerEl(ctx))\n },\n },\n },\n )\n}\n\nconst invoke = {\n change: (ctx: MachineContext) => {\n if (ctx.value == null) return\n ctx.onValueChange?.({ value: ctx.value })\n },\n focusChange: (ctx: MachineContext) => {\n if (ctx.focusedValue == null) return\n ctx.onFocusChange?.({ focusedValue: ctx.focusedValue })\n },\n}\n\nconst set = {\n value: (ctx: MachineContext, value: string | null) => {\n if (isEqual(value, ctx.value)) return\n ctx.value = value\n invoke.change(ctx)\n },\n focusedValue: (ctx: MachineContext, value: string | null) => {\n if (isEqual(value, ctx.focusedValue)) return\n ctx.focusedValue = value\n invoke.focusChange(ctx)\n },\n}\n","import { createProps } from \"@zag-js/types\"\nimport { createSplitProps } from \"@zag-js/utils\"\nimport type { ContentProps, TriggerProps, UserDefinedContext } from \"./tabs.types\"\n\nexport const props = createProps<UserDefinedContext>()([\n \"activationMode\",\n \"composite\",\n \"dir\",\n \"getRootNode\",\n \"id\",\n \"ids\",\n \"loopFocus\",\n \"onFocusChange\",\n \"onValueChange\",\n \"orientation\",\n \"translations\",\n \"value\",\n])\n\nexport const splitProps = createSplitProps<Partial<UserDefinedContext>>(props)\n\nexport const triggerProps = createProps<TriggerProps>()([\"disabled\", \"value\"])\nexport const splitTriggerProps = createSplitProps<TriggerProps>(triggerProps)\n\nexport const contentProps = createProps<ContentProps>()([\"value\"])\nexport const splitContentProps = createSplitProps<ContentProps>(contentProps)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAA8B;AAEvB,IAAM,cAAU,8BAAc,MAAM,EAAE,MAAM,QAAQ,QAAQ,WAAW,WAAW,WAAW;AAC7F,IAAM,QAAQ,QAAQ,MAAM;;;ACHnC,uBAA8D;AAC9D,IAAAA,oBAAiD;;;ACDjD,uBAAoE;AACpE,mBAA4B;AAGrB,IAAM,UAAM,8BAAY;AAAA,EAC7B,WAAW,CAAC,QAAa,IAAI,KAAK,QAAQ,QAAQ,IAAI,EAAE;AAAA,EACxD,WAAW,CAAC,QAAa,IAAI,KAAK,QAAQ,QAAQ,IAAI,EAAE;AAAA,EACxD,cAAc,CAAC,KAAU,OAAe,IAAI,KAAK,WAAW,QAAQ,IAAI,EAAE,YAAY,EAAE;AAAA,EACxF,cAAc,CAAC,KAAU,OAAe,IAAI,KAAK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AM,YAAQ,0BAAgC,EAAE;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,iBAAa,gCAA8C,KAAK;AAEtE,IAAM,mBAAe,0BAA0B,EAAE,CAAC,YAAY,OAAO,CAAC;AACtE,IAAM,wBAAoB,gCAA+B,YAAY;AAErE,IAAM,mBAAe,0BAA0B,EAAE,CAAC,OAAO,CAAC;AAC1D,IAAM,wBAAoB,gCAA+B,YAAY;","names":["import_dom_query","props","import_dom_event","import_dom_query","import_utils","ctx","import_utils"]}