@zag-js/tabs 1.43.0 → 2.0.0-next.1
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/tabs.connect.js +15 -16
- package/dist/tabs.connect.mjs +15 -16
- package/dist/tabs.dom.js +10 -10
- package/dist/tabs.dom.mjs +11 -11
- package/dist/tabs.machine.js +10 -7
- package/dist/tabs.machine.mjs +10 -7
- package/dist/tabs.props.js +1 -1
- package/dist/tabs.props.mjs +1 -1
- package/dist/tabs.types.d.mts +19 -3
- package/dist/tabs.types.d.ts +19 -3
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './tabs.anatomy.mjs';
|
|
|
2
2
|
export { connect } from './tabs.connect.mjs';
|
|
3
3
|
export { machine } from './tabs.machine.mjs';
|
|
4
4
|
export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps } from './tabs.props.mjs';
|
|
5
|
-
export { TabsApi as Api, ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.mjs';
|
|
5
|
+
export { TabsApi as Api, ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.mjs';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/core';
|
|
8
8
|
import '@zag-js/types';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './tabs.anatomy.js';
|
|
|
2
2
|
export { connect } from './tabs.connect.js';
|
|
3
3
|
export { machine } from './tabs.machine.js';
|
|
4
4
|
export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps } from './tabs.props.js';
|
|
5
|
-
export { TabsApi as Api, ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.js';
|
|
5
|
+
export { TabsApi as Api, ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.js';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/core';
|
|
8
8
|
import '@zag-js/types';
|
package/dist/tabs.connect.js
CHANGED
|
@@ -43,7 +43,7 @@ function connect(service, normalize) {
|
|
|
43
43
|
const focused = state.matches("focused");
|
|
44
44
|
const isVertical = prop("orientation") === "vertical";
|
|
45
45
|
const isHorizontal = prop("orientation") === "horizontal";
|
|
46
|
-
const
|
|
46
|
+
const virtualFocus = prop("virtualFocus");
|
|
47
47
|
function getTriggerState(props) {
|
|
48
48
|
return {
|
|
49
49
|
selected: context.get("value") === props.value,
|
|
@@ -51,6 +51,9 @@ function connect(service, normalize) {
|
|
|
51
51
|
disabled: !!props.disabled
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
function getContentState(props) {
|
|
55
|
+
return { selected: context.get("value") === props.value };
|
|
56
|
+
}
|
|
54
57
|
return {
|
|
55
58
|
value: context.get("value"),
|
|
56
59
|
focusedValue: context.get("focusedValue"),
|
|
@@ -82,8 +85,7 @@ function connect(service, normalize) {
|
|
|
82
85
|
},
|
|
83
86
|
getRootProps() {
|
|
84
87
|
return normalize.element({
|
|
85
|
-
...import_tabs.parts.root.attrs,
|
|
86
|
-
id: dom.getRootId(scope),
|
|
88
|
+
...import_tabs.parts.root.attrs(scope.id),
|
|
87
89
|
"data-orientation": prop("orientation"),
|
|
88
90
|
"data-focus": (0, import_dom_query.dataAttr)(focused),
|
|
89
91
|
dir: prop("dir")
|
|
@@ -91,8 +93,7 @@ function connect(service, normalize) {
|
|
|
91
93
|
},
|
|
92
94
|
getListProps() {
|
|
93
95
|
return normalize.element({
|
|
94
|
-
...import_tabs.parts.list.attrs,
|
|
95
|
-
id: dom.getListId(scope),
|
|
96
|
+
...import_tabs.parts.list.attrs(scope.id),
|
|
96
97
|
role: "tablist",
|
|
97
98
|
dir: prop("dir"),
|
|
98
99
|
"data-focus": (0, import_dom_query.dataAttr)(focused),
|
|
@@ -145,7 +146,7 @@ function connect(service, normalize) {
|
|
|
145
146
|
const { value, disabled } = props;
|
|
146
147
|
const triggerState = getTriggerState(props);
|
|
147
148
|
return normalize.button({
|
|
148
|
-
...import_tabs.parts.trigger.attrs,
|
|
149
|
+
...import_tabs.parts.trigger.attrs(scope.id),
|
|
149
150
|
role: "tab",
|
|
150
151
|
type: "button",
|
|
151
152
|
disabled,
|
|
@@ -158,10 +159,9 @@ function connect(service, normalize) {
|
|
|
158
159
|
"data-selected": (0, import_dom_query.dataAttr)(triggerState.selected),
|
|
159
160
|
"data-focus": (0, import_dom_query.dataAttr)(triggerState.focused),
|
|
160
161
|
"aria-controls": triggerState.selected ? dom.getContentId(scope, value) : void 0,
|
|
161
|
-
"data-ownedby": dom.getListId(scope),
|
|
162
162
|
"data-ssr": (0, import_dom_query.dataAttr)(context.get("ssr")),
|
|
163
163
|
id: dom.getTriggerId(scope, value),
|
|
164
|
-
tabIndex: triggerState.selected &&
|
|
164
|
+
tabIndex: triggerState.selected && !virtualFocus ? 0 : -1,
|
|
165
165
|
onFocus() {
|
|
166
166
|
send({ type: "TAB_FOCUS", value });
|
|
167
167
|
},
|
|
@@ -182,28 +182,27 @@ function connect(service, normalize) {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
},
|
|
185
|
+
getContentState,
|
|
185
186
|
getContentProps(props) {
|
|
186
187
|
const { value } = props;
|
|
187
|
-
const
|
|
188
|
+
const contentState = getContentState(props);
|
|
188
189
|
return normalize.element({
|
|
189
|
-
...import_tabs.parts.content.attrs,
|
|
190
|
+
...import_tabs.parts.content.attrs(scope.id),
|
|
190
191
|
dir: prop("dir"),
|
|
191
192
|
id: dom.getContentId(scope, value),
|
|
192
|
-
tabIndex:
|
|
193
|
+
tabIndex: !virtualFocus ? 0 : -1,
|
|
193
194
|
"aria-labelledby": dom.getTriggerId(scope, value),
|
|
194
195
|
role: "tabpanel",
|
|
195
|
-
"data-
|
|
196
|
-
"data-selected": (0, import_dom_query.dataAttr)(selected),
|
|
196
|
+
"data-selected": (0, import_dom_query.dataAttr)(contentState.selected),
|
|
197
197
|
"data-orientation": prop("orientation"),
|
|
198
|
-
hidden: !selected
|
|
198
|
+
hidden: !contentState.selected
|
|
199
199
|
});
|
|
200
200
|
},
|
|
201
201
|
getIndicatorProps() {
|
|
202
202
|
const rect = context.get("indicatorRect");
|
|
203
203
|
const animateIndicator = context.get("animateIndicator");
|
|
204
204
|
return normalize.element({
|
|
205
|
-
|
|
206
|
-
...import_tabs.parts.indicator.attrs,
|
|
205
|
+
...import_tabs.parts.indicator.attrs(scope.id),
|
|
207
206
|
dir: prop("dir"),
|
|
208
207
|
"data-orientation": prop("orientation"),
|
|
209
208
|
hidden: isRectEmpty(rect),
|
package/dist/tabs.connect.mjs
CHANGED
|
@@ -17,7 +17,7 @@ function connect(service, normalize) {
|
|
|
17
17
|
const focused = state.matches("focused");
|
|
18
18
|
const isVertical = prop("orientation") === "vertical";
|
|
19
19
|
const isHorizontal = prop("orientation") === "horizontal";
|
|
20
|
-
const
|
|
20
|
+
const virtualFocus = prop("virtualFocus");
|
|
21
21
|
function getTriggerState(props) {
|
|
22
22
|
return {
|
|
23
23
|
selected: context.get("value") === props.value,
|
|
@@ -25,6 +25,9 @@ function connect(service, normalize) {
|
|
|
25
25
|
disabled: !!props.disabled
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function getContentState(props) {
|
|
29
|
+
return { selected: context.get("value") === props.value };
|
|
30
|
+
}
|
|
28
31
|
return {
|
|
29
32
|
value: context.get("value"),
|
|
30
33
|
focusedValue: context.get("focusedValue"),
|
|
@@ -56,8 +59,7 @@ function connect(service, normalize) {
|
|
|
56
59
|
},
|
|
57
60
|
getRootProps() {
|
|
58
61
|
return normalize.element({
|
|
59
|
-
...parts.root.attrs,
|
|
60
|
-
id: dom.getRootId(scope),
|
|
62
|
+
...parts.root.attrs(scope.id),
|
|
61
63
|
"data-orientation": prop("orientation"),
|
|
62
64
|
"data-focus": dataAttr(focused),
|
|
63
65
|
dir: prop("dir")
|
|
@@ -65,8 +67,7 @@ function connect(service, normalize) {
|
|
|
65
67
|
},
|
|
66
68
|
getListProps() {
|
|
67
69
|
return normalize.element({
|
|
68
|
-
...parts.list.attrs,
|
|
69
|
-
id: dom.getListId(scope),
|
|
70
|
+
...parts.list.attrs(scope.id),
|
|
70
71
|
role: "tablist",
|
|
71
72
|
dir: prop("dir"),
|
|
72
73
|
"data-focus": dataAttr(focused),
|
|
@@ -119,7 +120,7 @@ function connect(service, normalize) {
|
|
|
119
120
|
const { value, disabled } = props;
|
|
120
121
|
const triggerState = getTriggerState(props);
|
|
121
122
|
return normalize.button({
|
|
122
|
-
...parts.trigger.attrs,
|
|
123
|
+
...parts.trigger.attrs(scope.id),
|
|
123
124
|
role: "tab",
|
|
124
125
|
type: "button",
|
|
125
126
|
disabled,
|
|
@@ -132,10 +133,9 @@ function connect(service, normalize) {
|
|
|
132
133
|
"data-selected": dataAttr(triggerState.selected),
|
|
133
134
|
"data-focus": dataAttr(triggerState.focused),
|
|
134
135
|
"aria-controls": triggerState.selected ? dom.getContentId(scope, value) : void 0,
|
|
135
|
-
"data-ownedby": dom.getListId(scope),
|
|
136
136
|
"data-ssr": dataAttr(context.get("ssr")),
|
|
137
137
|
id: dom.getTriggerId(scope, value),
|
|
138
|
-
tabIndex: triggerState.selected &&
|
|
138
|
+
tabIndex: triggerState.selected && !virtualFocus ? 0 : -1,
|
|
139
139
|
onFocus() {
|
|
140
140
|
send({ type: "TAB_FOCUS", value });
|
|
141
141
|
},
|
|
@@ -156,28 +156,27 @@ function connect(service, normalize) {
|
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
},
|
|
159
|
+
getContentState,
|
|
159
160
|
getContentProps(props) {
|
|
160
161
|
const { value } = props;
|
|
161
|
-
const
|
|
162
|
+
const contentState = getContentState(props);
|
|
162
163
|
return normalize.element({
|
|
163
|
-
...parts.content.attrs,
|
|
164
|
+
...parts.content.attrs(scope.id),
|
|
164
165
|
dir: prop("dir"),
|
|
165
166
|
id: dom.getContentId(scope, value),
|
|
166
|
-
tabIndex:
|
|
167
|
+
tabIndex: !virtualFocus ? 0 : -1,
|
|
167
168
|
"aria-labelledby": dom.getTriggerId(scope, value),
|
|
168
169
|
role: "tabpanel",
|
|
169
|
-
"data-
|
|
170
|
-
"data-selected": dataAttr(selected),
|
|
170
|
+
"data-selected": dataAttr(contentState.selected),
|
|
171
171
|
"data-orientation": prop("orientation"),
|
|
172
|
-
hidden: !selected
|
|
172
|
+
hidden: !contentState.selected
|
|
173
173
|
});
|
|
174
174
|
},
|
|
175
175
|
getIndicatorProps() {
|
|
176
176
|
const rect = context.get("indicatorRect");
|
|
177
177
|
const animateIndicator = context.get("animateIndicator");
|
|
178
178
|
return normalize.element({
|
|
179
|
-
|
|
180
|
-
...parts.indicator.attrs,
|
|
179
|
+
...parts.indicator.attrs(scope.id),
|
|
181
180
|
dir: prop("dir"),
|
|
182
181
|
"data-orientation": prop("orientation"),
|
|
183
182
|
hidden: isRectEmpty(rect),
|
package/dist/tabs.dom.js
CHANGED
|
@@ -40,18 +40,18 @@ __export(tabs_dom_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(tabs_dom_exports);
|
|
41
41
|
var import_dom_query = require("@zag-js/dom-query");
|
|
42
42
|
var import_utils = require("@zag-js/utils");
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
43
|
+
var import_tabs = require("./tabs.anatomy.js");
|
|
44
|
+
var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
|
|
45
|
+
var getListId = (ctx) => ctx.ids?.list ?? `${ctx.id}:list`;
|
|
46
|
+
var getContentId = (ctx, value) => ctx.ids?.content?.(value) ?? `${ctx.id}:content:${value}`;
|
|
47
|
+
var getTriggerId = (ctx, value) => ctx.ids?.trigger?.(value) ?? `${ctx.id}:trigger:${value}`;
|
|
48
|
+
var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `${ctx.id}:indicator`;
|
|
49
|
+
var getListEl = (ctx) => ctx.query(ctx.selector(import_tabs.parts.list));
|
|
49
50
|
var getContentEl = (ctx, value) => ctx.getById(getContentId(ctx, value));
|
|
50
|
-
var getTriggerEl = (ctx, value) => value != null ? ctx.
|
|
51
|
-
var getIndicatorEl = (ctx) => ctx.
|
|
51
|
+
var getTriggerEl = (ctx, value) => value != null ? ctx.query(`${ctx.selector(import_tabs.parts.trigger)}[data-value="${value}"]`) : null;
|
|
52
|
+
var getIndicatorEl = (ctx) => ctx.query(ctx.selector(import_tabs.parts.indicator));
|
|
52
53
|
var getElements = (ctx) => {
|
|
53
|
-
|
|
54
|
-
return (0, import_dom_query.queryAll)(getListEl(ctx), selector);
|
|
54
|
+
return ctx.queryAll(`${ctx.selector(import_tabs.parts.trigger)}:not([disabled])`);
|
|
55
55
|
};
|
|
56
56
|
var getFirstTriggerEl = (ctx) => (0, import_utils.first)(getElements(ctx));
|
|
57
57
|
var getLastTriggerEl = (ctx) => (0, import_utils.last)(getElements(ctx));
|
package/dist/tabs.dom.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// src/tabs.dom.ts
|
|
2
|
-
import {
|
|
2
|
+
import { itemById, nextById, prevById } from "@zag-js/dom-query";
|
|
3
3
|
import { first, last } from "@zag-js/utils";
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
4
|
+
import { parts } from "./tabs.anatomy.mjs";
|
|
5
|
+
var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
|
|
6
|
+
var getListId = (ctx) => ctx.ids?.list ?? `${ctx.id}:list`;
|
|
7
|
+
var getContentId = (ctx, value) => ctx.ids?.content?.(value) ?? `${ctx.id}:content:${value}`;
|
|
8
|
+
var getTriggerId = (ctx, value) => ctx.ids?.trigger?.(value) ?? `${ctx.id}:trigger:${value}`;
|
|
9
|
+
var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `${ctx.id}:indicator`;
|
|
10
|
+
var getListEl = (ctx) => ctx.query(ctx.selector(parts.list));
|
|
10
11
|
var getContentEl = (ctx, value) => ctx.getById(getContentId(ctx, value));
|
|
11
|
-
var getTriggerEl = (ctx, value) => value != null ? ctx.
|
|
12
|
-
var getIndicatorEl = (ctx) => ctx.
|
|
12
|
+
var getTriggerEl = (ctx, value) => value != null ? ctx.query(`${ctx.selector(parts.trigger)}[data-value="${value}"]`) : null;
|
|
13
|
+
var getIndicatorEl = (ctx) => ctx.query(ctx.selector(parts.indicator));
|
|
13
14
|
var getElements = (ctx) => {
|
|
14
|
-
|
|
15
|
-
return queryAll(getListEl(ctx), selector);
|
|
15
|
+
return ctx.queryAll(`${ctx.selector(parts.trigger)}:not([disabled])`);
|
|
16
16
|
};
|
|
17
17
|
var getFirstTriggerEl = (ctx) => first(getElements(ctx));
|
|
18
18
|
var getLastTriggerEl = (ctx) => last(getElements(ctx));
|
package/dist/tabs.machine.js
CHANGED
|
@@ -45,7 +45,6 @@ var machine = createMachine({
|
|
|
45
45
|
orientation: "horizontal",
|
|
46
46
|
activationMode: "automatic",
|
|
47
47
|
loopFocus: true,
|
|
48
|
-
composite: true,
|
|
49
48
|
navigate(details) {
|
|
50
49
|
(0, import_dom_query.clickIfLink)(details.node);
|
|
51
50
|
},
|
|
@@ -226,10 +225,12 @@ var machine = createMachine({
|
|
|
226
225
|
loopFocus: prop("loopFocus")
|
|
227
226
|
});
|
|
228
227
|
(0, import_dom_query.raf)(() => {
|
|
229
|
-
if (prop("
|
|
228
|
+
if (prop("virtualFocus")) {
|
|
229
|
+
if (triggerEl?.dataset.value != null) {
|
|
230
|
+
context.set("focusedValue", triggerEl.dataset.value);
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
230
233
|
triggerEl?.focus();
|
|
231
|
-
} else if (triggerEl?.dataset.value != null) {
|
|
232
|
-
context.set("focusedValue", triggerEl.dataset.value);
|
|
233
234
|
}
|
|
234
235
|
});
|
|
235
236
|
},
|
|
@@ -241,10 +242,12 @@ var machine = createMachine({
|
|
|
241
242
|
loopFocus: prop("loopFocus")
|
|
242
243
|
});
|
|
243
244
|
(0, import_dom_query.raf)(() => {
|
|
244
|
-
if (prop("
|
|
245
|
+
if (prop("virtualFocus")) {
|
|
246
|
+
if (triggerEl?.dataset.value != null) {
|
|
247
|
+
context.set("focusedValue", triggerEl.dataset.value);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
245
250
|
triggerEl?.focus();
|
|
246
|
-
} else if (triggerEl?.dataset.value != null) {
|
|
247
|
-
context.set("focusedValue", triggerEl.dataset.value);
|
|
248
251
|
}
|
|
249
252
|
});
|
|
250
253
|
},
|
package/dist/tabs.machine.mjs
CHANGED
|
@@ -11,7 +11,6 @@ var machine = createMachine({
|
|
|
11
11
|
orientation: "horizontal",
|
|
12
12
|
activationMode: "automatic",
|
|
13
13
|
loopFocus: true,
|
|
14
|
-
composite: true,
|
|
15
14
|
navigate(details) {
|
|
16
15
|
clickIfLink(details.node);
|
|
17
16
|
},
|
|
@@ -192,10 +191,12 @@ var machine = createMachine({
|
|
|
192
191
|
loopFocus: prop("loopFocus")
|
|
193
192
|
});
|
|
194
193
|
raf(() => {
|
|
195
|
-
if (prop("
|
|
194
|
+
if (prop("virtualFocus")) {
|
|
195
|
+
if (triggerEl?.dataset.value != null) {
|
|
196
|
+
context.set("focusedValue", triggerEl.dataset.value);
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
196
199
|
triggerEl?.focus();
|
|
197
|
-
} else if (triggerEl?.dataset.value != null) {
|
|
198
|
-
context.set("focusedValue", triggerEl.dataset.value);
|
|
199
200
|
}
|
|
200
201
|
});
|
|
201
202
|
},
|
|
@@ -207,10 +208,12 @@ var machine = createMachine({
|
|
|
207
208
|
loopFocus: prop("loopFocus")
|
|
208
209
|
});
|
|
209
210
|
raf(() => {
|
|
210
|
-
if (prop("
|
|
211
|
+
if (prop("virtualFocus")) {
|
|
212
|
+
if (triggerEl?.dataset.value != null) {
|
|
213
|
+
context.set("focusedValue", triggerEl.dataset.value);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
211
216
|
triggerEl?.focus();
|
|
212
|
-
} else if (triggerEl?.dataset.value != null) {
|
|
213
|
-
context.set("focusedValue", triggerEl.dataset.value);
|
|
214
217
|
}
|
|
215
218
|
});
|
|
216
219
|
},
|
package/dist/tabs.props.js
CHANGED
package/dist/tabs.props.mjs
CHANGED
package/dist/tabs.types.d.mts
CHANGED
|
@@ -70,9 +70,15 @@ interface TabsProps extends DirectionProperty, CommonProperties {
|
|
|
70
70
|
*/
|
|
71
71
|
onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
|
|
72
72
|
/**
|
|
73
|
-
* Whether the
|
|
73
|
+
* Whether the tabs use virtual focus instead of roving tabindex.
|
|
74
|
+
*
|
|
75
|
+
* When `true`, triggers receive no DOM focus — arrow keys update `focusedValue`
|
|
76
|
+
* and all triggers remain `tabIndex: -1`. Useful when tabs live inside another
|
|
77
|
+
* widget that manages focus (e.g. a combobox).
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
74
80
|
*/
|
|
75
|
-
|
|
81
|
+
virtualFocus?: boolean | undefined;
|
|
76
82
|
/**
|
|
77
83
|
* Whether the active tab can be deselected when clicking on it.
|
|
78
84
|
*/
|
|
@@ -138,6 +144,12 @@ interface ContentProps {
|
|
|
138
144
|
*/
|
|
139
145
|
value: string;
|
|
140
146
|
}
|
|
147
|
+
interface ContentState {
|
|
148
|
+
/**
|
|
149
|
+
* Whether the tab content is selected
|
|
150
|
+
*/
|
|
151
|
+
selected: boolean;
|
|
152
|
+
}
|
|
141
153
|
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
142
154
|
/**
|
|
143
155
|
* The current value of the tabs.
|
|
@@ -183,8 +195,12 @@ interface TabsApi<T extends PropTypes = PropTypes> {
|
|
|
183
195
|
getRootProps: () => T["element"];
|
|
184
196
|
getListProps: () => T["element"];
|
|
185
197
|
getTriggerProps: (props: TriggerProps) => T["button"];
|
|
198
|
+
/**
|
|
199
|
+
* Returns the state of the content with the given props
|
|
200
|
+
*/
|
|
201
|
+
getContentState: (props: ContentProps) => ContentState;
|
|
186
202
|
getContentProps: (props: ContentProps) => T["element"];
|
|
187
203
|
getIndicatorProps: () => T["element"];
|
|
188
204
|
}
|
|
189
205
|
|
|
190
|
-
export type { ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
|
206
|
+
export type { ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
package/dist/tabs.types.d.ts
CHANGED
|
@@ -70,9 +70,15 @@ interface TabsProps extends DirectionProperty, CommonProperties {
|
|
|
70
70
|
*/
|
|
71
71
|
onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
|
|
72
72
|
/**
|
|
73
|
-
* Whether the
|
|
73
|
+
* Whether the tabs use virtual focus instead of roving tabindex.
|
|
74
|
+
*
|
|
75
|
+
* When `true`, triggers receive no DOM focus — arrow keys update `focusedValue`
|
|
76
|
+
* and all triggers remain `tabIndex: -1`. Useful when tabs live inside another
|
|
77
|
+
* widget that manages focus (e.g. a combobox).
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
74
80
|
*/
|
|
75
|
-
|
|
81
|
+
virtualFocus?: boolean | undefined;
|
|
76
82
|
/**
|
|
77
83
|
* Whether the active tab can be deselected when clicking on it.
|
|
78
84
|
*/
|
|
@@ -138,6 +144,12 @@ interface ContentProps {
|
|
|
138
144
|
*/
|
|
139
145
|
value: string;
|
|
140
146
|
}
|
|
147
|
+
interface ContentState {
|
|
148
|
+
/**
|
|
149
|
+
* Whether the tab content is selected
|
|
150
|
+
*/
|
|
151
|
+
selected: boolean;
|
|
152
|
+
}
|
|
141
153
|
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
142
154
|
/**
|
|
143
155
|
* The current value of the tabs.
|
|
@@ -183,8 +195,12 @@ interface TabsApi<T extends PropTypes = PropTypes> {
|
|
|
183
195
|
getRootProps: () => T["element"];
|
|
184
196
|
getListProps: () => T["element"];
|
|
185
197
|
getTriggerProps: (props: TriggerProps) => T["button"];
|
|
198
|
+
/**
|
|
199
|
+
* Returns the state of the content with the given props
|
|
200
|
+
*/
|
|
201
|
+
getContentState: (props: ContentProps) => ContentState;
|
|
186
202
|
getContentProps: (props: ContentProps) => T["element"];
|
|
187
203
|
getIndicatorProps: () => T["element"];
|
|
188
204
|
}
|
|
189
205
|
|
|
190
|
-
export type { ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
|
206
|
+
export type { ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tabs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "Core logic for the tabs widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/anatomy": "
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/
|
|
35
|
-
"@zag-js/
|
|
36
|
-
"@zag-js/
|
|
32
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
33
|
+
"@zag-js/utils": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/types": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/core": "2.0.0-next.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"clean-package": "2.2.0"
|