@destyler/switch 0.0.3 → 0.0.5
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/README.md +7 -0
- package/dist/component.cjs +5 -2
- package/dist/component.d.cts +1 -1
- package/dist/component.d.mts +1 -1
- package/dist/component.d.ts +1 -1
- package/dist/component.mjs +1 -1
- package/dist/index.cjs +50 -25
- package/dist/index.d.cts +133 -41
- package/dist/index.d.mts +133 -41
- package/dist/index.d.ts +133 -41
- package/dist/index.mjs +47 -25
- package/dist/resolver.cjs +4 -3
- package/dist/resolver.d.cts +2 -2
- package/dist/resolver.d.mts +2 -2
- package/dist/resolver.d.ts +2 -2
- package/dist/resolver.mjs +4 -3
- package/package.json +15 -17
package/dist/index.mjs
CHANGED
|
@@ -1,56 +1,80 @@
|
|
|
1
1
|
import { defineComponent, toRefs, computed, withDirectives, h, mergeProps, withModifiers } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { primitiveProps, Primitive } from '@destyler/primitive';
|
|
3
3
|
import { useVModel, useForwardExpose, useFormControl } from '@destyler/composition';
|
|
4
4
|
import { createContext } from '@destyler/shared';
|
|
5
5
|
import { BindOnceDirective } from '@destyler/directives';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const switchRootProps = {
|
|
8
|
+
...primitiveProps,
|
|
9
|
+
/**
|
|
10
|
+
* @default button
|
|
11
|
+
*/
|
|
8
12
|
as: {
|
|
9
|
-
|
|
10
|
-
required: false,
|
|
13
|
+
...primitiveProps.as,
|
|
11
14
|
default: "button"
|
|
12
15
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
16
|
+
/**
|
|
17
|
+
* The state of the switch when it is initially rendered.
|
|
18
|
+
* Use when you do not need to control its state.
|
|
19
|
+
*/
|
|
18
20
|
defaultChecked: {
|
|
19
21
|
type: Boolean,
|
|
20
22
|
required: false
|
|
21
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* The controlled state of the switch.
|
|
26
|
+
* Can be bind as `v-model:checked`.
|
|
27
|
+
*/
|
|
22
28
|
checked: {
|
|
23
29
|
type: Boolean,
|
|
24
30
|
required: false,
|
|
25
31
|
default: void 0
|
|
26
32
|
},
|
|
33
|
+
/**
|
|
34
|
+
* When `true`, prevents the user from interacting with the switch.
|
|
35
|
+
*/
|
|
27
36
|
disabled: {
|
|
28
37
|
type: Boolean,
|
|
29
38
|
required: false
|
|
30
39
|
},
|
|
40
|
+
/**
|
|
41
|
+
* When `true`, indicates that the user must check the switch before the owning form can be submitted.
|
|
42
|
+
*/
|
|
31
43
|
required: {
|
|
32
44
|
type: Boolean,
|
|
33
45
|
required: false
|
|
34
46
|
},
|
|
47
|
+
/**
|
|
48
|
+
* The name of the switch. Submitted with its owning form as part of a name/value pair.
|
|
49
|
+
*/
|
|
35
50
|
name: {
|
|
36
51
|
type: String,
|
|
37
52
|
required: false
|
|
38
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* Id of the element
|
|
56
|
+
*/
|
|
39
57
|
id: {
|
|
40
58
|
type: String,
|
|
41
59
|
required: false
|
|
42
60
|
},
|
|
61
|
+
/**
|
|
62
|
+
* The value given as data when submitted with a `name`.
|
|
63
|
+
*/
|
|
43
64
|
value: {
|
|
44
65
|
type: String,
|
|
45
66
|
required: false,
|
|
46
67
|
default: "on"
|
|
47
68
|
}
|
|
48
69
|
};
|
|
70
|
+
const switchRootEmits = {
|
|
71
|
+
"update:checked": (_checked) => true
|
|
72
|
+
};
|
|
49
73
|
const [injectSwitchRootContext, provideSwitchRootContext] = createContext("DestylerSwitchRoot");
|
|
50
|
-
const
|
|
74
|
+
const SwitchRoot = defineComponent({
|
|
51
75
|
name: "DestylerSwitchRoot",
|
|
52
|
-
props:
|
|
53
|
-
emits:
|
|
76
|
+
props: switchRootProps,
|
|
77
|
+
emits: switchRootEmits,
|
|
54
78
|
setup(props, { emit }) {
|
|
55
79
|
const { disabled } = toRefs(props);
|
|
56
80
|
const checked = useVModel(props, "checked", emit, {
|
|
@@ -81,7 +105,7 @@ const DestylerSwitchRoot = defineComponent({
|
|
|
81
105
|
},
|
|
82
106
|
render() {
|
|
83
107
|
return [
|
|
84
|
-
withDirectives(h(
|
|
108
|
+
withDirectives(h(Primitive, mergeProps(this.$attrs, {
|
|
85
109
|
"ref": (el) => this.forwardRef(el),
|
|
86
110
|
"role": "switch",
|
|
87
111
|
"type": this.$props.as === "button" ? "button" : void 0,
|
|
@@ -126,21 +150,19 @@ const DestylerSwitchRoot = defineComponent({
|
|
|
126
150
|
}
|
|
127
151
|
});
|
|
128
152
|
|
|
129
|
-
const
|
|
153
|
+
const switchThumbProps = {
|
|
154
|
+
...primitiveProps,
|
|
155
|
+
/**
|
|
156
|
+
* @default span
|
|
157
|
+
*/
|
|
130
158
|
as: {
|
|
131
|
-
|
|
132
|
-
required: false,
|
|
159
|
+
...primitiveProps.as,
|
|
133
160
|
default: "span"
|
|
134
|
-
},
|
|
135
|
-
asChild: {
|
|
136
|
-
type: Boolean,
|
|
137
|
-
required: false,
|
|
138
|
-
default: false
|
|
139
161
|
}
|
|
140
162
|
};
|
|
141
|
-
const
|
|
163
|
+
const SwitchThumb = defineComponent({
|
|
142
164
|
name: "DestylerSwitchThump",
|
|
143
|
-
props:
|
|
165
|
+
props: switchThumbProps,
|
|
144
166
|
setup(_) {
|
|
145
167
|
const rootContext = injectSwitchRootContext();
|
|
146
168
|
useForwardExpose();
|
|
@@ -149,7 +171,7 @@ const DestylerSwitchThump = defineComponent({
|
|
|
149
171
|
};
|
|
150
172
|
},
|
|
151
173
|
render() {
|
|
152
|
-
return h(
|
|
174
|
+
return h(Primitive, {
|
|
153
175
|
"data-state": this.rootContext.checked?.value ? "checked" : "unchecked",
|
|
154
176
|
"data-disabled": this.rootContext.disabled.value ? "" : void 0,
|
|
155
177
|
"asChild": this.$props.asChild,
|
|
@@ -158,4 +180,4 @@ const DestylerSwitchThump = defineComponent({
|
|
|
158
180
|
}
|
|
159
181
|
});
|
|
160
182
|
|
|
161
|
-
export {
|
|
183
|
+
export { SwitchRoot, SwitchThumb, switchRootEmits, switchRootProps, switchThumbProps };
|
package/dist/resolver.cjs
CHANGED
|
@@ -4,9 +4,10 @@ const name = "@destyler/switch";
|
|
|
4
4
|
|
|
5
5
|
const packageName = name;
|
|
6
6
|
const switchComponentName = [
|
|
7
|
-
"
|
|
7
|
+
"SwitchRoot",
|
|
8
|
+
"SwitchThumb"
|
|
8
9
|
];
|
|
9
|
-
function
|
|
10
|
+
function SwitchResolver() {
|
|
10
11
|
return {
|
|
11
12
|
type: "component",
|
|
12
13
|
resolve: (name2) => {
|
|
@@ -16,5 +17,5 @@ function DestylerTemplateResolver() {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
exports.
|
|
20
|
+
exports.SwitchResolver = SwitchResolver;
|
|
20
21
|
exports.switchComponentName = switchComponentName;
|
package/dist/resolver.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
2
|
|
|
3
3
|
declare const switchComponentName: string[];
|
|
4
|
-
declare function
|
|
4
|
+
declare function SwitchResolver(): ComponentResolver;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { SwitchResolver, switchComponentName };
|
package/dist/resolver.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
2
|
|
|
3
3
|
declare const switchComponentName: string[];
|
|
4
|
-
declare function
|
|
4
|
+
declare function SwitchResolver(): ComponentResolver;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { SwitchResolver, switchComponentName };
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentResolver } from 'unplugin-vue-components';
|
|
2
2
|
|
|
3
3
|
declare const switchComponentName: string[];
|
|
4
|
-
declare function
|
|
4
|
+
declare function SwitchResolver(): ComponentResolver;
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { SwitchResolver, switchComponentName };
|
package/dist/resolver.mjs
CHANGED
|
@@ -2,9 +2,10 @@ const name = "@destyler/switch";
|
|
|
2
2
|
|
|
3
3
|
const packageName = name;
|
|
4
4
|
const switchComponentName = [
|
|
5
|
-
"
|
|
5
|
+
"SwitchRoot",
|
|
6
|
+
"SwitchThumb"
|
|
6
7
|
];
|
|
7
|
-
function
|
|
8
|
+
function SwitchResolver() {
|
|
8
9
|
return {
|
|
9
10
|
type: "component",
|
|
10
11
|
resolve: (name2) => {
|
|
@@ -14,4 +15,4 @@ function DestylerTemplateResolver() {
|
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export {
|
|
18
|
+
export { SwitchResolver, switchComponentName };
|
package/package.json
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/switch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "0.0.5",
|
|
5
|
+
"description": "a control that allows the user to toggle between checked and not checked.",
|
|
6
6
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.
|
|
11
|
-
"
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"default": "./dist/index.mjs"
|
|
13
12
|
},
|
|
14
13
|
"./resolver": {
|
|
15
|
-
"types": "./dist/resolver.d.
|
|
16
|
-
"
|
|
17
|
-
"require": "./dist/resolver.cjs"
|
|
14
|
+
"types": "./dist/resolver.d.mts",
|
|
15
|
+
"default": "./dist/resolver.mjs"
|
|
18
16
|
},
|
|
19
17
|
"./component": {
|
|
20
|
-
"types": "./dist/component.d.
|
|
21
|
-
"
|
|
22
|
-
"require": "./dist/component.cjs"
|
|
18
|
+
"types": "./dist/component.d.mts",
|
|
19
|
+
"default": "./dist/component.mjs"
|
|
23
20
|
},
|
|
24
21
|
"./*": "./*"
|
|
25
22
|
},
|
|
@@ -31,16 +28,17 @@
|
|
|
31
28
|
"dist"
|
|
32
29
|
],
|
|
33
30
|
"peerDependencies": {
|
|
34
|
-
"vue": ">=3.
|
|
31
|
+
"vue": ">=3.4.21"
|
|
35
32
|
},
|
|
36
33
|
"dependencies": {
|
|
37
|
-
"@destyler/composition": "0.0.
|
|
38
|
-
"@destyler/
|
|
39
|
-
"@destyler/primitive": "0.0.
|
|
40
|
-
"@destyler/
|
|
34
|
+
"@destyler/composition": "0.0.5",
|
|
35
|
+
"@destyler/directives": "0.0.5",
|
|
36
|
+
"@destyler/primitive": "0.0.5",
|
|
37
|
+
"@destyler/shared": "0.0.5"
|
|
41
38
|
},
|
|
42
39
|
"scripts": {
|
|
43
40
|
"clear": "rimraf ./dist",
|
|
44
|
-
"build": "pnpm run clear && unbuild"
|
|
41
|
+
"build": "pnpm run clear && unbuild",
|
|
42
|
+
"stub": "unbuild --stub"
|
|
45
43
|
}
|
|
46
44
|
}
|