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