@destyler/switch 0.0.6 → 0.0.7-beta.1
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 +275 -178
- package/dist/index.d.cts +96 -239
- package/dist/index.d.mts +96 -239
- package/dist/index.d.ts +96 -239
- package/dist/index.mjs +271 -174
- package/package.json +11 -17
- package/README.md +0 -7
- package/dist/component.cjs +0 -16
- package/dist/component.d.cts +0 -4
- package/dist/component.d.mts +0 -4
- package/dist/component.d.ts +0 -4
- package/dist/component.mjs +0 -6
- package/dist/resolver.cjs +0 -21
- 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 -18
package/dist/index.d.mts
CHANGED
|
@@ -1,286 +1,143 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
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
5
|
|
|
6
|
-
declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
readonly defaultChecked: {
|
|
20
|
-
readonly type: PropType<boolean>;
|
|
21
|
-
readonly required: false;
|
|
22
|
-
};
|
|
6
|
+
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "control" | "thumb">;
|
|
7
|
+
|
|
8
|
+
interface CheckedChangeDetails {
|
|
9
|
+
checked: boolean;
|
|
10
|
+
}
|
|
11
|
+
type ElementIds = Partial<{
|
|
12
|
+
root: string;
|
|
13
|
+
hiddenInput: string;
|
|
14
|
+
control: string;
|
|
15
|
+
label: string;
|
|
16
|
+
thumb: string;
|
|
17
|
+
}>;
|
|
18
|
+
interface PublicContext extends DirectionProperty, CommonProperties {
|
|
23
19
|
/**
|
|
24
|
-
* The
|
|
25
|
-
* Can be bind as `v-model:checked`.
|
|
20
|
+
* The ids of the elements in the switch. Useful for composition.
|
|
26
21
|
*/
|
|
27
|
-
|
|
28
|
-
readonly type: PropType<boolean>;
|
|
29
|
-
readonly required: false;
|
|
30
|
-
readonly default: undefined;
|
|
31
|
-
};
|
|
22
|
+
ids?: ElementIds | undefined;
|
|
32
23
|
/**
|
|
33
|
-
*
|
|
24
|
+
* Specifies the localized strings that identifies the accessibility elements and their states
|
|
34
25
|
*/
|
|
35
|
-
|
|
36
|
-
readonly type: PropType<boolean>;
|
|
37
|
-
readonly required: false;
|
|
38
|
-
};
|
|
26
|
+
label: string;
|
|
39
27
|
/**
|
|
40
|
-
*
|
|
28
|
+
* Whether the switch is disabled.
|
|
41
29
|
*/
|
|
42
|
-
|
|
43
|
-
readonly type: PropType<boolean>;
|
|
44
|
-
readonly required: false;
|
|
45
|
-
};
|
|
30
|
+
disabled?: boolean | undefined;
|
|
46
31
|
/**
|
|
47
|
-
*
|
|
32
|
+
* If `true`, the switch is marked as invalid.
|
|
48
33
|
*/
|
|
49
|
-
|
|
50
|
-
readonly type: PropType<string>;
|
|
51
|
-
readonly required: false;
|
|
52
|
-
};
|
|
34
|
+
invalid?: boolean | undefined;
|
|
53
35
|
/**
|
|
54
|
-
*
|
|
36
|
+
* If `true`, the switch input is marked as required,
|
|
55
37
|
*/
|
|
56
|
-
|
|
57
|
-
readonly type: PropType<string>;
|
|
58
|
-
readonly required: false;
|
|
59
|
-
};
|
|
38
|
+
required?: boolean | undefined;
|
|
60
39
|
/**
|
|
61
|
-
*
|
|
40
|
+
* Whether the switch is read-only
|
|
62
41
|
*/
|
|
63
|
-
|
|
64
|
-
readonly type: PropType<string>;
|
|
65
|
-
readonly required: false;
|
|
66
|
-
readonly default: "on";
|
|
67
|
-
};
|
|
68
|
-
readonly asChild: {
|
|
69
|
-
readonly type: PropType<boolean>;
|
|
70
|
-
readonly required: false;
|
|
71
|
-
readonly default: false;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
type SwitchRootProps = ExtractPublicPropTypes<typeof switchRootProps>;
|
|
75
|
-
declare const switchRootEmits: {
|
|
76
|
-
'update:checked': (_checked: boolean) => boolean;
|
|
77
|
-
};
|
|
78
|
-
interface SwitchRootContext {
|
|
79
|
-
checked?: Ref<boolean>;
|
|
80
|
-
toggleCheck: () => void;
|
|
81
|
-
disabled: Ref<boolean | undefined>;
|
|
82
|
-
}
|
|
83
|
-
declare const SwitchRoot: vue.DefineComponent<{
|
|
42
|
+
readOnly?: boolean | undefined;
|
|
84
43
|
/**
|
|
85
|
-
*
|
|
44
|
+
* Function to call when the switch is clicked.
|
|
86
45
|
*/
|
|
87
|
-
|
|
88
|
-
readonly default: "button";
|
|
89
|
-
readonly type: PropType<_destyler_primitive.AsTag | vue.Component>;
|
|
90
|
-
readonly required: false;
|
|
91
|
-
};
|
|
46
|
+
onCheckedChange?: ((details: CheckedChangeDetails) => void) | undefined;
|
|
92
47
|
/**
|
|
93
|
-
*
|
|
94
|
-
* Use when you do not need to control its state.
|
|
48
|
+
* Whether the switch is checked.
|
|
95
49
|
*/
|
|
96
|
-
|
|
97
|
-
readonly type: PropType<boolean>;
|
|
98
|
-
readonly required: false;
|
|
99
|
-
};
|
|
50
|
+
checked: boolean;
|
|
100
51
|
/**
|
|
101
|
-
* The
|
|
102
|
-
*
|
|
52
|
+
* The name of the input field in a switch
|
|
53
|
+
* (Useful for form submission).
|
|
103
54
|
*/
|
|
104
|
-
|
|
105
|
-
readonly type: PropType<boolean>;
|
|
106
|
-
readonly required: false;
|
|
107
|
-
readonly default: undefined;
|
|
108
|
-
};
|
|
55
|
+
name?: string | undefined;
|
|
109
56
|
/**
|
|
110
|
-
*
|
|
57
|
+
* The id of the form that the switch belongs to
|
|
111
58
|
*/
|
|
112
|
-
|
|
113
|
-
readonly type: PropType<boolean>;
|
|
114
|
-
readonly required: false;
|
|
115
|
-
};
|
|
59
|
+
form?: string | undefined;
|
|
116
60
|
/**
|
|
117
|
-
*
|
|
61
|
+
* The value of switch input. Useful for form submission.
|
|
62
|
+
* @default "on"
|
|
118
63
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
64
|
+
value?: string | number | undefined;
|
|
65
|
+
}
|
|
66
|
+
type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
|
|
67
|
+
type ComputedContext = Readonly<{
|
|
123
68
|
/**
|
|
124
|
-
*
|
|
69
|
+
* Whether the switch is disabled
|
|
125
70
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
71
|
+
isDisabled: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
interface PrivateContext {
|
|
130
74
|
/**
|
|
131
|
-
*
|
|
75
|
+
* @internal
|
|
76
|
+
* Whether the checkbox is pressed
|
|
132
77
|
*/
|
|
133
|
-
|
|
134
|
-
readonly type: PropType<string>;
|
|
135
|
-
readonly required: false;
|
|
136
|
-
};
|
|
78
|
+
active?: boolean | undefined;
|
|
137
79
|
/**
|
|
138
|
-
*
|
|
80
|
+
* @internal
|
|
81
|
+
* Whether the checkbox has focus
|
|
139
82
|
*/
|
|
140
|
-
|
|
141
|
-
readonly type: PropType<string>;
|
|
142
|
-
readonly required: false;
|
|
143
|
-
readonly default: "on";
|
|
144
|
-
};
|
|
145
|
-
readonly asChild: {
|
|
146
|
-
readonly type: PropType<boolean>;
|
|
147
|
-
readonly required: false;
|
|
148
|
-
readonly default: false;
|
|
149
|
-
};
|
|
150
|
-
}, {
|
|
151
|
-
forwardRef: (ref: Element | vue.ComponentPublicInstance | null) => void;
|
|
152
|
-
toggleCheck: () => void;
|
|
153
|
-
isFormControl: vue.ComputedRef<boolean>;
|
|
154
|
-
ariaLabel: vue.ComputedRef<string | null | undefined>;
|
|
155
|
-
checked: Ref<boolean>;
|
|
156
|
-
disabled: Ref<boolean | undefined>;
|
|
157
|
-
}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
|
|
158
|
-
'update:checked': (_checked: boolean) => boolean;
|
|
159
|
-
}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
83
|
+
focused?: boolean | undefined;
|
|
160
84
|
/**
|
|
161
|
-
* @
|
|
85
|
+
* @internal
|
|
86
|
+
* Whether the checkbox has focus visible
|
|
162
87
|
*/
|
|
163
|
-
|
|
164
|
-
readonly default: "button";
|
|
165
|
-
readonly type: PropType<_destyler_primitive.AsTag | vue.Component>;
|
|
166
|
-
readonly required: false;
|
|
167
|
-
};
|
|
88
|
+
focusVisible?: boolean | undefined;
|
|
168
89
|
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
90
|
+
* @internal
|
|
91
|
+
* Whether the checkbox is hovered
|
|
171
92
|
*/
|
|
172
|
-
|
|
173
|
-
readonly type: PropType<boolean>;
|
|
174
|
-
readonly required: false;
|
|
175
|
-
};
|
|
93
|
+
hovered?: boolean | undefined;
|
|
176
94
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
95
|
+
* @internal
|
|
96
|
+
* Whether the checkbox fieldset is disabled
|
|
179
97
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
98
|
+
fieldsetDisabled: boolean;
|
|
99
|
+
}
|
|
100
|
+
interface MachineContext extends PublicContext, PrivateContext, ComputedContext {
|
|
101
|
+
}
|
|
102
|
+
interface MachineState {
|
|
103
|
+
value: 'ready';
|
|
104
|
+
}
|
|
105
|
+
type State = StateMachine.State<MachineContext, MachineState>;
|
|
106
|
+
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
107
|
+
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
108
|
+
interface MachineApi<T extends PropTypes = PropTypes> {
|
|
185
109
|
/**
|
|
186
|
-
*
|
|
110
|
+
* Whether the checkbox is checked
|
|
187
111
|
*/
|
|
188
|
-
|
|
189
|
-
readonly type: PropType<boolean>;
|
|
190
|
-
readonly required: false;
|
|
191
|
-
};
|
|
112
|
+
checked: boolean;
|
|
192
113
|
/**
|
|
193
|
-
*
|
|
114
|
+
* Whether the checkbox is disabled
|
|
194
115
|
*/
|
|
195
|
-
|
|
196
|
-
readonly type: PropType<boolean>;
|
|
197
|
-
readonly required: false;
|
|
198
|
-
};
|
|
116
|
+
disabled: boolean | undefined;
|
|
199
117
|
/**
|
|
200
|
-
*
|
|
118
|
+
* Whether the checkbox is focused
|
|
201
119
|
*/
|
|
202
|
-
|
|
203
|
-
readonly type: PropType<string>;
|
|
204
|
-
readonly required: false;
|
|
205
|
-
};
|
|
120
|
+
focused: boolean | undefined;
|
|
206
121
|
/**
|
|
207
|
-
*
|
|
122
|
+
* Function to set the checked state of the switch.
|
|
208
123
|
*/
|
|
209
|
-
|
|
210
|
-
readonly type: PropType<string>;
|
|
211
|
-
readonly required: false;
|
|
212
|
-
};
|
|
124
|
+
setChecked: (checked: boolean) => void;
|
|
213
125
|
/**
|
|
214
|
-
*
|
|
126
|
+
* Function to toggle the checked state of the checkbox
|
|
215
127
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
readonly required: false;
|
|
224
|
-
readonly default: false;
|
|
225
|
-
};
|
|
226
|
-
}>> & {
|
|
227
|
-
"onUpdate:checked"?: ((_checked: boolean) => any) | undefined;
|
|
228
|
-
}, {
|
|
229
|
-
readonly as: _destyler_primitive.AsTag | vue.Component;
|
|
230
|
-
readonly checked: boolean;
|
|
231
|
-
readonly value: string;
|
|
232
|
-
readonly asChild: boolean;
|
|
233
|
-
}, {}>;
|
|
128
|
+
toggleChecked: () => void;
|
|
129
|
+
getRootProps: () => T['label'];
|
|
130
|
+
getLabelProps: () => T['element'];
|
|
131
|
+
getThumbProps: () => T['element'];
|
|
132
|
+
getControlProps: () => T['element'];
|
|
133
|
+
getHiddenInputProps: () => T['input'];
|
|
134
|
+
}
|
|
234
135
|
|
|
235
|
-
declare
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
readonly type: vue.PropType<_destyler_primitive.AsTag | vue.Component>;
|
|
242
|
-
readonly required: false;
|
|
243
|
-
};
|
|
244
|
-
readonly asChild: {
|
|
245
|
-
readonly type: vue.PropType<boolean>;
|
|
246
|
-
readonly required: false;
|
|
247
|
-
readonly default: false;
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
type SwitchThumbProps = ExtractPublicPropTypes<typeof switchThumbProps>;
|
|
251
|
-
declare const SwitchThumb: vue.DefineComponent<{
|
|
252
|
-
/**
|
|
253
|
-
* @default span
|
|
254
|
-
*/
|
|
255
|
-
readonly as: {
|
|
256
|
-
readonly default: "span";
|
|
257
|
-
readonly type: vue.PropType<_destyler_primitive.AsTag | vue.Component>;
|
|
258
|
-
readonly required: false;
|
|
259
|
-
};
|
|
260
|
-
readonly asChild: {
|
|
261
|
-
readonly type: vue.PropType<boolean>;
|
|
262
|
-
readonly required: false;
|
|
263
|
-
readonly default: false;
|
|
264
|
-
};
|
|
265
|
-
}, {
|
|
266
|
-
rootContext: SwitchRootContext;
|
|
267
|
-
}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
268
|
-
/**
|
|
269
|
-
* @default span
|
|
270
|
-
*/
|
|
271
|
-
readonly as: {
|
|
272
|
-
readonly default: "span";
|
|
273
|
-
readonly type: vue.PropType<_destyler_primitive.AsTag | vue.Component>;
|
|
274
|
-
readonly required: false;
|
|
275
|
-
};
|
|
276
|
-
readonly asChild: {
|
|
277
|
-
readonly type: vue.PropType<boolean>;
|
|
278
|
-
readonly required: false;
|
|
279
|
-
readonly default: false;
|
|
280
|
-
};
|
|
281
|
-
}>>, {
|
|
282
|
-
readonly as: _destyler_primitive.AsTag | vue.Component;
|
|
283
|
-
readonly asChild: boolean;
|
|
284
|
-
}, {}>;
|
|
136
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
|
|
137
|
+
|
|
138
|
+
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
139
|
+
|
|
140
|
+
declare const props: ("label" | "ids" | "disabled" | "invalid" | "required" | "readOnly" | "onCheckedChange" | "checked" | "name" | "form" | "value" | "id" | "dir" | "getRootNode")[];
|
|
141
|
+
declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "label" | "ids" | "disabled" | "invalid" | "required" | "readOnly" | "onCheckedChange" | "checked" | "name" | "form" | "value" | "id" | "dir" | "getRootNode">];
|
|
285
142
|
|
|
286
|
-
export {
|
|
143
|
+
export { type MachineApi as Api, type CheckedChangeDetails, type UserDefinedContext as Context, type ElementIds, type Service, anatomy, connect, machine, props, splitProps };
|