@ecolovo/uniapp-components 1.0.10 → 2.0.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/README.md +202 -66
- package/components/aspect/aspect.vue +24 -15
- package/components/badge/badge.scss +20 -0
- package/components/badge/badge.vue +49 -40
- package/components/button/button.scss +15 -0
- package/components/button/button.vue +121 -177
- package/components/checkbox/checkbox.scss +10 -0
- package/components/checkbox/checkbox.vue +118 -146
- package/components/checkbox-group/checkbox-group.vue +79 -85
- package/components/checkbox-group2/checkbox-group2.vue +111 -107
- package/components/checkbox-group2/checkbox2.vue +104 -0
- package/components/data-list/data-list.scss +9 -0
- package/components/data-list/data-list.vue +70 -79
- package/components/date-picker/date-picker-view.vue +125 -124
- package/components/date-picker/date-picker.vue +145 -146
- package/components/dialog/dialog-content.vue +39 -47
- package/components/dialog/dialog.scss +11 -0
- package/components/dialog/dialog.vue +125 -138
- package/components/dropdown/dropdown.scss +11 -0
- package/components/dropdown/dropdown.vue +55 -97
- package/components/empty/empty.scss +14 -0
- package/components/empty/empty.vue +42 -41
- package/components/flex/flex.vue +45 -54
- package/components/form/form.vue +29 -24
- package/components/form-item/form-item.scss +11 -0
- package/components/form-item/form-item.vue +43 -40
- package/components/icon/icon.vue +70 -85
- package/components/image/image.vue +35 -38
- package/components/input/input.vue +65 -79
- package/components/input/password-input.vue +34 -42
- package/components/list-page/list-page.vue +73 -99
- package/components/load-more/load-more.scss +12 -0
- package/components/load-more/load-more.vue +29 -29
- package/components/loading/animations/loading-animation1.vue +8 -8
- package/components/loading/animations/loading-animation2.vue +8 -9
- package/components/loading/animations/loading-animation3.vue +11 -11
- package/components/loading/animations/loading-animation4.vue +8 -8
- package/components/loading/loading.vue +19 -20
- package/components/message-box/message-box.vue +59 -41
- package/components/number-dialog/number-dialog.scss +9 -0
- package/components/number-dialog/number-dialog.vue +209 -204
- package/components/number-input/number-input.scss +9 -0
- package/components/number-input/number-input.vue +233 -232
- package/components/numpad/numpad.scss +9 -0
- package/components/numpad/numpad.vue +133 -150
- package/components/page/page-body.scss +15 -0
- package/components/page/page-body.vue +137 -119
- package/components/page/page-footer.scss +13 -0
- package/components/page/page-footer.vue +31 -33
- package/components/page/page-header.scss +17 -0
- package/components/page/page-header.vue +89 -94
- package/components/page/page.scss +9 -0
- package/components/page/page.vue +105 -81
- package/components/picker/picker-popup.vue +218 -209
- package/components/picker/picker.vue +99 -104
- package/components/popover/popover-content.vue +54 -63
- package/components/popover/popover-mask.vue +63 -63
- package/components/popover/popover.scss +28 -0
- package/components/popover/popover.vue +49 -47
- package/components/popup/popup-content.vue +49 -53
- package/components/popup/popup.scss +11 -0
- package/components/popup/popup.vue +117 -132
- package/components/price/price.scss +20 -0
- package/components/price/price.vue +31 -42
- package/components/search/search.scss +12 -0
- package/components/search/search.vue +93 -117
- package/components/searching/searching.vue +33 -40
- package/components/selector/selector.vue +43 -48
- package/components/switch/switch.scss +12 -0
- package/components/switch/switch.vue +99 -96
- package/components/tab/tab.scss +19 -0
- package/components/tab/tab.vue +151 -145
- package/components/textarea/textarea.vue +104 -101
- package/composable/component-name.d.ts +2 -0
- package/composable/component-name.js +8 -0
- package/composable/component-name.ts +10 -0
- package/configs/index.d.ts +25 -10
- package/configs/index.js +14 -23
- package/configs/index.ts +82 -0
- package/easyCom.d.ts +9 -0
- package/easyCom.js +1 -2
- package/easyCom.ts +31 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.ts +1 -0
- package/init.d.ts +4 -7
- package/init.js +5 -4
- package/init.ts +34 -0
- package/package.json +14 -4
- package/styles/utils/css-var.scss +12 -15
- package/styles/utils/ellipsis.scss +0 -7
- package/styles/utils/z-index.scss +1 -1
- package/styles/var/component.scss +21 -245
- package/utils/date.d.ts +47 -0
- package/utils/date.js +23 -43
- package/utils/date.ts +153 -0
- package/utils/freezeDeep.d.ts +1 -0
- package/utils/freezeDeep.js +4 -14
- package/utils/freezeDeep.ts +9 -0
- package/utils/price.d.ts +24 -0
- package/utils/price.js +14 -8
- package/utils/price.ts +57 -0
- package/utils/round.d.ts +2 -0
- package/utils/round.js +2 -14
- package/utils/round.ts +11 -0
- package/utils/windowInfo.d.ts +24 -0
- package/utils/windowInfo.js +8 -36
- package/utils/windowInfo.ts +50 -0
- package/components/checkbox-group2/checkbox.vue +0 -109
- package/components/datetime-picker/datetime-picker-view.vue +0 -209
- package/components/datetime-picker/datetime-picker.vue +0 -235
- package/components/form/mixin.js +0 -13
- package/components/list-page/list-page.js +0 -10
- package/components/table/table.vue +0 -112
- package/components/time-picker/time-picker-view.vue +0 -127
- package/components/time-picker/time-picker.vue +0 -140
- package/components/uploader/download.js +0 -81
- package/components/uploader/file-uploader.vue +0 -52
- package/components/uploader/files.js +0 -225
- package/components/uploader/media-uploader.vue +0 -189
- package/components/uploader/mixin.js +0 -171
- package/components/uploader/uni.js +0 -38
- package/components/uploader/upload-button.vue +0 -29
- package/components/uploader/uploader copy.vue +0 -547
- package/components/uploader/uploader.vue +0 -117
- package/mixins/componentName.js +0 -32
- package/mixins/listPage.js +0 -1
- package/mixins/windowInfo.js +0 -1
- package/utils/fileSize.js +0 -39
- package/utils/floor.js +0 -20
|
@@ -1,103 +1,97 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
2
|
+
<view :class="[...classNames, $style['CheckboxGroup']]">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</view>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script>
|
|
8
|
-
import
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { computed, provide, ref, watch } from 'vue';
|
|
9
|
+
import useClassNames from '../../composable/component-name';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
name: 'CheckboxGroup',
|
|
11
|
+
defineOptions({
|
|
12
12
|
options: {
|
|
13
|
-
virtualHost: true,
|
|
14
13
|
styleIsolation: 'shared',
|
|
14
|
+
virtualHost: true,
|
|
15
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
|
-
data() {
|
|
52
|
-
return {
|
|
53
|
-
checkedValue: null,
|
|
54
|
-
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const classNames = useClassNames('checkbox-group');
|
|
19
|
+
|
|
20
|
+
type _Props = {
|
|
21
|
+
/** 绑定值 */
|
|
22
|
+
modelValue?: string | number | boolean | Array<unknown>;
|
|
23
|
+
/** 是否单选 */
|
|
24
|
+
radio?: boolean;
|
|
25
|
+
/** 是否显示勾选图标 */
|
|
26
|
+
icon?: boolean;
|
|
27
|
+
/** 选中时的图标 */
|
|
28
|
+
checkedIcon?: string;
|
|
29
|
+
/** 未选中时的图标 */
|
|
30
|
+
uncheckedIcon?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
34
|
+
modelValue: undefined,
|
|
35
|
+
radio: false,
|
|
36
|
+
icon: true,
|
|
37
|
+
checkedIcon: '',
|
|
38
|
+
uncheckedIcon: '',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
(event: 'update:modelValue', value?: string | number | boolean | Array<unknown>): void;
|
|
43
|
+
(event: 'change', value?: string | number | boolean | Array<unknown>): void;
|
|
44
|
+
}>();
|
|
45
|
+
|
|
46
|
+
const checkedValue = ref<undefined | string | number | boolean | Array<unknown>>(undefined);
|
|
47
|
+
|
|
48
|
+
const currentValue = computed({
|
|
49
|
+
get: function () {
|
|
50
|
+
return props.modelValue === undefined ? checkedValue.value : props.modelValue;
|
|
55
51
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
set: function (val) {
|
|
62
|
-
if (this.checkedValue === val) return;
|
|
63
|
-
this.$emit('input', val);
|
|
64
|
-
this.checkedValue = val;
|
|
65
|
-
this.$emit('change', val);
|
|
66
|
-
},
|
|
67
|
-
},
|
|
52
|
+
set: function (val) {
|
|
53
|
+
if (checkedValue.value === val) return;
|
|
54
|
+
emit('update:modelValue', val);
|
|
55
|
+
checkedValue.value = val;
|
|
56
|
+
emit('change', val);
|
|
68
57
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
deep: true,
|
|
79
|
-
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
watch(
|
|
61
|
+
() => props.modelValue,
|
|
62
|
+
(val) => {
|
|
63
|
+
if (checkedValue.value === val) return;
|
|
64
|
+
emit('update:modelValue', val);
|
|
65
|
+
checkedValue.value = val;
|
|
66
|
+
emit('change', val);
|
|
80
67
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
68
|
+
{
|
|
69
|
+
immediate: true,
|
|
70
|
+
deep: true,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
87
73
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
const check = (val: string | number | boolean | Array<unknown>) => {
|
|
75
|
+
if (props.radio) {
|
|
76
|
+
currentValue.value = val;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
92
79
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
if (!Array.isArray(currentValue.value)) {
|
|
81
|
+
currentValue.value = [val];
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (currentValue.value.includes(val)) {
|
|
86
|
+
currentValue.value = currentValue.value.filter((item) => item !== val);
|
|
87
|
+
} else {
|
|
88
|
+
currentValue.value = currentValue.value.concat(val);
|
|
89
|
+
}
|
|
100
90
|
};
|
|
91
|
+
|
|
92
|
+
provide('ecolovo/checkboxGroup/props', props);
|
|
93
|
+
provide('ecolovo/checkboxGroup/checkedValue', checkedValue);
|
|
94
|
+
provide('ecolovo/checkboxGroup/check', check);
|
|
101
95
|
</script>
|
|
102
96
|
|
|
103
97
|
<style lang="scss" module>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
3
|
-
<
|
|
2
|
+
<view :class="[...classNames, $style['CheckboxGroup2']]">
|
|
3
|
+
<checkbox2-cpn
|
|
4
4
|
v-for="(item, index) in options"
|
|
5
5
|
:key="index"
|
|
6
|
-
:value="
|
|
6
|
+
:value="
|
|
7
|
+
radio ? item.value === currentValue : Array.isArray(currentValue) && currentValue.includes(item.value)
|
|
8
|
+
"
|
|
7
9
|
:icon="icon"
|
|
8
10
|
:checked-icon="checkedIcon || (radio ? 'radio-checked' : 'checkbox-checked')"
|
|
9
11
|
:unchecked-icon="uncheckedIcon || (radio ? 'radio-unchecked' : 'checkbox-unchecked')"
|
|
@@ -11,120 +13,122 @@
|
|
|
11
13
|
@change="check(item.value)"
|
|
12
14
|
>
|
|
13
15
|
{{ item.label }}
|
|
14
|
-
</
|
|
16
|
+
</checkbox2-cpn>
|
|
15
17
|
</view>
|
|
16
18
|
</template>
|
|
17
19
|
|
|
18
|
-
<script>
|
|
19
|
-
import
|
|
20
|
-
import
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { computed, ref } from 'vue';
|
|
22
|
+
import useClassNames from '../../composable/component-name';
|
|
23
|
+
import Checkbox2Cpn from './checkbox2.vue';
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
name: 'CheckboxGroup2',
|
|
25
|
+
defineOptions({
|
|
24
26
|
options: {
|
|
25
|
-
virtualHost: true,
|
|
26
27
|
styleIsolation: 'shared',
|
|
28
|
+
virtualHost: true,
|
|
27
29
|
},
|
|
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
|
-
set(val) {
|
|
73
|
-
this.$emit('input', val);
|
|
74
|
-
this.checkedValue = val;
|
|
75
|
-
this.$emit('change', val);
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
optionsValue() {
|
|
79
|
-
return this.options.map((item) => item.value);
|
|
80
|
-
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const classNames = useClassNames('aspect');
|
|
33
|
+
|
|
34
|
+
type OptionValue = string | number | boolean;
|
|
35
|
+
interface _Option {
|
|
36
|
+
label: string;
|
|
37
|
+
value: OptionValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type _Props = {
|
|
41
|
+
/** 选项值 */
|
|
42
|
+
modelValue?: OptionValue | OptionValue[];
|
|
43
|
+
/** 选项 */
|
|
44
|
+
options?: _Option[];
|
|
45
|
+
/** 是否单选 */
|
|
46
|
+
radio?: boolean;
|
|
47
|
+
/** 是否显示勾选图标 */
|
|
48
|
+
icon?: boolean;
|
|
49
|
+
/** 选中时的图标 */
|
|
50
|
+
checkedIcon?: string;
|
|
51
|
+
/** 未选中时的图标 */
|
|
52
|
+
uncheckedIcon?: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
56
|
+
modelValue: undefined,
|
|
57
|
+
options: () => [],
|
|
58
|
+
radio: false,
|
|
59
|
+
icon: true,
|
|
60
|
+
checkedIcon: undefined,
|
|
61
|
+
uncheckedIcon: undefined,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const emit = defineEmits<{
|
|
65
|
+
(event: 'update:modelValue', value?: OptionValue | OptionValue[]): void;
|
|
66
|
+
(event: 'change', value?: OptionValue | OptionValue[]): void;
|
|
67
|
+
}>();
|
|
68
|
+
|
|
69
|
+
const checkedValue = ref<OptionValue | OptionValue[]>();
|
|
70
|
+
|
|
71
|
+
const currentValue = computed<undefined | OptionValue | OptionValue[]>({
|
|
72
|
+
get() {
|
|
73
|
+
return props.modelValue === undefined ? checkedValue.value : props.modelValue;
|
|
81
74
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!Array.isArray(this.currentValue)) {
|
|
90
|
-
this.currentValue = [val];
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.currentValue.includes(val)) {
|
|
95
|
-
this.currentValue = this.currentValue.filter((item) => item !== val);
|
|
96
|
-
} else {
|
|
97
|
-
this.currentValue.push(val);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
/** 切换全选
|
|
101
|
-
* @param {boolean | Array} isSelectedAll
|
|
102
|
-
*/
|
|
103
|
-
toggle(isSelectedAll) {
|
|
104
|
-
if (this.radio) return;
|
|
105
|
-
|
|
106
|
-
if (typeof isSelectedAll === 'boolean') {
|
|
107
|
-
if (isSelectedAll) {
|
|
108
|
-
this.currentValue = this.optionsValue;
|
|
109
|
-
} else {
|
|
110
|
-
this.currentValue = [];
|
|
111
|
-
}
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (Array.isArray(isSelectedAll)) {
|
|
116
|
-
this.currentValue = isSelectedAll.filter((item) => this.optionsValue.includes(item));
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (Array.isArray(this.currentValue) && this.currentValue.length === this.options.length) {
|
|
121
|
-
this.currentValue = [];
|
|
122
|
-
} else {
|
|
123
|
-
this.currentValue = this.optionsValue;
|
|
124
|
-
}
|
|
125
|
-
},
|
|
75
|
+
set(val) {
|
|
76
|
+
emit('update:modelValue', val);
|
|
77
|
+
checkedValue.value = val;
|
|
78
|
+
emit('change', val);
|
|
126
79
|
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const optionsValue = computed(() => {
|
|
83
|
+
return props.options.map((item) => item.value);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const check = (val: OptionValue) => {
|
|
87
|
+
if (props.radio) {
|
|
88
|
+
currentValue.value = val;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!Array.isArray(currentValue.value)) {
|
|
93
|
+
currentValue.value = [val];
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (currentValue.value.includes(val)) {
|
|
98
|
+
currentValue.value = currentValue.value.filter((item) => item !== val);
|
|
99
|
+
} else {
|
|
100
|
+
currentValue.value.push(val);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/** 切换全选
|
|
105
|
+
* @param {boolean | Array} isSelectedAll
|
|
106
|
+
*/
|
|
107
|
+
const toggle = (isSelectedAll: boolean | OptionValue | OptionValue[]) => {
|
|
108
|
+
if (props.radio) return;
|
|
109
|
+
|
|
110
|
+
if (typeof isSelectedAll === 'boolean') {
|
|
111
|
+
if (isSelectedAll) {
|
|
112
|
+
currentValue.value = optionsValue.value;
|
|
113
|
+
} else {
|
|
114
|
+
currentValue.value = [];
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (Array.isArray(isSelectedAll)) {
|
|
120
|
+
currentValue.value = isSelectedAll.filter((item) => optionsValue.value.includes(item));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (Array.isArray(currentValue.value) && currentValue.value.length === props.options.length) {
|
|
125
|
+
currentValue.value = [];
|
|
126
|
+
} else {
|
|
127
|
+
currentValue.value = optionsValue.value;
|
|
128
|
+
}
|
|
127
129
|
};
|
|
130
|
+
|
|
131
|
+
defineExpose({ toggle });
|
|
128
132
|
</script>
|
|
129
133
|
|
|
130
134
|
<style lang="scss" module>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="[...classNames, $style['Checkbox2']]" @click="toggle()">
|
|
3
|
+
<icon-cpn
|
|
4
|
+
v-if="icon"
|
|
5
|
+
:icon="currentValue ? checkedIcon || 'checkbox-checked' : uncheckedIcon || 'checkbox-unchecked'"
|
|
6
|
+
tap-size="50rpx"
|
|
7
|
+
:class="[$style['Checkbox2--icon'], { [$style['Checkbox2--checked']]: currentValue }]"
|
|
8
|
+
/>
|
|
9
|
+
<view :class="$style['Checkbox2--text']">
|
|
10
|
+
<slot></slot>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { computed, ref } from 'vue';
|
|
17
|
+
import useClassNames from '../../composable/component-name';
|
|
18
|
+
import IconCpn from '../icon/icon.vue';
|
|
19
|
+
|
|
20
|
+
defineOptions({
|
|
21
|
+
options: {
|
|
22
|
+
styleIsolation: 'shared',
|
|
23
|
+
virtualHost: true,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const classNames = useClassNames('aspect');
|
|
28
|
+
|
|
29
|
+
type _Props = {
|
|
30
|
+
/** 选项值 */
|
|
31
|
+
value?: boolean;
|
|
32
|
+
/** 是否显示勾选图标 */
|
|
33
|
+
icon?: boolean;
|
|
34
|
+
/** 选中时的图标 */
|
|
35
|
+
checkedIcon?: string;
|
|
36
|
+
/** 未选中时的图标 */
|
|
37
|
+
uncheckedIcon?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const props = withDefaults(defineProps<_Props>(), {
|
|
41
|
+
value: undefined,
|
|
42
|
+
icon: true,
|
|
43
|
+
checkedIcon: undefined,
|
|
44
|
+
uncheckedIcon: undefined,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const emit = defineEmits<{
|
|
48
|
+
(event: 'update:modelValue', value: boolean): void;
|
|
49
|
+
(event: 'change', value: boolean): void;
|
|
50
|
+
}>();
|
|
51
|
+
|
|
52
|
+
const innerValue = ref(false);
|
|
53
|
+
|
|
54
|
+
const currentValue = computed({
|
|
55
|
+
get: function () {
|
|
56
|
+
return props.value === undefined ? innerValue.value : props.value;
|
|
57
|
+
},
|
|
58
|
+
set: function (val) {
|
|
59
|
+
emit('update:modelValue', val);
|
|
60
|
+
innerValue.value = val;
|
|
61
|
+
emit('change', val);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** 切换选择 */
|
|
66
|
+
const toggle = (checked?: boolean) => {
|
|
67
|
+
if (checked === undefined || checked === null) {
|
|
68
|
+
currentValue.value = !currentValue.value;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (currentValue.value !== !!checked) {
|
|
73
|
+
currentValue.value = !!checked;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<style lang="scss" module>
|
|
79
|
+
@use '../../styles/utils' as *;
|
|
80
|
+
@use '../checkbox/checkbox' as *;
|
|
81
|
+
|
|
82
|
+
// 定义外部变量
|
|
83
|
+
%external-vars {
|
|
84
|
+
@include UTILS__DEFINE_COMPONENT_VARS($checkbox, 'checkbox');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.Checkbox2 {
|
|
88
|
+
@extend %external-vars;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
|
|
92
|
+
.Checkbox2--icon {
|
|
93
|
+
flex: none;
|
|
94
|
+
margin-right: 12rpx;
|
|
95
|
+
color: UTILS__LOCAL_VAR(unchecked-color);
|
|
96
|
+
}
|
|
97
|
+
.Checkbox2--checked {
|
|
98
|
+
color: UTILS__LOCAL_VAR(checked-color);
|
|
99
|
+
}
|
|
100
|
+
.Checkbox2--text {
|
|
101
|
+
flex: 0 1 auto;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
</style>
|