@zag-js/combobox 1.15.4 → 1.15.6

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 CHANGED
@@ -257,6 +257,7 @@ interface ComboboxSchema<T extends CollectionItem = CollectionItem> {
257
257
  valueAsString: string;
258
258
  };
259
259
  computed: {
260
+ isCustomValue: boolean;
260
261
  isInputValueEmpty: boolean;
261
262
  isInteractive: boolean;
262
263
  autoComplete: boolean;
package/dist/index.d.ts CHANGED
@@ -257,6 +257,7 @@ interface ComboboxSchema<T extends CollectionItem = CollectionItem> {
257
257
  valueAsString: string;
258
258
  };
259
259
  computed: {
260
+ isCustomValue: boolean;
260
261
  isInputValueEmpty: boolean;
261
262
  isInteractive: boolean;
262
263
  autoComplete: boolean;
package/dist/index.js CHANGED
@@ -263,7 +263,8 @@ function connect(service, normalize) {
263
263
  },
264
264
  Enter(event3) {
265
265
  send({ type: "INPUT.ENTER", keypress });
266
- if (open) {
266
+ const submittable = computed("isCustomValue") && prop("allowCustomValue");
267
+ if (open && !submittable) {
267
268
  event3.preventDefault();
268
269
  }
269
270
  if (highlightedValue == null) return;
@@ -313,6 +314,7 @@ function connect(service, normalize) {
313
314
  onPointerDown(event2) {
314
315
  if (!interactive) return;
315
316
  if (event2.pointerType === "touch") return;
317
+ if (!domQuery.isLeftClick(event2)) return;
316
318
  event2.preventDefault();
317
319
  queueMicrotask(() => {
318
320
  getInputEl(scope)?.focus({ preventScroll: true });
@@ -352,6 +354,7 @@ function connect(service, normalize) {
352
354
  "aria-multiselectable": prop("multiple") && composite ? true : void 0,
353
355
  "data-empty": domQuery.dataAttr(collection2.size === 0),
354
356
  onPointerDown(event2) {
357
+ if (!domQuery.isLeftClick(event2)) return;
355
358
  event2.preventDefault();
356
359
  }
357
360
  });
@@ -378,6 +381,7 @@ function connect(service, normalize) {
378
381
  "aria-controls": getInputId(scope),
379
382
  hidden: !context.get("value").length,
380
383
  onPointerDown(event2) {
384
+ if (!domQuery.isLeftClick(event2)) return;
381
385
  event2.preventDefault();
382
386
  },
383
387
  onClick(event2) {
@@ -577,7 +581,8 @@ var machine = createMachine({
577
581
  isInteractive: ({ prop }) => !(prop("readOnly") || prop("disabled")),
578
582
  autoComplete: ({ prop }) => prop("inputBehavior") === "autocomplete",
579
583
  autoHighlight: ({ prop }) => prop("inputBehavior") === "autohighlight",
580
- hasSelectedItems: ({ context }) => context.get("value").length > 0
584
+ hasSelectedItems: ({ context }) => context.get("value").length > 0,
585
+ isCustomValue: ({ context }) => context.get("inputValue") !== context.get("valueAsString")
581
586
  },
582
587
  watch({ context, prop, track, action }) {
583
588
  track([() => context.hash("value")], () => {
@@ -1112,7 +1117,7 @@ var machine = createMachine({
1112
1117
  autoHighlight: ({ computed }) => computed("autoHighlight"),
1113
1118
  isFirstItemHighlighted: ({ prop, context }) => prop("collection").firstValue === context.get("highlightedValue"),
1114
1119
  isLastItemHighlighted: ({ prop, context }) => prop("collection").lastValue === context.get("highlightedValue"),
1115
- isCustomValue: ({ context }) => context.get("inputValue") !== context.get("valueAsString"),
1120
+ isCustomValue: ({ computed }) => computed("isCustomValue"),
1116
1121
  allowCustomValue: ({ prop }) => !!prop("allowCustomValue"),
1117
1122
  hasHighlightedItem: ({ context }) => context.get("highlightedValue") != null,
1118
1123
  closeOnSelect: ({ prop }) => !!prop("closeOnSelect"),
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createAnatomy } from '@zag-js/anatomy';
2
2
  import { ListCollection } from '@zag-js/collection';
3
- import { raf, setCaretToEnd, observeAttributes, observeChildren, clickIfLink, scrollIntoView, query, dataAttr, ariaAttr, isDownloadingEvent, isOpeningInNewTab, isContextMenuEvent, getEventKey, isLeftClick, isComposingEvent, isAnchorElement } from '@zag-js/dom-query';
3
+ import { raf, setCaretToEnd, observeAttributes, observeChildren, clickIfLink, scrollIntoView, query, dataAttr, ariaAttr, isDownloadingEvent, isOpeningInNewTab, isContextMenuEvent, isLeftClick, getEventKey, isComposingEvent, isAnchorElement } from '@zag-js/dom-query';
4
4
  import { getPlacement, getPlacementStyles } from '@zag-js/popper';
5
5
  import { match, remove, addOrRemove, isBoolean, isEqual, createSplitProps, ensure } from '@zag-js/utils';
6
6
  import { ariaHidden } from '@zag-js/aria-hidden';
@@ -261,7 +261,8 @@ function connect(service, normalize) {
261
261
  },
262
262
  Enter(event3) {
263
263
  send({ type: "INPUT.ENTER", keypress });
264
- if (open) {
264
+ const submittable = computed("isCustomValue") && prop("allowCustomValue");
265
+ if (open && !submittable) {
265
266
  event3.preventDefault();
266
267
  }
267
268
  if (highlightedValue == null) return;
@@ -311,6 +312,7 @@ function connect(service, normalize) {
311
312
  onPointerDown(event2) {
312
313
  if (!interactive) return;
313
314
  if (event2.pointerType === "touch") return;
315
+ if (!isLeftClick(event2)) return;
314
316
  event2.preventDefault();
315
317
  queueMicrotask(() => {
316
318
  getInputEl(scope)?.focus({ preventScroll: true });
@@ -350,6 +352,7 @@ function connect(service, normalize) {
350
352
  "aria-multiselectable": prop("multiple") && composite ? true : void 0,
351
353
  "data-empty": dataAttr(collection2.size === 0),
352
354
  onPointerDown(event2) {
355
+ if (!isLeftClick(event2)) return;
353
356
  event2.preventDefault();
354
357
  }
355
358
  });
@@ -376,6 +379,7 @@ function connect(service, normalize) {
376
379
  "aria-controls": getInputId(scope),
377
380
  hidden: !context.get("value").length,
378
381
  onPointerDown(event2) {
382
+ if (!isLeftClick(event2)) return;
379
383
  event2.preventDefault();
380
384
  },
381
385
  onClick(event2) {
@@ -575,7 +579,8 @@ var machine = createMachine({
575
579
  isInteractive: ({ prop }) => !(prop("readOnly") || prop("disabled")),
576
580
  autoComplete: ({ prop }) => prop("inputBehavior") === "autocomplete",
577
581
  autoHighlight: ({ prop }) => prop("inputBehavior") === "autohighlight",
578
- hasSelectedItems: ({ context }) => context.get("value").length > 0
582
+ hasSelectedItems: ({ context }) => context.get("value").length > 0,
583
+ isCustomValue: ({ context }) => context.get("inputValue") !== context.get("valueAsString")
579
584
  },
580
585
  watch({ context, prop, track, action }) {
581
586
  track([() => context.hash("value")], () => {
@@ -1110,7 +1115,7 @@ var machine = createMachine({
1110
1115
  autoHighlight: ({ computed }) => computed("autoHighlight"),
1111
1116
  isFirstItemHighlighted: ({ prop, context }) => prop("collection").firstValue === context.get("highlightedValue"),
1112
1117
  isLastItemHighlighted: ({ prop, context }) => prop("collection").lastValue === context.get("highlightedValue"),
1113
- isCustomValue: ({ context }) => context.get("inputValue") !== context.get("valueAsString"),
1118
+ isCustomValue: ({ computed }) => computed("isCustomValue"),
1114
1119
  allowCustomValue: ({ prop }) => !!prop("allowCustomValue"),
1115
1120
  hasHighlightedItem: ({ context }) => context.get("highlightedValue") != null,
1116
1121
  closeOnSelect: ({ prop }) => !!prop("closeOnSelect"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/combobox",
3
- "version": "1.15.4",
3
+ "version": "1.15.6",
4
4
  "description": "Core logic for the combobox widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,15 +26,15 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "1.15.4",
30
- "@zag-js/aria-hidden": "1.15.4",
31
- "@zag-js/collection": "1.15.4",
32
- "@zag-js/core": "1.15.4",
33
- "@zag-js/dismissable": "1.15.4",
34
- "@zag-js/dom-query": "1.15.4",
35
- "@zag-js/utils": "1.15.4",
36
- "@zag-js/popper": "1.15.4",
37
- "@zag-js/types": "1.15.4"
29
+ "@zag-js/anatomy": "1.15.6",
30
+ "@zag-js/aria-hidden": "1.15.6",
31
+ "@zag-js/collection": "1.15.6",
32
+ "@zag-js/core": "1.15.6",
33
+ "@zag-js/dismissable": "1.15.6",
34
+ "@zag-js/dom-query": "1.15.6",
35
+ "@zag-js/utils": "1.15.6",
36
+ "@zag-js/popper": "1.15.6",
37
+ "@zag-js/types": "1.15.6"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"