@destyler/radio 0.0.6 → 0.0.7-beta.2
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.cjs +431 -14
- package/dist/index.d.cts +194 -4
- package/dist/index.d.mts +194 -4
- package/dist/index.d.ts +194 -4
- package/dist/index.mjs +428 -8
- package/package.json +11 -20
- package/README.md +0 -7
- package/dist/component.cjs +0 -416
- package/dist/component.d.cts +0 -216
- package/dist/component.d.mts +0 -216
- package/dist/component.d.ts +0 -216
- package/dist/component.mjs +0 -405
- package/dist/resolver.cjs +0 -22
- package/dist/resolver.d.cts +0 -6
- package/dist/resolver.d.mts +0 -6
- package/dist/resolver.d.ts +0 -6
- package/dist/resolver.mjs +0 -19
- package/dist/shared/radio.54693474.d.cts +0 -519
- package/dist/shared/radio.54693474.d.mts +0 -519
- package/dist/shared/radio.54693474.d.ts +0 -519
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,194 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { Machine, StateMachine } 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;
|
|
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 PublicContext extends DirectionProperty, CommonProperties {
|
|
21
|
+
/**
|
|
22
|
+
* The ids of the elements in the radio. Useful for composition.
|
|
23
|
+
*/
|
|
24
|
+
ids?: ElementIds | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The value of the checked radio
|
|
27
|
+
*/
|
|
28
|
+
value: string | null;
|
|
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
|
+
* Whether the checkbox is read-only
|
|
44
|
+
*/
|
|
45
|
+
readOnly?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Function called once a radio is checked
|
|
48
|
+
* @param value the value of the checked radio
|
|
49
|
+
*/
|
|
50
|
+
onValueChange?: (details: ValueChangeDetails) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Orientation of the radio group
|
|
53
|
+
*/
|
|
54
|
+
orientation?: 'horizontal' | 'vertical' | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface PrivateContext {
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
* The id of the active radio
|
|
60
|
+
*/
|
|
61
|
+
activeValue: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* The id of the focused radio
|
|
65
|
+
*/
|
|
66
|
+
focusedValue: string | null;
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* The id of the hovered radio
|
|
70
|
+
*/
|
|
71
|
+
hoveredValue: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
* The active tab indicator's dom rect
|
|
75
|
+
*/
|
|
76
|
+
indicatorRect: Partial<{
|
|
77
|
+
left: string;
|
|
78
|
+
top: string;
|
|
79
|
+
width: string;
|
|
80
|
+
height: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
* Whether the active tab indicator's rect can transition
|
|
85
|
+
*/
|
|
86
|
+
canIndicatorTransition?: boolean | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
* Function to clean up the observer for the active tab's rect
|
|
90
|
+
*/
|
|
91
|
+
indicatorCleanup?: VoidFunction | null | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
* Whether the radio group's fieldset is disabled
|
|
95
|
+
*/
|
|
96
|
+
fieldsetDisabled: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
* Whether the radio group is in focus
|
|
100
|
+
*/
|
|
101
|
+
focusVisible: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
* Whether the radio group is in server-side rendering
|
|
105
|
+
*/
|
|
106
|
+
ssr: boolean;
|
|
107
|
+
}
|
|
108
|
+
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
109
|
+
type ComputedContext = Readonly<{
|
|
110
|
+
/**
|
|
111
|
+
* @computed
|
|
112
|
+
* Whether the radio group is disabled
|
|
113
|
+
*/
|
|
114
|
+
isDisabled: boolean;
|
|
115
|
+
}>;
|
|
116
|
+
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
117
|
+
}
|
|
118
|
+
interface MachineState {
|
|
119
|
+
value: 'idle';
|
|
120
|
+
}
|
|
121
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
122
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
123
|
+
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
124
|
+
interface ItemProps {
|
|
125
|
+
value: string;
|
|
126
|
+
disabled?: boolean | undefined;
|
|
127
|
+
invalid?: boolean | undefined;
|
|
128
|
+
}
|
|
129
|
+
interface ItemState {
|
|
130
|
+
/**
|
|
131
|
+
* Whether the radio is invalid
|
|
132
|
+
*/
|
|
133
|
+
invalid: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the radio is disabled
|
|
136
|
+
*/
|
|
137
|
+
disabled: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether the radio is checked
|
|
140
|
+
*/
|
|
141
|
+
checked: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Whether the radio is focused
|
|
144
|
+
*/
|
|
145
|
+
focused: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether the radio is hovered
|
|
148
|
+
*/
|
|
149
|
+
hovered: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Whether the radio is active or pressed
|
|
152
|
+
*/
|
|
153
|
+
active: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
156
|
+
/**
|
|
157
|
+
* The current value of the radio group
|
|
158
|
+
*/
|
|
159
|
+
value: string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Function to set the value of the radio group
|
|
162
|
+
*/
|
|
163
|
+
setValue: (value: string) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Function to clear the value of the radio group
|
|
166
|
+
*/
|
|
167
|
+
clearValue: () => void;
|
|
168
|
+
/**
|
|
169
|
+
* Function to focus the radio group
|
|
170
|
+
*/
|
|
171
|
+
focus: () => void;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the state details of a radio input
|
|
174
|
+
*/
|
|
175
|
+
getItemState: (props: ItemProps) => ItemState;
|
|
176
|
+
getRootProps: () => T['element'];
|
|
177
|
+
getLabelProps: () => T['element'];
|
|
178
|
+
getItemProps: (props: ItemProps) => T['label'];
|
|
179
|
+
getItemTextProps: (props: ItemProps) => T['element'];
|
|
180
|
+
getItemControlProps: (props: ItemProps) => T['element'];
|
|
181
|
+
getItemHiddenInputProps: (props: ItemProps) => T['input'];
|
|
182
|
+
getIndicatorProps: () => T['element'];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
186
|
+
|
|
187
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
188
|
+
|
|
189
|
+
declare const props: ("ids" | "value" | "name" | "form" | "disabled" | "readOnly" | "onValueChange" | "orientation" | "id" | "dir" | "getRootNode")[];
|
|
190
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "value" | "name" | "form" | "disabled" | "readOnly" | "onValueChange" | "orientation" | "id" | "dir" | "getRootNode">];
|
|
191
|
+
declare const itemProps: (keyof ItemProps)[];
|
|
192
|
+
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>];
|
|
193
|
+
|
|
194
|
+
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type ItemProps, type ItemState, type Service, type ValueChangeDetails, anatomy, connect, itemProps, machine, props, splitItemProps, splitProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,194 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
1
|
+
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
+
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { Machine, StateMachine } 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;
|
|
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 PublicContext extends DirectionProperty, CommonProperties {
|
|
21
|
+
/**
|
|
22
|
+
* The ids of the elements in the radio. Useful for composition.
|
|
23
|
+
*/
|
|
24
|
+
ids?: ElementIds | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The value of the checked radio
|
|
27
|
+
*/
|
|
28
|
+
value: string | null;
|
|
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
|
+
* Whether the checkbox is read-only
|
|
44
|
+
*/
|
|
45
|
+
readOnly?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Function called once a radio is checked
|
|
48
|
+
* @param value the value of the checked radio
|
|
49
|
+
*/
|
|
50
|
+
onValueChange?: (details: ValueChangeDetails) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Orientation of the radio group
|
|
53
|
+
*/
|
|
54
|
+
orientation?: 'horizontal' | 'vertical' | undefined;
|
|
55
|
+
}
|
|
56
|
+
interface PrivateContext {
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
* The id of the active radio
|
|
60
|
+
*/
|
|
61
|
+
activeValue: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* The id of the focused radio
|
|
65
|
+
*/
|
|
66
|
+
focusedValue: string | null;
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
* The id of the hovered radio
|
|
70
|
+
*/
|
|
71
|
+
hoveredValue: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
* The active tab indicator's dom rect
|
|
75
|
+
*/
|
|
76
|
+
indicatorRect: Partial<{
|
|
77
|
+
left: string;
|
|
78
|
+
top: string;
|
|
79
|
+
width: string;
|
|
80
|
+
height: string;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* @internal
|
|
84
|
+
* Whether the active tab indicator's rect can transition
|
|
85
|
+
*/
|
|
86
|
+
canIndicatorTransition?: boolean | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* @internal
|
|
89
|
+
* Function to clean up the observer for the active tab's rect
|
|
90
|
+
*/
|
|
91
|
+
indicatorCleanup?: VoidFunction | null | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
* Whether the radio group's fieldset is disabled
|
|
95
|
+
*/
|
|
96
|
+
fieldsetDisabled: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
* Whether the radio group is in focus
|
|
100
|
+
*/
|
|
101
|
+
focusVisible: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
* Whether the radio group is in server-side rendering
|
|
105
|
+
*/
|
|
106
|
+
ssr: boolean;
|
|
107
|
+
}
|
|
108
|
+
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
109
|
+
type ComputedContext = Readonly<{
|
|
110
|
+
/**
|
|
111
|
+
* @computed
|
|
112
|
+
* Whether the radio group is disabled
|
|
113
|
+
*/
|
|
114
|
+
isDisabled: boolean;
|
|
115
|
+
}>;
|
|
116
|
+
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
117
|
+
}
|
|
118
|
+
interface MachineState {
|
|
119
|
+
value: 'idle';
|
|
120
|
+
}
|
|
121
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
122
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
123
|
+
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
124
|
+
interface ItemProps {
|
|
125
|
+
value: string;
|
|
126
|
+
disabled?: boolean | undefined;
|
|
127
|
+
invalid?: boolean | undefined;
|
|
128
|
+
}
|
|
129
|
+
interface ItemState {
|
|
130
|
+
/**
|
|
131
|
+
* Whether the radio is invalid
|
|
132
|
+
*/
|
|
133
|
+
invalid: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the radio is disabled
|
|
136
|
+
*/
|
|
137
|
+
disabled: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether the radio is checked
|
|
140
|
+
*/
|
|
141
|
+
checked: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Whether the radio is focused
|
|
144
|
+
*/
|
|
145
|
+
focused: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether the radio is hovered
|
|
148
|
+
*/
|
|
149
|
+
hovered: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Whether the radio is active or pressed
|
|
152
|
+
*/
|
|
153
|
+
active: boolean;
|
|
154
|
+
}
|
|
155
|
+
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
156
|
+
/**
|
|
157
|
+
* The current value of the radio group
|
|
158
|
+
*/
|
|
159
|
+
value: string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Function to set the value of the radio group
|
|
162
|
+
*/
|
|
163
|
+
setValue: (value: string) => void;
|
|
164
|
+
/**
|
|
165
|
+
* Function to clear the value of the radio group
|
|
166
|
+
*/
|
|
167
|
+
clearValue: () => void;
|
|
168
|
+
/**
|
|
169
|
+
* Function to focus the radio group
|
|
170
|
+
*/
|
|
171
|
+
focus: () => void;
|
|
172
|
+
/**
|
|
173
|
+
* Returns the state details of a radio input
|
|
174
|
+
*/
|
|
175
|
+
getItemState: (props: ItemProps) => ItemState;
|
|
176
|
+
getRootProps: () => T['element'];
|
|
177
|
+
getLabelProps: () => T['element'];
|
|
178
|
+
getItemProps: (props: ItemProps) => T['label'];
|
|
179
|
+
getItemTextProps: (props: ItemProps) => T['element'];
|
|
180
|
+
getItemControlProps: (props: ItemProps) => T['element'];
|
|
181
|
+
getItemHiddenInputProps: (props: ItemProps) => T['input'];
|
|
182
|
+
getIndicatorProps: () => T['element'];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
186
|
+
|
|
187
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
188
|
+
|
|
189
|
+
declare const props: ("ids" | "value" | "name" | "form" | "disabled" | "readOnly" | "onValueChange" | "orientation" | "id" | "dir" | "getRootNode")[];
|
|
190
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "ids" | "value" | "name" | "form" | "disabled" | "readOnly" | "onValueChange" | "orientation" | "id" | "dir" | "getRootNode">];
|
|
191
|
+
declare const itemProps: (keyof ItemProps)[];
|
|
192
|
+
declare const splitItemProps: <Props extends ItemProps>(props: Props) => [ItemProps, Omit<Props, keyof ItemProps>];
|
|
193
|
+
|
|
194
|
+
export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type ItemProps, type ItemState, type Service, type ValueChangeDetails, anatomy, connect, itemProps, machine, props, splitItemProps, splitProps };
|