@zag-js/radio-group 2.0.0-next.2 → 2.0.0-next.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.d.mts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +14 -38
- package/dist/index.mjs +2 -7
- package/dist/radio-group.anatomy.d.mts +2 -6
- package/dist/radio-group.anatomy.d.ts +2 -6
- package/dist/radio-group.anatomy.js +8 -40
- package/dist/radio-group.anatomy.mjs +4 -14
- package/dist/radio-group.connect.d.mts +3 -7
- package/dist/radio-group.connect.d.ts +3 -7
- package/dist/radio-group.connect.js +247 -257
- package/dist/radio-group.connect.mjs +242 -221
- package/dist/radio-group.dom.d.mts +26 -29
- package/dist/radio-group.dom.d.ts +26 -29
- package/dist/radio-group.dom.js +47 -85
- package/dist/radio-group.dom.mjs +28 -45
- package/dist/radio-group.machine.d.mts +2 -7
- package/dist/radio-group.machine.d.ts +2 -7
- package/dist/radio-group.machine.js +159 -217
- package/dist/radio-group.machine.mjs +155 -182
- package/dist/radio-group.props.d.mts +5 -10
- package/dist/radio-group.props.d.ts +5 -10
- package/dist/radio-group.props.js +32 -54
- package/dist/radio-group.props.mjs +25 -26
- package/dist/radio-group.types.d.mts +212 -213
- package/dist/radio-group.types.d.ts +212 -213
- package/dist/radio-group.types.js +4 -18
- package/dist/radio-group.types.mjs +1 -0
- package/package.json +8 -8
|
@@ -1,228 +1,227 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
interface ValueChangeDetails {
|
|
5
|
-
|
|
1
|
+
import { AnimationFrame } from "@zag-js/dom-query";
|
|
2
|
+
import { EventObject, Machine, Service } from "@zag-js/core";
|
|
3
|
+
import { CommonProperties, DirectionProperty, PropTypes, Rect } from "@zag-js/types";
|
|
4
|
+
export interface ValueChangeDetails {
|
|
5
|
+
value: string | null;
|
|
6
6
|
}
|
|
7
|
-
interface ElementIds {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
export interface ElementIds {
|
|
8
|
+
root?: string | undefined;
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
indicator?: string | undefined;
|
|
11
|
+
item?: ((value: string) => string) | undefined;
|
|
12
|
+
itemLabel?: ((value: string) => string) | undefined;
|
|
13
|
+
itemControl?: ((value: string) => string) | undefined;
|
|
14
|
+
itemHiddenInput?: ((value: string) => string) | undefined;
|
|
15
15
|
}
|
|
16
|
-
interface RadioGroupProps extends DirectionProperty, CommonProperties {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
16
|
+
export interface RadioGroupProps extends DirectionProperty, CommonProperties {
|
|
17
|
+
/**
|
|
18
|
+
* The ids of the elements in the radio. Useful for composition.
|
|
19
|
+
*/
|
|
20
|
+
ids?: ElementIds | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The controlled value of the radio group
|
|
23
|
+
*/
|
|
24
|
+
value?: string | null | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The initial value of the checked radio when rendered.
|
|
27
|
+
* Use when you don't need to control the value of the radio group.
|
|
28
|
+
*/
|
|
29
|
+
defaultValue?: string | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The name of the input fields in the radio
|
|
32
|
+
* (Useful for form submission).
|
|
33
|
+
*/
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The associate form of the underlying input.
|
|
37
|
+
*/
|
|
38
|
+
form?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* If `true`, the radio group will be disabled
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* If `true`, the radio group is marked as invalid.
|
|
45
|
+
*/
|
|
46
|
+
invalid?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* If `true`, the radio group is marked as required.
|
|
49
|
+
*/
|
|
50
|
+
required?: boolean | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the radio group is read-only
|
|
53
|
+
*/
|
|
54
|
+
readOnly?: boolean | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Function called once a radio is checked
|
|
57
|
+
*/
|
|
58
|
+
onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Orientation of the radio group
|
|
61
|
+
*/
|
|
62
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
63
63
|
}
|
|
64
64
|
interface PrivateContext {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
65
|
+
/**
|
|
66
|
+
* The value of the checked radio
|
|
67
|
+
*/
|
|
68
|
+
value: string | null;
|
|
69
|
+
/**
|
|
70
|
+
* The id of the active radio
|
|
71
|
+
*/
|
|
72
|
+
activeValue: string | null;
|
|
73
|
+
/**
|
|
74
|
+
* The id of the focused radio
|
|
75
|
+
*/
|
|
76
|
+
focusedValue: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* The id of the radio that has focus-visible
|
|
79
|
+
*/
|
|
80
|
+
focusVisibleValue: string | null;
|
|
81
|
+
/**
|
|
82
|
+
* The id of the hovered radio
|
|
83
|
+
*/
|
|
84
|
+
hoveredValue: string | null;
|
|
85
|
+
/**
|
|
86
|
+
* The active tab indicator's dom rect
|
|
87
|
+
*/
|
|
88
|
+
indicatorRect: Rect | null;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the indicator should skip transitions for the current frame
|
|
91
|
+
*/
|
|
92
|
+
indicatorInstant: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the radio group's fieldset is disabled
|
|
95
|
+
*/
|
|
96
|
+
fieldsetDisabled: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Whether the radio group is in server-side rendering
|
|
99
|
+
*/
|
|
100
|
+
ssr: boolean;
|
|
101
101
|
}
|
|
102
102
|
type PropsWithDefault = "orientation";
|
|
103
103
|
type ComputedContext = Readonly<{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Whether the radio group is disabled
|
|
106
|
+
*/
|
|
107
|
+
isDisabled: boolean;
|
|
108
108
|
}>;
|
|
109
109
|
interface Refs {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Function to clean up the observer for the active tab's rect
|
|
112
|
+
*/
|
|
113
|
+
indicatorCleanup: VoidFunction | null;
|
|
114
|
+
/**
|
|
115
|
+
* Frame that clears `indicatorInstant`
|
|
116
|
+
*/
|
|
117
|
+
indicatorFrame: AnimationFrame;
|
|
118
118
|
}
|
|
119
|
-
interface RadioGroupSchema {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
export interface RadioGroupSchema {
|
|
120
|
+
state: "idle";
|
|
121
|
+
props: RadioGroupProps;
|
|
122
|
+
defaultPropKey: PropsWithDefault;
|
|
123
|
+
context: PrivateContext;
|
|
124
|
+
computed: ComputedContext;
|
|
125
|
+
refs: Refs;
|
|
126
|
+
event: EventObject;
|
|
127
|
+
action: string;
|
|
128
|
+
effect: string;
|
|
129
|
+
guard: string;
|
|
130
130
|
}
|
|
131
|
-
type RadioGroupService = Service<RadioGroupSchema>;
|
|
132
|
-
type RadioGroupMachine = Machine<RadioGroupSchema>;
|
|
133
|
-
interface ItemProps {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
export type RadioGroupService = Service<RadioGroupSchema>;
|
|
132
|
+
export type RadioGroupMachine = Machine<RadioGroupSchema>;
|
|
133
|
+
export interface ItemProps {
|
|
134
|
+
value: string;
|
|
135
|
+
disabled?: boolean | undefined;
|
|
136
|
+
invalid?: boolean | undefined;
|
|
137
137
|
}
|
|
138
|
-
interface ItemState {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
138
|
+
export interface ItemState {
|
|
139
|
+
/**
|
|
140
|
+
* The value of the item
|
|
141
|
+
*/
|
|
142
|
+
value: string;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the item is invalid
|
|
145
|
+
*/
|
|
146
|
+
invalid: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Whether the item is disabled
|
|
149
|
+
*/
|
|
150
|
+
disabled: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Whether the item is checked
|
|
153
|
+
*/
|
|
154
|
+
checked: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Whether the item is focused
|
|
157
|
+
*/
|
|
158
|
+
focused: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether the item is focused and the focus is visible
|
|
161
|
+
*/
|
|
162
|
+
focusVisible: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the item is hovered
|
|
165
|
+
*/
|
|
166
|
+
hovered: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Whether the item is active or pressed
|
|
169
|
+
*/
|
|
170
|
+
active: boolean;
|
|
171
171
|
}
|
|
172
|
-
interface RootState {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
172
|
+
export interface RootState {
|
|
173
|
+
/**
|
|
174
|
+
* Whether the radio group is disabled
|
|
175
|
+
*/
|
|
176
|
+
disabled: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Whether the radio group is invalid
|
|
179
|
+
*/
|
|
180
|
+
invalid: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Whether the radio group is required
|
|
183
|
+
*/
|
|
184
|
+
required: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Whether the radio group is read-only
|
|
187
|
+
*/
|
|
188
|
+
readOnly: boolean;
|
|
189
|
+
/**
|
|
190
|
+
* The orientation of the radio group
|
|
191
|
+
*/
|
|
192
|
+
orientation: "horizontal" | "vertical" | undefined;
|
|
193
193
|
}
|
|
194
|
-
interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
194
|
+
export interface RadioGroupApi<T extends PropTypes = PropTypes> {
|
|
195
|
+
/**
|
|
196
|
+
* The current value of the radio group
|
|
197
|
+
*/
|
|
198
|
+
value: string | null;
|
|
199
|
+
/**
|
|
200
|
+
* Function to set the value of the radio group
|
|
201
|
+
*/
|
|
202
|
+
setValue: (value: string) => void;
|
|
203
|
+
/**
|
|
204
|
+
* Function to clear the value of the radio group
|
|
205
|
+
*/
|
|
206
|
+
clearValue: VoidFunction;
|
|
207
|
+
/**
|
|
208
|
+
* Function to focus the radio group
|
|
209
|
+
*/
|
|
210
|
+
focus: VoidFunction;
|
|
211
|
+
/**
|
|
212
|
+
* Returns the state details of a radio input
|
|
213
|
+
*/
|
|
214
|
+
getItemState: (props: ItemProps) => ItemState;
|
|
215
|
+
/**
|
|
216
|
+
* Returns the state of the radio group
|
|
217
|
+
*/
|
|
218
|
+
getRootState: () => RootState;
|
|
219
|
+
getRootProps: () => T["element"];
|
|
220
|
+
getLabelProps: () => T["element"];
|
|
221
|
+
getItemProps: (props: ItemProps) => T["label"];
|
|
222
|
+
getItemTextProps: (props: ItemProps) => T["element"];
|
|
223
|
+
getItemControlProps: (props: ItemProps) => T["element"];
|
|
224
|
+
getItemHiddenInputProps: (props: ItemProps) => T["input"];
|
|
225
|
+
getIndicatorProps: () => T["element"];
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
export type { ElementIds, ItemProps, ItemState, RadioGroupApi, RadioGroupMachine, RadioGroupProps, RadioGroupSchema, RadioGroupService, RootState, ValueChangeDetails };
|
|
227
|
+
export {};
|