@zag-js/combobox 0.77.1 → 0.78.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
@@ -322,6 +322,11 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
322
322
  * The value of the combobox input
323
323
  */
324
324
  setHighlightValue(value: string): void;
325
+ /**
326
+ * Function to sync the selected items with the value.
327
+ * Useful when `value` is updated from async sources.
328
+ */
329
+ syncSelectedItems(): void;
325
330
  /**
326
331
  * The selected items
327
332
  */
package/dist/index.d.ts CHANGED
@@ -322,6 +322,11 @@ interface MachineApi<T extends PropTypes = PropTypes, V extends CollectionItem =
322
322
  * The value of the combobox input
323
323
  */
324
324
  setHighlightValue(value: string): void;
325
+ /**
326
+ * Function to sync the selected items with the value.
327
+ * Useful when `value` is updated from async sources.
328
+ */
329
+ syncSelectedItems(): void;
325
330
  /**
326
331
  * The selected items
327
332
  */
package/dist/index.js CHANGED
@@ -87,9 +87,8 @@ function connect(state, send, normalize) {
87
87
  placement: state.context.currentPlacement
88
88
  });
89
89
  function getItemState(props) {
90
- const { item } = props;
91
- const disabled2 = collection2.getItemDisabled(item);
92
- const value = collection2.getItemValue(item);
90
+ const disabled2 = collection2.getItemDisabled(props.item);
91
+ const value = collection2.getItemValue(props.item);
93
92
  return {
94
93
  value,
95
94
  disabled: Boolean(disabled2 || disabled2),
@@ -110,6 +109,9 @@ function connect(state, send, normalize) {
110
109
  collection: state.context.collection,
111
110
  multiple: !!state.context.multiple,
112
111
  disabled: !!disabled,
112
+ syncSelectedItems() {
113
+ send({ type: "SELECTED_ITEMS.SYNC" });
114
+ },
113
115
  reposition(options = {}) {
114
116
  send({ type: "POSITIONING.SET", options });
115
117
  },
@@ -514,6 +516,9 @@ function machine(userContext) {
514
516
  open: ["toggleVisibility"]
515
517
  },
516
518
  on: {
519
+ "SELECTED_ITEMS.SYNC": {
520
+ actions: ["syncSelectedItems"]
521
+ },
517
522
  "HIGHLIGHTED_VALUE.SET": {
518
523
  actions: ["setHighlightedItem"]
519
524
  },
package/dist/index.mjs CHANGED
@@ -85,9 +85,8 @@ function connect(state, send, normalize) {
85
85
  placement: state.context.currentPlacement
86
86
  });
87
87
  function getItemState(props) {
88
- const { item } = props;
89
- const disabled2 = collection2.getItemDisabled(item);
90
- const value = collection2.getItemValue(item);
88
+ const disabled2 = collection2.getItemDisabled(props.item);
89
+ const value = collection2.getItemValue(props.item);
91
90
  return {
92
91
  value,
93
92
  disabled: Boolean(disabled2 || disabled2),
@@ -108,6 +107,9 @@ function connect(state, send, normalize) {
108
107
  collection: state.context.collection,
109
108
  multiple: !!state.context.multiple,
110
109
  disabled: !!disabled,
110
+ syncSelectedItems() {
111
+ send({ type: "SELECTED_ITEMS.SYNC" });
112
+ },
111
113
  reposition(options = {}) {
112
114
  send({ type: "POSITIONING.SET", options });
113
115
  },
@@ -512,6 +514,9 @@ function machine(userContext) {
512
514
  open: ["toggleVisibility"]
513
515
  },
514
516
  on: {
517
+ "SELECTED_ITEMS.SYNC": {
518
+ actions: ["syncSelectedItems"]
519
+ },
515
520
  "HIGHLIGHTED_VALUE.SET": {
516
521
  actions: ["setHighlightedItem"]
517
522
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/combobox",
3
- "version": "0.77.1",
3
+ "version": "0.78.0",
4
4
  "description": "Core logic for the combobox widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -26,16 +26,16 @@
26
26
  "url": "https://github.com/chakra-ui/zag/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@zag-js/anatomy": "0.77.1",
30
- "@zag-js/aria-hidden": "0.77.1",
31
- "@zag-js/collection": "0.77.1",
32
- "@zag-js/core": "0.77.1",
33
- "@zag-js/dismissable": "0.77.1",
34
- "@zag-js/dom-query": "0.77.1",
35
- "@zag-js/dom-event": "0.77.1",
36
- "@zag-js/utils": "0.77.1",
37
- "@zag-js/popper": "0.77.1",
38
- "@zag-js/types": "0.77.1"
29
+ "@zag-js/anatomy": "0.78.0",
30
+ "@zag-js/aria-hidden": "0.78.0",
31
+ "@zag-js/collection": "0.78.0",
32
+ "@zag-js/core": "0.78.0",
33
+ "@zag-js/dismissable": "0.78.0",
34
+ "@zag-js/dom-query": "0.78.0",
35
+ "@zag-js/dom-event": "0.78.0",
36
+ "@zag-js/utils": "0.78.0",
37
+ "@zag-js/popper": "0.78.0",
38
+ "@zag-js/types": "0.78.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "clean-package": "2.2.0"