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