@zag-js/tabs 2.0.0-next.3 → 2.0.0-next.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.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +16 -38
- package/dist/index.mjs +2 -7
- package/dist/tabs.anatomy.d.mts +2 -6
- package/dist/tabs.anatomy.d.ts +2 -6
- package/dist/tabs.anatomy.js +8 -33
- package/dist/tabs.anatomy.mjs +4 -7
- package/dist/tabs.connect.d.mts +4 -7
- package/dist/tabs.connect.d.ts +4 -7
- package/dist/tabs.connect.js +253 -231
- package/dist/tabs.connect.mjs +249 -204
- package/dist/tabs.dom.d.mts +27 -33
- package/dist/tabs.dom.d.ts +27 -33
- package/dist/tabs.dom.js +77 -84
- package/dist/tabs.dom.mjs +57 -44
- package/dist/tabs.machine.d.mts +2 -7
- package/dist/tabs.machine.d.ts +2 -7
- package/dist/tabs.machine.js +301 -329
- package/dist/tabs.machine.mjs +298 -294
- package/dist/tabs.props.d.mts +7 -12
- package/dist/tabs.props.d.ts +7 -12
- package/dist/tabs.props.js +33 -61
- package/dist/tabs.props.mjs +24 -31
- package/dist/tabs.types.d.mts +252 -194
- package/dist/tabs.types.d.ts +252 -194
- package/dist/tabs.types.js +4 -18
- package/dist/tabs.types.mjs +1 -0
- package/package.json +7 -7
package/dist/tabs.machine.mjs
CHANGED
|
@@ -1,296 +1,300 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { clickIfLink, getFocusables, isAnchorElement, raf, resizeObserverBorderBox } from "@zag-js/dom-query";
|
|
1
|
+
import { getActivationDirection, getContentEl, getElements, getFirstTriggerEl, getIndicatorEl, getLastTriggerEl, getListEl, getSiblingTriggerEl, getTriggerEl, getTriggerRect } from "./tabs.dom.mjs";
|
|
2
|
+
import { AnimationFrame, addDomEvent, getFocusables, isAnchorElement, observeChildren, resizeObserverBorderBox } from "@zag-js/dom-query";
|
|
4
3
|
import { callAll, isEqual } from "@zag-js/utils";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
4
|
+
import { setup } from "@zag-js/core";
|
|
5
|
+
// src/tabs.machine.ts
|
|
6
|
+
const { createMachine } = setup();
|
|
7
|
+
const machine = createMachine({
|
|
8
|
+
props({ props }) {
|
|
9
|
+
return {
|
|
10
|
+
dir: "ltr",
|
|
11
|
+
orientation: "horizontal",
|
|
12
|
+
activationMode: "automatic",
|
|
13
|
+
loopFocus: true,
|
|
14
|
+
defaultValue: null,
|
|
15
|
+
...props
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
initialState() {
|
|
19
|
+
return "idle";
|
|
20
|
+
},
|
|
21
|
+
context({ prop, bindable, scope, getEvent }) {
|
|
22
|
+
return {
|
|
23
|
+
value: bindable(() => ({
|
|
24
|
+
defaultValue: prop("defaultValue"),
|
|
25
|
+
value: prop("value"),
|
|
26
|
+
onChange(value, prevValue) {
|
|
27
|
+
const activationDirection = getActivationDirection(scope, prevValue ?? null, value, prop("orientation"));
|
|
28
|
+
const reason = getEvent().src;
|
|
29
|
+
prop("onValueChange")?.({
|
|
30
|
+
value,
|
|
31
|
+
activationDirection,
|
|
32
|
+
reason
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
})),
|
|
36
|
+
focusedValue: bindable(() => ({
|
|
37
|
+
defaultValue: prop("value") || prop("defaultValue"),
|
|
38
|
+
sync: true,
|
|
39
|
+
onChange(value) {
|
|
40
|
+
prop("onFocusChange")?.({ focusedValue: value });
|
|
41
|
+
}
|
|
42
|
+
})),
|
|
43
|
+
ssr: bindable(() => ({ defaultValue: true })),
|
|
44
|
+
indicatorRect: bindable(() => ({ defaultValue: null })),
|
|
45
|
+
indicatorInstant: bindable(() => ({ defaultValue: false })),
|
|
46
|
+
tabStopValue: bindable(() => ({ defaultValue: null })),
|
|
47
|
+
hasFocusableContent: bindable(() => ({ defaultValue: false })),
|
|
48
|
+
activationDirection: bindable(() => ({ defaultValue: "none" }))
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
refs({ prop }) {
|
|
52
|
+
return {
|
|
53
|
+
previousValue: prop("value") ?? prop("defaultValue") ?? null,
|
|
54
|
+
indicatorCleanup: null,
|
|
55
|
+
indicatorFrame: AnimationFrame.create(),
|
|
56
|
+
focusFrame: AnimationFrame.create(),
|
|
57
|
+
selectFrame: AnimationFrame.create(),
|
|
58
|
+
tabIndexFrame: AnimationFrame.create(),
|
|
59
|
+
directionFrame: AnimationFrame.create()
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
computed: { activationDirection({ context, refs, scope, prop }) {
|
|
63
|
+
const value = context.get("value");
|
|
64
|
+
const previousValue = refs.get("previousValue");
|
|
65
|
+
if (value === previousValue) return context.get("activationDirection");
|
|
66
|
+
return getActivationDirection(scope, previousValue, value, prop("orientation"));
|
|
67
|
+
} },
|
|
68
|
+
watch({ context, prop, track, action }) {
|
|
69
|
+
track([() => context.get("value")], () => {
|
|
70
|
+
action([
|
|
71
|
+
"setActivationDirection",
|
|
72
|
+
"syncIndicatorRect",
|
|
73
|
+
"syncTabIndex",
|
|
74
|
+
"syncTabStopValue"
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
track([() => prop("dir"), () => prop("orientation")], () => {
|
|
78
|
+
action(["snapIndicator", "syncIndicatorRect"]);
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
on: {
|
|
82
|
+
"TRIGGER.FOCUS": {
|
|
83
|
+
target: "focused",
|
|
84
|
+
actions: ["setFocusedValue"]
|
|
85
|
+
},
|
|
86
|
+
"TRIGGER.CLICK": {
|
|
87
|
+
target: "focused",
|
|
88
|
+
actions: [
|
|
89
|
+
"setFocusedValue",
|
|
90
|
+
"toggleValue",
|
|
91
|
+
"requestNavigation"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
"TRIGGERS.CHANGE": { actions: ["syncTabStopValue", "syncIndicatorRect"] },
|
|
95
|
+
"VALUE.SET": { actions: ["setValue"] },
|
|
96
|
+
"VALUE.STEP": [{
|
|
97
|
+
guard: "isVirtualFocus",
|
|
98
|
+
target: "focused",
|
|
99
|
+
actions: ["stepValue"]
|
|
100
|
+
}, { actions: ["stepValue"] }],
|
|
101
|
+
"INDICATOR.SET": { actions: ["setIndicatorRect"] },
|
|
102
|
+
"INDICATOR.RESIZE": [{
|
|
103
|
+
guard: "isIndicatorTransitioning",
|
|
104
|
+
actions: ["setResizedIndicatorRect"]
|
|
105
|
+
}, { actions: ["snapIndicator", "setResizedIndicatorRect"] }],
|
|
106
|
+
"CONTENT.SYNC": { actions: ["syncTabIndex"] }
|
|
107
|
+
},
|
|
108
|
+
effects: ["trackTriggers"],
|
|
109
|
+
entry: [
|
|
110
|
+
"syncIndicatorRect",
|
|
111
|
+
"syncTabIndex",
|
|
112
|
+
"syncTabStopValue",
|
|
113
|
+
"syncSsr"
|
|
114
|
+
],
|
|
115
|
+
exit: ["cleanupObserver", "cancelFrames"],
|
|
116
|
+
states: {
|
|
117
|
+
idle: {},
|
|
118
|
+
focused: {
|
|
119
|
+
exit: ["cancelFocusFrame"],
|
|
120
|
+
on: {
|
|
121
|
+
"FOCUS.MOVE": [{
|
|
122
|
+
guard: "selectOnFocus",
|
|
123
|
+
actions: ["moveFocus", "selectFocusedTab"]
|
|
124
|
+
}, { actions: ["moveFocus"] }],
|
|
125
|
+
"TRIGGER.BLUR": {
|
|
126
|
+
target: "idle",
|
|
127
|
+
actions: ["clearFocusedValue"]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
implementations: {
|
|
133
|
+
guards: {
|
|
134
|
+
selectOnFocus: ({ prop }) => prop("activationMode") === "automatic",
|
|
135
|
+
isIndicatorTransitioning: ({ event }) => !!event.transitioning,
|
|
136
|
+
isVirtualFocus: ({ prop }) => !!prop("virtualFocus")
|
|
137
|
+
},
|
|
138
|
+
actions: {
|
|
139
|
+
selectFocusedTab({ context, prop, event, scope, refs, send }) {
|
|
140
|
+
refs.get("selectFrame").request(() => {
|
|
141
|
+
const value = context.get("focusedValue");
|
|
142
|
+
if (!value || context.get("value") === value) return;
|
|
143
|
+
if (event.src === "keyboard") {
|
|
144
|
+
const triggerEl = getTriggerEl(scope, value);
|
|
145
|
+
if (isAnchorElement(triggerEl) && prop("navigate") !== null) {
|
|
146
|
+
triggerEl.click();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
send({
|
|
151
|
+
type: "VALUE.SET",
|
|
152
|
+
value,
|
|
153
|
+
src: "keyboard"
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
setFocusedValue({ context, event, flush }) {
|
|
158
|
+
if (event.value == null) return;
|
|
159
|
+
flush(() => {
|
|
160
|
+
context.set("focusedValue", event.value);
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
clearFocusedValue({ context }) {
|
|
164
|
+
context.set("focusedValue", null);
|
|
165
|
+
},
|
|
166
|
+
setValue({ context, event }) {
|
|
167
|
+
context.set("value", event.value);
|
|
168
|
+
},
|
|
169
|
+
toggleValue({ context, event, prop }) {
|
|
170
|
+
const deselect = prop("deselectable") && context.get("value") === event.value;
|
|
171
|
+
context.set("value", deselect ? null : event.value);
|
|
172
|
+
},
|
|
173
|
+
syncTabStopValue({ context, scope }) {
|
|
174
|
+
const selectedEl = getTriggerEl(scope, context.get("value"));
|
|
175
|
+
const reachable = selectedEl != null && !selectedEl.hasAttribute("disabled");
|
|
176
|
+
context.set("tabStopValue", reachable ? null : getFirstTriggerEl(scope)?.dataset.value ?? null);
|
|
177
|
+
},
|
|
178
|
+
moveFocus(params) {
|
|
179
|
+
const { context, prop, scope, event } = params;
|
|
180
|
+
const focusedValue = context.get("focusedValue");
|
|
181
|
+
focusTrigger(params, () => {
|
|
182
|
+
if (event.to === "first") return getFirstTriggerEl(scope);
|
|
183
|
+
if (event.to === "last") return getLastTriggerEl(scope);
|
|
184
|
+
if (!focusedValue) return null;
|
|
185
|
+
return getSiblingTriggerEl(scope, focusedValue, event.to === "next" ? 1 : -1, prop("loopFocus"));
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
stepValue({ context, prop, scope, event }) {
|
|
189
|
+
const value = getSiblingTriggerEl(scope, event.from ?? context.get("value"), event.step, prop("loopFocus"))?.dataset.value;
|
|
190
|
+
if (value == null) return;
|
|
191
|
+
context.set("value", value);
|
|
192
|
+
if (prop("virtualFocus")) context.set("focusedValue", value);
|
|
193
|
+
},
|
|
194
|
+
setActivationDirection({ refs, computed, context, scope, prop }) {
|
|
195
|
+
const previousValue = refs.get("previousValue");
|
|
196
|
+
const value = context.get("value");
|
|
197
|
+
context.set("activationDirection", computed("activationDirection"));
|
|
198
|
+
refs.set("previousValue", value);
|
|
199
|
+
if (value == null || getTriggerEl(scope, value)) return;
|
|
200
|
+
refs.get("directionFrame").request(() => {
|
|
201
|
+
context.set("activationDirection", getActivationDirection(scope, previousValue, value, prop("orientation")));
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
syncTabIndex({ context, scope, refs }) {
|
|
205
|
+
refs.get("tabIndexFrame").request(() => {
|
|
206
|
+
const contentEl = getContentEl(scope, context.get("value") ?? "");
|
|
207
|
+
context.set("hasFocusableContent", contentEl != null && getFocusables(contentEl).length > 0);
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
cancelFocusFrame({ refs }) {
|
|
211
|
+
refs.get("focusFrame").cancel();
|
|
212
|
+
},
|
|
213
|
+
cancelFrames({ refs }) {
|
|
214
|
+
refs.get("focusFrame").cancel();
|
|
215
|
+
refs.get("indicatorFrame").cancel();
|
|
216
|
+
refs.get("selectFrame").cancel();
|
|
217
|
+
refs.get("tabIndexFrame").cancel();
|
|
218
|
+
refs.get("directionFrame").cancel();
|
|
219
|
+
},
|
|
220
|
+
cleanupObserver({ refs }) {
|
|
221
|
+
const cleanup = refs.get("indicatorCleanup");
|
|
222
|
+
if (cleanup) cleanup();
|
|
223
|
+
},
|
|
224
|
+
setIndicatorRect({ context, event, scope }) {
|
|
225
|
+
if (!getIndicatorEl(scope)) return;
|
|
226
|
+
const triggerEl = getTriggerEl(scope, event.value ?? context.get("value"));
|
|
227
|
+
if (!triggerEl) return;
|
|
228
|
+
context.set("indicatorRect", getTriggerRect(scope, triggerEl));
|
|
229
|
+
},
|
|
230
|
+
syncSsr({ context }) {
|
|
231
|
+
context.set("ssr", false);
|
|
232
|
+
},
|
|
233
|
+
snapIndicator({ context, refs }) {
|
|
234
|
+
const frame = refs.get("indicatorFrame");
|
|
235
|
+
context.set("indicatorInstant", true);
|
|
236
|
+
frame.request(() => frame.request(() => context.set("indicatorInstant", false)));
|
|
237
|
+
},
|
|
238
|
+
setResizedIndicatorRect({ context, event }) {
|
|
239
|
+
context.set("indicatorRect", event.rect);
|
|
240
|
+
},
|
|
241
|
+
syncIndicatorRect({ context, refs, scope, send }) {
|
|
242
|
+
const cleanup = refs.get("indicatorCleanup");
|
|
243
|
+
if (cleanup) cleanup();
|
|
244
|
+
const indicatorEl = getIndicatorEl(scope);
|
|
245
|
+
if (!indicatorEl) return;
|
|
246
|
+
const getRect = () => {
|
|
247
|
+
const triggerEl = getTriggerEl(scope, context.get("value"));
|
|
248
|
+
return triggerEl ? getTriggerRect(scope, triggerEl) : null;
|
|
249
|
+
};
|
|
250
|
+
const rect = getRect();
|
|
251
|
+
if (rect) context.set("indicatorRect", (prev) => isEqual(prev, rect) ? prev : rect);
|
|
252
|
+
const onResize = () => {
|
|
253
|
+
const rect = getRect();
|
|
254
|
+
if (!rect || isEqual(context.get("indicatorRect"), rect)) return;
|
|
255
|
+
send({
|
|
256
|
+
type: "INDICATOR.RESIZE",
|
|
257
|
+
rect,
|
|
258
|
+
transitioning: indicatorEl.getAnimations?.().length > 0
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
const triggerEls = getElements(scope);
|
|
262
|
+
const listEl = getListEl(scope);
|
|
263
|
+
const indicatorCleanup = callAll(...triggerEls.map((el) => resizeObserverBorderBox.observe(el, onResize)), ...listEl ? [resizeObserverBorderBox.observe(listEl, onResize), addDomEvent(listEl, "scroll", onResize, { passive: true })] : []);
|
|
264
|
+
refs.set("indicatorCleanup", indicatorCleanup);
|
|
265
|
+
},
|
|
266
|
+
requestNavigation({ event, prop, scope }) {
|
|
267
|
+
const navigate = prop("navigate");
|
|
268
|
+
if (!navigate || event.value == null) return;
|
|
269
|
+
const node = getTriggerEl(scope, event.value);
|
|
270
|
+
if (!isAnchorElement(node)) return;
|
|
271
|
+
navigate({
|
|
272
|
+
value: event.value,
|
|
273
|
+
node,
|
|
274
|
+
href: node.href
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
effects: { trackTriggers({ scope, send }) {
|
|
279
|
+
return observeChildren(() => getListEl(scope), {
|
|
280
|
+
attributes: true,
|
|
281
|
+
attributeFilter: ["disabled"],
|
|
282
|
+
callback() {
|
|
283
|
+
send({ type: "TRIGGERS.CHANGE" });
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
} }
|
|
287
|
+
}
|
|
293
288
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
289
|
+
function focusTrigger(params, getTriggerEl) {
|
|
290
|
+
const { context, prop, refs } = params;
|
|
291
|
+
refs.get("focusFrame").request(() => {
|
|
292
|
+
const triggerEl = getTriggerEl();
|
|
293
|
+
if (!prop("virtualFocus")) {
|
|
294
|
+
triggerEl?.focus();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (triggerEl?.dataset.value != null) context.set("focusedValue", triggerEl.dataset.value);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
export { machine };
|
package/dist/tabs.props.d.mts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
9
|
-
declare const contentProps: "value"[];
|
|
10
|
-
declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
|
11
|
-
|
|
12
|
-
export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|
|
1
|
+
import { ContentProps, TabsProps, TriggerProps } from "./tabs.types.mjs";
|
|
2
|
+
export declare const props: (keyof TabsProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
|
|
4
|
+
export declare const triggerProps: (keyof TriggerProps)[];
|
|
5
|
+
export declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
6
|
+
export declare const contentProps: "value"[];
|
|
7
|
+
export declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
package/dist/tabs.props.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
9
|
-
declare const contentProps: "value"[];
|
|
10
|
-
declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
|
11
|
-
|
|
12
|
-
export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|
|
1
|
+
import { ContentProps, TabsProps, TriggerProps } from "./tabs.types.js";
|
|
2
|
+
export declare const props: (keyof TabsProps)[];
|
|
3
|
+
export declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
|
|
4
|
+
export declare const triggerProps: (keyof TriggerProps)[];
|
|
5
|
+
export declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
6
|
+
export declare const contentProps: "value"[];
|
|
7
|
+
export declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|