@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 CHANGED
@@ -1,194 +1,198 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
3
- import * as _zag_js_core from '@zag-js/core';
4
- import { StateMachine, Machine } from '@zag-js/core';
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
- value: string;
11
+ value: string;
10
12
  }
11
13
  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;
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
- * 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;
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
- * @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;
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
- * @computed
112
- * Whether the radio group is disabled
113
- */
114
- isDisabled: boolean;
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
- value: 'idle';
120
+ value: 'idle';
120
121
  }
121
- type State = StateMachine.State<MachineContext, MachineState>;
122
- type Send = StateMachine.Send<StateMachine.AnyEventObject>;
123
- type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
122
+ type State = XState<MachineContext, MachineState>;
123
+ type Send = XSend<AnyEventObject>;
124
+ type Service = Machine<MachineContext, MachineState, AnyEventObject>;
124
125
  interface ItemProps {
125
- value: string;
126
- disabled?: boolean | undefined;
127
- invalid?: boolean | undefined;
126
+ value: string;
127
+ disabled?: boolean | undefined;
128
+ invalid?: boolean | undefined;
128
129
  }
129
130
  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;
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
- * 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'];
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
- 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">];
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 };