@element-plus/nightly 0.0.20220206 → 0.0.20220207
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 +6 -12
- package/dist/index.css +1 -1
- package/dist/index.full.js +8 -6
- package/dist/index.full.min.js +2 -2
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +2 -2
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +8 -6
- package/dist/locale/af.js +1 -1
- package/dist/locale/af.min.js +1 -1
- package/dist/locale/af.min.mjs +1 -1
- package/dist/locale/af.mjs +1 -1
- package/dist/locale/ar.js +1 -1
- package/dist/locale/ar.min.js +1 -1
- package/dist/locale/ar.min.mjs +1 -1
- package/dist/locale/ar.mjs +1 -1
- package/dist/locale/bg.js +1 -1
- package/dist/locale/bg.min.js +1 -1
- package/dist/locale/bg.min.mjs +1 -1
- package/dist/locale/bg.mjs +1 -1
- package/dist/locale/bn.js +1 -1
- package/dist/locale/bn.min.js +1 -1
- package/dist/locale/bn.min.mjs +1 -1
- package/dist/locale/bn.mjs +1 -1
- package/dist/locale/ca.js +1 -1
- package/dist/locale/ca.min.js +1 -1
- package/dist/locale/ca.min.mjs +1 -1
- package/dist/locale/ca.mjs +1 -1
- package/dist/locale/cs.js +1 -1
- package/dist/locale/cs.min.js +1 -1
- package/dist/locale/cs.min.mjs +1 -1
- package/dist/locale/cs.mjs +1 -1
- package/dist/locale/da.js +1 -1
- package/dist/locale/da.min.js +1 -1
- package/dist/locale/da.min.mjs +1 -1
- package/dist/locale/da.mjs +1 -1
- package/dist/locale/de.js +1 -1
- package/dist/locale/de.min.js +1 -1
- package/dist/locale/de.min.mjs +1 -1
- package/dist/locale/de.mjs +1 -1
- package/dist/locale/el.js +1 -1
- package/dist/locale/el.min.js +1 -1
- package/dist/locale/el.min.mjs +1 -1
- package/dist/locale/el.mjs +1 -1
- package/dist/locale/en.js +1 -1
- package/dist/locale/en.min.js +1 -1
- package/dist/locale/en.min.mjs +1 -1
- package/dist/locale/en.mjs +1 -1
- package/dist/locale/eo.js +1 -1
- package/dist/locale/eo.min.js +1 -1
- package/dist/locale/eo.min.mjs +1 -1
- package/dist/locale/eo.mjs +1 -1
- package/dist/locale/es.js +1 -1
- package/dist/locale/es.min.js +1 -1
- package/dist/locale/es.min.mjs +1 -1
- package/dist/locale/es.mjs +1 -1
- package/dist/locale/et.js +1 -1
- package/dist/locale/et.min.js +1 -1
- package/dist/locale/et.min.mjs +1 -1
- package/dist/locale/et.mjs +1 -1
- package/dist/locale/eu.js +1 -1
- package/dist/locale/eu.min.js +1 -1
- package/dist/locale/eu.min.mjs +1 -1
- package/dist/locale/eu.mjs +1 -1
- package/dist/locale/fa.js +1 -1
- package/dist/locale/fa.min.js +1 -1
- package/dist/locale/fa.min.mjs +1 -1
- package/dist/locale/fa.mjs +1 -1
- package/dist/locale/fi.js +1 -1
- package/dist/locale/fi.min.js +1 -1
- package/dist/locale/fi.min.mjs +1 -1
- package/dist/locale/fi.mjs +1 -1
- package/dist/locale/fr.js +1 -1
- package/dist/locale/fr.min.js +1 -1
- package/dist/locale/fr.min.mjs +1 -1
- package/dist/locale/fr.mjs +1 -1
- package/dist/locale/he.js +1 -1
- package/dist/locale/he.min.js +1 -1
- package/dist/locale/he.min.mjs +1 -1
- package/dist/locale/he.mjs +1 -1
- package/dist/locale/hr.js +1 -1
- package/dist/locale/hr.min.js +1 -1
- package/dist/locale/hr.min.mjs +1 -1
- package/dist/locale/hr.mjs +1 -1
- package/dist/locale/hu.js +1 -1
- package/dist/locale/hu.min.js +1 -1
- package/dist/locale/hu.min.mjs +1 -1
- package/dist/locale/hu.mjs +1 -1
- package/dist/locale/hy-am.js +1 -1
- package/dist/locale/hy-am.min.js +1 -1
- package/dist/locale/hy-am.min.mjs +1 -1
- package/dist/locale/hy-am.mjs +1 -1
- package/dist/locale/id.js +1 -1
- package/dist/locale/id.min.js +1 -1
- package/dist/locale/id.min.mjs +1 -1
- package/dist/locale/id.mjs +1 -1
- package/dist/locale/it.js +1 -1
- package/dist/locale/it.min.js +1 -1
- package/dist/locale/it.min.mjs +1 -1
- package/dist/locale/it.mjs +1 -1
- package/dist/locale/ja.js +1 -1
- package/dist/locale/ja.min.js +1 -1
- package/dist/locale/ja.min.mjs +1 -1
- package/dist/locale/ja.mjs +1 -1
- package/dist/locale/kk.js +1 -1
- package/dist/locale/kk.min.js +1 -1
- package/dist/locale/kk.min.mjs +1 -1
- package/dist/locale/kk.mjs +1 -1
- package/dist/locale/km.js +1 -1
- package/dist/locale/km.min.js +1 -1
- package/dist/locale/km.min.mjs +1 -1
- package/dist/locale/km.mjs +1 -1
- package/dist/locale/ko.js +1 -1
- package/dist/locale/ko.min.js +1 -1
- package/dist/locale/ko.min.mjs +1 -1
- package/dist/locale/ko.mjs +1 -1
- package/dist/locale/ku.js +1 -1
- package/dist/locale/ku.min.js +1 -1
- package/dist/locale/ku.min.mjs +1 -1
- package/dist/locale/ku.mjs +1 -1
- package/dist/locale/ky.js +1 -1
- package/dist/locale/ky.min.js +1 -1
- package/dist/locale/ky.min.mjs +1 -1
- package/dist/locale/ky.mjs +1 -1
- package/dist/locale/lt.js +1 -1
- package/dist/locale/lt.min.js +1 -1
- package/dist/locale/lt.min.mjs +1 -1
- package/dist/locale/lt.mjs +1 -1
- package/dist/locale/lv.js +1 -1
- package/dist/locale/lv.min.js +1 -1
- package/dist/locale/lv.min.mjs +1 -1
- package/dist/locale/lv.mjs +1 -1
- package/dist/locale/mn.js +1 -1
- package/dist/locale/mn.min.js +1 -1
- package/dist/locale/mn.min.mjs +1 -1
- package/dist/locale/mn.mjs +1 -1
- package/dist/locale/nb-no.js +1 -1
- package/dist/locale/nb-no.min.js +1 -1
- package/dist/locale/nb-no.min.mjs +1 -1
- package/dist/locale/nb-no.mjs +1 -1
- package/dist/locale/nl.js +1 -1
- package/dist/locale/nl.min.js +1 -1
- package/dist/locale/nl.min.mjs +1 -1
- package/dist/locale/nl.mjs +1 -1
- package/dist/locale/pa.js +1 -1
- package/dist/locale/pa.min.js +1 -1
- package/dist/locale/pa.min.mjs +1 -1
- package/dist/locale/pa.mjs +1 -1
- package/dist/locale/pl.js +1 -1
- package/dist/locale/pl.min.js +1 -1
- package/dist/locale/pl.min.mjs +1 -1
- package/dist/locale/pl.mjs +1 -1
- package/dist/locale/pt-br.js +1 -1
- package/dist/locale/pt-br.min.js +1 -1
- package/dist/locale/pt-br.min.mjs +1 -1
- package/dist/locale/pt-br.mjs +1 -1
- package/dist/locale/pt.js +1 -1
- package/dist/locale/pt.min.js +1 -1
- package/dist/locale/pt.min.mjs +1 -1
- package/dist/locale/pt.mjs +1 -1
- package/dist/locale/ro.js +1 -1
- package/dist/locale/ro.min.js +1 -1
- package/dist/locale/ro.min.mjs +1 -1
- package/dist/locale/ro.mjs +1 -1
- package/dist/locale/ru.js +1 -1
- package/dist/locale/ru.min.js +1 -1
- package/dist/locale/ru.min.mjs +1 -1
- package/dist/locale/ru.mjs +1 -1
- package/dist/locale/sk.js +1 -1
- package/dist/locale/sk.min.js +1 -1
- package/dist/locale/sk.min.mjs +1 -1
- package/dist/locale/sk.mjs +1 -1
- package/dist/locale/sl.js +1 -1
- package/dist/locale/sl.min.js +1 -1
- package/dist/locale/sl.min.mjs +1 -1
- package/dist/locale/sl.mjs +1 -1
- package/dist/locale/sr.js +1 -1
- package/dist/locale/sr.min.js +1 -1
- package/dist/locale/sr.min.mjs +1 -1
- package/dist/locale/sr.mjs +1 -1
- package/dist/locale/sv.js +1 -1
- package/dist/locale/sv.min.js +1 -1
- package/dist/locale/sv.min.mjs +1 -1
- package/dist/locale/sv.mjs +1 -1
- package/dist/locale/ta.js +1 -1
- package/dist/locale/ta.min.js +1 -1
- package/dist/locale/ta.min.mjs +1 -1
- package/dist/locale/ta.mjs +1 -1
- package/dist/locale/th.js +1 -1
- package/dist/locale/th.min.js +1 -1
- package/dist/locale/th.min.mjs +1 -1
- package/dist/locale/th.mjs +1 -1
- package/dist/locale/tk.js +1 -1
- package/dist/locale/tk.min.js +1 -1
- package/dist/locale/tk.min.mjs +1 -1
- package/dist/locale/tk.mjs +1 -1
- package/dist/locale/tr.js +1 -1
- package/dist/locale/tr.min.js +1 -1
- package/dist/locale/tr.min.mjs +1 -1
- package/dist/locale/tr.mjs +1 -1
- package/dist/locale/ug-cn.js +1 -1
- package/dist/locale/ug-cn.min.js +1 -1
- package/dist/locale/ug-cn.min.mjs +1 -1
- package/dist/locale/ug-cn.mjs +1 -1
- package/dist/locale/uk.js +1 -1
- package/dist/locale/uk.min.js +1 -1
- package/dist/locale/uk.min.mjs +1 -1
- package/dist/locale/uk.mjs +1 -1
- package/dist/locale/uz-uz.js +1 -1
- package/dist/locale/uz-uz.min.js +1 -1
- package/dist/locale/uz-uz.min.mjs +1 -1
- package/dist/locale/uz-uz.mjs +1 -1
- package/dist/locale/vi.js +1 -1
- package/dist/locale/vi.min.js +1 -1
- package/dist/locale/vi.min.mjs +1 -1
- package/dist/locale/vi.mjs +1 -1
- package/dist/locale/zh-cn.js +1 -1
- package/dist/locale/zh-cn.min.js +1 -1
- package/dist/locale/zh-cn.min.mjs +1 -1
- package/dist/locale/zh-cn.mjs +1 -1
- package/dist/locale/zh-tw.js +1 -1
- package/dist/locale/zh-tw.min.js +1 -1
- package/dist/locale/zh-tw.min.mjs +1 -1
- package/dist/locale/zh-tw.mjs +1 -1
- package/es/components/index.mjs +2 -2
- package/es/components/pagination/src/pagination.mjs +5 -3
- package/es/components/pagination/src/pagination.mjs.map +1 -1
- package/es/components/popconfirm/src/popconfirm2.mjs +1 -1
- package/es/components/popconfirm/src/popconfirm2.mjs.map +1 -1
- package/es/components/switch/index.mjs +2 -2
- package/es/components/switch/src/switch.mjs +247 -86
- package/es/components/switch/src/switch.mjs.map +1 -1
- package/es/components/switch/src/switch2.mjs +86 -247
- package/es/components/switch/src/switch2.mjs.map +1 -1
- package/es/components/timeline/index.mjs +2 -2
- package/es/components/timeline/src/timeline-item.mjs +73 -37
- package/es/components/timeline/src/timeline-item.mjs.map +1 -1
- package/es/components/timeline/src/timeline-item2.mjs +37 -73
- package/es/components/timeline/src/timeline-item2.mjs.map +1 -1
- package/es/index.mjs +2 -2
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/es/version.mjs.map +1 -1
- package/lib/components/index.js +2 -2
- package/lib/components/pagination/src/pagination.js +5 -3
- package/lib/components/pagination/src/pagination.js.map +1 -1
- package/lib/components/popconfirm/src/popconfirm2.js +1 -1
- package/lib/components/popconfirm/src/popconfirm2.js.map +1 -1
- package/lib/components/switch/index.js +2 -2
- package/lib/components/switch/src/switch.js +247 -87
- package/lib/components/switch/src/switch.js.map +1 -1
- package/lib/components/switch/src/switch2.js +87 -247
- package/lib/components/switch/src/switch2.js.map +1 -1
- package/lib/components/timeline/index.js +2 -2
- package/lib/components/timeline/src/timeline-item.js +73 -37
- package/lib/components/timeline/src/timeline-item.js.map +1 -1
- package/lib/components/timeline/src/timeline-item2.js +37 -73
- package/lib/components/timeline/src/timeline-item2.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/theme-chalk/el-pagination.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/src/pagination.scss +4 -1
- package/web-types.json +1 -1
|
@@ -2,96 +2,256 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var constants = require('../../../utils/constants.js');
|
|
7
|
-
var util = require('../../../utils/util.js');
|
|
8
|
-
var validators = require('../../../utils/validators.js');
|
|
5
|
+
var vue = require('vue');
|
|
9
6
|
var shared = require('@vue/shared');
|
|
7
|
+
var util = require('../../../utils/util.js');
|
|
8
|
+
var error = require('../../../utils/error.js');
|
|
9
|
+
var index = require('../../icon/index.js');
|
|
10
|
+
var iconsVue = require('@element-plus/icons-vue');
|
|
11
|
+
var constants = require('../../../utils/constants.js');
|
|
12
|
+
require('../../../hooks/index.js');
|
|
13
|
+
var _switch = require('./switch2.js');
|
|
14
|
+
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
|
|
15
|
+
var index$1 = require('../../../hooks/use-form-item/index.js');
|
|
16
|
+
var index$2 = require('../../../hooks/use-common-props/index.js');
|
|
17
|
+
var index$3 = require('../../../hooks/use-namespace/index.js');
|
|
10
18
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
19
|
+
const COMPONENT_NAME = "ElSwitch";
|
|
20
|
+
const _sfc_main = vue.defineComponent({
|
|
21
|
+
name: COMPONENT_NAME,
|
|
22
|
+
components: { ElIcon: index.ElIcon, Loading: iconsVue.Loading },
|
|
23
|
+
props: _switch.switchProps,
|
|
24
|
+
emits: _switch.switchEmits,
|
|
25
|
+
setup(props, { emit }) {
|
|
26
|
+
const { formItem } = index$1.useFormItem();
|
|
27
|
+
const switchDisabled = index$2.useDisabled(vue.computed(() => props.loading));
|
|
28
|
+
const ns = index$3.useNamespace("switch");
|
|
29
|
+
const switchSize = index$2.useSize();
|
|
30
|
+
const isModelValue = vue.ref(props.modelValue !== false);
|
|
31
|
+
const input = vue.ref();
|
|
32
|
+
const core = vue.ref();
|
|
33
|
+
const switchKls = vue.computed(() => [
|
|
34
|
+
ns.b(),
|
|
35
|
+
ns.m(switchSize.value),
|
|
36
|
+
ns.is("disabled", switchDisabled.value),
|
|
37
|
+
ns.is("checked", checked.value)
|
|
38
|
+
]);
|
|
39
|
+
vue.watch(() => props.modelValue, () => {
|
|
40
|
+
isModelValue.value = true;
|
|
41
|
+
});
|
|
42
|
+
vue.watch(() => props.value, () => {
|
|
43
|
+
isModelValue.value = false;
|
|
44
|
+
});
|
|
45
|
+
const actualValue = vue.computed(() => {
|
|
46
|
+
return isModelValue.value ? props.modelValue : props.value;
|
|
47
|
+
});
|
|
48
|
+
const checked = vue.computed(() => actualValue.value === props.activeValue);
|
|
49
|
+
if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {
|
|
50
|
+
emit(constants.UPDATE_MODEL_EVENT, props.inactiveValue);
|
|
51
|
+
emit(constants.CHANGE_EVENT, props.inactiveValue);
|
|
52
|
+
emit(constants.INPUT_EVENT, props.inactiveValue);
|
|
53
|
+
}
|
|
54
|
+
vue.watch(checked, () => {
|
|
55
|
+
var _a;
|
|
56
|
+
input.value.checked = checked.value;
|
|
57
|
+
if (props.activeColor || props.inactiveColor) {
|
|
58
|
+
setBackgroundColor();
|
|
59
|
+
}
|
|
60
|
+
if (props.validateEvent) {
|
|
61
|
+
(_a = formItem == null ? void 0 : formItem.validate) == null ? void 0 : _a.call(formItem, "change");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const handleChange = () => {
|
|
65
|
+
const val = checked.value ? props.inactiveValue : props.activeValue;
|
|
66
|
+
emit(constants.UPDATE_MODEL_EVENT, val);
|
|
67
|
+
emit(constants.CHANGE_EVENT, val);
|
|
68
|
+
emit(constants.INPUT_EVENT, val);
|
|
69
|
+
vue.nextTick(() => {
|
|
70
|
+
input.value.checked = checked.value;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const switchValue = () => {
|
|
74
|
+
if (switchDisabled.value)
|
|
75
|
+
return;
|
|
76
|
+
const { beforeChange } = props;
|
|
77
|
+
if (!beforeChange) {
|
|
78
|
+
handleChange();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const shouldChange = beforeChange();
|
|
82
|
+
const isExpectType = [shared.isPromise(shouldChange), util.isBool(shouldChange)].some((i) => i);
|
|
83
|
+
if (!isExpectType) {
|
|
84
|
+
error.throwError(COMPONENT_NAME, "beforeChange must return type `Promise<boolean>` or `boolean`");
|
|
85
|
+
}
|
|
86
|
+
if (shared.isPromise(shouldChange)) {
|
|
87
|
+
shouldChange.then((result) => {
|
|
88
|
+
if (result) {
|
|
89
|
+
handleChange();
|
|
90
|
+
}
|
|
91
|
+
}).catch((e) => {
|
|
92
|
+
error.debugWarn(COMPONENT_NAME, `some error occurred: ${e}`);
|
|
93
|
+
});
|
|
94
|
+
} else if (shouldChange) {
|
|
95
|
+
handleChange();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const setBackgroundColor = () => {
|
|
99
|
+
const newColor = checked.value ? props.activeColor : props.inactiveColor;
|
|
100
|
+
const coreEl = core.value;
|
|
101
|
+
if (props.borderColor)
|
|
102
|
+
coreEl.style.borderColor = props.borderColor;
|
|
103
|
+
else if (!props.borderColor)
|
|
104
|
+
coreEl.style.borderColor = newColor;
|
|
105
|
+
coreEl.style.backgroundColor = newColor;
|
|
106
|
+
coreEl.children[0].style.color = newColor;
|
|
107
|
+
};
|
|
108
|
+
const focus = () => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
(_b = (_a = input.value) == null ? void 0 : _a.focus) == null ? void 0 : _b.call(_a);
|
|
111
|
+
};
|
|
112
|
+
vue.onMounted(() => {
|
|
113
|
+
if (props.activeColor || props.inactiveColor || props.borderColor) {
|
|
114
|
+
setBackgroundColor();
|
|
115
|
+
}
|
|
116
|
+
input.value.checked = checked.value;
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
ns,
|
|
120
|
+
input,
|
|
121
|
+
core,
|
|
122
|
+
switchDisabled,
|
|
123
|
+
checked,
|
|
124
|
+
switchKls,
|
|
125
|
+
handleChange,
|
|
126
|
+
switchValue,
|
|
127
|
+
focus
|
|
128
|
+
};
|
|
87
129
|
}
|
|
88
130
|
});
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
131
|
+
const _hoisted_1 = ["aria-checked", "aria-disabled"];
|
|
132
|
+
const _hoisted_2 = ["id", "name", "true-value", "false-value", "disabled"];
|
|
133
|
+
const _hoisted_3 = ["aria-hidden"];
|
|
134
|
+
const _hoisted_4 = ["aria-hidden"];
|
|
135
|
+
const _hoisted_5 = ["aria-hidden"];
|
|
136
|
+
const _hoisted_6 = ["aria-hidden"];
|
|
137
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
138
|
+
const _component_el_icon = vue.resolveComponent("el-icon");
|
|
139
|
+
const _component_loading = vue.resolveComponent("loading");
|
|
140
|
+
return vue.openBlock(), vue.createElementBlock("div", {
|
|
141
|
+
class: vue.normalizeClass(_ctx.switchKls),
|
|
142
|
+
role: "switch",
|
|
143
|
+
"aria-checked": _ctx.checked,
|
|
144
|
+
"aria-disabled": _ctx.switchDisabled,
|
|
145
|
+
onClick: _cache[2] || (_cache[2] = vue.withModifiers((...args) => _ctx.switchValue && _ctx.switchValue(...args), ["prevent"]))
|
|
146
|
+
}, [
|
|
147
|
+
vue.createElementVNode("input", {
|
|
148
|
+
id: _ctx.id,
|
|
149
|
+
ref: "input",
|
|
150
|
+
class: vue.normalizeClass(_ctx.ns.e("input")),
|
|
151
|
+
type: "checkbox",
|
|
152
|
+
name: _ctx.name,
|
|
153
|
+
"true-value": _ctx.activeValue,
|
|
154
|
+
"false-value": _ctx.inactiveValue,
|
|
155
|
+
disabled: _ctx.switchDisabled,
|
|
156
|
+
onChange: _cache[0] || (_cache[0] = (...args) => _ctx.handleChange && _ctx.handleChange(...args)),
|
|
157
|
+
onKeydown: _cache[1] || (_cache[1] = vue.withKeys((...args) => _ctx.switchValue && _ctx.switchValue(...args), ["enter"]))
|
|
158
|
+
}, null, 42, _hoisted_2),
|
|
159
|
+
!_ctx.inlinePrompt && (_ctx.inactiveIcon || _ctx.inactiveText) ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
160
|
+
key: 0,
|
|
161
|
+
class: vue.normalizeClass([
|
|
162
|
+
_ctx.ns.e("label"),
|
|
163
|
+
_ctx.ns.em("label", "left"),
|
|
164
|
+
_ctx.ns.is("active", !_ctx.checked)
|
|
165
|
+
])
|
|
166
|
+
}, [
|
|
167
|
+
_ctx.inactiveIcon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
168
|
+
default: vue.withCtx(() => [
|
|
169
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.inactiveIcon)))
|
|
170
|
+
]),
|
|
171
|
+
_: 1
|
|
172
|
+
})) : vue.createCommentVNode("v-if", true),
|
|
173
|
+
!_ctx.inactiveIcon && _ctx.inactiveText ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
174
|
+
key: 1,
|
|
175
|
+
"aria-hidden": _ctx.checked
|
|
176
|
+
}, vue.toDisplayString(_ctx.inactiveText), 9, _hoisted_3)) : vue.createCommentVNode("v-if", true)
|
|
177
|
+
], 2)) : vue.createCommentVNode("v-if", true),
|
|
178
|
+
vue.createElementVNode("span", {
|
|
179
|
+
ref: "core",
|
|
180
|
+
class: vue.normalizeClass(_ctx.ns.e("core")),
|
|
181
|
+
style: vue.normalizeStyle({ width: (_ctx.width || 40) + "px" })
|
|
182
|
+
}, [
|
|
183
|
+
_ctx.inlinePrompt ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
184
|
+
key: 0,
|
|
185
|
+
class: vue.normalizeClass(_ctx.ns.e("inner"))
|
|
186
|
+
}, [
|
|
187
|
+
_ctx.activeIcon || _ctx.inactiveIcon ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
188
|
+
_ctx.activeIcon ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
189
|
+
key: 0,
|
|
190
|
+
class: vue.normalizeClass([_ctx.ns.is("icon"), _ctx.checked ? _ctx.ns.is("show") : _ctx.ns.is("hide")])
|
|
191
|
+
}, {
|
|
192
|
+
default: vue.withCtx(() => [
|
|
193
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.activeIcon)))
|
|
194
|
+
]),
|
|
195
|
+
_: 1
|
|
196
|
+
}, 8, ["class"])) : vue.createCommentVNode("v-if", true),
|
|
197
|
+
_ctx.inactiveIcon ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
198
|
+
key: 1,
|
|
199
|
+
class: vue.normalizeClass([_ctx.ns.is("icon"), !_ctx.checked ? _ctx.ns.is("show") : _ctx.ns.is("hide")])
|
|
200
|
+
}, {
|
|
201
|
+
default: vue.withCtx(() => [
|
|
202
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.inactiveIcon)))
|
|
203
|
+
]),
|
|
204
|
+
_: 1
|
|
205
|
+
}, 8, ["class"])) : vue.createCommentVNode("v-if", true)
|
|
206
|
+
], 64)) : _ctx.activeText || _ctx.inactiveIcon ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 1 }, [
|
|
207
|
+
_ctx.activeText ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
208
|
+
key: 0,
|
|
209
|
+
class: vue.normalizeClass([_ctx.ns.is("text"), _ctx.checked ? _ctx.ns.is("show") : _ctx.ns.is("hide")]),
|
|
210
|
+
"aria-hidden": !_ctx.checked
|
|
211
|
+
}, vue.toDisplayString(_ctx.activeText.substr(0, 1)), 11, _hoisted_4)) : vue.createCommentVNode("v-if", true),
|
|
212
|
+
_ctx.inactiveText ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
213
|
+
key: 1,
|
|
214
|
+
class: vue.normalizeClass([_ctx.ns.is("text"), !_ctx.checked ? _ctx.ns.is("show") : _ctx.ns.is("hide")]),
|
|
215
|
+
"aria-hidden": _ctx.checked
|
|
216
|
+
}, vue.toDisplayString(_ctx.inactiveText.substr(0, 1)), 11, _hoisted_5)) : vue.createCommentVNode("v-if", true)
|
|
217
|
+
], 64)) : vue.createCommentVNode("v-if", true)
|
|
218
|
+
], 2)) : vue.createCommentVNode("v-if", true),
|
|
219
|
+
vue.createElementVNode("div", {
|
|
220
|
+
class: vue.normalizeClass(_ctx.ns.e("action"))
|
|
221
|
+
}, [
|
|
222
|
+
_ctx.loading ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
|
|
223
|
+
key: 0,
|
|
224
|
+
class: vue.normalizeClass(_ctx.ns.is("loading"))
|
|
225
|
+
}, {
|
|
226
|
+
default: vue.withCtx(() => [
|
|
227
|
+
vue.createVNode(_component_loading)
|
|
228
|
+
]),
|
|
229
|
+
_: 1
|
|
230
|
+
}, 8, ["class"])) : vue.createCommentVNode("v-if", true)
|
|
231
|
+
], 2)
|
|
232
|
+
], 6),
|
|
233
|
+
!_ctx.inlinePrompt && (_ctx.activeIcon || _ctx.activeText) ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
234
|
+
key: 1,
|
|
235
|
+
class: vue.normalizeClass([
|
|
236
|
+
_ctx.ns.e("label"),
|
|
237
|
+
_ctx.ns.em("label", "right"),
|
|
238
|
+
_ctx.ns.is("active", _ctx.checked)
|
|
239
|
+
])
|
|
240
|
+
}, [
|
|
241
|
+
_ctx.activeIcon ? (vue.openBlock(), vue.createBlock(_component_el_icon, { key: 0 }, {
|
|
242
|
+
default: vue.withCtx(() => [
|
|
243
|
+
(vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.activeIcon)))
|
|
244
|
+
]),
|
|
245
|
+
_: 1
|
|
246
|
+
})) : vue.createCommentVNode("v-if", true),
|
|
247
|
+
!_ctx.activeIcon && _ctx.activeText ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
248
|
+
key: 1,
|
|
249
|
+
"aria-hidden": !_ctx.checked
|
|
250
|
+
}, vue.toDisplayString(_ctx.activeText), 9, _hoisted_6)) : vue.createCommentVNode("v-if", true)
|
|
251
|
+
], 2)) : vue.createCommentVNode("v-if", true)
|
|
252
|
+
], 10, _hoisted_1);
|
|
253
|
+
}
|
|
254
|
+
var Switch = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
|
|
94
255
|
|
|
95
|
-
exports
|
|
96
|
-
exports.switchProps = switchProps;
|
|
256
|
+
exports["default"] = Switch;
|
|
97
257
|
//# sourceMappingURL=switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.js","sources":["../../../../../../packages/components/switch/src/switch.
|
|
1
|
+
{"version":3,"file":"switch.js","sources":["../../../../../../packages/components/switch/src/switch.vue"],"sourcesContent":["<template>\n <div\n :class=\"switchKls\"\n role=\"switch\"\n :aria-checked=\"checked\"\n :aria-disabled=\"switchDisabled\"\n @click.prevent=\"switchValue\"\n >\n <input\n :id=\"id\"\n ref=\"input\"\n :class=\"ns.e('input')\"\n type=\"checkbox\"\n :name=\"name\"\n :true-value=\"activeValue\"\n :false-value=\"inactiveValue\"\n :disabled=\"switchDisabled\"\n @change=\"handleChange\"\n @keydown.enter=\"switchValue\"\n />\n <span\n v-if=\"!inlinePrompt && (inactiveIcon || inactiveText)\"\n :class=\"[\n ns.e('label'),\n ns.em('label', 'left'),\n ns.is('active', !checked),\n ]\"\n >\n <el-icon v-if=\"inactiveIcon\"><component :is=\"inactiveIcon\" /></el-icon>\n <span v-if=\"!inactiveIcon && inactiveText\" :aria-hidden=\"checked\">{{\n inactiveText\n }}</span>\n </span>\n <span\n ref=\"core\"\n :class=\"ns.e('core')\"\n :style=\"{ width: (width || 40) + 'px' }\"\n >\n <div v-if=\"inlinePrompt\" :class=\"ns.e('inner')\">\n <template v-if=\"activeIcon || inactiveIcon\">\n <el-icon\n v-if=\"activeIcon\"\n :class=\"[ns.is('icon'), checked ? ns.is('show') : ns.is('hide')]\"\n >\n <component :is=\"activeIcon\" />\n </el-icon>\n <el-icon\n v-if=\"inactiveIcon\"\n :class=\"[ns.is('icon'), !checked ? ns.is('show') : ns.is('hide')]\"\n >\n <component :is=\"inactiveIcon\" />\n </el-icon>\n </template>\n <template v-else-if=\"activeText || inactiveIcon\">\n <span\n v-if=\"activeText\"\n :class=\"[ns.is('text'), checked ? ns.is('show') : ns.is('hide')]\"\n :aria-hidden=\"!checked\"\n >\n {{ activeText.substr(0, 1) }}\n </span>\n <span\n v-if=\"inactiveText\"\n :class=\"[ns.is('text'), !checked ? ns.is('show') : ns.is('hide')]\"\n :aria-hidden=\"checked\"\n >\n {{ inactiveText.substr(0, 1) }}\n </span>\n </template>\n </div>\n <div :class=\"ns.e('action')\">\n <el-icon v-if=\"loading\" :class=\"ns.is('loading')\"><loading /></el-icon>\n </div>\n </span>\n <span\n v-if=\"!inlinePrompt && (activeIcon || activeText)\"\n :class=\"[\n ns.e('label'),\n ns.em('label', 'right'),\n ns.is('active', checked),\n ]\"\n >\n <el-icon v-if=\"activeIcon\"><component :is=\"activeIcon\" /></el-icon>\n <span v-if=\"!activeIcon && activeText\" :aria-hidden=\"!checked\">{{\n activeText\n }}</span>\n </span>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, computed, onMounted, ref, nextTick, watch } from 'vue'\nimport { isPromise } from '@vue/shared'\nimport { isBool } from '@element-plus/utils/util'\nimport { throwError, debugWarn } from '@element-plus/utils/error'\nimport ElIcon from '@element-plus/components/icon'\nimport { Loading } from '@element-plus/icons-vue'\nimport {\n UPDATE_MODEL_EVENT,\n CHANGE_EVENT,\n INPUT_EVENT,\n} from '@element-plus/utils/constants'\nimport {\n useDisabled,\n useFormItem,\n useNamespace,\n useSize,\n} from '@element-plus/hooks'\nimport { switchProps, switchEmits } from './switch'\n\nconst COMPONENT_NAME = 'ElSwitch'\n\nexport default defineComponent({\n name: COMPONENT_NAME,\n components: { ElIcon, Loading },\n\n props: switchProps,\n emits: switchEmits,\n\n setup(props, { emit }) {\n const { formItem } = useFormItem()\n const switchDisabled = useDisabled(computed(() => props.loading))\n const ns = useNamespace('switch')\n\n const switchSize = useSize()\n const isModelValue = ref(props.modelValue !== false)\n const input = ref<HTMLInputElement>()\n const core = ref<HTMLSpanElement>()\n\n const switchKls = computed(() => [\n ns.b(),\n ns.m(switchSize.value),\n ns.is('disabled', switchDisabled.value),\n ns.is('checked', checked.value),\n ])\n\n watch(\n () => props.modelValue,\n () => {\n isModelValue.value = true\n }\n )\n\n watch(\n () => props.value,\n () => {\n isModelValue.value = false\n }\n )\n\n const actualValue = computed(() => {\n return isModelValue.value ? props.modelValue : props.value\n })\n\n const checked = computed(() => actualValue.value === props.activeValue)\n\n if (![props.activeValue, props.inactiveValue].includes(actualValue.value)) {\n emit(UPDATE_MODEL_EVENT, props.inactiveValue)\n emit(CHANGE_EVENT, props.inactiveValue)\n emit(INPUT_EVENT, props.inactiveValue)\n }\n\n watch(checked, () => {\n input.value!.checked = checked.value\n\n if (props.activeColor || props.inactiveColor) {\n setBackgroundColor()\n }\n\n if (props.validateEvent) {\n formItem?.validate?.('change')\n }\n })\n\n const handleChange = (): void => {\n const val = checked.value ? props.inactiveValue : props.activeValue\n emit(UPDATE_MODEL_EVENT, val)\n emit(CHANGE_EVENT, val)\n emit(INPUT_EVENT, val)\n nextTick(() => {\n input.value!.checked = checked.value\n })\n }\n\n const switchValue = (): void => {\n if (switchDisabled.value) return\n\n const { beforeChange } = props\n if (!beforeChange) {\n handleChange()\n return\n }\n\n const shouldChange = beforeChange()\n\n const isExpectType = [isPromise(shouldChange), isBool(shouldChange)].some(\n (i) => i\n )\n if (!isExpectType) {\n throwError(\n COMPONENT_NAME,\n 'beforeChange must return type `Promise<boolean>` or `boolean`'\n )\n }\n\n if (isPromise(shouldChange)) {\n shouldChange\n .then((result) => {\n if (result) {\n handleChange()\n }\n })\n .catch((e) => {\n debugWarn(COMPONENT_NAME, `some error occurred: ${e}`)\n })\n } else if (shouldChange) {\n handleChange()\n }\n }\n\n const setBackgroundColor = (): void => {\n const newColor = checked.value ? props.activeColor : props.inactiveColor\n const coreEl = core.value\n if (props.borderColor) coreEl!.style.borderColor = props.borderColor\n else if (!props.borderColor) coreEl!.style.borderColor = newColor\n coreEl!.style.backgroundColor = newColor\n ;(coreEl!.children[0] as HTMLDivElement).style.color = newColor\n }\n\n const focus = (): void => {\n input.value?.focus?.()\n }\n\n onMounted(() => {\n if (props.activeColor || props.inactiveColor || props.borderColor) {\n setBackgroundColor()\n }\n\n input.value!.checked = checked.value\n })\n\n return {\n ns,\n input,\n core,\n switchDisabled,\n checked,\n switchKls,\n handleChange,\n switchValue,\n focus,\n }\n },\n})\n</script>\n"],"names":["defineComponent","ElIcon","Loading","switchProps","switchEmits","useFormItem","useDisabled","computed","useNamespace","useSize","ref","UPDATE_MODEL_EVENT","CHANGE_EVENT","INPUT_EVENT"],"mappings":";;;;;;;;;;;;;;;;;;AA8GA,MAAM,iBAAiB;AAEvB,MAAK,YAAaA,oBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY,UAAEC,uBAAQC;AAAA,EAEtB,OAAOC;AAAA,EACP,OAAOC;AAAA,EAEP,MAAM,OAAO,EAAE,QAAQ;AACrB,UAAM,EAAE,aAAaC;AACrB,UAAM,iBAAiBC,oBAAYC,aAAS,MAAM,MAAM;AACxD,UAAM,KAAKC,qBAAa;AAExB,UAAM,aAAaC;AACnB,UAAM,eAAeC,QAAI,MAAM,eAAe;AAC9C,UAAM,QAAQA;AACd,UAAM,OAAOA;AAEb,UAAM,YAAYH,aAAS,MAAM;AAAA,MAC/B,GAAG;AAAA,MACH,GAAG,EAAE,WAAW;AAAA,MAChB,GAAG,GAAG,YAAY,eAAe;AAAA,MACjC,GAAG,GAAG,WAAW,QAAQ;AAAA;AAG3B,cACE,MAAM,MAAM,YACZ,MAAM;AACJ,mBAAa,QAAQ;AAAA;AAIzB,cACE,MAAM,MAAM,OACZ,MAAM;AACJ,mBAAa,QAAQ;AAAA;AAIzB,UAAM,cAAcA,aAAS,MAAM;AACjC,aAAO,aAAa,QAAQ,MAAM,aAAa,MAAM;AAAA;AAGvD,UAAM,UAAUA,aAAS,MAAM,YAAY,UAAU,MAAM;AAE3D,QAAI,CAAC,CAAC,MAAM,aAAa,MAAM,eAAe,SAAS,YAAY,QAAQ;AACzE,WAAKI,8BAAoB,MAAM;AAC/B,WAAKC,wBAAc,MAAM;AACzB,WAAKC,uBAAa,MAAM;AAAA;AAG1B,cAAM,SAAS,MAAM;AACnB,YAAM;AAEN;AACE;AAAA;AAGF;AACE,6BAAqB;AAAA;AAAA;AAIzB;AACE;AACA,+BAAyB;AACzB,WAAKF;AACL,WAAKC;AACL;AACE,kBAAM;AAAyB;AAAA;AAInC;AACE,UAAI;AAAsB;AAE1B;AACA;AACE;AACA;AAAA;AAGF;AAEA,YAAM,eAAe;AAGrB;AACE;AAEE;AAIJ;AACE;AAEI;AACE;AAAA;AAAA,WAGH;AACC;AAAkD;AAAA;AAGtD;AAAA;AAAA;AAIJ;AACE,+BAAyB;AACzB,YAAM;AACN;AAAuB,eAAQ;AAA0B,eAChD;AAAoB,eAAQ,MAAM;AAC3C;AACC,MAAC,OAAQ;AAA6C;AAGzD;AACE;AAAa;AAGf;AACE;AACE;AAAA;AAGF,4BAAuB;AAAQ;AAGjC,WAAO;AAAA,MACL;AAAA;AACA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA;AAAA;;;;;;;;;;;AAxPe;AACJ;AACZ,IACA;AAAe,IACf;AAAK;;AAEN;AACS;AACH;AACE,MACN;AAAe,MACd;AAAM,MACN;AAAA,MACA;AAAa,MACb,eAAU;AAAA,MACV;AAAM,MACN;AAAe;;AAGwB,0BAD1C;WAEQ;AAAA;AAAgB;AAAwB;AAAgC;;;AAM/D;AAA8C;AAAhC;;;;AACA;QAAe;AAAA,4BAC1C;AAAA;;AA2CG;AAvCK;AACJ;AACY;;AAEP;;AAAoB;;AACb;AAEI;YACf;AAAK;;;AAEN;;;;AAGkB;iBACZ;AAAA;;;AAEN;;;;;AAKgB;;AACV,4CACgB;AAAA;AAEnB,uGAGe;AAAA;;AACZ,4CACe;AAAA;AAElB;;sCAMH;AAAA;AAFO;;AACI;;AAAe;;;AAA+B;;;;;;AAIxD;;AACD;AAAgB;AAAwB;AAAiC;;;AAMhE;AAA0C;AAA9B;;;;AACA;QAAa;AAAA;AACtC;;;;;;;;;;"}
|