vdesign-ui 0.1.21 → 0.1.23
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/components/actionbar/actionbar-cell/index.vue +34 -0
- package/dist/components/actionbar/index.js +8 -0
- package/dist/components/actionbar/index.vue +39 -0
- package/dist/components/actionbar/style.less +48 -0
- package/dist/components/actions-cell/actions/index.js +7 -0
- package/dist/components/actions-cell/actions/index.vue +76 -0
- package/dist/components/actions-cell/actions/style.less +112 -0
- package/dist/components/actions-cell/index.js +7 -0
- package/dist/components/actions-cell/index.vue +94 -0
- package/dist/components/actions-cell/style.less +39 -0
- package/dist/components/activityviews/index.js +8 -0
- package/dist/components/activityviews/index.vue +140 -0
- package/dist/components/activityviews/style.less +138 -0
- package/dist/components/badge/index.js +8 -0
- package/dist/components/badge/index.vue +49 -0
- package/dist/components/badge/style.less +66 -0
- package/dist/components/button/index.js +8 -0
- package/dist/components/button/index.vue +89 -0
- package/dist/components/button/style.less +563 -0
- package/dist/components/calendar/end.png +0 -0
- package/dist/components/calendar/index-element.vue +84 -0
- package/dist/components/calendar/index.js +8 -0
- package/dist/components/calendar/index.vue +52 -0
- package/dist/components/calendar/start.png +0 -0
- package/dist/components/calendar/style.less +167 -0
- package/dist/components/checkbox/assist.js +34 -0
- package/dist/components/checkbox/checkbox-group/index.js +8 -0
- package/dist/components/checkbox/checkbox-group/index.vue +69 -0
- package/dist/components/checkbox/index.js +8 -0
- package/dist/components/checkbox/index.vue +184 -0
- package/dist/components/checkbox/style.less +291 -0
- package/dist/components/common/state/index.vue +80 -0
- package/dist/components/data-list/index.js +10 -0
- package/dist/components/data-list/index.vue +19 -0
- package/dist/components/data-list/style.less +624 -0
- package/dist/components/datetime-picker/index.js +8 -0
- package/dist/components/datetime-picker/index.vue +37 -0
- package/dist/components/datetime-picker/style.less +24 -0
- package/dist/components/dialog/index.js +8 -0
- package/dist/components/dialog/index.vue +162 -0
- package/dist/components/dialog/overlay-manager.js +18 -0
- package/dist/components/dialog/style.less +132 -0
- package/dist/components/divider/index.js +8 -0
- package/dist/components/divider/index.vue +54 -0
- package/dist/components/divider/style.less +92 -0
- package/dist/components/dropdown/index.js +8 -0
- package/dist/components/dropdown/index.vue +210 -0
- package/dist/components/dropdown/style.less +418 -0
- package/dist/components/empty/404-dark.png +0 -0
- package/dist/components/empty/404.png +0 -0
- package/dist/components/empty/index.js +8 -0
- package/dist/components/empty/index.vue +95 -0
- package/dist/components/empty/network-dark.png +0 -0
- package/dist/components/empty/network.png +0 -0
- package/dist/components/empty/nodata-dark.png +0 -0
- package/dist/components/empty/nodata.png +0 -0
- package/dist/components/empty/style.less +60 -0
- package/dist/components/footer/index.js +7 -0
- package/dist/components/footer/index.vue +29 -0
- package/dist/components/footer/style.less +22 -0
- package/dist/components/footnav/footnav-item/index.js +7 -0
- package/dist/components/footnav/footnav-item/index.vue +75 -0
- package/dist/components/footnav/footnav-item/style.less +39 -0
- package/dist/components/footnav/index.js +7 -0
- package/dist/components/footnav/index.vue +97 -0
- package/dist/components/footnav/style.less +23 -0
- package/dist/components/form/index.js +7 -0
- package/dist/components/form/index.vue +12 -0
- package/dist/components/headnav/index.js +7 -0
- package/dist/components/headnav/index.vue +163 -0
- package/dist/components/headnav/style.less +245 -0
- package/dist/components/icon/font/iconfont.css +1049 -0
- package/dist/components/icon/font/iconfont.js +2 -0
- package/dist/components/icon/index.js +9 -0
- package/dist/components/icon/index.vue +46 -0
- package/dist/components/icon/style.less +44 -0
- package/dist/components/input/calcTextareaHeight.js +266 -0
- package/dist/components/input/index.js +8 -0
- package/dist/components/input/index.vue +343 -0
- package/dist/components/input/password/index.js +8 -0
- package/dist/components/input/password/index.vue +60 -0
- package/dist/components/input/search/index.js +8 -0
- package/dist/components/input/search/index.vue +66 -0
- package/dist/components/input/stepper/index.js +8 -0
- package/dist/components/input/stepper/index.vue +136 -0
- package/dist/components/input/style.less +497 -0
- package/dist/components/list/index.js +8 -0
- package/dist/components/list/index.vue +159 -0
- package/dist/components/list/style.less +292 -0
- package/dist/components/loading/index.js +7 -0
- package/dist/components/loading/index.vue +53 -0
- package/dist/components/loading/loading.png +0 -0
- package/dist/components/loading/refresh.png +0 -0
- package/dist/components/loading/style.less +48 -0
- package/dist/components/mixins/clickoutside.js +81 -0
- package/dist/components/mixins/dom.js +41 -0
- package/dist/components/mixins/languageMixin.js +38 -0
- package/dist/components/mixins/outlineConfigPlugin.js +40 -0
- package/dist/components/mixins/router-link.js +23 -0
- package/dist/components/mixins/themeMixin.js +29 -0
- package/dist/components/noticebar/index.js +8 -0
- package/dist/components/noticebar/index.vue +247 -0
- package/dist/components/noticebar/style.less +332 -0
- package/dist/components/overlay/index.js +8 -0
- package/dist/components/overlay/index.vue +161 -0
- package/dist/components/overlay/style.less +23 -0
- package/dist/components/pagebreak/index.js +7 -0
- package/dist/components/pagebreak/index.vue +60 -0
- package/dist/components/pagebreak/style.less +43 -0
- package/dist/components/popover/index.js +8 -0
- package/dist/components/popover/index.vue +99 -0
- package/dist/components/popover/style.less +346 -0
- package/dist/components/popover/vue-popover.vue +314 -0
- package/dist/components/radio/assist.js +34 -0
- package/dist/components/radio/index.js +8 -0
- package/dist/components/radio/index.vue +158 -0
- package/dist/components/radio/radio-group/index.vue +70 -0
- package/dist/components/radio/style.css +213 -0
- package/dist/components/radio/style.less +302 -0
- package/dist/components/result/completed-dark.png +0 -0
- package/dist/components/result/completed.png +0 -0
- package/dist/components/result/error-dark.png +0 -0
- package/dist/components/result/error.png +0 -0
- package/dist/components/result/index.js +8 -0
- package/dist/components/result/index.vue +75 -0
- package/dist/components/result/style.less +42 -0
- package/dist/components/result/wait-dark.png +0 -0
- package/dist/components/result/wait.png +0 -0
- package/dist/components/selector/index.js +8 -0
- package/dist/components/selector/index.vue +124 -0
- package/dist/components/selector/style.less +474 -0
- package/dist/components/skeleton/index.js +7 -0
- package/dist/components/skeleton/index.vue +142 -0
- package/dist/components/skeleton/style.less +192 -0
- package/dist/components/slider/draggable.js +49 -0
- package/dist/components/slider/index.js +7 -0
- package/dist/components/slider/index.vue +173 -0
- package/dist/components/slider/style.less +96 -0
- package/dist/components/slider/utils.js +60 -0
- package/dist/components/step/index.js +7 -0
- package/dist/components/step/index.vue +48 -0
- package/dist/components/step/style.less +59 -0
- package/dist/components/step-item/index.js +7 -0
- package/dist/components/step-item/index.vue +117 -0
- package/dist/components/step-item/style.less +361 -0
- package/dist/components/style/index.vue +42 -0
- package/dist/components/switch/index.js +8 -0
- package/dist/components/switch/index.vue +72 -0
- package/dist/components/switch/style.less +56 -0
- package/dist/components/tabs/index.js +8 -0
- package/dist/components/tabs/index.vue +145 -0
- package/dist/components/tabs/style.less +385 -0
- package/dist/components/tabs/tab/index.vue +56 -0
- package/dist/components/tag/index.js +7 -0
- package/dist/components/tag/index.vue +50 -0
- package/dist/components/tag/style.less +211 -0
- package/dist/components/title/index.js +8 -0
- package/dist/components/title/index.vue +92 -0
- package/dist/components/title/style.less +188 -0
- package/dist/components/toast/index.js +80 -0
- package/dist/components/toast/index.vue +44 -0
- package/dist/components/toast/style.less +55 -0
- package/dist/components/transition/index.js +8 -0
- package/dist/components/transition/index.vue +13 -0
- package/dist/components/transition/style.less +208 -0
- package/dist/components/upload/index.js +7 -0
- package/dist/components/upload/index.vue +103 -0
- package/dist/components/upload/index1.vue +225 -0
- package/dist/components/upload/style.less +156 -0
- package/dist/demo.html +10 -0
- package/dist/img/404-dark.775df5bb.png +0 -0
- package/dist/img/completed-dark.4183a8a8.png +0 -0
- package/dist/img/error-dark.b80857da.png +0 -0
- package/dist/img/network-dark.11a147bb.png +0 -0
- package/dist/img/nodata-dark.b0ea0e39.png +0 -0
- package/dist/img/wait-dark.6aa28731.png +0 -0
- package/dist/locale/ar.js +98 -0
- package/dist/locale/en.js +98 -0
- package/dist/locale/zh.js +98 -0
- package/dist/token.css +2982 -0
- package/dist/vdesign-ui.common.js +27013 -0
- package/dist/vdesign-ui.css +1 -0
- package/dist/vdesign-ui.umd.js +27023 -0
- package/dist/vdesign-ui.umd.min.js +32 -0
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
.van-calendar__header {
|
|
2
|
+
box-shadow: none;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.van-calendar__header-subtitle {
|
|
6
|
+
height: calc(var(--height-datepicker-title-month_year) * 1px);
|
|
7
|
+
line-height: calc(var(--height-datepicker-title-month_year) * 1px);
|
|
8
|
+
color: var(--color-datepicker-title-month_year);
|
|
9
|
+
font-size: calc(var(--en-single-f-d-s-fontSize) * 1px);
|
|
10
|
+
font-weight: var(--en-single-f-d-s-fontWeight);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.van-calendar__weekdays {
|
|
14
|
+
padding: 0 20px;
|
|
15
|
+
height: calc(var(--height-datepicker-week) * 1px);
|
|
16
|
+
color: var(--color-datepicker-text-week);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.van-calendar__weekday {
|
|
20
|
+
line-height: calc(var(--height-datepicker-week) * 1px);
|
|
21
|
+
font-size: calc(var(--en-single-f-b-r-fontSize) * 1px);
|
|
22
|
+
font-weight: var(--en-single-f-b-r-fontWeight);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.van-calendar__days {
|
|
26
|
+
display: flex;
|
|
27
|
+
// grid-template-columns: repeat(7,1fr);
|
|
28
|
+
// grid-column-gap: calc(var(--spacing-datepicker-date-margin_y) * 1px);
|
|
29
|
+
padding: 0 20px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.van-calendar__day {
|
|
33
|
+
// width: calc(var(--height-datepicker-date) * 1px);
|
|
34
|
+
height: calc(var(--height-datepicker-date) * 1px);
|
|
35
|
+
font-size: calc(var(--en-single-f-d-s-fontSize) * 1px);
|
|
36
|
+
font-weight: var(--en-single-f-d-s-fontWeight);
|
|
37
|
+
color: var(--color-datepicker-date-text-default);
|
|
38
|
+
background-color: var(--color-datepicker-date-bg-default);
|
|
39
|
+
margin-block-start: calc(var(--spacing-datepicker-date-margin_top) * 1px);
|
|
40
|
+
margin-block-end: calc(var(--spacing-datepicker-date-margin_bottom) * 1px);
|
|
41
|
+
|
|
42
|
+
&--disabled {
|
|
43
|
+
color: var(--color-datepicker-date-text-disable);
|
|
44
|
+
background-color: var(--color-datepicker-date-bg-disable);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&--start {
|
|
48
|
+
font-size: calc(var(--en-single-f-d-s-fontSize) * 1px);
|
|
49
|
+
font-weight: var(--en-single-f-d-s-fontWeight);
|
|
50
|
+
color: var(--color-datepicker-date-text-active);
|
|
51
|
+
// background-color: var(--color-datepicker-date-bg-active);
|
|
52
|
+
// border-radius: calc(var(--height-datepicker-date) * 0.5px) 0 0 calc(var(--height-datepicker-date) * 0.5px);
|
|
53
|
+
border-radius: 0;
|
|
54
|
+
// background: url(./start.png) center center no-repeat;
|
|
55
|
+
background-image: url(./start.png) !important;
|
|
56
|
+
background-position: center center !important;
|
|
57
|
+
background-repeat: no-repeat !important;
|
|
58
|
+
background-size: cover !important;
|
|
59
|
+
// &::after{
|
|
60
|
+
// content: '';
|
|
61
|
+
// position: absolute;
|
|
62
|
+
// right: 0;
|
|
63
|
+
// top: 0;
|
|
64
|
+
// bottom: 0;
|
|
65
|
+
// background-color: #1BC47D;
|
|
66
|
+
// }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&--middle {
|
|
70
|
+
color: var(--color-datepicker-date-text-default) !important;
|
|
71
|
+
background-color: var(--color-datepicker-date_mask-bg-active);
|
|
72
|
+
|
|
73
|
+
// &::after,&::before{
|
|
74
|
+
// content: "";
|
|
75
|
+
// display: block;
|
|
76
|
+
// position: absolute;
|
|
77
|
+
// top: 0;
|
|
78
|
+
// width: 4px;
|
|
79
|
+
// height: 100%;
|
|
80
|
+
// background-color: var(--color-datepicker-date_mask-bg-active);
|
|
81
|
+
// opacity: 1;
|
|
82
|
+
// }
|
|
83
|
+
// &::before{
|
|
84
|
+
// left: 0;
|
|
85
|
+
// }
|
|
86
|
+
&::after {
|
|
87
|
+
background-color: transparent;
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&--end {
|
|
93
|
+
font-size: calc(var(--en-single-f-d-s-fontSize) * 1px);
|
|
94
|
+
font-weight: var(--en-single-f-d-s-fontWeight);
|
|
95
|
+
color: var(--color-datepicker-date-text-active);
|
|
96
|
+
background-color: var(--color-datepicker-date-bg-active);
|
|
97
|
+
// border-radius:0 calc(var(--height-datepicker-date) * 0.5px) calc(var(--height-datepicker-date) * 0.5px) 0;
|
|
98
|
+
border-radius: 0;
|
|
99
|
+
background-image: url(./end.png) !important;
|
|
100
|
+
background-position: center center !important;
|
|
101
|
+
background-repeat: no-repeat !important;
|
|
102
|
+
background-size: cover !important;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.van-calendar__selected-day {
|
|
107
|
+
background-color: var(--color-datepicker-date-bg-active);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.van-calendar__bottom-info {
|
|
111
|
+
bottom: -14px;
|
|
112
|
+
color: #1BC47D;
|
|
113
|
+
font-size: 12px;
|
|
114
|
+
font-weight: normal;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.van-calendar__top-info {
|
|
118
|
+
top: auto;
|
|
119
|
+
bottom: -14px;
|
|
120
|
+
color: var(--color-datepicker-today_dot);
|
|
121
|
+
font-size: 18px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
.vd-calendar-input {
|
|
126
|
+
padding-block-start: calc(var(--spacing-datepicker-range_picker-margin_top) * 1px);
|
|
127
|
+
padding-block-end: calc(var(--spacing-datepicker-range_picker-margin_bottom) * 1px);
|
|
128
|
+
padding-inline-start: calc(var(--spacing-datepicker-padding_y) * 1px);
|
|
129
|
+
padding-inline-end: calc(var(--spacing-datepicker-padding_y) * 1px);
|
|
130
|
+
|
|
131
|
+
&-inner {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
border-radius: calc(var(--radius-datepicker-range_picker_bg) * 1px);
|
|
135
|
+
background-color: var(--color-datepicker-range_picker-bg);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&__inputs {
|
|
139
|
+
width: 100%;
|
|
140
|
+
text-align: center;
|
|
141
|
+
background-color: transparent;
|
|
142
|
+
height: calc(var(--height-datepicker-range_picker_bg) * 1px);
|
|
143
|
+
line-height: calc(var(--height-datepicker-range_picker_bg) * 1px);
|
|
144
|
+
font-size: calc(var(--en-single-f-d-r-fontSize) * 1px);
|
|
145
|
+
font-weight: var(--en-single-f-d-r-fontWeight);
|
|
146
|
+
color: var(--color-datepicker-range_picker-text-active);
|
|
147
|
+
|
|
148
|
+
::-webkit-input-placeholder {
|
|
149
|
+
color: var(--color-datepicker-range_picker-text-default);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
&__line {
|
|
154
|
+
width: calc(var(--width-datepicker-range_picker_divider) * 1px);
|
|
155
|
+
height: calc(var(--height-datepicker-range_picker_divider) * 1px);
|
|
156
|
+
background-color: var(--color-datepicker-range_picker_divider);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.van-hairline-unset--top-bottom::after {
|
|
161
|
+
border-width: 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.van-picker__frame {
|
|
165
|
+
left: calc(var(--spacing-datepicker-padding_y) * 1px);
|
|
166
|
+
right: calc(var(--spacing-datepicker-padding_y) * 1px);
|
|
167
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
// Find components downward
|
|
4
|
+
export function findComponentsDownward (context, componentName, ignoreComponentNames = []) {
|
|
5
|
+
if (!Array.isArray(ignoreComponentNames)) {
|
|
6
|
+
ignoreComponentNames = [ignoreComponentNames];
|
|
7
|
+
}
|
|
8
|
+
return context.$children.reduce((components, child) => {
|
|
9
|
+
if (child.$options.name === componentName) components.push(child);
|
|
10
|
+
if (ignoreComponentNames.indexOf(child.$options.name) < 0) {
|
|
11
|
+
const foundChilds = findComponentsDownward(child, componentName);
|
|
12
|
+
return components.concat(foundChilds);
|
|
13
|
+
} else {
|
|
14
|
+
return components;
|
|
15
|
+
}
|
|
16
|
+
}, []);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Find components upward
|
|
20
|
+
export function findComponentUpward (context, componentName, componentNames) {
|
|
21
|
+
if (typeof componentName === 'string') {
|
|
22
|
+
componentNames = [componentName];
|
|
23
|
+
} else {
|
|
24
|
+
componentNames = componentName;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let parent = context.$parent;
|
|
28
|
+
let name = parent.$options.name;
|
|
29
|
+
while (parent && (!name || componentNames.indexOf(name) < 0)) {
|
|
30
|
+
parent = parent.$parent;
|
|
31
|
+
if (parent) name = parent.$options.name;
|
|
32
|
+
}
|
|
33
|
+
return parent;
|
|
34
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
import { findComponentsDownward } from '../assist';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const prefixCls = 'vd-checkbox-group';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'vd-checkbox-group',
|
|
14
|
+
props: {
|
|
15
|
+
value: {
|
|
16
|
+
type: Array,
|
|
17
|
+
default() {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
currentValue: this.value,
|
|
26
|
+
childrens: []
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
classes() {
|
|
31
|
+
return [
|
|
32
|
+
`${prefixCls}`,
|
|
33
|
+
{
|
|
34
|
+
[`${prefixCls}__${this.type}`]: this.type,
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
mounted() {
|
|
40
|
+
this.updateModel(true);
|
|
41
|
+
},
|
|
42
|
+
methods: {
|
|
43
|
+
updateModel(update) {
|
|
44
|
+
this.childrens = findComponentsDownward(this, 'vd-checkbox', 'vd-checkbox-group');
|
|
45
|
+
if (this.childrens) {
|
|
46
|
+
const { value } = this;
|
|
47
|
+
this.childrens.forEach(child => {
|
|
48
|
+
child.model = value;
|
|
49
|
+
|
|
50
|
+
if (update) {
|
|
51
|
+
child.currentValue = value.indexOf(child.name) >= 0;
|
|
52
|
+
child.group = true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
change(data) {
|
|
58
|
+
this.currentValue = data;
|
|
59
|
+
this.$emit('input', data);
|
|
60
|
+
this.$emit('change', data);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
watch: {
|
|
64
|
+
value() {
|
|
65
|
+
this.updateModel(true);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
</script>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :class="wrapClasses" v-if="!checkboxButton">
|
|
3
|
+
<span :class="checkboxClasses">
|
|
4
|
+
<span :class="innerClasses"></span>
|
|
5
|
+
<input v-if="group" type="checkbox" :class="inputClasses" :disabled="disabled" :value="name" v-model="model"
|
|
6
|
+
@change="change" />
|
|
7
|
+
<input v-else type="checkbox" :class="inputClasses" :disabled="disabled" :checked="currentValue"
|
|
8
|
+
@change="change" />
|
|
9
|
+
</span>
|
|
10
|
+
<div class="vd-checkbox__label" v-if="$slots.default">
|
|
11
|
+
<p class="vd-checkbox__text">
|
|
12
|
+
<slot></slot>
|
|
13
|
+
</p>
|
|
14
|
+
<p class="vd-checkbox__description" v-if="extra">{{ extra }}</p>
|
|
15
|
+
</div>
|
|
16
|
+
</label>
|
|
17
|
+
|
|
18
|
+
<label class="vd-checkbox vd-checkbox-button" :class="checkboxButtonClasses" v-else>
|
|
19
|
+
<input type="checkbox" :class="inputClasses" :disabled="disabled" :checked="currentValue" @change="change" />
|
|
20
|
+
<template v-if="type === 'small'">
|
|
21
|
+
<vd-icon v-if="icon" :name="icon" class="vd-checkbox-button__icon--small"></vd-icon>
|
|
22
|
+
<span class="vd-checkbox-button__text">
|
|
23
|
+
<slot></slot>
|
|
24
|
+
</span>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<template v-if="type === 'medium'">
|
|
28
|
+
<span class="vd-checkbox-button__text">
|
|
29
|
+
<slot></slot>
|
|
30
|
+
</span>
|
|
31
|
+
<span class="vd-checkbox-button__description" v-if="extra">{{ extra }}</span>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<template v-if="type === 'large'">
|
|
35
|
+
<vd-icon v-if="icon" :name="icon" class="vd-checkbox-button__icon--large"></vd-icon>
|
|
36
|
+
<span class="vd-checkbox-button__text">
|
|
37
|
+
<slot></slot>
|
|
38
|
+
</span>
|
|
39
|
+
</template>
|
|
40
|
+
<!-- <div class="vd-checkbox-button__icon">
|
|
41
|
+
<vd-icon
|
|
42
|
+
v-if="icon"
|
|
43
|
+
:name="icon"
|
|
44
|
+
class="vd-checkbox-button__icon--large"
|
|
45
|
+
:class="{ 'vd-checkbox-button__icon-mb': iconDescriptionText }"
|
|
46
|
+
></vd-icon>
|
|
47
|
+
<vd-icon
|
|
48
|
+
v-if="LeftIcon"
|
|
49
|
+
:name="LeftIcon"
|
|
50
|
+
class="vd-checkbox-button__icon--small"
|
|
51
|
+
></vd-icon>
|
|
52
|
+
<span
|
|
53
|
+
v-if="iconText"
|
|
54
|
+
class="vd-checkbox-button__text"
|
|
55
|
+
:class="{ 'vd-checkbox-button__text-mb': descriptionText }"
|
|
56
|
+
>{{ iconText }}</span
|
|
57
|
+
>
|
|
58
|
+
</div>
|
|
59
|
+
<span class="vd-checkbox-button-descript" v-if="descriptionText">{{
|
|
60
|
+
descriptionText
|
|
61
|
+
}}</span>
|
|
62
|
+
<span class="vd-checkbox-button__icon-descript" v-if="iconDescriptionText">{{
|
|
63
|
+
iconDescriptionText
|
|
64
|
+
}}</span> -->
|
|
65
|
+
</label>
|
|
66
|
+
</template>
|
|
67
|
+
<script>
|
|
68
|
+
import { findComponentUpward } from "./assist";
|
|
69
|
+
const prefixCls = "vd-checkbox";
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
name: "vd-checkbox",
|
|
73
|
+
props: {
|
|
74
|
+
checkboxButton: Boolean,
|
|
75
|
+
disabled: Boolean,
|
|
76
|
+
extra: [String, Number, Boolean],
|
|
77
|
+
descriptionText: [String, Number, Boolean],
|
|
78
|
+
iconDescriptionText: [String, Number, Boolean],
|
|
79
|
+
value: [String, Number, Boolean],
|
|
80
|
+
trueValue: {
|
|
81
|
+
type: [String, Number, Boolean],
|
|
82
|
+
default: true,
|
|
83
|
+
},
|
|
84
|
+
falseValue: {
|
|
85
|
+
type: [String, Number, Boolean],
|
|
86
|
+
default: false,
|
|
87
|
+
},
|
|
88
|
+
name: null,
|
|
89
|
+
indeterminate: Boolean,
|
|
90
|
+
icon: String,
|
|
91
|
+
iconText: [String, Number, Boolean],
|
|
92
|
+
type: String,
|
|
93
|
+
},
|
|
94
|
+
data() {
|
|
95
|
+
return {
|
|
96
|
+
model: [],
|
|
97
|
+
currentValue: this.value,
|
|
98
|
+
group: false,
|
|
99
|
+
parent: findComponentUpward(this, "vd-checkbox-group"),
|
|
100
|
+
// name: "",
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
computed: {
|
|
104
|
+
wrapClasses() {
|
|
105
|
+
return [
|
|
106
|
+
`${prefixCls}`,
|
|
107
|
+
{
|
|
108
|
+
[`${prefixCls}--checked`]: this.currentValue,
|
|
109
|
+
[`${prefixCls}--disabled`]: this.disabled,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
},
|
|
113
|
+
checkboxClasses() {
|
|
114
|
+
return [
|
|
115
|
+
`${prefixCls}__input`,
|
|
116
|
+
{
|
|
117
|
+
[`${prefixCls}--indeterminate`]: this.indeterminate,
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
},
|
|
121
|
+
innerClasses() {
|
|
122
|
+
return [`${prefixCls}__icon`];
|
|
123
|
+
},
|
|
124
|
+
inputClasses() {
|
|
125
|
+
return `${prefixCls}__original`;
|
|
126
|
+
},
|
|
127
|
+
checkboxButtonClasses() {
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
[`${prefixCls}-button--checked`]: this.currentValue,
|
|
131
|
+
[`${prefixCls}-button--${this.type}`]: this.type,
|
|
132
|
+
[`${prefixCls}-button--disabled`]: this.disabled,
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
mounted() {
|
|
138
|
+
this.parent = findComponentUpward(this, "vd-checkbox-group");
|
|
139
|
+
if (this.parent) {
|
|
140
|
+
this.group = true;
|
|
141
|
+
}
|
|
142
|
+
if (this.group) {
|
|
143
|
+
this.parent.updateModel(true);
|
|
144
|
+
} else {
|
|
145
|
+
this.updateModel();
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
methods: {
|
|
149
|
+
change(event) {
|
|
150
|
+
if (this.disabled) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const checked = event.target.checked;
|
|
155
|
+
this.currentValue = checked;
|
|
156
|
+
|
|
157
|
+
const value = checked ? this.trueValue : this.falseValue;
|
|
158
|
+
this.$emit("input", value);
|
|
159
|
+
|
|
160
|
+
if (this.group) {
|
|
161
|
+
this.parent.change(this.model);
|
|
162
|
+
} else {
|
|
163
|
+
this.$emit("change", value);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
updateModel() {
|
|
167
|
+
this.currentValue = this.value === this.trueValue;
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
watch: {
|
|
171
|
+
value(val) {
|
|
172
|
+
if (val === this.trueValue || val === this.falseValue) {
|
|
173
|
+
this.updateModel();
|
|
174
|
+
} else {
|
|
175
|
+
throw "Value should be trueValue or falseValue.";
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<style lang="less">
|
|
183
|
+
@import "./style.less";
|
|
184
|
+
</style>
|