@zag-js/combobox 1.12.2 → 1.12.4

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
@@ -192,10 +192,10 @@ function connect(service, normalize) {
192
192
  dir: prop("dir"),
193
193
  "aria-invalid": domQuery.ariaAttr(invalid),
194
194
  "data-invalid": domQuery.dataAttr(invalid),
195
+ "data-autofocus": domQuery.dataAttr(prop("autoFocus")),
195
196
  name: prop("name"),
196
197
  form: prop("form"),
197
198
  disabled,
198
- autoFocus: prop("autoFocus"),
199
199
  required: prop("required"),
200
200
  autoComplete: "off",
201
201
  autoCorrect: "off",
@@ -467,8 +467,9 @@ function connect(service, normalize) {
467
467
  }
468
468
  };
469
469
  }
470
- var { and, not } = core.createGuards();
471
- var machine = core.createMachine({
470
+ var { guards, createMachine, choose } = core.setup();
471
+ var { and, not } = guards;
472
+ var machine = createMachine({
472
473
  props({ props: props2 }) {
473
474
  return {
474
475
  loopFocus: true,
@@ -615,6 +616,12 @@ var machine = core.createMachine({
615
616
  actions: ["reposition"]
616
617
  }
617
618
  },
619
+ entry: choose([
620
+ {
621
+ guard: "autoFocus",
622
+ actions: ["setInitialFocus"]
623
+ }
624
+ ]),
618
625
  states: {
619
626
  idle: {
620
627
  tags: ["idle", "closed"],
@@ -1116,7 +1123,8 @@ var machine = core.createMachine({
1116
1123
  return !!openOnChange?.({ inputValue: context.get("inputValue") });
1117
1124
  },
1118
1125
  restoreFocus: ({ event }) => event.restoreFocus == null ? true : !!event.restoreFocus,
1119
- isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE"
1126
+ isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE",
1127
+ autoFocus: ({ prop }) => !!prop("autoFocus")
1120
1128
  },
1121
1129
  effects: {
1122
1130
  trackDismissableLayer({ send, prop, scope }) {
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { raf, setCaretToEnd, observeAttributes, observeChildren, clickIfLink, sc
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';
7
- import { createGuards, createMachine } from '@zag-js/core';
7
+ import { setup } from '@zag-js/core';
8
8
  import { trackDismissableElement } from '@zag-js/dismissable';
9
9
  import { createProps } from '@zag-js/types';
10
10
 
@@ -190,10 +190,10 @@ function connect(service, normalize) {
190
190
  dir: prop("dir"),
191
191
  "aria-invalid": ariaAttr(invalid),
192
192
  "data-invalid": dataAttr(invalid),
193
+ "data-autofocus": dataAttr(prop("autoFocus")),
193
194
  name: prop("name"),
194
195
  form: prop("form"),
195
196
  disabled,
196
- autoFocus: prop("autoFocus"),
197
197
  required: prop("required"),
198
198
  autoComplete: "off",
199
199
  autoCorrect: "off",
@@ -465,7 +465,8 @@ function connect(service, normalize) {
465
465
  }
466
466
  };
467
467
  }
468
- var { and, not } = createGuards();
468
+ var { guards, createMachine, choose } = setup();
469
+ var { and, not } = guards;
469
470
  var machine = createMachine({
470
471
  props({ props: props2 }) {
471
472
  return {
@@ -613,6 +614,12 @@ var machine = createMachine({
613
614
  actions: ["reposition"]
614
615
  }
615
616
  },
617
+ entry: choose([
618
+ {
619
+ guard: "autoFocus",
620
+ actions: ["setInitialFocus"]
621
+ }
622
+ ]),
616
623
  states: {
617
624
  idle: {
618
625
  tags: ["idle", "closed"],
@@ -1114,7 +1121,8 @@ var machine = createMachine({
1114
1121
  return !!openOnChange?.({ inputValue: context.get("inputValue") });
1115
1122
  },
1116
1123
  restoreFocus: ({ event }) => event.restoreFocus == null ? true : !!event.restoreFocus,
1117
- isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE"
1124
+ isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE",
1125
+ autoFocus: ({ prop }) => !!prop("autoFocus")
1118
1126
  },
1119
1127
  effects: {
1120
1128
  trackDismissableLayer({ send, prop, scope }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/combobox",
3
- "version": "1.12.2",
3
+ "version": "1.12.4",
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.12.2",
30
- "@zag-js/aria-hidden": "1.12.2",
31
- "@zag-js/collection": "1.12.2",
32
- "@zag-js/core": "1.12.2",
33
- "@zag-js/dismissable": "1.12.2",
34
- "@zag-js/dom-query": "1.12.2",
35
- "@zag-js/utils": "1.12.2",
36
- "@zag-js/popper": "1.12.2",
37
- "@zag-js/types": "1.12.2"
29
+ "@zag-js/anatomy": "1.12.4",
30
+ "@zag-js/aria-hidden": "1.12.4",
31
+ "@zag-js/collection": "1.12.4",
32
+ "@zag-js/core": "1.12.4",
33
+ "@zag-js/dismissable": "1.12.4",
34
+ "@zag-js/dom-query": "1.12.4",
35
+ "@zag-js/utils": "1.12.4",
36
+ "@zag-js/popper": "1.12.4",
37
+ "@zag-js/types": "1.12.4"
38
38
  },
39
39
  "devDependencies": {
40
40
  "clean-package": "2.2.0"