@zag-js/tabs 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -7
- package/dist/index.js +8 -491
- package/dist/index.mjs +3 -15
- package/dist/tabs.anatomy.d.ts +3 -6
- package/dist/tabs.anatomy.js +10 -33
- package/dist/tabs.anatomy.mjs +6 -8
- package/dist/tabs.connect.d.ts +3 -7
- package/dist/tabs.connect.js +30 -112
- package/dist/tabs.connect.mjs +159 -8
- package/dist/tabs.dom.d.ts +20 -25
- package/dist/tabs.dom.js +15 -37
- package/dist/tabs.dom.mjs +56 -6
- package/dist/tabs.machine.d.ts +3 -7
- package/dist/tabs.machine.js +31 -109
- package/dist/tabs.machine.mjs +247 -7
- package/dist/tabs.types.d.ts +10 -12
- package/package.json +10 -15
- package/dist/chunk-EU4R7SET.mjs +0 -58
- package/dist/chunk-GMBCGZJ4.mjs +0 -166
- package/dist/chunk-HGL32F6R.mjs +0 -252
- package/dist/chunk-S2KW2DT4.mjs +0 -9
- package/dist/tabs.types.js +0 -18
- package/dist/tabs.types.mjs +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export { anatomy } from
|
|
2
|
-
export { connect } from
|
|
3
|
-
export { machine } from
|
|
4
|
-
export {
|
|
5
|
-
import '@zag-js/anatomy';
|
|
6
|
-
import '@zag-js/types';
|
|
7
|
-
import '@zag-js/core';
|
|
1
|
+
export { anatomy } from "./tabs.anatomy";
|
|
2
|
+
export { connect } from "./tabs.connect";
|
|
3
|
+
export { machine } from "./tabs.machine";
|
|
4
|
+
export type { UserDefinedContext as Context, TriggerProps, ContentProps } from "./tabs.types";
|
package/dist/index.js
CHANGED
|
@@ -1,496 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
anatomy: () => anatomy,
|
|
24
|
-
connect: () => connect,
|
|
25
|
-
machine: () => machine
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(src_exports);
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
28
4
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var parts = anatomy.build();
|
|
5
|
+
const tabs_anatomy = require('./tabs.anatomy.js');
|
|
6
|
+
const tabs_connect = require('./tabs.connect.js');
|
|
7
|
+
const tabs_machine = require('./tabs.machine.js');
|
|
33
8
|
|
|
34
|
-
// src/tabs.connect.ts
|
|
35
|
-
var import_dom_event = require("@zag-js/dom-event");
|
|
36
|
-
var import_dom_query2 = require("@zag-js/dom-query");
|
|
37
9
|
|
|
38
|
-
// src/tabs.dom.ts
|
|
39
|
-
var import_dom_query = require("@zag-js/dom-query");
|
|
40
|
-
var import_utils = require("@zag-js/utils");
|
|
41
|
-
var dom = (0, import_dom_query.createScope)({
|
|
42
|
-
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
43
|
-
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
44
|
-
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
45
|
-
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
46
|
-
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
47
|
-
getIndicatorId: (ctx) => ctx.ids?.indicator ?? `tabs:${ctx.id}:indicator`,
|
|
48
|
-
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
49
|
-
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
50
|
-
getTriggerEl: (ctx, id) => dom.getById(ctx, dom.getTriggerId(ctx, id)),
|
|
51
|
-
getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
|
|
52
|
-
getElements: (ctx) => {
|
|
53
|
-
const ownerId = CSS.escape(dom.getTablistId(ctx));
|
|
54
|
-
const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`;
|
|
55
|
-
return (0, import_dom_query.queryAll)(dom.getTablistEl(ctx), selector);
|
|
56
|
-
},
|
|
57
|
-
getFirstEl: (ctx) => (0, import_utils.first)(dom.getElements(ctx)),
|
|
58
|
-
getLastEl: (ctx) => (0, import_utils.last)(dom.getElements(ctx)),
|
|
59
|
-
getNextEl: (ctx, id) => (0, import_dom_query.nextById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loop),
|
|
60
|
-
getPrevEl: (ctx, id) => (0, import_dom_query.prevById)(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loop),
|
|
61
|
-
getActiveContentEl: (ctx) => {
|
|
62
|
-
if (!ctx.value)
|
|
63
|
-
return;
|
|
64
|
-
return dom.getContentEl(ctx, ctx.value);
|
|
65
|
-
},
|
|
66
|
-
getActiveTabEl: (ctx) => {
|
|
67
|
-
if (!ctx.value)
|
|
68
|
-
return;
|
|
69
|
-
return dom.getTriggerEl(ctx, ctx.value);
|
|
70
|
-
},
|
|
71
|
-
getOffsetRect: (el) => {
|
|
72
|
-
return {
|
|
73
|
-
left: el?.offsetLeft ?? 0,
|
|
74
|
-
top: el?.offsetTop ?? 0,
|
|
75
|
-
width: el?.offsetWidth ?? 0,
|
|
76
|
-
height: el?.offsetHeight ?? 0
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
getRectById: (ctx, id) => {
|
|
80
|
-
const tab = (0, import_dom_query.itemById)(dom.getElements(ctx), dom.getTriggerId(ctx, id));
|
|
81
|
-
return dom.resolveRect(dom.getOffsetRect(tab), ctx.orientation);
|
|
82
|
-
},
|
|
83
|
-
resolveRect(rect, orientation) {
|
|
84
|
-
const sizeProp = orientation === "vertical" ? "height" : "width";
|
|
85
|
-
const placementProp = orientation === "vertical" ? "top" : "left";
|
|
86
|
-
return {
|
|
87
|
-
[placementProp]: `${rect[placementProp]}px`,
|
|
88
|
-
[sizeProp]: `${rect[sizeProp]}px`
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
10
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const isFocused = state.matches("focused");
|
|
97
|
-
return {
|
|
98
|
-
/**
|
|
99
|
-
* The current value of the tabs.
|
|
100
|
-
*/
|
|
101
|
-
value: state.context.value,
|
|
102
|
-
/**
|
|
103
|
-
* The value of the tab that is currently focused.
|
|
104
|
-
*/
|
|
105
|
-
focusedValue: state.context.focusedValue,
|
|
106
|
-
/**
|
|
107
|
-
* The previous values of the tabs in sequence of selection.
|
|
108
|
-
*/
|
|
109
|
-
previousValues: Array.from(state.context.previousValues),
|
|
110
|
-
/**
|
|
111
|
-
* Sets the value of the tabs.
|
|
112
|
-
*/
|
|
113
|
-
setValue(value) {
|
|
114
|
-
send({ type: "SET_VALUE", value });
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* Clears the value of the tabs.
|
|
118
|
-
*/
|
|
119
|
-
clearValue() {
|
|
120
|
-
send({ type: "CLEAR_VALUE" });
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
* Sets the indicator rect to the tab with the given id.
|
|
124
|
-
*/
|
|
125
|
-
setIndicatorRect(id) {
|
|
126
|
-
send({ type: "SET_INDICATOR_RECT", id });
|
|
127
|
-
},
|
|
128
|
-
rootProps: normalize.element({
|
|
129
|
-
...parts.root.attrs,
|
|
130
|
-
id: dom.getRootId(state.context),
|
|
131
|
-
"data-orientation": state.context.orientation,
|
|
132
|
-
"data-focus": (0, import_dom_query2.dataAttr)(isFocused),
|
|
133
|
-
dir: state.context.dir
|
|
134
|
-
}),
|
|
135
|
-
tablistProps: normalize.element({
|
|
136
|
-
...parts.tablist.attrs,
|
|
137
|
-
id: dom.getTablistId(state.context),
|
|
138
|
-
role: "tablist",
|
|
139
|
-
"data-focus": (0, import_dom_query2.dataAttr)(isFocused),
|
|
140
|
-
"aria-orientation": state.context.orientation,
|
|
141
|
-
"data-orientation": state.context.orientation,
|
|
142
|
-
"aria-label": translations.tablistLabel,
|
|
143
|
-
onKeyDown(event) {
|
|
144
|
-
const keyMap = {
|
|
145
|
-
ArrowDown() {
|
|
146
|
-
send("ARROW_DOWN");
|
|
147
|
-
},
|
|
148
|
-
ArrowUp() {
|
|
149
|
-
send("ARROW_UP");
|
|
150
|
-
},
|
|
151
|
-
ArrowLeft() {
|
|
152
|
-
send("ARROW_LEFT");
|
|
153
|
-
},
|
|
154
|
-
ArrowRight() {
|
|
155
|
-
send("ARROW_RIGHT");
|
|
156
|
-
},
|
|
157
|
-
Home() {
|
|
158
|
-
send("HOME");
|
|
159
|
-
},
|
|
160
|
-
End() {
|
|
161
|
-
send("END");
|
|
162
|
-
},
|
|
163
|
-
Enter() {
|
|
164
|
-
send({ type: "ENTER", value: state.context.focusedValue });
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
let key = (0, import_dom_event.getEventKey)(event, state.context);
|
|
168
|
-
const exec = keyMap[key];
|
|
169
|
-
if (exec) {
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
exec(event);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}),
|
|
175
|
-
getTriggerProps(props) {
|
|
176
|
-
const { value, disabled } = props;
|
|
177
|
-
const selected = state.context.value === value;
|
|
178
|
-
return normalize.button({
|
|
179
|
-
...parts.trigger.attrs,
|
|
180
|
-
role: "tab",
|
|
181
|
-
type: "button",
|
|
182
|
-
disabled,
|
|
183
|
-
"data-orientation": state.context.orientation,
|
|
184
|
-
"data-disabled": (0, import_dom_query2.dataAttr)(disabled),
|
|
185
|
-
"aria-disabled": disabled,
|
|
186
|
-
"data-value": value,
|
|
187
|
-
"aria-selected": selected,
|
|
188
|
-
"data-selected": (0, import_dom_query2.dataAttr)(selected),
|
|
189
|
-
"aria-controls": dom.getContentId(state.context, value),
|
|
190
|
-
"data-ownedby": dom.getTablistId(state.context),
|
|
191
|
-
id: dom.getTriggerId(state.context, value),
|
|
192
|
-
tabIndex: selected ? 0 : -1,
|
|
193
|
-
onFocus() {
|
|
194
|
-
send({ type: "TAB_FOCUS", value });
|
|
195
|
-
},
|
|
196
|
-
onBlur(event) {
|
|
197
|
-
const target = event.relatedTarget;
|
|
198
|
-
if (target?.getAttribute("role") !== "tab") {
|
|
199
|
-
send({ type: "TAB_BLUR" });
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
onClick(event) {
|
|
203
|
-
if (disabled)
|
|
204
|
-
return;
|
|
205
|
-
if ((0, import_dom_query2.isSafari)()) {
|
|
206
|
-
event.currentTarget.focus();
|
|
207
|
-
}
|
|
208
|
-
send({ type: "TAB_CLICK", value });
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
},
|
|
212
|
-
contentGroupProps: normalize.element({
|
|
213
|
-
...parts.contentGroup.attrs,
|
|
214
|
-
id: dom.getContentGroupId(state.context),
|
|
215
|
-
"data-orientation": state.context.orientation
|
|
216
|
-
}),
|
|
217
|
-
getContentProps({ value }) {
|
|
218
|
-
const selected = state.context.value === value;
|
|
219
|
-
return normalize.element({
|
|
220
|
-
...parts.content.attrs,
|
|
221
|
-
id: dom.getContentId(state.context, value),
|
|
222
|
-
tabIndex: 0,
|
|
223
|
-
"aria-labelledby": dom.getTriggerId(state.context, value),
|
|
224
|
-
role: "tabpanel",
|
|
225
|
-
"data-ownedby": dom.getTablistId(state.context),
|
|
226
|
-
hidden: !selected
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
indicatorProps: normalize.element({
|
|
230
|
-
id: dom.getIndicatorId(state.context),
|
|
231
|
-
...parts.indicator.attrs,
|
|
232
|
-
"data-orientation": state.context.orientation,
|
|
233
|
-
style: {
|
|
234
|
-
"--transition-duration": "150ms",
|
|
235
|
-
"--transition-property": "left, right, top, bottom, width, height",
|
|
236
|
-
position: "absolute",
|
|
237
|
-
willChange: "var(--transition-property)",
|
|
238
|
-
transitionProperty: "var(--transition-property)",
|
|
239
|
-
transitionDuration: state.context.canIndicatorTransition ? "var(--transition-duration)" : "0ms",
|
|
240
|
-
transitionTimingFunction: "var(--transition-timing-function)",
|
|
241
|
-
...state.context.indicatorRect
|
|
242
|
-
}
|
|
243
|
-
})
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// src/tabs.machine.ts
|
|
248
|
-
var import_core = require("@zag-js/core");
|
|
249
|
-
var import_dom_query3 = require("@zag-js/dom-query");
|
|
250
|
-
var import_element_rect = require("@zag-js/element-rect");
|
|
251
|
-
var import_tabbable = require("@zag-js/tabbable");
|
|
252
|
-
var import_utils2 = require("@zag-js/utils");
|
|
253
|
-
var { not } = import_core.guards;
|
|
254
|
-
function machine(userContext) {
|
|
255
|
-
const ctx = (0, import_utils2.compact)(userContext);
|
|
256
|
-
return (0, import_core.createMachine)(
|
|
257
|
-
{
|
|
258
|
-
initial: "idle",
|
|
259
|
-
context: {
|
|
260
|
-
dir: "ltr",
|
|
261
|
-
orientation: "horizontal",
|
|
262
|
-
activationMode: "automatic",
|
|
263
|
-
value: null,
|
|
264
|
-
focusedValue: null,
|
|
265
|
-
previousValues: [],
|
|
266
|
-
indicatorRect: {
|
|
267
|
-
left: "0px",
|
|
268
|
-
top: "0px",
|
|
269
|
-
width: "0px",
|
|
270
|
-
height: "0px"
|
|
271
|
-
},
|
|
272
|
-
canIndicatorTransition: false,
|
|
273
|
-
isIndicatorRendered: false,
|
|
274
|
-
loop: true,
|
|
275
|
-
translations: {},
|
|
276
|
-
...ctx
|
|
277
|
-
},
|
|
278
|
-
computed: {
|
|
279
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
280
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
281
|
-
},
|
|
282
|
-
created: ["setPrevSelectedTabs"],
|
|
283
|
-
entry: ["checkRenderedElements", "syncIndicatorRect", "setContentTabIndex"],
|
|
284
|
-
exit: ["cleanupObserver"],
|
|
285
|
-
watch: {
|
|
286
|
-
focusedValue: "invokeOnFocus",
|
|
287
|
-
value: [
|
|
288
|
-
"enableIndicatorTransition",
|
|
289
|
-
"invokeOnChange",
|
|
290
|
-
"setPrevSelectedTabs",
|
|
291
|
-
"syncIndicatorRect",
|
|
292
|
-
"setContentTabIndex"
|
|
293
|
-
],
|
|
294
|
-
dir: ["syncIndicatorRect"],
|
|
295
|
-
orientation: ["syncIndicatorRect"]
|
|
296
|
-
},
|
|
297
|
-
on: {
|
|
298
|
-
SET_VALUE: {
|
|
299
|
-
actions: "setValue"
|
|
300
|
-
},
|
|
301
|
-
CLEAR_VALUE: {
|
|
302
|
-
actions: "clearValue"
|
|
303
|
-
},
|
|
304
|
-
SET_INDICATOR_RECT: {
|
|
305
|
-
actions: "setIndicatorRect"
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
states: {
|
|
309
|
-
idle: {
|
|
310
|
-
on: {
|
|
311
|
-
TAB_FOCUS: [
|
|
312
|
-
{
|
|
313
|
-
guard: "selectOnFocus",
|
|
314
|
-
target: "focused",
|
|
315
|
-
actions: ["setFocusedValue", "setValue"]
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
target: "focused",
|
|
319
|
-
actions: "setFocusedValue"
|
|
320
|
-
}
|
|
321
|
-
],
|
|
322
|
-
TAB_CLICK: {
|
|
323
|
-
target: "focused",
|
|
324
|
-
actions: ["setFocusedValue", "setValue"]
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
focused: {
|
|
329
|
-
on: {
|
|
330
|
-
TAB_CLICK: {
|
|
331
|
-
target: "focused",
|
|
332
|
-
actions: ["setFocusedValue", "setValue"]
|
|
333
|
-
},
|
|
334
|
-
ARROW_LEFT: {
|
|
335
|
-
guard: "isHorizontal",
|
|
336
|
-
actions: "focusPrevTab"
|
|
337
|
-
},
|
|
338
|
-
ARROW_RIGHT: {
|
|
339
|
-
guard: "isHorizontal",
|
|
340
|
-
actions: "focusNextTab"
|
|
341
|
-
},
|
|
342
|
-
ARROW_UP: {
|
|
343
|
-
guard: "isVertical",
|
|
344
|
-
actions: "focusPrevTab"
|
|
345
|
-
},
|
|
346
|
-
ARROW_DOWN: {
|
|
347
|
-
guard: "isVertical",
|
|
348
|
-
actions: "focusNextTab"
|
|
349
|
-
},
|
|
350
|
-
HOME: {
|
|
351
|
-
actions: "focusFirstTab"
|
|
352
|
-
},
|
|
353
|
-
END: {
|
|
354
|
-
actions: "focusLastTab"
|
|
355
|
-
},
|
|
356
|
-
ENTER: {
|
|
357
|
-
guard: not("selectOnFocus"),
|
|
358
|
-
actions: "setValue"
|
|
359
|
-
},
|
|
360
|
-
TAB_FOCUS: [
|
|
361
|
-
{
|
|
362
|
-
guard: "selectOnFocus",
|
|
363
|
-
actions: ["setFocusedValue", "setValue"]
|
|
364
|
-
},
|
|
365
|
-
{ actions: "setFocusedValue" }
|
|
366
|
-
],
|
|
367
|
-
TAB_BLUR: {
|
|
368
|
-
target: "idle",
|
|
369
|
-
actions: "clearFocusedValue"
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
guards: {
|
|
377
|
-
isVertical: (ctx2) => ctx2.isVertical,
|
|
378
|
-
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
379
|
-
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
380
|
-
},
|
|
381
|
-
actions: {
|
|
382
|
-
setFocusedValue(ctx2, evt) {
|
|
383
|
-
ctx2.focusedValue = evt.value;
|
|
384
|
-
},
|
|
385
|
-
clearFocusedValue(ctx2) {
|
|
386
|
-
ctx2.focusedValue = null;
|
|
387
|
-
},
|
|
388
|
-
setValue(ctx2, evt) {
|
|
389
|
-
ctx2.value = evt.value;
|
|
390
|
-
},
|
|
391
|
-
clearValue(ctx2) {
|
|
392
|
-
ctx2.value = null;
|
|
393
|
-
},
|
|
394
|
-
focusFirstTab(ctx2) {
|
|
395
|
-
(0, import_dom_query3.raf)(() => dom.getFirstEl(ctx2)?.focus());
|
|
396
|
-
},
|
|
397
|
-
focusLastTab(ctx2) {
|
|
398
|
-
(0, import_dom_query3.raf)(() => dom.getLastEl(ctx2)?.focus());
|
|
399
|
-
},
|
|
400
|
-
focusNextTab(ctx2) {
|
|
401
|
-
if (!ctx2.focusedValue)
|
|
402
|
-
return;
|
|
403
|
-
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
404
|
-
(0, import_dom_query3.raf)(() => next?.focus());
|
|
405
|
-
},
|
|
406
|
-
focusPrevTab(ctx2) {
|
|
407
|
-
if (!ctx2.focusedValue)
|
|
408
|
-
return;
|
|
409
|
-
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
410
|
-
(0, import_dom_query3.raf)(() => prev?.focus());
|
|
411
|
-
},
|
|
412
|
-
checkRenderedElements(ctx2) {
|
|
413
|
-
ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
|
|
414
|
-
},
|
|
415
|
-
invokeOnChange(ctx2) {
|
|
416
|
-
ctx2.onChange?.({ value: ctx2.value });
|
|
417
|
-
},
|
|
418
|
-
invokeOnFocus(ctx2) {
|
|
419
|
-
ctx2.onFocus?.({ value: ctx2.focusedValue });
|
|
420
|
-
},
|
|
421
|
-
setPrevSelectedTabs(ctx2) {
|
|
422
|
-
if (ctx2.value != null) {
|
|
423
|
-
ctx2.previousValues = pushUnique(ctx2.previousValues, ctx2.value);
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
// if tab panel contains focusable elements, remove the tabindex attribute
|
|
427
|
-
setContentTabIndex(ctx2) {
|
|
428
|
-
(0, import_dom_query3.raf)(() => {
|
|
429
|
-
const panel = dom.getActiveContentEl(ctx2);
|
|
430
|
-
if (!panel)
|
|
431
|
-
return;
|
|
432
|
-
const focusables = (0, import_tabbable.getFocusables)(panel);
|
|
433
|
-
if (focusables.length > 0) {
|
|
434
|
-
panel.removeAttribute("tabindex");
|
|
435
|
-
} else {
|
|
436
|
-
panel.setAttribute("tabindex", "0");
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
},
|
|
440
|
-
cleanupObserver(ctx2) {
|
|
441
|
-
ctx2.indicatorCleanup?.();
|
|
442
|
-
},
|
|
443
|
-
enableIndicatorTransition(ctx2) {
|
|
444
|
-
ctx2.canIndicatorTransition = true;
|
|
445
|
-
},
|
|
446
|
-
setIndicatorRect(ctx2, evt) {
|
|
447
|
-
const value = evt.id ?? ctx2.value;
|
|
448
|
-
if (!ctx2.isIndicatorRendered || !value)
|
|
449
|
-
return;
|
|
450
|
-
const tabEl = dom.getTriggerEl(ctx2, value);
|
|
451
|
-
if (!tabEl)
|
|
452
|
-
return;
|
|
453
|
-
ctx2.indicatorRect = dom.getRectById(ctx2, value);
|
|
454
|
-
(0, import_dom_query3.nextTick)(() => {
|
|
455
|
-
ctx2.canIndicatorTransition = false;
|
|
456
|
-
});
|
|
457
|
-
},
|
|
458
|
-
syncIndicatorRect(ctx2) {
|
|
459
|
-
ctx2.indicatorCleanup?.();
|
|
460
|
-
const value = ctx2.value;
|
|
461
|
-
if (!ctx2.isIndicatorRendered || !value)
|
|
462
|
-
return;
|
|
463
|
-
const tabEl = dom.getActiveTabEl(ctx2);
|
|
464
|
-
if (!tabEl)
|
|
465
|
-
return;
|
|
466
|
-
ctx2.indicatorCleanup = (0, import_element_rect.trackElementRect)(tabEl, {
|
|
467
|
-
getRect(el) {
|
|
468
|
-
return dom.getOffsetRect(el);
|
|
469
|
-
},
|
|
470
|
-
onChange(rect) {
|
|
471
|
-
ctx2.indicatorRect = dom.resolveRect(rect, ctx2.orientation);
|
|
472
|
-
(0, import_dom_query3.nextTick)(() => {
|
|
473
|
-
ctx2.canIndicatorTransition = false;
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
);
|
|
481
|
-
}
|
|
482
|
-
function pushUnique(arr, value) {
|
|
483
|
-
const newArr = Array.from(arr).slice();
|
|
484
|
-
const index = newArr.indexOf(value);
|
|
485
|
-
if (index > -1) {
|
|
486
|
-
newArr.splice(index, 1);
|
|
487
|
-
}
|
|
488
|
-
newArr.push(value);
|
|
489
|
-
return newArr;
|
|
490
|
-
}
|
|
491
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
492
|
-
0 && (module.exports = {
|
|
493
|
-
anatomy,
|
|
494
|
-
connect,
|
|
495
|
-
machine
|
|
496
|
-
});
|
|
11
|
+
exports.anatomy = tabs_anatomy.anatomy;
|
|
12
|
+
exports.connect = tabs_connect.connect;
|
|
13
|
+
exports.machine = tabs_machine.machine;
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
} from
|
|
4
|
-
import {
|
|
5
|
-
anatomy
|
|
6
|
-
} from "./chunk-S2KW2DT4.mjs";
|
|
7
|
-
import {
|
|
8
|
-
machine
|
|
9
|
-
} from "./chunk-HGL32F6R.mjs";
|
|
10
|
-
import "./chunk-EU4R7SET.mjs";
|
|
11
|
-
export {
|
|
12
|
-
anatomy,
|
|
13
|
-
connect,
|
|
14
|
-
machine
|
|
15
|
-
};
|
|
1
|
+
export { anatomy } from './tabs.anatomy.mjs';
|
|
2
|
+
export { connect } from './tabs.connect.mjs';
|
|
3
|
+
export { machine } from './tabs.machine.mjs';
|
package/dist/tabs.anatomy.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const parts: Record<"root" | "tablist" | "trigger" | "contentGroup" | "content" | "indicator", _zag_js_anatomy.AnatomyPart>;
|
|
5
|
-
|
|
6
|
-
export { anatomy, parts };
|
|
1
|
+
import { AnatomyInstance, AnatomyPart } from '@zag-js/anatomy';
|
|
2
|
+
export declare const anatomy: AnatomyInstance<"root" | "tablist" | "trigger" | "contentGroup" | "content" | "indicator">;
|
|
3
|
+
export declare const parts: Record<"root" | "tablist" | "trigger" | "contentGroup" | "content" | "indicator", AnatomyPart>;
|
package/dist/tabs.anatomy.js
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
'use strict';
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var parts = anatomy.build();
|
|
30
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
-
0 && (module.exports = {
|
|
32
|
-
anatomy,
|
|
33
|
-
parts
|
|
34
|
-
});
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const anatomy$1 = require('@zag-js/anatomy');
|
|
6
|
+
|
|
7
|
+
const anatomy = anatomy$1.createAnatomy("tabs").parts("root", "tablist", "trigger", "contentGroup", "content", "indicator");
|
|
8
|
+
const parts = anatomy.build();
|
|
9
|
+
|
|
10
|
+
exports.anatomy = anatomy;
|
|
11
|
+
exports.parts = parts;
|
package/dist/tabs.anatomy.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
parts
|
|
8
|
-
};
|
|
1
|
+
import { createAnatomy } from '@zag-js/anatomy';
|
|
2
|
+
|
|
3
|
+
const anatomy = createAnatomy("tabs").parts("root", "tablist", "trigger", "contentGroup", "content", "indicator");
|
|
4
|
+
const parts = anatomy.build();
|
|
5
|
+
|
|
6
|
+
export { anatomy, parts };
|
package/dist/tabs.connect.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { ContentProps, Send, State, TriggerProps } from "./tabs.types";
|
|
3
|
+
export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
6
4
|
/**
|
|
7
5
|
* The current value of the tabs.
|
|
8
6
|
*/
|
|
@@ -34,5 +32,3 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
|
|
|
34
32
|
getContentProps({ value }: ContentProps): T["element"];
|
|
35
33
|
indicatorProps: T["element"];
|
|
36
34
|
};
|
|
37
|
-
|
|
38
|
-
export { connect };
|