@zag-js/radio-group 1.29.1 → 1.31.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
@@ -45,7 +45,15 @@ interface RadioGroupProps extends DirectionProperty, CommonProperties {
45
45
  */
46
46
  disabled?: boolean | undefined;
47
47
  /**
48
- * Whether the checkbox is read-only
48
+ * If `true`, the radio group is marked as invalid.
49
+ */
50
+ invalid?: boolean | undefined;
51
+ /**
52
+ * If `true`, the radio group is marked as required.
53
+ */
54
+ required?: boolean | undefined;
55
+ /**
56
+ * Whether the radio group is read-only
49
57
  */
50
58
  readOnly?: boolean | undefined;
51
59
  /**
package/dist/index.d.ts CHANGED
@@ -45,7 +45,15 @@ interface RadioGroupProps extends DirectionProperty, CommonProperties {
45
45
  */
46
46
  disabled?: boolean | undefined;
47
47
  /**
48
- * Whether the checkbox is read-only
48
+ * If `true`, the radio group is marked as invalid.
49
+ */
50
+ invalid?: boolean | undefined;
51
+ /**
52
+ * If `true`, the radio group is marked as required.
53
+ */
54
+ required?: boolean | undefined;
55
+ /**
56
+ * Whether the radio group is read-only
49
57
  */
50
58
  readOnly?: boolean | undefined;
51
59
  /**
package/dist/index.js CHANGED
@@ -49,11 +49,12 @@ var getOffsetRect = (el) => ({
49
49
  function connect(service, normalize) {
50
50
  const { context, send, computed, prop, scope } = service;
51
51
  const groupDisabled = computed("isDisabled");
52
+ const groupInvalid = prop("invalid");
52
53
  const readOnly = prop("readOnly");
53
54
  function getItemState(props2) {
54
55
  return {
55
56
  value: props2.value,
56
- invalid: !!props2.invalid,
57
+ invalid: !!props2.invalid || !!groupInvalid,
57
58
  disabled: !!props2.disabled || groupDisabled,
58
59
  checked: context.get("value") === props2.value,
59
60
  focused: context.get("focusedValue") === props2.value,
@@ -95,8 +96,13 @@ function connect(service, normalize) {
95
96
  role: "radiogroup",
96
97
  id: getRootId(scope),
97
98
  "aria-labelledby": getLabelId(scope),
99
+ "aria-required": prop("required") || void 0,
100
+ "aria-disabled": groupDisabled || void 0,
101
+ "aria-readonly": readOnly || void 0,
98
102
  "data-orientation": prop("orientation"),
99
103
  "data-disabled": domQuery.dataAttr(groupDisabled),
104
+ "data-invalid": domQuery.dataAttr(groupInvalid),
105
+ "data-required": domQuery.dataAttr(prop("required")),
100
106
  "aria-orientation": prop("orientation"),
101
107
  dir: prop("dir"),
102
108
  style: {
@@ -110,6 +116,8 @@ function connect(service, normalize) {
110
116
  dir: prop("dir"),
111
117
  "data-orientation": prop("orientation"),
112
118
  "data-disabled": domQuery.dataAttr(groupDisabled),
119
+ "data-invalid": domQuery.dataAttr(groupInvalid),
120
+ "data-required": domQuery.dataAttr(prop("required")),
113
121
  id: getLabelId(scope),
114
122
  onClick: focus
115
123
  });
@@ -179,6 +187,8 @@ function connect(service, normalize) {
179
187
  name: prop("name") || prop("id"),
180
188
  form: prop("form"),
181
189
  value: props2.value,
190
+ required: prop("required"),
191
+ "aria-invalid": itemState.invalid || void 0,
182
192
  onClick(event) {
183
193
  if (readOnly) {
184
194
  event.preventDefault();
@@ -214,11 +224,12 @@ function connect(service, normalize) {
214
224
  },
215
225
  getIndicatorProps() {
216
226
  const rect = context.get("indicatorRect");
227
+ const rectIsEmpty = rect == null || rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
217
228
  return normalize.element({
218
229
  id: getIndicatorId(scope),
219
230
  ...parts.indicator.attrs,
220
231
  dir: prop("dir"),
221
- hidden: context.get("value") == null || rect == null,
232
+ hidden: context.get("value") == null || rectIsEmpty,
222
233
  "data-disabled": domQuery.dataAttr(groupDisabled),
223
234
  "data-orientation": prop("orientation"),
224
235
  style: {
@@ -401,10 +412,12 @@ var props = types.createProps()([
401
412
  "getRootNode",
402
413
  "id",
403
414
  "ids",
415
+ "invalid",
404
416
  "name",
405
417
  "onValueChange",
406
418
  "orientation",
407
419
  "readOnly",
420
+ "required",
408
421
  "value",
409
422
  "defaultValue"
410
423
  ]);
package/dist/index.mjs CHANGED
@@ -47,11 +47,12 @@ var getOffsetRect = (el) => ({
47
47
  function connect(service, normalize) {
48
48
  const { context, send, computed, prop, scope } = service;
49
49
  const groupDisabled = computed("isDisabled");
50
+ const groupInvalid = prop("invalid");
50
51
  const readOnly = prop("readOnly");
51
52
  function getItemState(props2) {
52
53
  return {
53
54
  value: props2.value,
54
- invalid: !!props2.invalid,
55
+ invalid: !!props2.invalid || !!groupInvalid,
55
56
  disabled: !!props2.disabled || groupDisabled,
56
57
  checked: context.get("value") === props2.value,
57
58
  focused: context.get("focusedValue") === props2.value,
@@ -93,8 +94,13 @@ function connect(service, normalize) {
93
94
  role: "radiogroup",
94
95
  id: getRootId(scope),
95
96
  "aria-labelledby": getLabelId(scope),
97
+ "aria-required": prop("required") || void 0,
98
+ "aria-disabled": groupDisabled || void 0,
99
+ "aria-readonly": readOnly || void 0,
96
100
  "data-orientation": prop("orientation"),
97
101
  "data-disabled": dataAttr(groupDisabled),
102
+ "data-invalid": dataAttr(groupInvalid),
103
+ "data-required": dataAttr(prop("required")),
98
104
  "aria-orientation": prop("orientation"),
99
105
  dir: prop("dir"),
100
106
  style: {
@@ -108,6 +114,8 @@ function connect(service, normalize) {
108
114
  dir: prop("dir"),
109
115
  "data-orientation": prop("orientation"),
110
116
  "data-disabled": dataAttr(groupDisabled),
117
+ "data-invalid": dataAttr(groupInvalid),
118
+ "data-required": dataAttr(prop("required")),
111
119
  id: getLabelId(scope),
112
120
  onClick: focus
113
121
  });
@@ -177,6 +185,8 @@ function connect(service, normalize) {
177
185
  name: prop("name") || prop("id"),
178
186
  form: prop("form"),
179
187
  value: props2.value,
188
+ required: prop("required"),
189
+ "aria-invalid": itemState.invalid || void 0,
180
190
  onClick(event) {
181
191
  if (readOnly) {
182
192
  event.preventDefault();
@@ -212,11 +222,12 @@ function connect(service, normalize) {
212
222
  },
213
223
  getIndicatorProps() {
214
224
  const rect = context.get("indicatorRect");
225
+ const rectIsEmpty = rect == null || rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
215
226
  return normalize.element({
216
227
  id: getIndicatorId(scope),
217
228
  ...parts.indicator.attrs,
218
229
  dir: prop("dir"),
219
- hidden: context.get("value") == null || rect == null,
230
+ hidden: context.get("value") == null || rectIsEmpty,
220
231
  "data-disabled": dataAttr(groupDisabled),
221
232
  "data-orientation": prop("orientation"),
222
233
  style: {
@@ -399,10 +410,12 @@ var props = createProps()([
399
410
  "getRootNode",
400
411
  "id",
401
412
  "ids",
413
+ "invalid",
402
414
  "name",
403
415
  "onValueChange",
404
416
  "orientation",
405
417
  "readOnly",
418
+ "required",
406
419
  "value",
407
420
  "defaultValue"
408
421
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/radio-group",
3
- "version": "1.29.1",
3
+ "version": "1.31.0",
4
4
  "description": "Core logic for the radio group widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,12 +27,12 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "1.29.1",
31
- "@zag-js/dom-query": "1.29.1",
32
- "@zag-js/focus-visible": "1.29.1",
33
- "@zag-js/utils": "1.29.1",
34
- "@zag-js/core": "1.29.1",
35
- "@zag-js/types": "1.29.1"
30
+ "@zag-js/anatomy": "1.31.0",
31
+ "@zag-js/dom-query": "1.31.0",
32
+ "@zag-js/focus-visible": "1.31.0",
33
+ "@zag-js/utils": "1.31.0",
34
+ "@zag-js/core": "1.31.0",
35
+ "@zag-js/types": "1.31.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "clean-package": "2.2.0"