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