@zag-js/combobox 1.27.1 → 1.29.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.
package/dist/index.d.mts CHANGED
@@ -39,6 +39,7 @@ type OpenChangeReason = "input-click" | "trigger-click" | "script" | "arrow-key"
39
39
  interface OpenChangeDetails {
40
40
  open: boolean;
41
41
  reason?: OpenChangeReason | undefined;
42
+ value: string[];
42
43
  }
43
44
  interface ScrollToIndexDetails {
44
45
  index: number;
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ type OpenChangeReason = "input-click" | "trigger-click" | "script" | "arrow-key"
39
39
  interface OpenChangeDetails {
40
40
  open: boolean;
41
41
  reason?: OpenChangeReason | undefined;
42
+ value: string[];
42
43
  }
43
44
  interface ScrollToIndexDetails {
44
45
  index: number;
package/dist/index.js CHANGED
@@ -993,12 +993,16 @@ var machine = createMachine({
993
993
  ],
994
994
  CHILDREN_CHANGE: [
995
995
  {
996
- guard: "autoHighlight",
997
- actions: ["highlightFirstItem"]
996
+ guard: and("isHighlightedItemRemoved", "hasCollectionItems", "autoHighlight"),
997
+ actions: ["clearHighlightedValue", "highlightFirstItem"]
998
998
  },
999
999
  {
1000
1000
  guard: "isHighlightedItemRemoved",
1001
1001
  actions: ["clearHighlightedValue"]
1002
+ },
1003
+ {
1004
+ guard: "autoHighlight",
1005
+ actions: ["highlightFirstItem"]
1002
1006
  }
1003
1007
  ],
1004
1008
  "INPUT.ARROW_DOWN": {
@@ -1153,7 +1157,8 @@ var machine = createMachine({
1153
1157
  },
1154
1158
  isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE",
1155
1159
  autoFocus: ({ prop }) => !!prop("autoFocus"),
1156
- isHighlightedItemRemoved: ({ prop, context }) => !prop("collection").has(context.get("highlightedValue"))
1160
+ isHighlightedItemRemoved: ({ prop, context }) => !prop("collection").has(context.get("highlightedValue")),
1161
+ hasCollectionItems: ({ prop }) => prop("collection").size > 0
1157
1162
  },
1158
1163
  effects: {
1159
1164
  trackDismissableLayer({ send, prop, scope }) {
@@ -1386,13 +1391,13 @@ var machine = createMachine({
1386
1391
  contentEl.scrollTop = 0;
1387
1392
  }
1388
1393
  },
1389
- invokeOnOpen({ prop, event }) {
1394
+ invokeOnOpen({ prop, event, context }) {
1390
1395
  const reason = getOpenChangeReason(event);
1391
- prop("onOpenChange")?.({ open: true, reason });
1396
+ prop("onOpenChange")?.({ open: true, reason, value: context.get("value") });
1392
1397
  },
1393
- invokeOnClose({ prop, event }) {
1398
+ invokeOnClose({ prop, event, context }) {
1394
1399
  const reason = getOpenChangeReason(event);
1395
- prop("onOpenChange")?.({ open: false, reason });
1400
+ prop("onOpenChange")?.({ open: false, reason, value: context.get("value") });
1396
1401
  },
1397
1402
  highlightFirstItem({ context, prop, scope }) {
1398
1403
  const exec = getContentEl(scope) ? queueMicrotask : domQuery.raf;
package/dist/index.mjs CHANGED
@@ -991,12 +991,16 @@ var machine = createMachine({
991
991
  ],
992
992
  CHILDREN_CHANGE: [
993
993
  {
994
- guard: "autoHighlight",
995
- actions: ["highlightFirstItem"]
994
+ guard: and("isHighlightedItemRemoved", "hasCollectionItems", "autoHighlight"),
995
+ actions: ["clearHighlightedValue", "highlightFirstItem"]
996
996
  },
997
997
  {
998
998
  guard: "isHighlightedItemRemoved",
999
999
  actions: ["clearHighlightedValue"]
1000
+ },
1001
+ {
1002
+ guard: "autoHighlight",
1003
+ actions: ["highlightFirstItem"]
1000
1004
  }
1001
1005
  ],
1002
1006
  "INPUT.ARROW_DOWN": {
@@ -1151,7 +1155,8 @@ var machine = createMachine({
1151
1155
  },
1152
1156
  isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE",
1153
1157
  autoFocus: ({ prop }) => !!prop("autoFocus"),
1154
- isHighlightedItemRemoved: ({ prop, context }) => !prop("collection").has(context.get("highlightedValue"))
1158
+ isHighlightedItemRemoved: ({ prop, context }) => !prop("collection").has(context.get("highlightedValue")),
1159
+ hasCollectionItems: ({ prop }) => prop("collection").size > 0
1155
1160
  },
1156
1161
  effects: {
1157
1162
  trackDismissableLayer({ send, prop, scope }) {
@@ -1384,13 +1389,13 @@ var machine = createMachine({
1384
1389
  contentEl.scrollTop = 0;
1385
1390
  }
1386
1391
  },
1387
- invokeOnOpen({ prop, event }) {
1392
+ invokeOnOpen({ prop, event, context }) {
1388
1393
  const reason = getOpenChangeReason(event);
1389
- prop("onOpenChange")?.({ open: true, reason });
1394
+ prop("onOpenChange")?.({ open: true, reason, value: context.get("value") });
1390
1395
  },
1391
- invokeOnClose({ prop, event }) {
1396
+ invokeOnClose({ prop, event, context }) {
1392
1397
  const reason = getOpenChangeReason(event);
1393
- prop("onOpenChange")?.({ open: false, reason });
1398
+ prop("onOpenChange")?.({ open: false, reason, value: context.get("value") });
1394
1399
  },
1395
1400
  highlightFirstItem({ context, prop, scope }) {
1396
1401
  const exec = getContentEl(scope) ? queueMicrotask : raf;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/combobox",
3
- "version": "1.27.1",
3
+ "version": "1.29.0",
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.27.1",
30
- "@zag-js/aria-hidden": "1.27.1",
31
- "@zag-js/collection": "1.27.1",
32
- "@zag-js/core": "1.27.1",
33
- "@zag-js/dismissable": "1.27.1",
34
- "@zag-js/dom-query": "1.27.1",
35
- "@zag-js/utils": "1.27.1",
36
- "@zag-js/popper": "1.27.1",
37
- "@zag-js/types": "1.27.1"
29
+ "@zag-js/anatomy": "1.29.0",
30
+ "@zag-js/aria-hidden": "1.29.0",
31
+ "@zag-js/collection": "1.29.0",
32
+ "@zag-js/core": "1.29.0",
33
+ "@zag-js/dismissable": "1.29.0",
34
+ "@zag-js/dom-query": "1.29.0",
35
+ "@zag-js/utils": "1.29.0",
36
+ "@zag-js/popper": "1.29.0",
37
+ "@zag-js/types": "1.29.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"