@zag-js/tabs 0.1.12 → 0.1.14

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.js CHANGED
@@ -1,31 +1,4 @@
1
- "use strict";
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);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- connect: () => connect,
24
- machine: () => machine
25
- });
26
- module.exports = __toCommonJS(src_exports);
27
-
28
- // ../../utilities/dom/dist/index.mjs
1
+ // ../../utilities/dom/dist/index.js
29
2
  var dataAttr = (guard) => {
30
3
  return guard ? "" : void 0;
31
4
  };
@@ -103,9 +76,7 @@ function isFocusable(element) {
103
76
  }
104
77
  var rtlKeyMap = {
105
78
  ArrowLeft: "ArrowRight",
106
- ArrowRight: "ArrowLeft",
107
- Home: "End",
108
- End: "Home"
79
+ ArrowRight: "ArrowLeft"
109
80
  };
110
81
  var sameKeyMap = {
111
82
  Up: "ArrowUp",
@@ -168,7 +139,7 @@ function prevById(v, id, loop = true) {
168
139
  return v[idx];
169
140
  }
170
141
 
171
- // ../../utilities/core/dist/index.mjs
142
+ // ../../utilities/core/dist/index.js
172
143
  var first = (v) => v[0];
173
144
  var last = (v) => v[v.length - 1];
174
145
 
@@ -379,10 +350,10 @@ function connect(state, send, normalize) {
379
350
  }
380
351
 
381
352
  // src/tabs.machine.ts
382
- var import_core = require("@zag-js/core");
383
- var { not } = import_core.guards;
353
+ import { createMachine, guards } from "@zag-js/core";
354
+ var { not } = guards;
384
355
  function machine(ctx) {
385
- return (0, import_core.createMachine)(
356
+ return createMachine(
386
357
  {
387
358
  initial: "unknown",
388
359
  context: {
@@ -579,8 +550,7 @@ function machine(ctx) {
579
550
  }
580
551
  );
581
552
  }
582
- // Annotate the CommonJS export names for ESM import in node:
583
- 0 && (module.exports = {
553
+ export {
584
554
  connect,
585
555
  machine
586
- });
556
+ };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "type": "module",
2
3
  "name": "@zag-js/tabs",
3
- "version": "0.1.12",
4
+ "version": "0.1.14",
4
5
  "description": "Core logic for the tabs widget implemented as a state machine",
5
6
  "keywords": [
6
7
  "js",
@@ -16,7 +17,6 @@
16
17
  "license": "MIT",
17
18
  "main": "dist/index.js",
18
19
  "types": "dist/index.d.ts",
19
- "module": "dist/index.mjs",
20
20
  "repository": "https://github.com/chakra-ui/zag/tree/main/packages/tabs",
21
21
  "sideEffects": false,
22
22
  "files": [
@@ -29,17 +29,17 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.1.9",
33
- "@zag-js/types": "0.2.4"
32
+ "@zag-js/core": "0.1.11",
33
+ "@zag-js/types": "0.2.6"
34
34
  },
35
35
  "devDependencies": {
36
- "@zag-js/dom-utils": "0.1.10",
37
- "@zag-js/utils": "0.1.3"
36
+ "@zag-js/dom-utils": "0.1.12",
37
+ "@zag-js/utils": "0.1.5"
38
38
  },
39
39
  "scripts": {
40
- "build-fast": "tsup src/index.ts --format=esm,cjs",
40
+ "build-fast": "tsup src/index.ts --format=esm",
41
41
  "start": "pnpm build --watch",
42
- "build": "tsup src/index.ts --format=esm,cjs --dts",
42
+ "build": "tsup src/index.ts --format=esm --dts",
43
43
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
44
44
  "lint": "eslint src --ext .ts,.tsx",
45
45
  "test-ci": "pnpm test --ci --runInBand",
package/dist/index.mjs DELETED
@@ -1,558 +0,0 @@
1
- // ../../utilities/dom/dist/index.mjs
2
- var dataAttr = (guard) => {
3
- return guard ? "" : void 0;
4
- };
5
- var isDom = () => typeof window !== "undefined";
6
- function getPlatform() {
7
- const agent = navigator.userAgentData;
8
- return (agent == null ? void 0 : agent.platform) ?? navigator.platform;
9
- }
10
- var pt = (v) => isDom() && v.test(getPlatform());
11
- var vn = (v) => isDom() && v.test(navigator.vendor);
12
- var isSafari = () => isApple() && vn(/apple/i);
13
- var isApple = () => pt(/mac|iphone|ipad|ipod/i);
14
- function isDocument(el) {
15
- return el.nodeType === Node.DOCUMENT_NODE;
16
- }
17
- function isWindow(value) {
18
- return (value == null ? void 0 : value.toString()) === "[object Window]";
19
- }
20
- function isFrame(element) {
21
- return element.localName === "iframe";
22
- }
23
- function getDocument(el) {
24
- if (isWindow(el))
25
- return el.document;
26
- if (isDocument(el))
27
- return el;
28
- return (el == null ? void 0 : el.ownerDocument) ?? document;
29
- }
30
- function defineDomHelpers(helpers) {
31
- const dom2 = {
32
- getRootNode: (ctx) => {
33
- var _a;
34
- return ((_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) ?? document;
35
- },
36
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
37
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
38
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
39
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
40
- };
41
- return {
42
- ...dom2,
43
- ...helpers
44
- };
45
- }
46
- function isHTMLElement(v) {
47
- return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
48
- }
49
- function isVisible(el) {
50
- if (!isHTMLElement(el))
51
- return false;
52
- return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
53
- }
54
- var focusableSelector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";
55
- var getFocusables = (container, includeContainer = false) => {
56
- if (!container)
57
- return [];
58
- const elements = Array.from(container.querySelectorAll(focusableSelector));
59
- const include = includeContainer == true || includeContainer == "if-empty" && elements.length === 0;
60
- if (include && isHTMLElement(container) && isFocusable(container)) {
61
- elements.unshift(container);
62
- }
63
- const focusableElements = elements.filter(isFocusable);
64
- focusableElements.forEach((element, i) => {
65
- if (isFrame(element) && element.contentDocument) {
66
- const frameBody = element.contentDocument.body;
67
- focusableElements.splice(i, 1, ...getFocusables(frameBody));
68
- }
69
- });
70
- return focusableElements;
71
- };
72
- function isFocusable(element) {
73
- if (!element)
74
- return false;
75
- return element.matches(focusableSelector) && isVisible(element);
76
- }
77
- var rtlKeyMap = {
78
- ArrowLeft: "ArrowRight",
79
- ArrowRight: "ArrowLeft",
80
- Home: "End",
81
- End: "Home"
82
- };
83
- var sameKeyMap = {
84
- Up: "ArrowUp",
85
- Down: "ArrowDown",
86
- Esc: "Escape",
87
- " ": "Space",
88
- ",": "Comma",
89
- Left: "ArrowLeft",
90
- Right: "ArrowRight"
91
- };
92
- function getEventKey(event, options = {}) {
93
- const { dir = "ltr", orientation = "horizontal" } = options;
94
- let { key } = event;
95
- key = sameKeyMap[key] ?? key;
96
- const isRtl = dir === "rtl" && orientation === "horizontal";
97
- if (isRtl && key in rtlKeyMap) {
98
- key = rtlKeyMap[key];
99
- }
100
- return key;
101
- }
102
- function nextTick(fn) {
103
- const set = /* @__PURE__ */ new Set();
104
- function raf2(fn2) {
105
- const id = globalThis.requestAnimationFrame(fn2);
106
- set.add(() => globalThis.cancelAnimationFrame(id));
107
- }
108
- raf2(() => raf2(fn));
109
- return function cleanup() {
110
- set.forEach(function(fn2) {
111
- fn2();
112
- });
113
- };
114
- }
115
- function raf(fn) {
116
- const id = globalThis.requestAnimationFrame(fn);
117
- return function cleanup() {
118
- globalThis.cancelAnimationFrame(id);
119
- };
120
- }
121
- function queryAll(root, selector) {
122
- return Array.from((root == null ? void 0 : root.querySelectorAll(selector)) ?? []);
123
- }
124
- function itemById(v, id) {
125
- return v.find((node) => node.id === id);
126
- }
127
- function indexOfId(v, id) {
128
- const item = itemById(v, id);
129
- return item ? v.indexOf(item) : -1;
130
- }
131
- function nextById(v, id, loop = true) {
132
- let idx = indexOfId(v, id);
133
- idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1);
134
- return v[idx];
135
- }
136
- function prevById(v, id, loop = true) {
137
- let idx = indexOfId(v, id);
138
- if (idx === -1)
139
- return loop ? v[v.length - 1] : null;
140
- idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1);
141
- return v[idx];
142
- }
143
-
144
- // ../../utilities/core/dist/index.mjs
145
- var first = (v) => v[0];
146
- var last = (v) => v[v.length - 1];
147
-
148
- // src/tabs.dom.ts
149
- var dom = defineDomHelpers({
150
- getRootId: (ctx) => {
151
- var _a;
152
- return ((_a = ctx.ids) == null ? void 0 : _a.root) ?? `tabs:${ctx.id}`;
153
- },
154
- getTriggerGroupId: (ctx) => {
155
- var _a;
156
- return ((_a = ctx.ids) == null ? void 0 : _a.triggerGroup) ?? `tabs:${ctx.id}:trigger-group`;
157
- },
158
- getContentId: (ctx, id) => {
159
- var _a;
160
- return ((_a = ctx.ids) == null ? void 0 : _a.content) ?? `tabs:${ctx.id}:content-${id}`;
161
- },
162
- getContentGroupId: (ctx) => {
163
- var _a;
164
- return ((_a = ctx.ids) == null ? void 0 : _a.contentGroup) ?? `tabs:${ctx.id}:content-group`;
165
- },
166
- getTriggerId: (ctx, id) => {
167
- var _a;
168
- return ((_a = ctx.ids) == null ? void 0 : _a.trigger) ?? `tabs:${ctx.id}:trigger-${id}`;
169
- },
170
- getIndicatorId: (ctx) => `tabs:${ctx.id}:indicator`,
171
- getTriggerGroupEl: (ctx) => dom.getById(ctx, dom.getTriggerGroupId(ctx)),
172
- getContentEl: (ctx, id) => dom.getById(ctx, dom.getContentId(ctx, id)),
173
- getTriggerEl: (ctx, id) => dom.getById(ctx, dom.getTriggerId(ctx, id)),
174
- getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
175
- getElements: (ctx) => {
176
- const ownerId = CSS.escape(dom.getTriggerGroupId(ctx));
177
- const selector = `[role=tab][data-ownedby='${ownerId}']:not([disabled])`;
178
- return queryAll(dom.getTriggerGroupEl(ctx), selector);
179
- },
180
- getFirstEl: (ctx) => first(dom.getElements(ctx)),
181
- getLastEl: (ctx) => last(dom.getElements(ctx)),
182
- getNextEl: (ctx, id) => nextById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loop),
183
- getPrevEl: (ctx, id) => prevById(dom.getElements(ctx), dom.getTriggerId(ctx, id), ctx.loop),
184
- getActiveContentEl: (ctx) => {
185
- if (!ctx.value)
186
- return;
187
- const id = dom.getContentId(ctx, ctx.value);
188
- return dom.getById(ctx, id);
189
- },
190
- getRectById: (ctx, id) => {
191
- const empty = {
192
- offsetLeft: 0,
193
- offsetTop: 0,
194
- offsetWidth: 0,
195
- offsetHeight: 0
196
- };
197
- const tab = itemById(dom.getElements(ctx), dom.getTriggerId(ctx, id)) ?? empty;
198
- if (ctx.isVertical) {
199
- return {
200
- top: `${tab.offsetTop}px`,
201
- height: `${tab.offsetHeight}px`
202
- };
203
- }
204
- return {
205
- left: `${tab.offsetLeft}px`,
206
- width: `${tab.offsetWidth}px`
207
- };
208
- }
209
- });
210
-
211
- // src/tabs.connect.ts
212
- function connect(state, send, normalize) {
213
- const messages = state.context.messages;
214
- const isFocused = state.matches("focused");
215
- return {
216
- value: state.context.value,
217
- focusedValue: state.context.focusedValue,
218
- previousValues: Array.from(state.context.previousValues),
219
- setValue(value) {
220
- send({ type: "SET_VALUE", value });
221
- },
222
- rootProps: normalize.element({
223
- "data-part": "root",
224
- id: dom.getRootId(state.context),
225
- "data-orientation": state.context.orientation,
226
- "data-focus": dataAttr(isFocused),
227
- dir: state.context.dir
228
- }),
229
- triggerGroupProps: normalize.element({
230
- "data-part": "trigger-group",
231
- id: dom.getTriggerGroupId(state.context),
232
- role: "tablist",
233
- "data-focus": dataAttr(isFocused),
234
- "aria-orientation": state.context.orientation,
235
- "data-orientation": state.context.orientation,
236
- "aria-label": messages.tablistLabel,
237
- onKeyDown(event) {
238
- const keyMap = {
239
- ArrowDown() {
240
- send("ARROW_DOWN");
241
- },
242
- ArrowUp() {
243
- send("ARROW_UP");
244
- },
245
- ArrowLeft() {
246
- send("ARROW_LEFT");
247
- },
248
- ArrowRight() {
249
- send("ARROW_RIGHT");
250
- },
251
- Home() {
252
- send("HOME");
253
- },
254
- End() {
255
- send("END");
256
- },
257
- Enter() {
258
- send({ type: "ENTER", value: state.context.focusedValue });
259
- }
260
- };
261
- let key = getEventKey(event, state.context);
262
- const exec = keyMap[key];
263
- if (exec) {
264
- event.preventDefault();
265
- exec(event);
266
- }
267
- }
268
- }),
269
- getTriggerProps(props) {
270
- const { value, disabled } = props;
271
- const selected = state.context.value === value;
272
- return normalize.button({
273
- "data-part": "trigger",
274
- role: "tab",
275
- type: "button",
276
- disabled,
277
- "data-orientation": state.context.orientation,
278
- "data-disabled": dataAttr(disabled),
279
- "aria-disabled": disabled,
280
- "data-value": value,
281
- "aria-selected": selected,
282
- "data-selected": dataAttr(selected),
283
- "aria-controls": dom.getContentId(state.context, value),
284
- "data-ownedby": dom.getTriggerGroupId(state.context),
285
- id: dom.getTriggerId(state.context, value),
286
- tabIndex: selected ? 0 : -1,
287
- onFocus() {
288
- send({ type: "TAB_FOCUS", value });
289
- },
290
- onBlur(event) {
291
- const target = event.relatedTarget;
292
- if ((target == null ? void 0 : target.getAttribute("role")) !== "tab") {
293
- send({ type: "TAB_BLUR" });
294
- }
295
- },
296
- onClick(event) {
297
- if (disabled)
298
- return;
299
- if (isSafari()) {
300
- event.currentTarget.focus();
301
- }
302
- send({ type: "TAB_CLICK", value });
303
- }
304
- });
305
- },
306
- contentGroupProps: normalize.element({
307
- "data-part": "content-group",
308
- id: dom.getContentGroupId(state.context),
309
- "data-orientation": state.context.orientation
310
- }),
311
- getContentProps({ value }) {
312
- const selected = state.context.value === value;
313
- return normalize.element({
314
- "data-part": "content",
315
- id: dom.getContentId(state.context, value),
316
- tabIndex: 0,
317
- "aria-labelledby": dom.getTriggerId(state.context, value),
318
- role: "tabpanel",
319
- "data-ownedby": dom.getTriggerGroupId(state.context),
320
- hidden: !selected
321
- });
322
- },
323
- getDeleteButtonProps({ value, disabled }) {
324
- var _a;
325
- return normalize.button({
326
- "data-part": "delete-button",
327
- type: "button",
328
- tabIndex: -1,
329
- "aria-label": (_a = messages.deleteLabel) == null ? void 0 : _a.call(messages, value),
330
- disabled,
331
- onClick() {
332
- send({ type: "DELETE", value });
333
- }
334
- });
335
- },
336
- indicatorProps: normalize.element({
337
- id: dom.getIndicatorId(state.context),
338
- "data-part": "indicator",
339
- "data-orientation": state.context.orientation,
340
- style: {
341
- "--transition-duration": "200ms",
342
- "--transition-property": "left, right, top, bottom, width, height",
343
- position: "absolute",
344
- willChange: "var(--transition-property)",
345
- transitionProperty: "var(--transition-property)",
346
- transitionDuration: state.context.hasMeasuredRect ? "var(--transition-duration)" : "0ms",
347
- transitionTimingFunction: "var(--transition-timing-function)",
348
- ...state.context.indicatorRect
349
- }
350
- })
351
- };
352
- }
353
-
354
- // src/tabs.machine.ts
355
- import { createMachine, guards } from "@zag-js/core";
356
- var { not } = guards;
357
- function machine(ctx) {
358
- return createMachine(
359
- {
360
- initial: "unknown",
361
- context: {
362
- dir: "ltr",
363
- orientation: "horizontal",
364
- activationMode: "automatic",
365
- value: null,
366
- focusedValue: null,
367
- previousValues: [],
368
- indicatorRect: { left: "0px", top: "0px", width: "0px", height: "0px" },
369
- hasMeasuredRect: false,
370
- isIndicatorRendered: false,
371
- loop: true,
372
- messages: {},
373
- ...ctx
374
- },
375
- computed: {
376
- isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
377
- isVertical: (ctx2) => ctx2.orientation === "vertical"
378
- },
379
- created: ["setPrevSelectedTabs"],
380
- watch: {
381
- focusedValue: "invokeOnFocus",
382
- value: ["invokeOnChange", "setPrevSelectedTabs", "setIndicatorRect", "setContentTabIndex"],
383
- dir: ["clearMeasured", "setIndicatorRect"]
384
- },
385
- on: {
386
- SET_VALUE: {
387
- actions: "setValue"
388
- },
389
- DELETE: {
390
- actions: "deleteValue"
391
- }
392
- },
393
- states: {
394
- unknown: {
395
- on: {
396
- SETUP: {
397
- target: "idle",
398
- actions: ["checkRenderedElements", "setIndicatorRect", "setContentTabIndex"]
399
- }
400
- }
401
- },
402
- idle: {
403
- on: {
404
- TAB_FOCUS: {
405
- guard: "selectOnFocus",
406
- target: "focused",
407
- actions: ["setFocusedValue", "setValue"]
408
- },
409
- TAB_CLICK: {
410
- target: "focused",
411
- actions: ["setFocusedValue", "setValue"]
412
- }
413
- }
414
- },
415
- focused: {
416
- on: {
417
- TAB_CLICK: {
418
- target: "focused",
419
- actions: ["setFocusedValue", "setValue"]
420
- },
421
- ARROW_LEFT: {
422
- guard: "isHorizontal",
423
- actions: "focusPrevTab"
424
- },
425
- ARROW_RIGHT: {
426
- guard: "isHorizontal",
427
- actions: "focusNextTab"
428
- },
429
- ARROW_UP: {
430
- guard: "isVertical",
431
- actions: "focusPrevTab"
432
- },
433
- ARROW_DOWN: {
434
- guard: "isVertical",
435
- actions: "focusNextTab"
436
- },
437
- HOME: {
438
- actions: "focusFirstTab"
439
- },
440
- END: {
441
- actions: "focusLastTab"
442
- },
443
- ENTER: {
444
- guard: not("selectOnFocus"),
445
- actions: "setValue"
446
- },
447
- TAB_FOCUS: [
448
- {
449
- guard: "selectOnFocus",
450
- actions: ["setFocusedValue", "setValue"]
451
- },
452
- { actions: "setFocusedValue" }
453
- ],
454
- TAB_BLUR: {
455
- target: "idle",
456
- actions: "clearFocusedValue"
457
- }
458
- }
459
- }
460
- }
461
- },
462
- {
463
- guards: {
464
- isVertical: (ctx2) => ctx2.isVertical,
465
- isHorizontal: (ctx2) => ctx2.isHorizontal,
466
- selectOnFocus: (ctx2) => ctx2.activationMode === "automatic"
467
- },
468
- actions: {
469
- setFocusedValue(ctx2, evt) {
470
- ctx2.focusedValue = evt.value;
471
- },
472
- clearFocusedValue(ctx2) {
473
- ctx2.focusedValue = null;
474
- },
475
- setValue(ctx2, evt) {
476
- ctx2.value = evt.value;
477
- },
478
- invokeOnDelete(ctx2, evt) {
479
- var _a;
480
- (_a = ctx2.onDelete) == null ? void 0 : _a.call(ctx2, { value: evt.value });
481
- },
482
- focusFirstTab(ctx2) {
483
- raf(() => {
484
- var _a;
485
- return (_a = dom.getFirstEl(ctx2)) == null ? void 0 : _a.focus();
486
- });
487
- },
488
- focusLastTab(ctx2) {
489
- raf(() => {
490
- var _a;
491
- return (_a = dom.getLastEl(ctx2)) == null ? void 0 : _a.focus();
492
- });
493
- },
494
- focusNextTab(ctx2) {
495
- if (!ctx2.focusedValue)
496
- return;
497
- const next = dom.getNextEl(ctx2, ctx2.focusedValue);
498
- raf(() => next == null ? void 0 : next.focus());
499
- },
500
- focusPrevTab(ctx2) {
501
- if (!ctx2.focusedValue)
502
- return;
503
- const prev = dom.getPrevEl(ctx2, ctx2.focusedValue);
504
- raf(() => prev == null ? void 0 : prev.focus());
505
- },
506
- setIndicatorRect(ctx2) {
507
- nextTick(() => {
508
- if (!ctx2.isIndicatorRendered || !ctx2.value)
509
- return;
510
- ctx2.indicatorRect = dom.getRectById(ctx2, ctx2.value);
511
- if (ctx2.hasMeasuredRect)
512
- return;
513
- nextTick(() => {
514
- ctx2.hasMeasuredRect = true;
515
- });
516
- });
517
- },
518
- checkRenderedElements(ctx2) {
519
- ctx2.isIndicatorRendered = !!dom.getIndicatorEl(ctx2);
520
- },
521
- clearMeasured(ctx2) {
522
- ctx2.hasMeasuredRect = false;
523
- },
524
- invokeOnChange(ctx2) {
525
- var _a;
526
- (_a = ctx2.onChange) == null ? void 0 : _a.call(ctx2, { value: ctx2.value });
527
- },
528
- invokeOnFocus(ctx2) {
529
- var _a;
530
- (_a = ctx2.onFocus) == null ? void 0 : _a.call(ctx2, { value: ctx2.focusedValue });
531
- },
532
- setPrevSelectedTabs(ctx2) {
533
- if (ctx2.value != null) {
534
- const newSelected = Array.from(ctx2.previousValues).concat(ctx2.value);
535
- ctx2.previousValues = Array.from(new Set(newSelected));
536
- }
537
- },
538
- setContentTabIndex(ctx2) {
539
- raf(() => {
540
- const panel = dom.getActiveContentEl(ctx2);
541
- if (!panel)
542
- return;
543
- const focusables = getFocusables(panel);
544
- if (focusables.length > 0) {
545
- panel.removeAttribute("tabindex");
546
- } else {
547
- panel.setAttribute("tabindex", "0");
548
- }
549
- });
550
- }
551
- }
552
- }
553
- );
554
- }
555
- export {
556
- connect,
557
- machine
558
- };