@zag-js/radio-group 0.1.11 → 0.1.12

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.
@@ -127,7 +127,7 @@ function machine(userContext) {
127
127
  }
128
128
  },
129
129
  watch: {
130
- value: ["dispatchChangeEvent", "invokeOnChange"]
130
+ value: ["dispatchChangeEvent", "invokeOnChange", "syncInputElements"]
131
131
  },
132
132
  entry: ["checkValue"],
133
133
  states: {
@@ -171,6 +171,12 @@ function machine(userContext) {
171
171
  return;
172
172
  const el = dom.getRadioInputEl(ctx2, evt.value);
173
173
  dispatchInputCheckedEvent(el, !!evt.value);
174
+ },
175
+ syncInputElements(ctx2) {
176
+ const inputs = dom.getInputEls(ctx2);
177
+ inputs.forEach((input) => {
178
+ input.checked = input.value === ctx2.value;
179
+ });
174
180
  }
175
181
  }
176
182
  }
@@ -71,6 +71,9 @@ function connect(state, send, normalize) {
71
71
  setValue(value) {
72
72
  send({ type: "SET_VALUE", value, manual: true });
73
73
  },
74
+ clearValue() {
75
+ send({ type: "SET_VALUE", value: null, manual: true });
76
+ },
74
77
  focus,
75
78
  blur() {
76
79
  const focusedElement = dom.getActiveElement(state.context);
package/dist/index.js CHANGED
@@ -189,6 +189,9 @@ function connect(state, send, normalize) {
189
189
  setValue(value) {
190
190
  send({ type: "SET_VALUE", value, manual: true });
191
191
  },
192
+ clearValue() {
193
+ send({ type: "SET_VALUE", value: null, manual: true });
194
+ },
192
195
  focus,
193
196
  blur() {
194
197
  const focusedElement = dom.getActiveElement(state.context);
@@ -404,7 +407,7 @@ function machine(userContext) {
404
407
  }
405
408
  },
406
409
  watch: {
407
- value: ["dispatchChangeEvent", "invokeOnChange"]
410
+ value: ["dispatchChangeEvent", "invokeOnChange", "syncInputElements"]
408
411
  },
409
412
  entry: ["checkValue"],
410
413
  states: {
@@ -448,6 +451,12 @@ function machine(userContext) {
448
451
  return;
449
452
  const el = dom.getRadioInputEl(ctx2, evt.value);
450
453
  dispatchInputCheckedEvent(el, !!evt.value);
454
+ },
455
+ syncInputElements(ctx2) {
456
+ const inputs = dom.getInputEls(ctx2);
457
+ inputs.forEach((input) => {
458
+ input.checked = input.value === ctx2.value;
459
+ });
451
460
  }
452
461
  }
453
462
  }
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-F57UWPRI.mjs";
3
+ } from "./chunk-YT2IAITX.mjs";
4
4
  import {
5
5
  anatomy
6
6
  } from "./chunk-MGLN5L3R.mjs";
7
7
  import {
8
8
  machine
9
- } from "./chunk-IKYBQJIH.mjs";
9
+ } from "./chunk-SGHDM6EU.mjs";
10
10
  import "./chunk-CYVZAWTC.mjs";
11
11
  export {
12
12
  anatomy,
@@ -5,6 +5,7 @@ import '@zag-js/core';
5
5
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
6
6
  value: string | null;
7
7
  setValue(value: string): void;
8
+ clearValue(): void;
8
9
  focus: () => void;
9
10
  blur(): void;
10
11
  rootProps: T["element"];
@@ -154,6 +154,9 @@ function connect(state, send, normalize) {
154
154
  setValue(value) {
155
155
  send({ type: "SET_VALUE", value, manual: true });
156
156
  },
157
+ clearValue() {
158
+ send({ type: "SET_VALUE", value: null, manual: true });
159
+ },
157
160
  focus,
158
161
  blur() {
159
162
  const focusedElement = dom.getActiveElement(state.context);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-F57UWPRI.mjs";
3
+ } from "./chunk-YT2IAITX.mjs";
4
4
  import "./chunk-MGLN5L3R.mjs";
5
5
  import "./chunk-CYVZAWTC.mjs";
6
6
  export {
@@ -29,7 +29,7 @@ declare const dom: {
29
29
  getRadioInputEl: (ctx: MachineContext, value: string) => HTMLInputElement | null;
30
30
  getFirstEnabledInputEl: (ctx: MachineContext) => HTMLInputElement | null | undefined;
31
31
  getFirstEnabledAndCheckedInputEl: (ctx: MachineContext) => HTMLInputElement | null | undefined;
32
- getInputEls: (ctx: MachineContext) => HTMLElement[];
32
+ getInputEls: (ctx: MachineContext) => HTMLInputElement[];
33
33
  };
34
34
 
35
35
  export { dom };
@@ -201,7 +201,7 @@ function machine(userContext) {
201
201
  }
202
202
  },
203
203
  watch: {
204
- value: ["dispatchChangeEvent", "invokeOnChange"]
204
+ value: ["dispatchChangeEvent", "invokeOnChange", "syncInputElements"]
205
205
  },
206
206
  entry: ["checkValue"],
207
207
  states: {
@@ -245,6 +245,12 @@ function machine(userContext) {
245
245
  return;
246
246
  const el = dom.getRadioInputEl(ctx2, evt.value);
247
247
  dispatchInputCheckedEvent(el, !!evt.value);
248
+ },
249
+ syncInputElements(ctx2) {
250
+ const inputs = dom.getInputEls(ctx2);
251
+ inputs.forEach((input) => {
252
+ input.checked = input.value === ctx2.value;
253
+ });
248
254
  }
249
255
  }
250
256
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  machine
3
- } from "./chunk-IKYBQJIH.mjs";
3
+ } from "./chunk-SGHDM6EU.mjs";
4
4
  import "./chunk-CYVZAWTC.mjs";
5
5
  export {
6
6
  machine
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/radio-group",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Core logic for the radio group widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@zag-js/anatomy": "0.1.4",
31
- "@zag-js/core": "0.2.8",
31
+ "@zag-js/core": "0.2.9",
32
32
  "@zag-js/types": "0.3.4"
33
33
  },
34
34
  "devDependencies": {