@zag-js/radio-group 1.43.0 → 2.0.0-next.1
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/radio-group.connect.js +27 -20
- package/dist/radio-group.connect.mjs +27 -20
- package/dist/radio-group.dom.js +11 -12
- package/dist/radio-group.dom.mjs +11 -12
- package/dist/radio-group.types.d.mts +27 -1
- package/dist/radio-group.types.d.ts +27 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './radio-group.anatomy.mjs';
|
|
|
2
2
|
export { connect } from './radio-group.connect.mjs';
|
|
3
3
|
export { machine } from './radio-group.machine.mjs';
|
|
4
4
|
export { itemProps, props, splitItemProps, splitProps } from './radio-group.props.mjs';
|
|
5
|
-
export { RadioGroupApi as Api, ElementIds, ItemProps, ItemState, RadioGroupMachine as Machine, RadioGroupProps as Props, RadioGroupService as Service, ValueChangeDetails } from './radio-group.types.mjs';
|
|
5
|
+
export { RadioGroupApi as Api, ElementIds, ItemProps, ItemState, RadioGroupMachine as Machine, RadioGroupProps as Props, RootState, RadioGroupService as Service, ValueChangeDetails } from './radio-group.types.mjs';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/types';
|
|
8
8
|
import '@zag-js/core';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './radio-group.anatomy.js';
|
|
|
2
2
|
export { connect } from './radio-group.connect.js';
|
|
3
3
|
export { machine } from './radio-group.machine.js';
|
|
4
4
|
export { itemProps, props, splitItemProps, splitProps } from './radio-group.props.js';
|
|
5
|
-
export { RadioGroupApi as Api, ElementIds, ItemProps, ItemState, RadioGroupMachine as Machine, RadioGroupProps as Props, RadioGroupService as Service, ValueChangeDetails } from './radio-group.types.js';
|
|
5
|
+
export { RadioGroupApi as Api, ElementIds, ItemProps, ItemState, RadioGroupMachine as Machine, RadioGroupProps as Props, RootState, RadioGroupService as Service, ValueChangeDetails } from './radio-group.types.js';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/types';
|
|
8
8
|
import '@zag-js/core';
|
|
@@ -41,8 +41,17 @@ var dom = __toESM(require("./radio-group.dom.js"));
|
|
|
41
41
|
function connect(service, normalize) {
|
|
42
42
|
const { context, send, computed, prop, scope } = service;
|
|
43
43
|
const groupDisabled = computed("isDisabled");
|
|
44
|
-
const groupInvalid = prop("invalid");
|
|
45
|
-
const readOnly = prop("readOnly");
|
|
44
|
+
const groupInvalid = !!prop("invalid");
|
|
45
|
+
const readOnly = !!prop("readOnly");
|
|
46
|
+
function getRootState() {
|
|
47
|
+
return {
|
|
48
|
+
disabled: groupDisabled,
|
|
49
|
+
invalid: groupInvalid,
|
|
50
|
+
required: !!prop("required"),
|
|
51
|
+
readOnly,
|
|
52
|
+
orientation: prop("orientation")
|
|
53
|
+
};
|
|
54
|
+
}
|
|
46
55
|
function getItemState(props) {
|
|
47
56
|
return {
|
|
48
57
|
value: props.value,
|
|
@@ -82,20 +91,21 @@ function connect(service, normalize) {
|
|
|
82
91
|
clearValue() {
|
|
83
92
|
send({ type: "SET_VALUE", value: null, isTrusted: false });
|
|
84
93
|
},
|
|
94
|
+
getRootState,
|
|
85
95
|
getRootProps() {
|
|
96
|
+
const rootState = getRootState();
|
|
86
97
|
return normalize.element({
|
|
87
|
-
...import_radio_group.parts.root.attrs,
|
|
98
|
+
...import_radio_group.parts.root.attrs(scope.id),
|
|
88
99
|
role: "radiogroup",
|
|
89
|
-
id: dom.getRootId(scope),
|
|
90
100
|
"aria-labelledby": dom.getLabelId(scope),
|
|
91
|
-
"aria-required":
|
|
92
|
-
"aria-disabled":
|
|
93
|
-
"aria-readonly": readOnly || void 0,
|
|
94
|
-
"data-orientation":
|
|
95
|
-
"data-disabled": (0, import_dom_query.dataAttr)(
|
|
96
|
-
"data-invalid": (0, import_dom_query.dataAttr)(
|
|
97
|
-
"data-required": (0, import_dom_query.dataAttr)(
|
|
98
|
-
"aria-orientation":
|
|
101
|
+
"aria-required": rootState.required || void 0,
|
|
102
|
+
"aria-disabled": rootState.disabled || void 0,
|
|
103
|
+
"aria-readonly": rootState.readOnly || void 0,
|
|
104
|
+
"data-orientation": rootState.orientation,
|
|
105
|
+
"data-disabled": (0, import_dom_query.dataAttr)(rootState.disabled),
|
|
106
|
+
"data-invalid": (0, import_dom_query.dataAttr)(rootState.invalid),
|
|
107
|
+
"data-required": (0, import_dom_query.dataAttr)(rootState.required),
|
|
108
|
+
"aria-orientation": rootState.orientation,
|
|
99
109
|
dir: prop("dir"),
|
|
100
110
|
style: {
|
|
101
111
|
position: "relative"
|
|
@@ -104,7 +114,7 @@ function connect(service, normalize) {
|
|
|
104
114
|
},
|
|
105
115
|
getLabelProps() {
|
|
106
116
|
return normalize.element({
|
|
107
|
-
...import_radio_group.parts.label.attrs,
|
|
117
|
+
...import_radio_group.parts.label.attrs(scope.id),
|
|
108
118
|
dir: prop("dir"),
|
|
109
119
|
"data-orientation": prop("orientation"),
|
|
110
120
|
"data-disabled": (0, import_dom_query.dataAttr)(groupDisabled),
|
|
@@ -118,7 +128,7 @@ function connect(service, normalize) {
|
|
|
118
128
|
getItemProps(props) {
|
|
119
129
|
const itemState = getItemState(props);
|
|
120
130
|
return normalize.label({
|
|
121
|
-
...import_radio_group.parts.item.attrs,
|
|
131
|
+
...import_radio_group.parts.item.attrs(scope.id),
|
|
122
132
|
dir: prop("dir"),
|
|
123
133
|
id: dom.getItemId(scope, props.value),
|
|
124
134
|
htmlFor: dom.getItemHiddenInputId(scope, props.value),
|
|
@@ -153,7 +163,7 @@ function connect(service, normalize) {
|
|
|
153
163
|
},
|
|
154
164
|
getItemTextProps(props) {
|
|
155
165
|
return normalize.element({
|
|
156
|
-
...import_radio_group.parts.itemText.attrs,
|
|
166
|
+
...import_radio_group.parts.itemText.attrs(scope.id),
|
|
157
167
|
dir: prop("dir"),
|
|
158
168
|
id: dom.getItemLabelId(scope, props.value),
|
|
159
169
|
...getItemDataAttrs(props)
|
|
@@ -162,9 +172,8 @@ function connect(service, normalize) {
|
|
|
162
172
|
getItemControlProps(props) {
|
|
163
173
|
const itemState = getItemState(props);
|
|
164
174
|
return normalize.element({
|
|
165
|
-
...import_radio_group.parts.itemControl.attrs,
|
|
175
|
+
...import_radio_group.parts.itemControl.attrs(scope.id),
|
|
166
176
|
dir: prop("dir"),
|
|
167
|
-
id: dom.getItemControlId(scope, props.value),
|
|
168
177
|
"data-active": (0, import_dom_query.dataAttr)(itemState.active),
|
|
169
178
|
"aria-hidden": true,
|
|
170
179
|
...getItemDataAttrs(props)
|
|
@@ -173,7 +182,6 @@ function connect(service, normalize) {
|
|
|
173
182
|
getItemHiddenInputProps(props) {
|
|
174
183
|
const itemState = getItemState(props);
|
|
175
184
|
return normalize.input({
|
|
176
|
-
"data-ownedby": dom.getRootId(scope),
|
|
177
185
|
id: dom.getItemHiddenInputId(scope, props.value),
|
|
178
186
|
type: "radio",
|
|
179
187
|
name: prop("name") || prop("id"),
|
|
@@ -219,8 +227,7 @@ function connect(service, normalize) {
|
|
|
219
227
|
const rect = context.get("indicatorRect");
|
|
220
228
|
const animateIndicator = context.get("animateIndicator");
|
|
221
229
|
return normalize.element({
|
|
222
|
-
|
|
223
|
-
...import_radio_group.parts.indicator.attrs,
|
|
230
|
+
...import_radio_group.parts.indicator.attrs(scope.id),
|
|
224
231
|
dir: prop("dir"),
|
|
225
232
|
hidden: context.get("value") == null || isRectEmpty(rect),
|
|
226
233
|
"data-disabled": (0, import_dom_query.dataAttr)(groupDisabled),
|
|
@@ -7,8 +7,17 @@ import * as dom from "./radio-group.dom.mjs";
|
|
|
7
7
|
function connect(service, normalize) {
|
|
8
8
|
const { context, send, computed, prop, scope } = service;
|
|
9
9
|
const groupDisabled = computed("isDisabled");
|
|
10
|
-
const groupInvalid = prop("invalid");
|
|
11
|
-
const readOnly = prop("readOnly");
|
|
10
|
+
const groupInvalid = !!prop("invalid");
|
|
11
|
+
const readOnly = !!prop("readOnly");
|
|
12
|
+
function getRootState() {
|
|
13
|
+
return {
|
|
14
|
+
disabled: groupDisabled,
|
|
15
|
+
invalid: groupInvalid,
|
|
16
|
+
required: !!prop("required"),
|
|
17
|
+
readOnly,
|
|
18
|
+
orientation: prop("orientation")
|
|
19
|
+
};
|
|
20
|
+
}
|
|
12
21
|
function getItemState(props) {
|
|
13
22
|
return {
|
|
14
23
|
value: props.value,
|
|
@@ -48,20 +57,21 @@ function connect(service, normalize) {
|
|
|
48
57
|
clearValue() {
|
|
49
58
|
send({ type: "SET_VALUE", value: null, isTrusted: false });
|
|
50
59
|
},
|
|
60
|
+
getRootState,
|
|
51
61
|
getRootProps() {
|
|
62
|
+
const rootState = getRootState();
|
|
52
63
|
return normalize.element({
|
|
53
|
-
...parts.root.attrs,
|
|
64
|
+
...parts.root.attrs(scope.id),
|
|
54
65
|
role: "radiogroup",
|
|
55
|
-
id: dom.getRootId(scope),
|
|
56
66
|
"aria-labelledby": dom.getLabelId(scope),
|
|
57
|
-
"aria-required":
|
|
58
|
-
"aria-disabled":
|
|
59
|
-
"aria-readonly": readOnly || void 0,
|
|
60
|
-
"data-orientation":
|
|
61
|
-
"data-disabled": dataAttr(
|
|
62
|
-
"data-invalid": dataAttr(
|
|
63
|
-
"data-required": dataAttr(
|
|
64
|
-
"aria-orientation":
|
|
67
|
+
"aria-required": rootState.required || void 0,
|
|
68
|
+
"aria-disabled": rootState.disabled || void 0,
|
|
69
|
+
"aria-readonly": rootState.readOnly || void 0,
|
|
70
|
+
"data-orientation": rootState.orientation,
|
|
71
|
+
"data-disabled": dataAttr(rootState.disabled),
|
|
72
|
+
"data-invalid": dataAttr(rootState.invalid),
|
|
73
|
+
"data-required": dataAttr(rootState.required),
|
|
74
|
+
"aria-orientation": rootState.orientation,
|
|
65
75
|
dir: prop("dir"),
|
|
66
76
|
style: {
|
|
67
77
|
position: "relative"
|
|
@@ -70,7 +80,7 @@ function connect(service, normalize) {
|
|
|
70
80
|
},
|
|
71
81
|
getLabelProps() {
|
|
72
82
|
return normalize.element({
|
|
73
|
-
...parts.label.attrs,
|
|
83
|
+
...parts.label.attrs(scope.id),
|
|
74
84
|
dir: prop("dir"),
|
|
75
85
|
"data-orientation": prop("orientation"),
|
|
76
86
|
"data-disabled": dataAttr(groupDisabled),
|
|
@@ -84,7 +94,7 @@ function connect(service, normalize) {
|
|
|
84
94
|
getItemProps(props) {
|
|
85
95
|
const itemState = getItemState(props);
|
|
86
96
|
return normalize.label({
|
|
87
|
-
...parts.item.attrs,
|
|
97
|
+
...parts.item.attrs(scope.id),
|
|
88
98
|
dir: prop("dir"),
|
|
89
99
|
id: dom.getItemId(scope, props.value),
|
|
90
100
|
htmlFor: dom.getItemHiddenInputId(scope, props.value),
|
|
@@ -119,7 +129,7 @@ function connect(service, normalize) {
|
|
|
119
129
|
},
|
|
120
130
|
getItemTextProps(props) {
|
|
121
131
|
return normalize.element({
|
|
122
|
-
...parts.itemText.attrs,
|
|
132
|
+
...parts.itemText.attrs(scope.id),
|
|
123
133
|
dir: prop("dir"),
|
|
124
134
|
id: dom.getItemLabelId(scope, props.value),
|
|
125
135
|
...getItemDataAttrs(props)
|
|
@@ -128,9 +138,8 @@ function connect(service, normalize) {
|
|
|
128
138
|
getItemControlProps(props) {
|
|
129
139
|
const itemState = getItemState(props);
|
|
130
140
|
return normalize.element({
|
|
131
|
-
...parts.itemControl.attrs,
|
|
141
|
+
...parts.itemControl.attrs(scope.id),
|
|
132
142
|
dir: prop("dir"),
|
|
133
|
-
id: dom.getItemControlId(scope, props.value),
|
|
134
143
|
"data-active": dataAttr(itemState.active),
|
|
135
144
|
"aria-hidden": true,
|
|
136
145
|
...getItemDataAttrs(props)
|
|
@@ -139,7 +148,6 @@ function connect(service, normalize) {
|
|
|
139
148
|
getItemHiddenInputProps(props) {
|
|
140
149
|
const itemState = getItemState(props);
|
|
141
150
|
return normalize.input({
|
|
142
|
-
"data-ownedby": dom.getRootId(scope),
|
|
143
151
|
id: dom.getItemHiddenInputId(scope, props.value),
|
|
144
152
|
type: "radio",
|
|
145
153
|
name: prop("name") || prop("id"),
|
|
@@ -185,8 +193,7 @@ function connect(service, normalize) {
|
|
|
185
193
|
const rect = context.get("indicatorRect");
|
|
186
194
|
const animateIndicator = context.get("animateIndicator");
|
|
187
195
|
return normalize.element({
|
|
188
|
-
|
|
189
|
-
...parts.indicator.attrs,
|
|
196
|
+
...parts.indicator.attrs(scope.id),
|
|
190
197
|
dir: prop("dir"),
|
|
191
198
|
hidden: context.get("value") == null || isRectEmpty(rect),
|
|
192
199
|
"data-disabled": dataAttr(groupDisabled),
|
package/dist/radio-group.dom.js
CHANGED
|
@@ -38,22 +38,21 @@ __export(radio_group_dom_exports, {
|
|
|
38
38
|
getRootId: () => getRootId
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(radio_group_dom_exports);
|
|
41
|
-
var
|
|
42
|
-
var getRootId = (ctx) => ctx.ids?.root ??
|
|
43
|
-
var getLabelId = (ctx) => ctx.ids?.label ??
|
|
44
|
-
var getItemId = (ctx, value) => ctx.ids?.item?.(value) ??
|
|
45
|
-
var getItemHiddenInputId = (ctx, value) => ctx.ids?.itemHiddenInput?.(value) ??
|
|
46
|
-
var getItemControlId = (ctx, value) => ctx.ids?.itemControl?.(value) ??
|
|
47
|
-
var getItemLabelId = (ctx, value) => ctx.ids?.itemLabel?.(value) ??
|
|
48
|
-
var getIndicatorId = (ctx) => ctx.ids?.indicator ??
|
|
49
|
-
var getRootEl = (ctx) => ctx.
|
|
41
|
+
var import_radio_group = require("./radio-group.anatomy.js");
|
|
42
|
+
var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
|
|
43
|
+
var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
|
|
44
|
+
var getItemId = (ctx, value) => ctx.ids?.item?.(value) ?? `${ctx.id}:radio:${value}`;
|
|
45
|
+
var getItemHiddenInputId = (ctx, value) => ctx.ids?.itemHiddenInput?.(value) ?? `${ctx.id}:radio-input:${value}`;
|
|
46
|
+
var getItemControlId = (ctx, value) => ctx.ids?.itemControl?.(value) ?? `${ctx.id}:radio-control:${value}`;
|
|
47
|
+
var getItemLabelId = (ctx, value) => ctx.ids?.itemLabel?.(value) ?? `${ctx.id}:radio-label:${value}`;
|
|
48
|
+
var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `${ctx.id}:indicator`;
|
|
49
|
+
var getRootEl = (ctx) => ctx.query(ctx.selector(import_radio_group.parts.root));
|
|
50
50
|
var getItemHiddenInputEl = (ctx, value) => ctx.getById(getItemHiddenInputId(ctx, value));
|
|
51
|
-
var getIndicatorEl = (ctx) => ctx.
|
|
51
|
+
var getIndicatorEl = (ctx) => ctx.query(ctx.selector(import_radio_group.parts.indicator));
|
|
52
52
|
var getFirstEnabledInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled)");
|
|
53
53
|
var getFirstEnabledAndCheckedInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled):checked");
|
|
54
54
|
var getInputEls = (ctx) => {
|
|
55
|
-
|
|
56
|
-
return (0, import_dom_query.queryAll)(getRootEl(ctx), selector);
|
|
55
|
+
return ctx.queryAll(`${ctx.selector(import_radio_group.parts.item)} input[type=radio]:not([disabled])`);
|
|
57
56
|
};
|
|
58
57
|
var getRadioEl = (ctx, value) => {
|
|
59
58
|
if (!value) return;
|
package/dist/radio-group.dom.mjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// src/radio-group.dom.ts
|
|
2
|
-
import {
|
|
3
|
-
var getRootId = (ctx) => ctx.ids?.root ??
|
|
4
|
-
var getLabelId = (ctx) => ctx.ids?.label ??
|
|
5
|
-
var getItemId = (ctx, value) => ctx.ids?.item?.(value) ??
|
|
6
|
-
var getItemHiddenInputId = (ctx, value) => ctx.ids?.itemHiddenInput?.(value) ??
|
|
7
|
-
var getItemControlId = (ctx, value) => ctx.ids?.itemControl?.(value) ??
|
|
8
|
-
var getItemLabelId = (ctx, value) => ctx.ids?.itemLabel?.(value) ??
|
|
9
|
-
var getIndicatorId = (ctx) => ctx.ids?.indicator ??
|
|
10
|
-
var getRootEl = (ctx) => ctx.
|
|
2
|
+
import { parts } from "./radio-group.anatomy.mjs";
|
|
3
|
+
var getRootId = (ctx) => ctx.ids?.root ?? `${ctx.id}`;
|
|
4
|
+
var getLabelId = (ctx) => ctx.ids?.label ?? `${ctx.id}:label`;
|
|
5
|
+
var getItemId = (ctx, value) => ctx.ids?.item?.(value) ?? `${ctx.id}:radio:${value}`;
|
|
6
|
+
var getItemHiddenInputId = (ctx, value) => ctx.ids?.itemHiddenInput?.(value) ?? `${ctx.id}:radio-input:${value}`;
|
|
7
|
+
var getItemControlId = (ctx, value) => ctx.ids?.itemControl?.(value) ?? `${ctx.id}:radio-control:${value}`;
|
|
8
|
+
var getItemLabelId = (ctx, value) => ctx.ids?.itemLabel?.(value) ?? `${ctx.id}:radio-label:${value}`;
|
|
9
|
+
var getIndicatorId = (ctx) => ctx.ids?.indicator ?? `${ctx.id}:indicator`;
|
|
10
|
+
var getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
|
|
11
11
|
var getItemHiddenInputEl = (ctx, value) => ctx.getById(getItemHiddenInputId(ctx, value));
|
|
12
|
-
var getIndicatorEl = (ctx) => ctx.
|
|
12
|
+
var getIndicatorEl = (ctx) => ctx.query(ctx.selector(parts.indicator));
|
|
13
13
|
var getFirstEnabledInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled)");
|
|
14
14
|
var getFirstEnabledAndCheckedInputEl = (ctx) => getRootEl(ctx)?.querySelector("input:not(:disabled):checked");
|
|
15
15
|
var getInputEls = (ctx) => {
|
|
16
|
-
|
|
17
|
-
return queryAll(getRootEl(ctx), selector);
|
|
16
|
+
return ctx.queryAll(`${ctx.selector(parts.item)} input[type=radio]:not([disabled])`);
|
|
18
17
|
};
|
|
19
18
|
var getRadioEl = (ctx, value) => {
|
|
20
19
|
if (!value) return;
|
|
@@ -168,6 +168,28 @@ interface ItemState {
|
|
|
168
168
|
*/
|
|
169
169
|
active: boolean;
|
|
170
170
|
}
|
|
171
|
+
interface RootState {
|
|
172
|
+
/**
|
|
173
|
+
* Whether the radio group is disabled
|
|
174
|
+
*/
|
|
175
|
+
disabled: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the radio group is invalid
|
|
178
|
+
*/
|
|
179
|
+
invalid: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Whether the radio group is required
|
|
182
|
+
*/
|
|
183
|
+
required: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Whether the radio group is read-only
|
|
186
|
+
*/
|
|
187
|
+
readOnly: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The orientation of the radio group
|
|
190
|
+
*/
|
|
191
|
+
orientation: "horizontal" | "vertical" | undefined;
|
|
192
|
+
}
|
|
171
193
|
interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
172
194
|
/**
|
|
173
195
|
* The current value of the radio group
|
|
@@ -189,6 +211,10 @@ interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
|
189
211
|
* Returns the state details of a radio input
|
|
190
212
|
*/
|
|
191
213
|
getItemState: (props: ItemProps) => ItemState;
|
|
214
|
+
/**
|
|
215
|
+
* Returns the state of the radio group
|
|
216
|
+
*/
|
|
217
|
+
getRootState: () => RootState;
|
|
192
218
|
getRootProps: () => T["element"];
|
|
193
219
|
getLabelProps: () => T["element"];
|
|
194
220
|
getItemProps: (props: ItemProps) => T["label"];
|
|
@@ -198,4 +224,4 @@ interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
|
198
224
|
getIndicatorProps: () => T["element"];
|
|
199
225
|
}
|
|
200
226
|
|
|
201
|
-
export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, ValueChangeDetails };
|
|
227
|
+
export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, RootState, ValueChangeDetails };
|
|
@@ -168,6 +168,28 @@ interface ItemState {
|
|
|
168
168
|
*/
|
|
169
169
|
active: boolean;
|
|
170
170
|
}
|
|
171
|
+
interface RootState {
|
|
172
|
+
/**
|
|
173
|
+
* Whether the radio group is disabled
|
|
174
|
+
*/
|
|
175
|
+
disabled: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the radio group is invalid
|
|
178
|
+
*/
|
|
179
|
+
invalid: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Whether the radio group is required
|
|
182
|
+
*/
|
|
183
|
+
required: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Whether the radio group is read-only
|
|
186
|
+
*/
|
|
187
|
+
readOnly: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* The orientation of the radio group
|
|
190
|
+
*/
|
|
191
|
+
orientation: "horizontal" | "vertical" | undefined;
|
|
192
|
+
}
|
|
171
193
|
interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
172
194
|
/**
|
|
173
195
|
* The current value of the radio group
|
|
@@ -189,6 +211,10 @@ interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
|
189
211
|
* Returns the state details of a radio input
|
|
190
212
|
*/
|
|
191
213
|
getItemState: (props: ItemProps) => ItemState;
|
|
214
|
+
/**
|
|
215
|
+
* Returns the state of the radio group
|
|
216
|
+
*/
|
|
217
|
+
getRootState: () => RootState;
|
|
192
218
|
getRootProps: () => T["element"];
|
|
193
219
|
getLabelProps: () => T["element"];
|
|
194
220
|
getItemProps: (props: ItemProps) => T["label"];
|
|
@@ -198,4 +224,4 @@ interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
|
198
224
|
getIndicatorProps: () => T["element"];
|
|
199
225
|
}
|
|
200
226
|
|
|
201
|
-
export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, ValueChangeDetails };
|
|
227
|
+
export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, RootState, ValueChangeDetails };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/radio-group",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "Core logic for the radio group widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@zag-js/anatomy": "
|
|
34
|
-
"@zag-js/dom-query": "
|
|
35
|
-
"@zag-js/focus-visible": "
|
|
36
|
-
"@zag-js/utils": "
|
|
37
|
-
"@zag-js/core": "
|
|
38
|
-
"@zag-js/types": "
|
|
33
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/focus-visible": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/utils": "2.0.0-next.1",
|
|
37
|
+
"@zag-js/core": "2.0.0-next.1",
|
|
38
|
+
"@zag-js/types": "2.0.0-next.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"clean-package": "2.2.0"
|