@zag-js/tabs 0.2.8 → 0.2.9
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/{chunk-T37OKX74.mjs → chunk-3DBUWLYX.mjs} +10 -26
- package/dist/{chunk-OCAWEK4A.mjs → chunk-4CROPD6E.mjs} +12 -36
- package/dist/{chunk-GUXUMDPX.mjs → chunk-IVTIBLCN.mjs} +5 -7
- package/dist/{chunk-BBWXWUXV.mjs → chunk-S2KW2DT4.mjs} +0 -0
- package/dist/index.js +24 -66
- package/dist/index.mjs +4 -4
- package/dist/tabs.anatomy.mjs +1 -1
- package/dist/tabs.connect.js +14 -40
- package/dist/tabs.connect.mjs +3 -3
- package/dist/tabs.dom.js +11 -35
- package/dist/tabs.dom.mjs +1 -1
- package/dist/tabs.machine.js +21 -61
- package/dist/tabs.machine.mjs +2 -2
- package/dist/tabs.types.d.ts +1 -1
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isFrame,
|
|
4
4
|
isHTMLElement,
|
|
5
5
|
isVisible
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4CROPD6E.mjs";
|
|
7
7
|
|
|
8
8
|
// src/tabs.machine.ts
|
|
9
9
|
import { createMachine, guards } from "@zag-js/core";
|
|
@@ -73,7 +73,7 @@ function machine(userContext) {
|
|
|
73
73
|
const ctx = compact(userContext);
|
|
74
74
|
return createMachine(
|
|
75
75
|
{
|
|
76
|
-
initial: "
|
|
76
|
+
initial: "idle",
|
|
77
77
|
context: {
|
|
78
78
|
dir: "ltr",
|
|
79
79
|
orientation: "horizontal",
|
|
@@ -106,15 +106,8 @@ function machine(userContext) {
|
|
|
106
106
|
actions: "clearValue"
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
+
entry: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"],
|
|
109
110
|
states: {
|
|
110
|
-
unknown: {
|
|
111
|
-
on: {
|
|
112
|
-
SETUP: {
|
|
113
|
-
target: "idle",
|
|
114
|
-
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
111
|
idle: {
|
|
119
112
|
on: {
|
|
120
113
|
TAB_FOCUS: {
|
|
@@ -195,32 +188,25 @@ function machine(userContext) {
|
|
|
195
188
|
ctx2.value = null;
|
|
196
189
|
},
|
|
197
190
|
invokeOnDelete(ctx2, evt) {
|
|
198
|
-
|
|
199
|
-
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
191
|
+
ctx2.onDelete?.({ value: evt.value });
|
|
200
192
|
},
|
|
201
193
|
focusFirstTab(ctx2) {
|
|
202
|
-
raf(() =>
|
|
203
|
-
var _a;
|
|
204
|
-
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
205
|
-
});
|
|
194
|
+
raf(() => dom.getFirstEl(ctx2)?.focus());
|
|
206
195
|
},
|
|
207
196
|
focusLastTab(ctx2) {
|
|
208
|
-
raf(() =>
|
|
209
|
-
var _a;
|
|
210
|
-
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
211
|
-
});
|
|
197
|
+
raf(() => dom.getLastEl(ctx2)?.focus());
|
|
212
198
|
},
|
|
213
199
|
focusNextTab(ctx2) {
|
|
214
200
|
if (!ctx2.focusedValue)
|
|
215
201
|
return;
|
|
216
202
|
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
217
|
-
raf(() => next
|
|
203
|
+
raf(() => next?.focus());
|
|
218
204
|
},
|
|
219
205
|
focusPrevTab(ctx2) {
|
|
220
206
|
if (!ctx2.focusedValue)
|
|
221
207
|
return;
|
|
222
208
|
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
223
|
-
raf(() => prev
|
|
209
|
+
raf(() => prev?.focus());
|
|
224
210
|
},
|
|
225
211
|
setIndicatorRect(ctx2) {
|
|
226
212
|
nextTick(() => {
|
|
@@ -241,12 +227,10 @@ function machine(userContext) {
|
|
|
241
227
|
ctx2.hasMeasuredRect = false;
|
|
242
228
|
},
|
|
243
229
|
invokeOnChange(ctx2) {
|
|
244
|
-
|
|
245
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
230
|
+
ctx2.onChange?.({ value: ctx2.value });
|
|
246
231
|
},
|
|
247
232
|
invokeOnFocus(ctx2) {
|
|
248
|
-
|
|
249
|
-
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
233
|
+
ctx2.onFocus?.({ value: ctx2.focusedValue });
|
|
250
234
|
},
|
|
251
235
|
setPrevSelectedTabs(ctx2) {
|
|
252
236
|
if (ctx2.value != null) {
|
|
@@ -7,30 +7,23 @@ function isDocument(el) {
|
|
|
7
7
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
8
8
|
}
|
|
9
9
|
function isWindow(value) {
|
|
10
|
-
return
|
|
10
|
+
return value?.toString() === "[object Window]";
|
|
11
11
|
}
|
|
12
12
|
function isFrame(element) {
|
|
13
13
|
return element.localName === "iframe";
|
|
14
14
|
}
|
|
15
15
|
function getDocument(el) {
|
|
16
|
-
var _a;
|
|
17
16
|
if (isWindow(el))
|
|
18
17
|
return el.document;
|
|
19
18
|
if (isDocument(el))
|
|
20
19
|
return el;
|
|
21
|
-
return
|
|
20
|
+
return el?.ownerDocument ?? document;
|
|
22
21
|
}
|
|
23
22
|
function defineDomHelpers(helpers) {
|
|
24
23
|
const dom2 = {
|
|
25
|
-
getRootNode: (ctx) =>
|
|
26
|
-
var _a, _b;
|
|
27
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
28
|
-
},
|
|
24
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
29
25
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
30
|
-
getWin: (ctx) =>
|
|
31
|
-
var _a;
|
|
32
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
33
|
-
},
|
|
26
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
34
27
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
35
28
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
36
29
|
};
|
|
@@ -40,7 +33,7 @@ function defineDomHelpers(helpers) {
|
|
|
40
33
|
};
|
|
41
34
|
}
|
|
42
35
|
function isHTMLElement(v) {
|
|
43
|
-
return typeof v === "object" &&
|
|
36
|
+
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
44
37
|
}
|
|
45
38
|
function isVisible(el) {
|
|
46
39
|
if (!isHTMLElement(el))
|
|
@@ -50,8 +43,7 @@ function isVisible(el) {
|
|
|
50
43
|
|
|
51
44
|
// ../../utilities/dom/src/nodelist.ts
|
|
52
45
|
function queryAll(root, selector) {
|
|
53
|
-
|
|
54
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
46
|
+
return Array.from(root?.querySelectorAll(selector) ?? []);
|
|
55
47
|
}
|
|
56
48
|
function itemById(v, id) {
|
|
57
49
|
return v.find((node) => node.id === id);
|
|
@@ -75,26 +67,11 @@ function prevById(v, id, loop = true) {
|
|
|
75
67
|
|
|
76
68
|
// src/tabs.dom.ts
|
|
77
69
|
var dom = defineDomHelpers({
|
|
78
|
-
getRootId: (ctx) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var _a, _b;
|
|
84
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.tablist) != null ? _b : `tabs:${ctx.id}:list`;
|
|
85
|
-
},
|
|
86
|
-
getContentId: (ctx, id) => {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tabs:${ctx.id}:content-${id}`;
|
|
89
|
-
},
|
|
90
|
-
getContentGroupId: (ctx) => {
|
|
91
|
-
var _a, _b;
|
|
92
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.contentGroup) != null ? _b : `tabs:${ctx.id}:content-group`;
|
|
93
|
-
},
|
|
94
|
-
getTriggerId: (ctx, id) => {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tabs:${ctx.id}:trigger-${id}`;
|
|
97
|
-
},
|
|
70
|
+
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
71
|
+
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
72
|
+
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
73
|
+
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
74
|
+
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
98
75
|
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
99
76
|
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
100
77
|
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
@@ -116,14 +93,13 @@ var dom = defineDomHelpers({
|
|
|
116
93
|
return dom.getById(ctx, id);
|
|
117
94
|
},
|
|
118
95
|
getRectById: (ctx, id) => {
|
|
119
|
-
var _a;
|
|
120
96
|
const empty = {
|
|
121
97
|
offsetLeft: 0,
|
|
122
98
|
offsetTop: 0,
|
|
123
99
|
offsetWidth: 0,
|
|
124
100
|
offsetHeight: 0
|
|
125
101
|
};
|
|
126
|
-
const tab =
|
|
102
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
127
103
|
if (ctx.isVertical) {
|
|
128
104
|
return {
|
|
129
105
|
top: `${tab.offsetTop}px`,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S2KW2DT4.mjs";
|
|
4
4
|
import {
|
|
5
5
|
dom
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4CROPD6E.mjs";
|
|
7
7
|
|
|
8
8
|
// ../../utilities/dom/src/attrs.ts
|
|
9
9
|
var dataAttr = (guard) => {
|
|
@@ -13,9 +13,8 @@ var dataAttr = (guard) => {
|
|
|
13
13
|
// ../../utilities/dom/src/platform.ts
|
|
14
14
|
var isDom = () => typeof window !== "undefined";
|
|
15
15
|
function getPlatform() {
|
|
16
|
-
var _a;
|
|
17
16
|
const agent = navigator.userAgentData;
|
|
18
|
-
return
|
|
17
|
+
return agent?.platform ?? navigator.platform;
|
|
19
18
|
}
|
|
20
19
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
21
20
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
@@ -37,10 +36,9 @@ var sameKeyMap = {
|
|
|
37
36
|
Right: "ArrowRight"
|
|
38
37
|
};
|
|
39
38
|
function getEventKey(event, options = {}) {
|
|
40
|
-
var _a;
|
|
41
39
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
42
40
|
let { key } = event;
|
|
43
|
-
key =
|
|
41
|
+
key = sameKeyMap[key] ?? key;
|
|
44
42
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
45
43
|
if (isRtl && key in rtlKeyMap) {
|
|
46
44
|
key = rtlKeyMap[key];
|
|
@@ -132,7 +130,7 @@ function connect(state, send, normalize) {
|
|
|
132
130
|
},
|
|
133
131
|
onBlur(event) {
|
|
134
132
|
const target = event.relatedTarget;
|
|
135
|
-
if (
|
|
133
|
+
if (target?.getAttribute("role") !== "tab") {
|
|
136
134
|
send({ type: "TAB_BLUR" });
|
|
137
135
|
}
|
|
138
136
|
},
|
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -56,9 +56,8 @@ function compact(obj) {
|
|
|
56
56
|
// ../../utilities/dom/src/platform.ts
|
|
57
57
|
var isDom = () => typeof window !== "undefined";
|
|
58
58
|
function getPlatform() {
|
|
59
|
-
var _a;
|
|
60
59
|
const agent = navigator.userAgentData;
|
|
61
|
-
return
|
|
60
|
+
return agent?.platform ?? navigator.platform;
|
|
62
61
|
}
|
|
63
62
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
64
63
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
@@ -70,30 +69,23 @@ function isDocument(el) {
|
|
|
70
69
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
71
70
|
}
|
|
72
71
|
function isWindow(value) {
|
|
73
|
-
return
|
|
72
|
+
return value?.toString() === "[object Window]";
|
|
74
73
|
}
|
|
75
74
|
function isFrame(element) {
|
|
76
75
|
return element.localName === "iframe";
|
|
77
76
|
}
|
|
78
77
|
function getDocument(el) {
|
|
79
|
-
var _a;
|
|
80
78
|
if (isWindow(el))
|
|
81
79
|
return el.document;
|
|
82
80
|
if (isDocument(el))
|
|
83
81
|
return el;
|
|
84
|
-
return
|
|
82
|
+
return el?.ownerDocument ?? document;
|
|
85
83
|
}
|
|
86
84
|
function defineDomHelpers(helpers) {
|
|
87
85
|
const dom2 = {
|
|
88
|
-
getRootNode: (ctx) =>
|
|
89
|
-
var _a, _b;
|
|
90
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
91
|
-
},
|
|
86
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
92
87
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
93
|
-
getWin: (ctx) =>
|
|
94
|
-
var _a;
|
|
95
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
96
|
-
},
|
|
88
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
97
89
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
98
90
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
99
91
|
};
|
|
@@ -103,7 +95,7 @@ function defineDomHelpers(helpers) {
|
|
|
103
95
|
};
|
|
104
96
|
}
|
|
105
97
|
function isHTMLElement(v) {
|
|
106
|
-
return typeof v === "object" &&
|
|
98
|
+
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
107
99
|
}
|
|
108
100
|
function isVisible(el) {
|
|
109
101
|
if (!isHTMLElement(el))
|
|
@@ -151,10 +143,9 @@ var sameKeyMap = {
|
|
|
151
143
|
Right: "ArrowRight"
|
|
152
144
|
};
|
|
153
145
|
function getEventKey(event, options = {}) {
|
|
154
|
-
var _a;
|
|
155
146
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
156
147
|
let { key } = event;
|
|
157
|
-
key =
|
|
148
|
+
key = sameKeyMap[key] ?? key;
|
|
158
149
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
159
150
|
if (isRtl && key in rtlKeyMap) {
|
|
160
151
|
key = rtlKeyMap[key];
|
|
@@ -185,8 +176,7 @@ function raf(fn) {
|
|
|
185
176
|
|
|
186
177
|
// ../../utilities/dom/src/nodelist.ts
|
|
187
178
|
function queryAll(root, selector) {
|
|
188
|
-
|
|
189
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
179
|
+
return Array.from(root?.querySelectorAll(selector) ?? []);
|
|
190
180
|
}
|
|
191
181
|
function itemById(v, id) {
|
|
192
182
|
return v.find((node) => node.id === id);
|
|
@@ -210,26 +200,11 @@ function prevById(v, id, loop = true) {
|
|
|
210
200
|
|
|
211
201
|
// src/tabs.dom.ts
|
|
212
202
|
var dom = defineDomHelpers({
|
|
213
|
-
getRootId: (ctx) => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
var _a, _b;
|
|
219
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.tablist) != null ? _b : `tabs:${ctx.id}:list`;
|
|
220
|
-
},
|
|
221
|
-
getContentId: (ctx, id) => {
|
|
222
|
-
var _a, _b;
|
|
223
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tabs:${ctx.id}:content-${id}`;
|
|
224
|
-
},
|
|
225
|
-
getContentGroupId: (ctx) => {
|
|
226
|
-
var _a, _b;
|
|
227
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.contentGroup) != null ? _b : `tabs:${ctx.id}:content-group`;
|
|
228
|
-
},
|
|
229
|
-
getTriggerId: (ctx, id) => {
|
|
230
|
-
var _a, _b;
|
|
231
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tabs:${ctx.id}:trigger-${id}`;
|
|
232
|
-
},
|
|
203
|
+
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
204
|
+
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
205
|
+
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
206
|
+
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
207
|
+
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
233
208
|
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
234
209
|
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
235
210
|
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
@@ -251,14 +226,13 @@ var dom = defineDomHelpers({
|
|
|
251
226
|
return dom.getById(ctx, id);
|
|
252
227
|
},
|
|
253
228
|
getRectById: (ctx, id) => {
|
|
254
|
-
var _a;
|
|
255
229
|
const empty = {
|
|
256
230
|
offsetLeft: 0,
|
|
257
231
|
offsetTop: 0,
|
|
258
232
|
offsetWidth: 0,
|
|
259
233
|
offsetHeight: 0
|
|
260
234
|
};
|
|
261
|
-
const tab =
|
|
235
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
262
236
|
if (ctx.isVertical) {
|
|
263
237
|
return {
|
|
264
238
|
top: `${tab.offsetTop}px`,
|
|
@@ -356,7 +330,7 @@ function connect(state, send, normalize) {
|
|
|
356
330
|
},
|
|
357
331
|
onBlur(event) {
|
|
358
332
|
const target = event.relatedTarget;
|
|
359
|
-
if (
|
|
333
|
+
if (target?.getAttribute("role") !== "tab") {
|
|
360
334
|
send({ type: "TAB_BLUR" });
|
|
361
335
|
}
|
|
362
336
|
},
|
|
@@ -412,7 +386,7 @@ function machine(userContext) {
|
|
|
412
386
|
const ctx = compact(userContext);
|
|
413
387
|
return (0, import_core.createMachine)(
|
|
414
388
|
{
|
|
415
|
-
initial: "
|
|
389
|
+
initial: "idle",
|
|
416
390
|
context: {
|
|
417
391
|
dir: "ltr",
|
|
418
392
|
orientation: "horizontal",
|
|
@@ -445,15 +419,8 @@ function machine(userContext) {
|
|
|
445
419
|
actions: "clearValue"
|
|
446
420
|
}
|
|
447
421
|
},
|
|
422
|
+
entry: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"],
|
|
448
423
|
states: {
|
|
449
|
-
unknown: {
|
|
450
|
-
on: {
|
|
451
|
-
SETUP: {
|
|
452
|
-
target: "idle",
|
|
453
|
-
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
},
|
|
457
424
|
idle: {
|
|
458
425
|
on: {
|
|
459
426
|
TAB_FOCUS: {
|
|
@@ -534,32 +501,25 @@ function machine(userContext) {
|
|
|
534
501
|
ctx2.value = null;
|
|
535
502
|
},
|
|
536
503
|
invokeOnDelete(ctx2, evt) {
|
|
537
|
-
|
|
538
|
-
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
504
|
+
ctx2.onDelete?.({ value: evt.value });
|
|
539
505
|
},
|
|
540
506
|
focusFirstTab(ctx2) {
|
|
541
|
-
raf(() =>
|
|
542
|
-
var _a;
|
|
543
|
-
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
544
|
-
});
|
|
507
|
+
raf(() => dom.getFirstEl(ctx2)?.focus());
|
|
545
508
|
},
|
|
546
509
|
focusLastTab(ctx2) {
|
|
547
|
-
raf(() =>
|
|
548
|
-
var _a;
|
|
549
|
-
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
550
|
-
});
|
|
510
|
+
raf(() => dom.getLastEl(ctx2)?.focus());
|
|
551
511
|
},
|
|
552
512
|
focusNextTab(ctx2) {
|
|
553
513
|
if (!ctx2.focusedValue)
|
|
554
514
|
return;
|
|
555
515
|
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
556
|
-
raf(() => next
|
|
516
|
+
raf(() => next?.focus());
|
|
557
517
|
},
|
|
558
518
|
focusPrevTab(ctx2) {
|
|
559
519
|
if (!ctx2.focusedValue)
|
|
560
520
|
return;
|
|
561
521
|
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
562
|
-
raf(() => prev
|
|
522
|
+
raf(() => prev?.focus());
|
|
563
523
|
},
|
|
564
524
|
setIndicatorRect(ctx2) {
|
|
565
525
|
nextTick(() => {
|
|
@@ -580,12 +540,10 @@ function machine(userContext) {
|
|
|
580
540
|
ctx2.hasMeasuredRect = false;
|
|
581
541
|
},
|
|
582
542
|
invokeOnChange(ctx2) {
|
|
583
|
-
|
|
584
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
543
|
+
ctx2.onChange?.({ value: ctx2.value });
|
|
585
544
|
},
|
|
586
545
|
invokeOnFocus(ctx2) {
|
|
587
|
-
|
|
588
|
-
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
546
|
+
ctx2.onFocus?.({ value: ctx2.focusedValue });
|
|
589
547
|
},
|
|
590
548
|
setPrevSelectedTabs(ctx2) {
|
|
591
549
|
if (ctx2.value != null) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
connect
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IVTIBLCN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
anatomy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S2KW2DT4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
machine
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-3DBUWLYX.mjs";
|
|
10
|
+
import "./chunk-4CROPD6E.mjs";
|
|
11
11
|
export {
|
|
12
12
|
anatomy,
|
|
13
13
|
connect,
|
package/dist/tabs.anatomy.mjs
CHANGED
package/dist/tabs.connect.js
CHANGED
|
@@ -36,9 +36,8 @@ var last = (v) => v[v.length - 1];
|
|
|
36
36
|
// ../../utilities/dom/src/platform.ts
|
|
37
37
|
var isDom = () => typeof window !== "undefined";
|
|
38
38
|
function getPlatform() {
|
|
39
|
-
var _a;
|
|
40
39
|
const agent = navigator.userAgentData;
|
|
41
|
-
return
|
|
40
|
+
return agent?.platform ?? navigator.platform;
|
|
42
41
|
}
|
|
43
42
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
44
43
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
@@ -50,27 +49,20 @@ function isDocument(el) {
|
|
|
50
49
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
51
50
|
}
|
|
52
51
|
function isWindow(value) {
|
|
53
|
-
return
|
|
52
|
+
return value?.toString() === "[object Window]";
|
|
54
53
|
}
|
|
55
54
|
function getDocument(el) {
|
|
56
|
-
var _a;
|
|
57
55
|
if (isWindow(el))
|
|
58
56
|
return el.document;
|
|
59
57
|
if (isDocument(el))
|
|
60
58
|
return el;
|
|
61
|
-
return
|
|
59
|
+
return el?.ownerDocument ?? document;
|
|
62
60
|
}
|
|
63
61
|
function defineDomHelpers(helpers) {
|
|
64
62
|
const dom2 = {
|
|
65
|
-
getRootNode: (ctx) =>
|
|
66
|
-
var _a, _b;
|
|
67
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
68
|
-
},
|
|
63
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
69
64
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
70
|
-
getWin: (ctx) =>
|
|
71
|
-
var _a;
|
|
72
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
73
|
-
},
|
|
65
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
74
66
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
75
67
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
76
68
|
};
|
|
@@ -95,10 +87,9 @@ var sameKeyMap = {
|
|
|
95
87
|
Right: "ArrowRight"
|
|
96
88
|
};
|
|
97
89
|
function getEventKey(event, options = {}) {
|
|
98
|
-
var _a;
|
|
99
90
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
100
91
|
let { key } = event;
|
|
101
|
-
key =
|
|
92
|
+
key = sameKeyMap[key] ?? key;
|
|
102
93
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
103
94
|
if (isRtl && key in rtlKeyMap) {
|
|
104
95
|
key = rtlKeyMap[key];
|
|
@@ -108,8 +99,7 @@ function getEventKey(event, options = {}) {
|
|
|
108
99
|
|
|
109
100
|
// ../../utilities/dom/src/nodelist.ts
|
|
110
101
|
function queryAll(root, selector) {
|
|
111
|
-
|
|
112
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
102
|
+
return Array.from(root?.querySelectorAll(selector) ?? []);
|
|
113
103
|
}
|
|
114
104
|
function itemById(v, id) {
|
|
115
105
|
return v.find((node) => node.id === id);
|
|
@@ -138,26 +128,11 @@ var parts = anatomy.build();
|
|
|
138
128
|
|
|
139
129
|
// src/tabs.dom.ts
|
|
140
130
|
var dom = defineDomHelpers({
|
|
141
|
-
getRootId: (ctx) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
var _a, _b;
|
|
147
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.tablist) != null ? _b : `tabs:${ctx.id}:list`;
|
|
148
|
-
},
|
|
149
|
-
getContentId: (ctx, id) => {
|
|
150
|
-
var _a, _b;
|
|
151
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tabs:${ctx.id}:content-${id}`;
|
|
152
|
-
},
|
|
153
|
-
getContentGroupId: (ctx) => {
|
|
154
|
-
var _a, _b;
|
|
155
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.contentGroup) != null ? _b : `tabs:${ctx.id}:content-group`;
|
|
156
|
-
},
|
|
157
|
-
getTriggerId: (ctx, id) => {
|
|
158
|
-
var _a, _b;
|
|
159
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tabs:${ctx.id}:trigger-${id}`;
|
|
160
|
-
},
|
|
131
|
+
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
132
|
+
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
133
|
+
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
134
|
+
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
135
|
+
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
161
136
|
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
162
137
|
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
163
138
|
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
@@ -179,14 +154,13 @@ var dom = defineDomHelpers({
|
|
|
179
154
|
return dom.getById(ctx, id);
|
|
180
155
|
},
|
|
181
156
|
getRectById: (ctx, id) => {
|
|
182
|
-
var _a;
|
|
183
157
|
const empty = {
|
|
184
158
|
offsetLeft: 0,
|
|
185
159
|
offsetTop: 0,
|
|
186
160
|
offsetWidth: 0,
|
|
187
161
|
offsetHeight: 0
|
|
188
162
|
};
|
|
189
|
-
const tab =
|
|
163
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
190
164
|
if (ctx.isVertical) {
|
|
191
165
|
return {
|
|
192
166
|
top: `${tab.offsetTop}px`,
|
|
@@ -284,7 +258,7 @@ function connect(state, send, normalize) {
|
|
|
284
258
|
},
|
|
285
259
|
onBlur(event) {
|
|
286
260
|
const target = event.relatedTarget;
|
|
287
|
-
if (
|
|
261
|
+
if (target?.getAttribute("role") !== "tab") {
|
|
288
262
|
send({ type: "TAB_BLUR" });
|
|
289
263
|
}
|
|
290
264
|
},
|
package/dist/tabs.connect.mjs
CHANGED
package/dist/tabs.dom.js
CHANGED
|
@@ -33,27 +33,20 @@ function isDocument(el) {
|
|
|
33
33
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
34
34
|
}
|
|
35
35
|
function isWindow(value) {
|
|
36
|
-
return
|
|
36
|
+
return value?.toString() === "[object Window]";
|
|
37
37
|
}
|
|
38
38
|
function getDocument(el) {
|
|
39
|
-
var _a;
|
|
40
39
|
if (isWindow(el))
|
|
41
40
|
return el.document;
|
|
42
41
|
if (isDocument(el))
|
|
43
42
|
return el;
|
|
44
|
-
return
|
|
43
|
+
return el?.ownerDocument ?? document;
|
|
45
44
|
}
|
|
46
45
|
function defineDomHelpers(helpers) {
|
|
47
46
|
const dom2 = {
|
|
48
|
-
getRootNode: (ctx) =>
|
|
49
|
-
var _a, _b;
|
|
50
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
51
|
-
},
|
|
47
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
52
48
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
53
|
-
getWin: (ctx) =>
|
|
54
|
-
var _a;
|
|
55
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
56
|
-
},
|
|
49
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
57
50
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
58
51
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
59
52
|
};
|
|
@@ -65,8 +58,7 @@ function defineDomHelpers(helpers) {
|
|
|
65
58
|
|
|
66
59
|
// ../../utilities/dom/src/nodelist.ts
|
|
67
60
|
function queryAll(root, selector) {
|
|
68
|
-
|
|
69
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
61
|
+
return Array.from(root?.querySelectorAll(selector) ?? []);
|
|
70
62
|
}
|
|
71
63
|
function itemById(v, id) {
|
|
72
64
|
return v.find((node) => node.id === id);
|
|
@@ -90,26 +82,11 @@ function prevById(v, id, loop = true) {
|
|
|
90
82
|
|
|
91
83
|
// src/tabs.dom.ts
|
|
92
84
|
var dom = defineDomHelpers({
|
|
93
|
-
getRootId: (ctx) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
var _a, _b;
|
|
99
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.tablist) != null ? _b : `tabs:${ctx.id}:list`;
|
|
100
|
-
},
|
|
101
|
-
getContentId: (ctx, id) => {
|
|
102
|
-
var _a, _b;
|
|
103
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tabs:${ctx.id}:content-${id}`;
|
|
104
|
-
},
|
|
105
|
-
getContentGroupId: (ctx) => {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.contentGroup) != null ? _b : `tabs:${ctx.id}:content-group`;
|
|
108
|
-
},
|
|
109
|
-
getTriggerId: (ctx, id) => {
|
|
110
|
-
var _a, _b;
|
|
111
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tabs:${ctx.id}:trigger-${id}`;
|
|
112
|
-
},
|
|
85
|
+
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
86
|
+
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
87
|
+
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
88
|
+
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
89
|
+
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
113
90
|
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
114
91
|
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
115
92
|
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
@@ -131,14 +108,13 @@ var dom = defineDomHelpers({
|
|
|
131
108
|
return dom.getById(ctx, id);
|
|
132
109
|
},
|
|
133
110
|
getRectById: (ctx, id) => {
|
|
134
|
-
var _a;
|
|
135
111
|
const empty = {
|
|
136
112
|
offsetLeft: 0,
|
|
137
113
|
offsetTop: 0,
|
|
138
114
|
offsetWidth: 0,
|
|
139
115
|
offsetHeight: 0
|
|
140
116
|
};
|
|
141
|
-
const tab =
|
|
117
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
142
118
|
if (ctx.isVertical) {
|
|
143
119
|
return {
|
|
144
120
|
top: `${tab.offsetTop}px`,
|
package/dist/tabs.dom.mjs
CHANGED
package/dist/tabs.machine.js
CHANGED
|
@@ -47,30 +47,23 @@ function isDocument(el) {
|
|
|
47
47
|
return el.nodeType === Node.DOCUMENT_NODE;
|
|
48
48
|
}
|
|
49
49
|
function isWindow(value) {
|
|
50
|
-
return
|
|
50
|
+
return value?.toString() === "[object Window]";
|
|
51
51
|
}
|
|
52
52
|
function isFrame(element) {
|
|
53
53
|
return element.localName === "iframe";
|
|
54
54
|
}
|
|
55
55
|
function getDocument(el) {
|
|
56
|
-
var _a;
|
|
57
56
|
if (isWindow(el))
|
|
58
57
|
return el.document;
|
|
59
58
|
if (isDocument(el))
|
|
60
59
|
return el;
|
|
61
|
-
return
|
|
60
|
+
return el?.ownerDocument ?? document;
|
|
62
61
|
}
|
|
63
62
|
function defineDomHelpers(helpers) {
|
|
64
63
|
const dom2 = {
|
|
65
|
-
getRootNode: (ctx) =>
|
|
66
|
-
var _a, _b;
|
|
67
|
-
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
|
|
68
|
-
},
|
|
64
|
+
getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
|
|
69
65
|
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
70
|
-
getWin: (ctx) =>
|
|
71
|
-
var _a;
|
|
72
|
-
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
73
|
-
},
|
|
66
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
74
67
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
75
68
|
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
76
69
|
};
|
|
@@ -80,7 +73,7 @@ function defineDomHelpers(helpers) {
|
|
|
80
73
|
};
|
|
81
74
|
}
|
|
82
75
|
function isHTMLElement(v) {
|
|
83
|
-
return typeof v === "object" &&
|
|
76
|
+
return typeof v === "object" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === "string";
|
|
84
77
|
}
|
|
85
78
|
function isVisible(el) {
|
|
86
79
|
if (!isHTMLElement(el))
|
|
@@ -136,8 +129,7 @@ function raf(fn) {
|
|
|
136
129
|
|
|
137
130
|
// ../../utilities/dom/src/nodelist.ts
|
|
138
131
|
function queryAll(root, selector) {
|
|
139
|
-
|
|
140
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
132
|
+
return Array.from(root?.querySelectorAll(selector) ?? []);
|
|
141
133
|
}
|
|
142
134
|
function itemById(v, id) {
|
|
143
135
|
return v.find((node) => node.id === id);
|
|
@@ -161,26 +153,11 @@ function prevById(v, id, loop = true) {
|
|
|
161
153
|
|
|
162
154
|
// src/tabs.dom.ts
|
|
163
155
|
var dom = defineDomHelpers({
|
|
164
|
-
getRootId: (ctx) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var _a, _b;
|
|
170
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.tablist) != null ? _b : `tabs:${ctx.id}:list`;
|
|
171
|
-
},
|
|
172
|
-
getContentId: (ctx, id) => {
|
|
173
|
-
var _a, _b;
|
|
174
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `tabs:${ctx.id}:content-${id}`;
|
|
175
|
-
},
|
|
176
|
-
getContentGroupId: (ctx) => {
|
|
177
|
-
var _a, _b;
|
|
178
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.contentGroup) != null ? _b : `tabs:${ctx.id}:content-group`;
|
|
179
|
-
},
|
|
180
|
-
getTriggerId: (ctx, id) => {
|
|
181
|
-
var _a, _b;
|
|
182
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `tabs:${ctx.id}:trigger-${id}`;
|
|
183
|
-
},
|
|
156
|
+
getRootId: (ctx) => ctx.ids?.root ?? `tabs:${ctx.id}`,
|
|
157
|
+
getTablistId: (ctx) => ctx.ids?.tablist ?? `tabs:${ctx.id}:list`,
|
|
158
|
+
getContentId: (ctx, id) => ctx.ids?.content ?? `tabs:${ctx.id}:content-${id}`,
|
|
159
|
+
getContentGroupId: (ctx) => ctx.ids?.contentGroup ?? `tabs:${ctx.id}:content-group`,
|
|
160
|
+
getTriggerId: (ctx, id) => ctx.ids?.trigger ?? `tabs:${ctx.id}:trigger-${id}`,
|
|
184
161
|
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
185
162
|
getTablistEl: (ctx) => dom.getById(ctx, dom.getTablistId(ctx)),
|
|
186
163
|
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
@@ -202,14 +179,13 @@ var dom = defineDomHelpers({
|
|
|
202
179
|
return dom.getById(ctx, id);
|
|
203
180
|
},
|
|
204
181
|
getRectById: (ctx, id) => {
|
|
205
|
-
var _a;
|
|
206
182
|
const empty = {
|
|
207
183
|
offsetLeft: 0,
|
|
208
184
|
offsetTop: 0,
|
|
209
185
|
offsetWidth: 0,
|
|
210
186
|
offsetHeight: 0
|
|
211
187
|
};
|
|
212
|
-
const tab =
|
|
188
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
213
189
|
if (ctx.isVertical) {
|
|
214
190
|
return {
|
|
215
191
|
top: `${tab.offsetTop}px`,
|
|
@@ -229,7 +205,7 @@ function machine(userContext) {
|
|
|
229
205
|
const ctx = compact(userContext);
|
|
230
206
|
return (0, import_core.createMachine)(
|
|
231
207
|
{
|
|
232
|
-
initial: "
|
|
208
|
+
initial: "idle",
|
|
233
209
|
context: {
|
|
234
210
|
dir: "ltr",
|
|
235
211
|
orientation: "horizontal",
|
|
@@ -262,15 +238,8 @@ function machine(userContext) {
|
|
|
262
238
|
actions: "clearValue"
|
|
263
239
|
}
|
|
264
240
|
},
|
|
241
|
+
entry: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"],
|
|
265
242
|
states: {
|
|
266
|
-
unknown: {
|
|
267
|
-
on: {
|
|
268
|
-
SETUP: {
|
|
269
|
-
target: "idle",
|
|
270
|
-
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
243
|
idle: {
|
|
275
244
|
on: {
|
|
276
245
|
TAB_FOCUS: {
|
|
@@ -351,32 +320,25 @@ function machine(userContext) {
|
|
|
351
320
|
ctx2.value = null;
|
|
352
321
|
},
|
|
353
322
|
invokeOnDelete(ctx2, evt) {
|
|
354
|
-
|
|
355
|
-
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
323
|
+
ctx2.onDelete?.({ value: evt.value });
|
|
356
324
|
},
|
|
357
325
|
focusFirstTab(ctx2) {
|
|
358
|
-
raf(() =>
|
|
359
|
-
var _a;
|
|
360
|
-
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
361
|
-
});
|
|
326
|
+
raf(() => dom.getFirstEl(ctx2)?.focus());
|
|
362
327
|
},
|
|
363
328
|
focusLastTab(ctx2) {
|
|
364
|
-
raf(() =>
|
|
365
|
-
var _a;
|
|
366
|
-
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
367
|
-
});
|
|
329
|
+
raf(() => dom.getLastEl(ctx2)?.focus());
|
|
368
330
|
},
|
|
369
331
|
focusNextTab(ctx2) {
|
|
370
332
|
if (!ctx2.focusedValue)
|
|
371
333
|
return;
|
|
372
334
|
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
373
|
-
raf(() => next
|
|
335
|
+
raf(() => next?.focus());
|
|
374
336
|
},
|
|
375
337
|
focusPrevTab(ctx2) {
|
|
376
338
|
if (!ctx2.focusedValue)
|
|
377
339
|
return;
|
|
378
340
|
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
379
|
-
raf(() => prev
|
|
341
|
+
raf(() => prev?.focus());
|
|
380
342
|
},
|
|
381
343
|
setIndicatorRect(ctx2) {
|
|
382
344
|
nextTick(() => {
|
|
@@ -397,12 +359,10 @@ function machine(userContext) {
|
|
|
397
359
|
ctx2.hasMeasuredRect = false;
|
|
398
360
|
},
|
|
399
361
|
invokeOnChange(ctx2) {
|
|
400
|
-
|
|
401
|
-
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
362
|
+
ctx2.onChange?.({ value: ctx2.value });
|
|
402
363
|
},
|
|
403
364
|
invokeOnFocus(ctx2) {
|
|
404
|
-
|
|
405
|
-
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
365
|
+
ctx2.onFocus?.({ value: ctx2.focusedValue });
|
|
406
366
|
},
|
|
407
367
|
setPrevSelectedTabs(ctx2) {
|
|
408
368
|
if (ctx2.value != null) {
|
package/dist/tabs.machine.mjs
CHANGED
package/dist/tabs.types.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ type ComputedContext = Readonly<{
|
|
|
83
83
|
type PrivateContext = Context<{}>;
|
|
84
84
|
type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
85
85
|
type MachineState = {
|
|
86
|
-
value: "
|
|
86
|
+
value: "idle" | "focused";
|
|
87
87
|
};
|
|
88
88
|
type State = StateMachine.State<MachineContext, MachineState>;
|
|
89
89
|
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tabs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Core logic for the tabs widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "0.1.
|
|
30
|
-
"@zag-js/core": "0.2.
|
|
31
|
-
"@zag-js/types": "0.3.
|
|
29
|
+
"@zag-js/anatomy": "0.1.4",
|
|
30
|
+
"@zag-js/core": "0.2.7",
|
|
31
|
+
"@zag-js/types": "0.3.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"clean-package": "2.2.0",
|
|
35
|
-
"@zag-js/dom-utils": "0.2.
|
|
36
|
-
"@zag-js/utils": "0.3.
|
|
35
|
+
"@zag-js/dom-utils": "0.2.4",
|
|
36
|
+
"@zag-js/utils": "0.3.3"
|
|
37
37
|
},
|
|
38
38
|
"clean-package": "../../../clean-package.config.json",
|
|
39
39
|
"main": "dist/index.js",
|