@zag-js/tabs 0.1.9 → 0.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +115 -3
- package/dist/index.js +236 -233
- package/dist/index.mjs +232 -237
- package/package.json +14 -11
- package/dist/tabs.connect.d.ts +0 -17
- package/dist/tabs.dom.d.ts +0 -32
- package/dist/tabs.machine.d.ts +0 -2
- package/dist/tabs.types.d.ts +0 -120
package/dist/index.js
CHANGED
|
@@ -2,21 +2,7 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __spreadValues = (a, b) => {
|
|
10
|
-
for (var prop in b || (b = {}))
|
|
11
|
-
if (__hasOwnProp.call(b, prop))
|
|
12
|
-
__defNormalProp(a, prop, b[prop]);
|
|
13
|
-
if (__getOwnPropSymbols)
|
|
14
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
-
if (__propIsEnum.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
}
|
|
18
|
-
return a;
|
|
19
|
-
};
|
|
20
6
|
var __export = (target, all) => {
|
|
21
7
|
for (var name in all)
|
|
22
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -45,17 +31,45 @@ var dataAttr = (guard) => {
|
|
|
45
31
|
};
|
|
46
32
|
var isDom = () => typeof window !== "undefined";
|
|
47
33
|
function getPlatform() {
|
|
48
|
-
var _a;
|
|
49
34
|
const agent = navigator.userAgentData;
|
|
50
|
-
return (
|
|
35
|
+
return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
|
|
51
36
|
}
|
|
52
37
|
var pt = (v) => isDom() && v.test(getPlatform());
|
|
53
38
|
var vn = (v) => isDom() && v.test(navigator.vendor);
|
|
54
39
|
var isSafari = () => isApple() && vn(/apple/i);
|
|
55
40
|
var isApple = () => pt(/mac|iphone|ipad|ipod/i);
|
|
41
|
+
function isDocument(el) {
|
|
42
|
+
return el.nodeType === Node.DOCUMENT_NODE;
|
|
43
|
+
}
|
|
44
|
+
function isWindow(value) {
|
|
45
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
46
|
+
}
|
|
56
47
|
function isFrame(element) {
|
|
57
48
|
return element.localName === "iframe";
|
|
58
49
|
}
|
|
50
|
+
function getDocument(el) {
|
|
51
|
+
if (isWindow(el))
|
|
52
|
+
return el.document;
|
|
53
|
+
if (isDocument(el))
|
|
54
|
+
return el;
|
|
55
|
+
return (el == null ? void 0 : el.ownerDocument) ?? document;
|
|
56
|
+
}
|
|
57
|
+
function defineDomHelpers(helpers) {
|
|
58
|
+
const dom2 = {
|
|
59
|
+
getRootNode: (ctx) => {
|
|
60
|
+
var _a;
|
|
61
|
+
return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
|
|
62
|
+
},
|
|
63
|
+
getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
|
|
64
|
+
getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
|
|
65
|
+
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
66
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
...dom2,
|
|
70
|
+
...helpers
|
|
71
|
+
};
|
|
72
|
+
}
|
|
59
73
|
function isHTMLElement(v) {
|
|
60
74
|
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
61
75
|
}
|
|
@@ -103,10 +117,9 @@ var sameKeyMap = {
|
|
|
103
117
|
Right: "ArrowRight"
|
|
104
118
|
};
|
|
105
119
|
function getEventKey(event, options = {}) {
|
|
106
|
-
var _a;
|
|
107
120
|
const { dir = "ltr", orientation = "horizontal" } = options;
|
|
108
121
|
let { key } = event;
|
|
109
|
-
key =
|
|
122
|
+
key = sameKeyMap[key] ?? key;
|
|
110
123
|
const isRtl = dir === "rtl" && orientation === "horizontal";
|
|
111
124
|
if (isRtl && key in rtlKeyMap) {
|
|
112
125
|
key = rtlKeyMap[key];
|
|
@@ -133,8 +146,7 @@ function raf(fn) {
|
|
|
133
146
|
};
|
|
134
147
|
}
|
|
135
148
|
function queryAll(root, selector) {
|
|
136
|
-
|
|
137
|
-
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
149
|
+
return Array.from((root == null ? void 0 : root.querySelectorAll(selector)) ?? []);
|
|
138
150
|
}
|
|
139
151
|
function itemById(v, id) {
|
|
140
152
|
return v.find((node) => node.id === id);
|
|
@@ -161,40 +173,32 @@ var first = (v) => v[0];
|
|
|
161
173
|
var last = (v) => v[v.length - 1];
|
|
162
174
|
|
|
163
175
|
// src/tabs.dom.ts
|
|
164
|
-
var dom = {
|
|
165
|
-
getDoc: (ctx) => {
|
|
166
|
-
var _a;
|
|
167
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
168
|
-
},
|
|
169
|
-
getRootNode: (ctx) => {
|
|
170
|
-
var _a;
|
|
171
|
-
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
|
|
172
|
-
},
|
|
176
|
+
var dom = defineDomHelpers({
|
|
173
177
|
getRootId: (ctx) => {
|
|
174
|
-
var _a
|
|
175
|
-
return (
|
|
178
|
+
var _a;
|
|
179
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.root) ?? `tabs:${ctx.id}`;
|
|
176
180
|
},
|
|
177
181
|
getTriggerGroupId: (ctx) => {
|
|
178
|
-
var _a
|
|
179
|
-
return (
|
|
182
|
+
var _a;
|
|
183
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.triggerGroup) ?? `tabs:${ctx.id}:trigger-group`;
|
|
180
184
|
},
|
|
181
185
|
getContentId: (ctx, id) => {
|
|
182
|
-
var _a
|
|
183
|
-
return (
|
|
186
|
+
var _a;
|
|
187
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.content) ?? `tabs:${ctx.id}:content-${id}`;
|
|
184
188
|
},
|
|
185
189
|
getContentGroupId: (ctx) => {
|
|
186
|
-
var _a
|
|
187
|
-
return (
|
|
190
|
+
var _a;
|
|
191
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.contentGroup) ?? `tabs:${ctx.id}:content-group`;
|
|
188
192
|
},
|
|
189
193
|
getTriggerId: (ctx, id) => {
|
|
190
|
-
var _a
|
|
191
|
-
return (
|
|
194
|
+
var _a;
|
|
195
|
+
return ((_a = ctx.ids) == null ? void 0 : _a.trigger) ?? `tabs:${ctx.id}:trigger-${id}`;
|
|
192
196
|
},
|
|
193
|
-
getIndicatorId: (ctx) => `tabs:${ctx.
|
|
194
|
-
getTriggerGroupEl: (ctx) => dom.
|
|
195
|
-
getContentEl: (ctx, id) => dom.
|
|
196
|
-
getTriggerEl: (ctx, id) => dom.
|
|
197
|
-
getIndicatorEl: (ctx) => dom.
|
|
197
|
+
getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
|
|
198
|
+
getTriggerGroupEl: (ctx) => dom.getById(ctx, dom.getTriggerGroupId(ctx)),
|
|
199
|
+
getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
|
|
200
|
+
getTriggerEl: (ctx, id) => dom.getById(ctx, dom.getTriggerId(ctx, id)),
|
|
201
|
+
getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
|
|
198
202
|
getElements: (ctx) => {
|
|
199
203
|
const ownerId = CSS.escape(dom.getTriggerGroupId(ctx));
|
|
200
204
|
const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`;
|
|
@@ -208,17 +212,16 @@ var dom = {
|
|
|
208
212
|
if (!ctx.value)
|
|
209
213
|
return;
|
|
210
214
|
const id = dom.getContentId(ctx, ctx.value);
|
|
211
|
-
return dom.
|
|
215
|
+
return dom.getById(ctx, id);
|
|
212
216
|
},
|
|
213
217
|
getRectById: (ctx, id) => {
|
|
214
|
-
var _a;
|
|
215
218
|
const empty = {
|
|
216
219
|
offsetLeft: 0,
|
|
217
220
|
offsetTop: 0,
|
|
218
221
|
offsetWidth: 0,
|
|
219
222
|
offsetHeight: 0
|
|
220
223
|
};
|
|
221
|
-
const tab =
|
|
224
|
+
const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
|
|
222
225
|
if (ctx.isVertical) {
|
|
223
226
|
return {
|
|
224
227
|
top: `${tab.offsetTop}px`,
|
|
@@ -230,7 +233,7 @@ var dom = {
|
|
|
230
233
|
width: `${tab.offsetWidth}px`
|
|
231
234
|
};
|
|
232
235
|
}
|
|
233
|
-
};
|
|
236
|
+
});
|
|
234
237
|
|
|
235
238
|
// src/tabs.connect.ts
|
|
236
239
|
function connect(state, send, normalize) {
|
|
@@ -361,15 +364,16 @@ function connect(state, send, normalize) {
|
|
|
361
364
|
id: dom.getIndicatorId(state.context),
|
|
362
365
|
"data-part": "indicator",
|
|
363
366
|
"data-orientation": state.context.orientation,
|
|
364
|
-
style:
|
|
367
|
+
style: {
|
|
365
368
|
"--transition-duration": "200ms",
|
|
366
369
|
"--transition-property": "left, right, top, bottom, width, height",
|
|
367
370
|
position: "absolute",
|
|
368
371
|
willChange: "var(--transition-property)",
|
|
369
372
|
transitionProperty: "var(--transition-property)",
|
|
370
373
|
transitionDuration: state.context.hasMeasuredRect ? "var(--transition-duration)" : "0ms",
|
|
371
|
-
transitionTimingFunction: "var(--transition-timing-function)"
|
|
372
|
-
|
|
374
|
+
transitionTimingFunction: "var(--transition-timing-function)",
|
|
375
|
+
...state.context.indicatorRect
|
|
376
|
+
}
|
|
373
377
|
})
|
|
374
378
|
};
|
|
375
379
|
}
|
|
@@ -377,207 +381,206 @@ function connect(state, send, normalize) {
|
|
|
377
381
|
// src/tabs.machine.ts
|
|
378
382
|
var import_core = require("@zag-js/core");
|
|
379
383
|
var { not } = import_core.guards;
|
|
380
|
-
function machine(ctx
|
|
381
|
-
return (0, import_core.createMachine)(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
computed: {
|
|
398
|
-
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
399
|
-
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
400
|
-
},
|
|
401
|
-
created: ["setPrevSelectedTabs"],
|
|
402
|
-
watch: {
|
|
403
|
-
focusedValue: "invokeOnFocus",
|
|
404
|
-
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
405
|
-
dir: ["clearMeasured", "setIndicatorRect"]
|
|
406
|
-
},
|
|
407
|
-
on: {
|
|
408
|
-
SET_VALUE: {
|
|
409
|
-
actions: "setValue"
|
|
384
|
+
function machine(ctx) {
|
|
385
|
+
return (0, import_core.createMachine)(
|
|
386
|
+
{
|
|
387
|
+
initial: "unknown",
|
|
388
|
+
context: {
|
|
389
|
+
dir: "ltr",
|
|
390
|
+
orientation: "horizontal",
|
|
391
|
+
activationMode: "automatic",
|
|
392
|
+
value: null,
|
|
393
|
+
focusedValue: null,
|
|
394
|
+
previousValues: [],
|
|
395
|
+
indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
|
|
396
|
+
hasMeasuredRect: false,
|
|
397
|
+
isIndicatorRendered: false,
|
|
398
|
+
loop: true,
|
|
399
|
+
messages: {},
|
|
400
|
+
...ctx
|
|
410
401
|
},
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
},
|
|
415
|
-
states: {
|
|
416
|
-
unknown: {
|
|
417
|
-
on: {
|
|
418
|
-
SETUP: {
|
|
419
|
-
target: "idle",
|
|
420
|
-
actions: ["setupDocument", "checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
421
|
-
}
|
|
422
|
-
}
|
|
402
|
+
computed: {
|
|
403
|
+
isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
|
|
404
|
+
isVertical: (ctx2) => ctx2.orientation === "vertical"
|
|
423
405
|
},
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
406
|
+
created: ["setPrevSelectedTabs"],
|
|
407
|
+
watch: {
|
|
408
|
+
focusedValue: "invokeOnFocus",
|
|
409
|
+
value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
|
|
410
|
+
dir: ["clearMeasured", "setIndicatorRect"]
|
|
411
|
+
},
|
|
412
|
+
on: {
|
|
413
|
+
SET_VALUE: {
|
|
414
|
+
actions: "setValue"
|
|
415
|
+
},
|
|
416
|
+
DELETE: {
|
|
417
|
+
actions: "deleteValue"
|
|
435
418
|
}
|
|
436
419
|
},
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
actions: "focusNextTab"
|
|
450
|
-
},
|
|
451
|
-
ARROW_UP: {
|
|
452
|
-
guard: "isVertical",
|
|
453
|
-
actions: "focusPrevTab"
|
|
454
|
-
},
|
|
455
|
-
ARROW_DOWN: {
|
|
456
|
-
guard: "isVertical",
|
|
457
|
-
actions: "focusNextTab"
|
|
458
|
-
},
|
|
459
|
-
HOME: {
|
|
460
|
-
actions: "focusFirstTab"
|
|
461
|
-
},
|
|
462
|
-
END: {
|
|
463
|
-
actions: "focusLastTab"
|
|
464
|
-
},
|
|
465
|
-
ENTER: {
|
|
466
|
-
guard: not("selectOnFocus"),
|
|
467
|
-
actions: "setValue"
|
|
468
|
-
},
|
|
469
|
-
TAB_FOCUS: [
|
|
470
|
-
{
|
|
420
|
+
states: {
|
|
421
|
+
unknown: {
|
|
422
|
+
on: {
|
|
423
|
+
SETUP: {
|
|
424
|
+
target: "idle",
|
|
425
|
+
actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
idle: {
|
|
430
|
+
on: {
|
|
431
|
+
TAB_FOCUS: {
|
|
471
432
|
guard: "selectOnFocus",
|
|
433
|
+
target: "focused",
|
|
434
|
+
actions: ["setFocusedValue", "setValue"]
|
|
435
|
+
},
|
|
436
|
+
TAB_CLICK: {
|
|
437
|
+
target: "focused",
|
|
438
|
+
actions: ["setFocusedValue", "setValue"]
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
focused: {
|
|
443
|
+
on: {
|
|
444
|
+
TAB_CLICK: {
|
|
445
|
+
target: "focused",
|
|
472
446
|
actions: ["setFocusedValue", "setValue"]
|
|
473
447
|
},
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
448
|
+
ARROW_LEFT: {
|
|
449
|
+
guard: "isHorizontal",
|
|
450
|
+
actions: "focusPrevTab"
|
|
451
|
+
},
|
|
452
|
+
ARROW_RIGHT: {
|
|
453
|
+
guard: "isHorizontal",
|
|
454
|
+
actions: "focusNextTab"
|
|
455
|
+
},
|
|
456
|
+
ARROW_UP: {
|
|
457
|
+
guard: "isVertical",
|
|
458
|
+
actions: "focusPrevTab"
|
|
459
|
+
},
|
|
460
|
+
ARROW_DOWN: {
|
|
461
|
+
guard: "isVertical",
|
|
462
|
+
actions: "focusNextTab"
|
|
463
|
+
},
|
|
464
|
+
HOME: {
|
|
465
|
+
actions: "focusFirstTab"
|
|
466
|
+
},
|
|
467
|
+
END: {
|
|
468
|
+
actions: "focusLastTab"
|
|
469
|
+
},
|
|
470
|
+
ENTER: {
|
|
471
|
+
guard: not("selectOnFocus"),
|
|
472
|
+
actions: "setValue"
|
|
473
|
+
},
|
|
474
|
+
TAB_FOCUS: [
|
|
475
|
+
{
|
|
476
|
+
guard: "selectOnFocus",
|
|
477
|
+
actions: ["setFocusedValue", "setValue"]
|
|
478
|
+
},
|
|
479
|
+
{ actions: "setFocusedValue" }
|
|
480
|
+
],
|
|
481
|
+
TAB_BLUR: {
|
|
482
|
+
target: "idle",
|
|
483
|
+
actions: "clearFocusedValue"
|
|
484
|
+
}
|
|
479
485
|
}
|
|
480
486
|
}
|
|
481
487
|
}
|
|
482
|
-
}
|
|
483
|
-
}, {
|
|
484
|
-
guards: {
|
|
485
|
-
isVertical: (ctx2) => ctx2.isVertical,
|
|
486
|
-
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
487
|
-
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
488
488
|
},
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
ctx2
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
if (evt.root)
|
|
495
|
-
ctx2.rootNode = (0, import_core.ref)(evt.root);
|
|
496
|
-
},
|
|
497
|
-
setFocusedValue(ctx2, evt) {
|
|
498
|
-
ctx2.focusedValue = evt.value;
|
|
499
|
-
},
|
|
500
|
-
clearFocusedValue(ctx2) {
|
|
501
|
-
ctx2.focusedValue = null;
|
|
502
|
-
},
|
|
503
|
-
setValue(ctx2, evt) {
|
|
504
|
-
ctx2.value = evt.value;
|
|
489
|
+
{
|
|
490
|
+
guards: {
|
|
491
|
+
isVertical: (ctx2) => ctx2.isVertical,
|
|
492
|
+
isHorizontal: (ctx2) => ctx2.isHorizontal,
|
|
493
|
+
selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
|
|
505
494
|
},
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
raf(() => {
|
|
495
|
+
actions: {
|
|
496
|
+
setFocusedValue(ctx2, evt) {
|
|
497
|
+
ctx2.focusedValue = evt.value;
|
|
498
|
+
},
|
|
499
|
+
clearFocusedValue(ctx2) {
|
|
500
|
+
ctx2.focusedValue = null;
|
|
501
|
+
},
|
|
502
|
+
setValue(ctx2, evt) {
|
|
503
|
+
ctx2.value = evt.value;
|
|
504
|
+
},
|
|
505
|
+
invokeOnDelete(ctx2, evt) {
|
|
518
506
|
var _a;
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
nextTick(() => {
|
|
536
|
-
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
507
|
+
(_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
|
|
508
|
+
},
|
|
509
|
+
focusFirstTab(ctx2) {
|
|
510
|
+
raf(() => {
|
|
511
|
+
var _a;
|
|
512
|
+
return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
focusLastTab(ctx2) {
|
|
516
|
+
raf(() => {
|
|
517
|
+
var _a;
|
|
518
|
+
return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
focusNextTab(ctx2) {
|
|
522
|
+
if (!ctx2.focusedValue)
|
|
537
523
|
return;
|
|
538
|
-
|
|
539
|
-
|
|
524
|
+
const next = dom.getNextEl(ctx2, ctx2.focusedValue);
|
|
525
|
+
raf(() => next == null ? void 0 : next.focus());
|
|
526
|
+
},
|
|
527
|
+
focusPrevTab(ctx2) {
|
|
528
|
+
if (!ctx2.focusedValue)
|
|
540
529
|
return;
|
|
530
|
+
const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
|
|
531
|
+
raf(() => prev == null ? void 0 : prev.focus());
|
|
532
|
+
},
|
|
533
|
+
setIndicatorRect(ctx2) {
|
|
541
534
|
nextTick(() => {
|
|
542
|
-
ctx2.
|
|
535
|
+
if (!ctx2.isIndicatorRendered || !ctx2.value)
|
|
536
|
+
return;
|
|
537
|
+
ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
|
|
538
|
+
if (ctx2.hasMeasuredRect)
|
|
539
|
+
return;
|
|
540
|
+
nextTick(() => {
|
|
541
|
+
ctx2.hasMeasuredRect = true;
|
|
542
|
+
});
|
|
543
543
|
});
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
checkRenderedElements(ctx2) {
|
|
547
|
-
nextTick(() => {
|
|
544
|
+
},
|
|
545
|
+
checkRenderedElements(ctx2) {
|
|
548
546
|
ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
setContentTabIndex(ctx2) {
|
|
569
|
-
raf(() => {
|
|
570
|
-
const panel = dom.getActiveContentEl(ctx2);
|
|
571
|
-
if (!panel)
|
|
572
|
-
return;
|
|
573
|
-
const focusables = getFocusables(panel);
|
|
574
|
-
if (focusables.length > 0) {
|
|
575
|
-
panel.removeAttribute("tabindex");
|
|
576
|
-
} else {
|
|
577
|
-
panel.setAttribute("tabindex", "0");
|
|
547
|
+
},
|
|
548
|
+
clearMeasured(ctx2) {
|
|
549
|
+
ctx2.hasMeasuredRect = false;
|
|
550
|
+
},
|
|
551
|
+
invokeOnChange(ctx2) {
|
|
552
|
+
var _a;
|
|
553
|
+
(_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
|
|
554
|
+
},
|
|
555
|
+
invokeOnFocus(ctx2) {
|
|
556
|
+
var _a;
|
|
557
|
+
(_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
|
|
558
|
+
},
|
|
559
|
+
setPrevSelectedTabs(ctx2) {
|
|
560
|
+
if (ctx2.value != null) {
|
|
561
|
+
const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
|
|
562
|
+
ctx2.previousValues = Array.from(new Set(newSelected));
|
|
578
563
|
}
|
|
579
|
-
}
|
|
564
|
+
},
|
|
565
|
+
setContentTabIndex(ctx2) {
|
|
566
|
+
raf(() => {
|
|
567
|
+
const panel = dom.getActiveContentEl(ctx2);
|
|
568
|
+
if (!panel)
|
|
569
|
+
return;
|
|
570
|
+
const focusables = getFocusables(panel);
|
|
571
|
+
if (focusables.length > 0) {
|
|
572
|
+
panel.removeAttribute("tabindex");
|
|
573
|
+
} else {
|
|
574
|
+
panel.setAttribute("tabindex", "0");
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
580
578
|
}
|
|
581
579
|
}
|
|
582
|
-
|
|
580
|
+
);
|
|
583
581
|
}
|
|
582
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
583
|
+
0 && (module.exports = {
|
|
584
|
+
connect,
|
|
585
|
+
machine
|
|
586
|
+
});
|