@zag-js/combobox 1.34.1 → 1.35.0

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.
@@ -0,0 +1,6 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "clearTrigger" | "content" | "control" | "input" | "item" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "label" | "list" | "positioner" | "trigger">;
4
+ declare const parts: Record<"root" | "clearTrigger" | "content" | "control" | "input" | "item" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "label" | "list" | "positioner" | "trigger", _zag_js_anatomy.AnatomyPart>;
5
+
6
+ export { anatomy, parts };
@@ -0,0 +1,6 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "clearTrigger" | "content" | "control" | "input" | "item" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "label" | "list" | "positioner" | "trigger">;
4
+ declare const parts: Record<"root" | "clearTrigger" | "content" | "control" | "input" | "item" | "itemGroup" | "itemGroupLabel" | "itemIndicator" | "itemText" | "label" | "list" | "positioner" | "trigger", _zag_js_anatomy.AnatomyPart>;
5
+
6
+ export { anatomy, parts };
@@ -0,0 +1,49 @@
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/combobox.anatomy.ts
21
+ var combobox_anatomy_exports = {};
22
+ __export(combobox_anatomy_exports, {
23
+ anatomy: () => anatomy,
24
+ parts: () => parts
25
+ });
26
+ module.exports = __toCommonJS(combobox_anatomy_exports);
27
+ var import_anatomy = require("@zag-js/anatomy");
28
+ var anatomy = (0, import_anatomy.createAnatomy)("combobox").parts(
29
+ "root",
30
+ "clearTrigger",
31
+ "content",
32
+ "control",
33
+ "input",
34
+ "item",
35
+ "itemGroup",
36
+ "itemGroupLabel",
37
+ "itemIndicator",
38
+ "itemText",
39
+ "label",
40
+ "list",
41
+ "positioner",
42
+ "trigger"
43
+ );
44
+ var parts = anatomy.build();
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ anatomy,
48
+ parts
49
+ });
@@ -0,0 +1,23 @@
1
+ // src/combobox.anatomy.ts
2
+ import { createAnatomy } from "@zag-js/anatomy";
3
+ var anatomy = createAnatomy("combobox").parts(
4
+ "root",
5
+ "clearTrigger",
6
+ "content",
7
+ "control",
8
+ "input",
9
+ "item",
10
+ "itemGroup",
11
+ "itemGroupLabel",
12
+ "itemIndicator",
13
+ "itemText",
14
+ "label",
15
+ "list",
16
+ "positioner",
17
+ "trigger"
18
+ );
19
+ var parts = anatomy.build();
20
+ export {
21
+ anatomy,
22
+ parts
23
+ };
@@ -0,0 +1,8 @@
1
+ import { CollectionOptions, ListCollection, CollectionItem } from '@zag-js/collection';
2
+
3
+ declare const collection: {
4
+ <T extends unknown>(options: CollectionOptions<T>): ListCollection<T>;
5
+ empty(): ListCollection<CollectionItem>;
6
+ };
7
+
8
+ export { collection };
@@ -0,0 +1,8 @@
1
+ import { CollectionOptions, ListCollection, CollectionItem } from '@zag-js/collection';
2
+
3
+ declare const collection: {
4
+ <T extends unknown>(options: CollectionOptions<T>): ListCollection<T>;
5
+ empty(): ListCollection<CollectionItem>;
6
+ };
7
+
8
+ export { collection };
@@ -0,0 +1,36 @@
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/combobox.collection.ts
21
+ var combobox_collection_exports = {};
22
+ __export(combobox_collection_exports, {
23
+ collection: () => collection
24
+ });
25
+ module.exports = __toCommonJS(combobox_collection_exports);
26
+ var import_collection = require("@zag-js/collection");
27
+ var collection = (options) => {
28
+ return new import_collection.ListCollection(options);
29
+ };
30
+ collection.empty = () => {
31
+ return new import_collection.ListCollection({ items: [] });
32
+ };
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ collection
36
+ });
@@ -0,0 +1,11 @@
1
+ // src/combobox.collection.ts
2
+ import { ListCollection } from "@zag-js/collection";
3
+ var collection = (options) => {
4
+ return new ListCollection(options);
5
+ };
6
+ collection.empty = () => {
7
+ return new ListCollection({ items: [] });
8
+ };
9
+ export {
10
+ collection
11
+ };
@@ -0,0 +1,10 @@
1
+ import { PropTypes, NormalizeProps } from '@zag-js/types';
2
+ import { ComboboxService, ComboboxApi } from './combobox.types.mjs';
3
+ import { CollectionItem } from '@zag-js/collection';
4
+ import '@zag-js/core';
5
+ import '@zag-js/dismissable';
6
+ import '@zag-js/popper';
7
+
8
+ declare function connect<T extends PropTypes, V extends CollectionItem>(service: ComboboxService<V>, normalize: NormalizeProps<T>): ComboboxApi<T, V>;
9
+
10
+ export { connect };
@@ -0,0 +1,10 @@
1
+ import { PropTypes, NormalizeProps } from '@zag-js/types';
2
+ import { ComboboxService, ComboboxApi } from './combobox.types.js';
3
+ import { CollectionItem } from '@zag-js/collection';
4
+ import '@zag-js/core';
5
+ import '@zag-js/dismissable';
6
+ import '@zag-js/popper';
7
+
8
+ declare function connect<T extends PropTypes, V extends CollectionItem>(service: ComboboxService<V>, normalize: NormalizeProps<T>): ComboboxApi<T, V>;
9
+
10
+ export { connect };
@@ -0,0 +1,454 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/combobox.connect.ts
31
+ var combobox_connect_exports = {};
32
+ __export(combobox_connect_exports, {
33
+ connect: () => connect
34
+ });
35
+ module.exports = __toCommonJS(combobox_connect_exports);
36
+ var import_dom_query = require("@zag-js/dom-query");
37
+ var import_popper = require("@zag-js/popper");
38
+ var import_utils = require("@zag-js/utils");
39
+ var import_combobox = require("./combobox.anatomy.cjs");
40
+ var dom = __toESM(require("./combobox.dom.cjs"));
41
+ function connect(service, normalize) {
42
+ const { context, prop, state, send, scope, computed, event } = service;
43
+ const translations = prop("translations");
44
+ const collection = prop("collection");
45
+ const disabled = !!prop("disabled");
46
+ const interactive = computed("isInteractive");
47
+ const invalid = !!prop("invalid");
48
+ const required = !!prop("required");
49
+ const readOnly = !!prop("readOnly");
50
+ const open = state.hasTag("open");
51
+ const focused = state.hasTag("focused");
52
+ const composite = prop("composite");
53
+ const highlightedValue = context.get("highlightedValue");
54
+ const popperStyles = (0, import_popper.getPlacementStyles)({
55
+ ...prop("positioning"),
56
+ placement: context.get("currentPlacement")
57
+ });
58
+ function getItemState(props) {
59
+ const itemDisabled = collection.getItemDisabled(props.item);
60
+ const value = collection.getItemValue(props.item);
61
+ (0, import_utils.ensure)(value, () => `[zag-js] No value found for item ${JSON.stringify(props.item)}`);
62
+ return {
63
+ value,
64
+ disabled: Boolean(disabled || itemDisabled),
65
+ highlighted: highlightedValue === value,
66
+ selected: context.get("value").includes(value)
67
+ };
68
+ }
69
+ return {
70
+ focused,
71
+ open,
72
+ inputValue: context.get("inputValue"),
73
+ highlightedValue,
74
+ highlightedItem: context.get("highlightedItem"),
75
+ value: context.get("value"),
76
+ valueAsString: computed("valueAsString"),
77
+ hasSelectedItems: computed("hasSelectedItems"),
78
+ selectedItems: context.get("selectedItems"),
79
+ collection: prop("collection"),
80
+ multiple: !!prop("multiple"),
81
+ disabled: !!disabled,
82
+ syncSelectedItems() {
83
+ send({ type: "SELECTED_ITEMS.SYNC" });
84
+ },
85
+ reposition(options = {}) {
86
+ send({ type: "POSITIONING.SET", options });
87
+ },
88
+ setHighlightValue(value) {
89
+ send({ type: "HIGHLIGHTED_VALUE.SET", value });
90
+ },
91
+ clearHighlightValue() {
92
+ send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
93
+ },
94
+ selectValue(value) {
95
+ send({ type: "ITEM.SELECT", value });
96
+ },
97
+ setValue(value) {
98
+ send({ type: "VALUE.SET", value });
99
+ },
100
+ setInputValue(value, reason = "script") {
101
+ send({ type: "INPUT_VALUE.SET", value, src: reason });
102
+ },
103
+ clearValue(value) {
104
+ if (value != null) {
105
+ send({ type: "ITEM.CLEAR", value });
106
+ } else {
107
+ send({ type: "VALUE.CLEAR" });
108
+ }
109
+ },
110
+ focus() {
111
+ dom.getInputEl(scope)?.focus();
112
+ },
113
+ setOpen(nextOpen, reason = "script") {
114
+ const open2 = state.hasTag("open");
115
+ if (open2 === nextOpen) return;
116
+ send({ type: nextOpen ? "OPEN" : "CLOSE", src: reason });
117
+ },
118
+ getRootProps() {
119
+ return normalize.element({
120
+ ...import_combobox.parts.root.attrs,
121
+ dir: prop("dir"),
122
+ id: dom.getRootId(scope),
123
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid),
124
+ "data-readonly": (0, import_dom_query.dataAttr)(readOnly)
125
+ });
126
+ },
127
+ getLabelProps() {
128
+ return normalize.label({
129
+ ...import_combobox.parts.label.attrs,
130
+ dir: prop("dir"),
131
+ htmlFor: dom.getInputId(scope),
132
+ id: dom.getLabelId(scope),
133
+ "data-readonly": (0, import_dom_query.dataAttr)(readOnly),
134
+ "data-disabled": (0, import_dom_query.dataAttr)(disabled),
135
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid),
136
+ "data-required": (0, import_dom_query.dataAttr)(required),
137
+ "data-focus": (0, import_dom_query.dataAttr)(focused),
138
+ onClick(event2) {
139
+ if (composite) return;
140
+ event2.preventDefault();
141
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
142
+ }
143
+ });
144
+ },
145
+ getControlProps() {
146
+ return normalize.element({
147
+ ...import_combobox.parts.control.attrs,
148
+ dir: prop("dir"),
149
+ id: dom.getControlId(scope),
150
+ "data-state": open ? "open" : "closed",
151
+ "data-focus": (0, import_dom_query.dataAttr)(focused),
152
+ "data-disabled": (0, import_dom_query.dataAttr)(disabled),
153
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid)
154
+ });
155
+ },
156
+ getPositionerProps() {
157
+ return normalize.element({
158
+ ...import_combobox.parts.positioner.attrs,
159
+ dir: prop("dir"),
160
+ id: dom.getPositionerId(scope),
161
+ style: popperStyles.floating
162
+ });
163
+ },
164
+ getInputProps() {
165
+ return normalize.input({
166
+ ...import_combobox.parts.input.attrs,
167
+ dir: prop("dir"),
168
+ "aria-invalid": (0, import_dom_query.ariaAttr)(invalid),
169
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid),
170
+ "data-autofocus": (0, import_dom_query.dataAttr)(prop("autoFocus")),
171
+ name: prop("name"),
172
+ form: prop("form"),
173
+ disabled,
174
+ required: prop("required"),
175
+ autoComplete: "off",
176
+ autoCorrect: "off",
177
+ autoCapitalize: "none",
178
+ spellCheck: "false",
179
+ readOnly,
180
+ placeholder: prop("placeholder"),
181
+ id: dom.getInputId(scope),
182
+ type: "text",
183
+ role: "combobox",
184
+ defaultValue: context.get("inputValue"),
185
+ "aria-autocomplete": computed("autoComplete") ? "both" : "list",
186
+ "aria-controls": dom.getContentId(scope),
187
+ "aria-expanded": open,
188
+ "data-state": open ? "open" : "closed",
189
+ "aria-activedescendant": highlightedValue ? dom.getItemId(scope, highlightedValue) : void 0,
190
+ onClick(event2) {
191
+ if (event2.defaultPrevented) return;
192
+ if (!prop("openOnClick")) return;
193
+ if (!interactive) return;
194
+ send({ type: "INPUT.CLICK", src: "input-click" });
195
+ },
196
+ onFocus() {
197
+ if (disabled) return;
198
+ send({ type: "INPUT.FOCUS" });
199
+ },
200
+ onBlur() {
201
+ if (disabled) return;
202
+ send({ type: "INPUT.BLUR" });
203
+ },
204
+ onChange(event2) {
205
+ send({ type: "INPUT.CHANGE", value: event2.currentTarget.value, src: "input-change" });
206
+ },
207
+ onKeyDown(event2) {
208
+ if (event2.defaultPrevented) return;
209
+ if (!interactive) return;
210
+ if (event2.ctrlKey || event2.shiftKey || (0, import_dom_query.isComposingEvent)(event2)) return;
211
+ const openOnKeyPress = prop("openOnKeyPress");
212
+ const isModifierKey = event2.ctrlKey || event2.metaKey || event2.shiftKey;
213
+ const keypress = true;
214
+ const keymap = {
215
+ ArrowDown(event3) {
216
+ if (!openOnKeyPress && !open) return;
217
+ send({ type: event3.altKey ? "OPEN" : "INPUT.ARROW_DOWN", keypress, src: "arrow-key" });
218
+ event3.preventDefault();
219
+ },
220
+ ArrowUp() {
221
+ if (!openOnKeyPress && !open) return;
222
+ send({ type: event2.altKey ? "CLOSE" : "INPUT.ARROW_UP", keypress, src: "arrow-key" });
223
+ event2.preventDefault();
224
+ },
225
+ Home(event3) {
226
+ if (isModifierKey) return;
227
+ send({ type: "INPUT.HOME", keypress });
228
+ if (open) {
229
+ event3.preventDefault();
230
+ }
231
+ },
232
+ End(event3) {
233
+ if (isModifierKey) return;
234
+ send({ type: "INPUT.END", keypress });
235
+ if (open) {
236
+ event3.preventDefault();
237
+ }
238
+ },
239
+ Enter(event3) {
240
+ send({ type: "INPUT.ENTER", keypress, src: "item-select" });
241
+ const submittable = computed("isCustomValue") && prop("allowCustomValue");
242
+ const hasHighlight = highlightedValue != null;
243
+ const alwaysSubmit = prop("alwaysSubmitOnEnter");
244
+ if (open && !submittable && !alwaysSubmit && hasHighlight) {
245
+ event3.preventDefault();
246
+ }
247
+ if (highlightedValue == null) return;
248
+ const itemEl = dom.getItemEl(scope, highlightedValue);
249
+ if ((0, import_dom_query.isAnchorElement)(itemEl)) {
250
+ prop("navigate")?.({ value: highlightedValue, node: itemEl, href: itemEl.href });
251
+ }
252
+ },
253
+ Escape() {
254
+ send({ type: "INPUT.ESCAPE", keypress, src: "escape-key" });
255
+ event2.preventDefault();
256
+ }
257
+ };
258
+ const key = (0, import_dom_query.getEventKey)(event2, { dir: prop("dir") });
259
+ const exec = keymap[key];
260
+ exec?.(event2);
261
+ }
262
+ });
263
+ },
264
+ getTriggerProps(props = {}) {
265
+ return normalize.button({
266
+ ...import_combobox.parts.trigger.attrs,
267
+ dir: prop("dir"),
268
+ id: dom.getTriggerId(scope),
269
+ "aria-haspopup": composite ? "listbox" : "dialog",
270
+ type: "button",
271
+ tabIndex: props.focusable ? void 0 : -1,
272
+ "aria-label": translations.triggerLabel,
273
+ "aria-expanded": open,
274
+ "data-state": open ? "open" : "closed",
275
+ "aria-controls": open ? dom.getContentId(scope) : void 0,
276
+ disabled,
277
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid),
278
+ "data-focusable": (0, import_dom_query.dataAttr)(props.focusable),
279
+ "data-readonly": (0, import_dom_query.dataAttr)(readOnly),
280
+ "data-disabled": (0, import_dom_query.dataAttr)(disabled),
281
+ onFocus() {
282
+ if (!props.focusable) return;
283
+ send({ type: "INPUT.FOCUS", src: "trigger" });
284
+ },
285
+ onClick(event2) {
286
+ if (event2.defaultPrevented) return;
287
+ if (!interactive) return;
288
+ if (!(0, import_dom_query.isLeftClick)(event2)) return;
289
+ send({ type: "TRIGGER.CLICK", src: "trigger-click" });
290
+ },
291
+ onPointerDown(event2) {
292
+ if (!interactive) return;
293
+ if (event2.pointerType === "touch") return;
294
+ if (!(0, import_dom_query.isLeftClick)(event2)) return;
295
+ event2.preventDefault();
296
+ queueMicrotask(() => {
297
+ dom.focusInputEl(scope);
298
+ });
299
+ },
300
+ onKeyDown(event2) {
301
+ if (event2.defaultPrevented) return;
302
+ if (composite) return;
303
+ const keyMap = {
304
+ ArrowDown() {
305
+ send({ type: "INPUT.ARROW_DOWN", src: "arrow-key" });
306
+ },
307
+ ArrowUp() {
308
+ send({ type: "INPUT.ARROW_UP", src: "arrow-key" });
309
+ }
310
+ };
311
+ const key = (0, import_dom_query.getEventKey)(event2, { dir: prop("dir") });
312
+ const exec = keyMap[key];
313
+ if (exec) {
314
+ exec(event2);
315
+ event2.preventDefault();
316
+ }
317
+ }
318
+ });
319
+ },
320
+ getContentProps() {
321
+ return normalize.element({
322
+ ...import_combobox.parts.content.attrs,
323
+ dir: prop("dir"),
324
+ id: dom.getContentId(scope),
325
+ role: !composite ? "dialog" : "listbox",
326
+ tabIndex: -1,
327
+ hidden: !open,
328
+ "data-state": open ? "open" : "closed",
329
+ "data-placement": context.get("currentPlacement"),
330
+ "aria-labelledby": dom.getLabelId(scope),
331
+ "aria-multiselectable": prop("multiple") && composite ? true : void 0,
332
+ "data-empty": (0, import_dom_query.dataAttr)(collection.size === 0),
333
+ onPointerDown(event2) {
334
+ if (!(0, import_dom_query.isLeftClick)(event2)) return;
335
+ event2.preventDefault();
336
+ }
337
+ });
338
+ },
339
+ getListProps() {
340
+ return normalize.element({
341
+ ...import_combobox.parts.list.attrs,
342
+ role: !composite ? "listbox" : void 0,
343
+ "data-empty": (0, import_dom_query.dataAttr)(collection.size === 0),
344
+ "aria-labelledby": dom.getLabelId(scope),
345
+ "aria-multiselectable": prop("multiple") && !composite ? true : void 0
346
+ });
347
+ },
348
+ getClearTriggerProps() {
349
+ return normalize.button({
350
+ ...import_combobox.parts.clearTrigger.attrs,
351
+ dir: prop("dir"),
352
+ id: dom.getClearTriggerId(scope),
353
+ type: "button",
354
+ tabIndex: -1,
355
+ disabled,
356
+ "data-invalid": (0, import_dom_query.dataAttr)(invalid),
357
+ "aria-label": translations.clearTriggerLabel,
358
+ "aria-controls": dom.getInputId(scope),
359
+ hidden: !context.get("value").length,
360
+ onPointerDown(event2) {
361
+ if (!(0, import_dom_query.isLeftClick)(event2)) return;
362
+ event2.preventDefault();
363
+ },
364
+ onClick(event2) {
365
+ if (event2.defaultPrevented) return;
366
+ if (!interactive) return;
367
+ send({ type: "VALUE.CLEAR", src: "clear-trigger" });
368
+ }
369
+ });
370
+ },
371
+ getItemState,
372
+ getItemProps(props) {
373
+ const itemState = getItemState(props);
374
+ const value = itemState.value;
375
+ return normalize.element({
376
+ ...import_combobox.parts.item.attrs,
377
+ dir: prop("dir"),
378
+ id: dom.getItemId(scope, value),
379
+ role: "option",
380
+ tabIndex: -1,
381
+ "data-highlighted": (0, import_dom_query.dataAttr)(itemState.highlighted),
382
+ "data-state": itemState.selected ? "checked" : "unchecked",
383
+ "aria-selected": (0, import_dom_query.ariaAttr)(itemState.selected),
384
+ "aria-disabled": (0, import_dom_query.ariaAttr)(itemState.disabled),
385
+ "data-disabled": (0, import_dom_query.dataAttr)(itemState.disabled),
386
+ "data-value": itemState.value,
387
+ onPointerMove() {
388
+ if (itemState.disabled) return;
389
+ if (itemState.highlighted) return;
390
+ send({ type: "ITEM.POINTER_MOVE", value });
391
+ },
392
+ onPointerLeave() {
393
+ if (props.persistFocus) return;
394
+ if (itemState.disabled) return;
395
+ const prev = event.previous();
396
+ const mouseMoved = prev?.type.includes("POINTER");
397
+ if (!mouseMoved) return;
398
+ send({ type: "ITEM.POINTER_LEAVE", value });
399
+ },
400
+ onClick(event2) {
401
+ if ((0, import_dom_query.isDownloadingEvent)(event2)) return;
402
+ if ((0, import_dom_query.isOpeningInNewTab)(event2)) return;
403
+ if ((0, import_dom_query.isContextMenuEvent)(event2)) return;
404
+ if (itemState.disabled) return;
405
+ send({ type: "ITEM.CLICK", src: "item-select", value });
406
+ }
407
+ });
408
+ },
409
+ getItemTextProps(props) {
410
+ const itemState = getItemState(props);
411
+ return normalize.element({
412
+ ...import_combobox.parts.itemText.attrs,
413
+ dir: prop("dir"),
414
+ "data-state": itemState.selected ? "checked" : "unchecked",
415
+ "data-disabled": (0, import_dom_query.dataAttr)(itemState.disabled),
416
+ "data-highlighted": (0, import_dom_query.dataAttr)(itemState.highlighted)
417
+ });
418
+ },
419
+ getItemIndicatorProps(props) {
420
+ const itemState = getItemState(props);
421
+ return normalize.element({
422
+ "aria-hidden": true,
423
+ ...import_combobox.parts.itemIndicator.attrs,
424
+ dir: prop("dir"),
425
+ "data-state": itemState.selected ? "checked" : "unchecked",
426
+ hidden: !itemState.selected
427
+ });
428
+ },
429
+ getItemGroupProps(props) {
430
+ const { id } = props;
431
+ return normalize.element({
432
+ ...import_combobox.parts.itemGroup.attrs,
433
+ dir: prop("dir"),
434
+ id: dom.getItemGroupId(scope, id),
435
+ "aria-labelledby": dom.getItemGroupLabelId(scope, id),
436
+ "data-empty": (0, import_dom_query.dataAttr)(collection.size === 0),
437
+ role: "group"
438
+ });
439
+ },
440
+ getItemGroupLabelProps(props) {
441
+ const { htmlFor } = props;
442
+ return normalize.element({
443
+ ...import_combobox.parts.itemGroupLabel.attrs,
444
+ dir: prop("dir"),
445
+ id: dom.getItemGroupLabelId(scope, htmlFor),
446
+ role: "presentation"
447
+ });
448
+ }
449
+ };
450
+ }
451
+ // Annotate the CommonJS export names for ESM import in node:
452
+ 0 && (module.exports = {
453
+ connect
454
+ });